Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ibm mobilefirst IBM Worklight 5.0.6-登录需要两次单击,而不是一次_Ibm Mobilefirst_Worklight Adapters_Worklight Security - Fatal编程技术网

Ibm mobilefirst IBM Worklight 5.0.6-登录需要两次单击,而不是一次

Ibm mobilefirst IBM Worklight 5.0.6-登录需要两次单击,而不是一次,ibm-mobilefirst,worklight-adapters,worklight-security,Ibm Mobilefirst,Worklight Adapters,Worklight Security,我正在我的应用程序中使用基于表单的身份验证和质询处理程序(示例代码)。问题是,它不是在登录按钮上单击一次就对用户进行身份验证-我必须单击两次。为什么? 我已经保护了所有适配器功能 我的挑战处理者: var myAppRealmChallengeHandler = WL.Client.createChallengeHandler("myAppRealm"); myAppRealmChallengeHandler.isCustomResponse = function(response) {

我正在我的应用程序中使用基于表单的身份验证和质询处理程序(示例代码)。问题是,它不是在登录按钮上单击一次就对用户进行身份验证-我必须单击两次。为什么?

我已经保护了所有适配器功能

我的挑战处理者

var myAppRealmChallengeHandler = WL.Client.createChallengeHandler("myAppRealm");
myAppRealmChallengeHandler.isCustomResponse = function(response) {
     if (!response || response.responseText === null) {
        return false;
    }
    var indicatorIdx = response.responseText.search('j_security_check');
    WL.Logger.debug("indicatorIdx =" + indicatorIdx);
    if (indicatorIdx >= 0){ return true; }  
    return false; 
};
myAppRealmChallengeHandler.handleChallenge = function(response) {
    $.mobile.changePage("#landingPage" , { transition: "slide"});
    WL.Logger.debug("Login Again");
};

myAppRealmChallengeHandler.submitLoginFormCallback = function(response) {
    var isLoginFormResponse = myAppRealmChallengeHandler.isCustomResponse(response);
    WL.Logger.debug("submitLoginFormCallback " + isLoginFormResponse + " responseText " + response.responseText);
    if (isLoginFormResponse){
        myAppRealmChallengeHandler.handleChallenge(response);
    } else {
        myAppRealmChallengeHandler.submitSuccess();
    }
};
$('#logindone').bind('click', function () {
        var reqURL = '/j_security_check';
        var options = {};
            options.parameters = {
                j_username : $.trim($('#fldloginUserID').val().toLowerCase()),
                j_password : $.trim($('#fldloginUserPassword').val())
            };
            options.headers = {};
            myAppRealmChallengeHandler.submitLoginForm(reqURL, options, myAppRealmChallengeHandler.submitLoginFormCallback);
    processLogin();
});
authenticationConfig.xml

<securityTests>
        <mobileSecurityTest name="myMobileSecurity">
            <testUser realm="myAppRealm"/>
            <testDeviceId provisioningType="none"/>
        </mobileSecurityTest>       
        <customSecurityTest name="PushApplication-custom-securityTest">                             
            <test isInternalUserID="true" realm="PushAppRealm"/>   
        </customSecurityTest>       
        <customSecurityTest name="myAppSecurityTestCustom">                             
            <test isInternalUserID="true" realm="myAppRealm"/>   
        </customSecurityTest>       
        <customSecurityTest name="WorklightConsole">
            <test realm="WorklightConsole" isInternalUserID="true"/>
        </customSecurityTest>
</securityTests>    
<realms>
        <realm loginModule="StrongRC" name="myAppRealm">
            <className>com.worklight.core.auth.ext.FormBasedAuthenticator</className>
            <!--<parameter name="login-page" value="login.html"/>-->
        </realm>
        <realm loginModule="PushAppLoginModule" name="PushAppRealm">                                                
            <className>com.worklight.core.auth.ext.BasicAuthenticator</className>   
            <parameter name="basic-realm-name" value="PushAppRealm"/>                                                  
        </realm>
        <realm loginModule="Console" name="WorklightConsole">
            <className>com.worklight.core.auth.ext.FormBasedAuthenticator</className>
            <onLoginUrl>/console</onLoginUrl>
        </realm>
</realms>
<loginModules>
         <loginModule name="PushAppLoginModule">
            <className>com.rc.services.RCAuthModule</className>
        </loginModule>      
        <loginModule name="StrongRC">
            <className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
        </loginModule>      
        <loginModule name="Console">
            <className>com.worklight.core.auth.ext.SingleIdentityLoginModule</className>
        </loginModule>
</loginModules>

ValidateUsersListSummariesDetails适配器功能使用上面给出的myAppSecurityTestCustom进行保护。

应用程序启动时,您的登录页面(登录页面)看起来是可见的,并且第一次单击登录时,目前还没有进行身份验证。这不会按你期望的方式工作

将其他页面设为应用程序的默认页面。 从单击处理程序中调用processLogin()。在submitLoginFormCallback()的成功案例中,我还将转换到mainPage

现在,在wlCommonInit()中调用WL.Client.login()。
(这将触发身份验证)将对processLogin()的调用放入对WL.Client.login()调用的成功回调中。

我在使用IP地址进行测试时遇到了这个问题,并且代码中存在DNS条目,即我的URL是mydomain.com,IP是123.123.123.123,现在如果我使用123.123.123构建应用程序,我必须点击登录按钮两次

我找到的解决方案是在主机/DNS服务器中添加mydomain.com,然后为mydomain.com构建应用程序


对我来说非常有效

客户通过在IBM打开的PMR回答了这个问题。此后,他们将实现更改为使用基于适配器的身份验证,因为这是适合其应用程序结构的身份验证流。这个问题现在有点过时了…

它是在预览中出现的,还是仅在emulator/simulator/device中出现的?哪种设备?您的Worklight版本是什么?单击处理程序末尾对processLogin()的调用有什么作用?@Idan,它在预览和设备上都会发生。我使用的是WL Consumer 5.0.6。@davidhuyveter,processLogin()获取用户ID和密码并调用适配器函数。一旦用户标识/密码被验证,它就可以让用户进入应用程序(主页)。这听起来像是在第一次调用的认证过程中,正在进行第二个适配器调用。如果您正在进行另一个适配器调用,则在单击处理程序中调用PaltLogin()将触发第二个身份验证,因为您在处理中间的身份验证尚未完成。首先解释如何触发身份验证可能会有所帮助。(某处进行适配器调用…)并提供processLogin()的源代码David,谢谢你的建议,我一定会尝试一下,明天会给你更新,希望它能起作用。谢谢,我试过了,但它不起作用,它只在浏览器上起作用,但在设备上不起作用!我们还能做什么?谢谢,只需在浏览器中单击一下,它就能工作吗?您是否有来自设备的日志cat?
function processLogin(userid,password){ 
    var userid = $("#fldloginUserID").val();
    var password = $("#fldloginUserPassword").val();    
    WL.Logger.debug("Authenticating user credentials...");
    var invocationData = {  adapter: "LDAPAdapter", procedure: "ValidateUsers", parameters: [userid, password]};    
    WL.Client.invokeProcedure(invocationData, { 
        onSuccess: checkUserAccountStatus,  
        onFailure: function(){  hideBusyIndicator();
            showPopUp(msg_en.LoginFailed_MsgTitle , msg_en.LoginFailed_MsgDescription_2);
        } ,timeout : 30000  });
}

function checkUserAccountStatus(response){
    WL.Logger.debug("Checking user account status...");
    xmlDoc = $.parseXML(response.invocationResult.result);
    $xml = $( xmlDoc ); 
    if (!response ||!response.invocationResult || !response.invocationResult.result ||
            $xml.find("isUserValidated").text()=="false" ) { hideBusyIndicator();  
            showPopUp(msg_en.LoginFailed_MsgTitle, msg_en.LoginFailed_MsgDescription_2);
    else { getUserDetails(response.invocationResult.result); }  
}

function getUserDetails($xml){
 ...doing something over retrieved data from LDAP ,like saving in local var......
 ....
 ...then calling another adapter....
    if($xml.find("LDAPuserID").text() > 0){                 
            var invocationData = {adapter: "MQAdapter",procedure: "ListSummariesDetails", parameters: [$xml.find("LDAPuserID").text() ] };
            WL.Client.invokeProcedure(invocationData, {
                onSuccess: getSecretSuccessData_Callback,
                onFailure: function(){ hideBusyIndicator();
                    showPopUp(msg_en.SystemError_Title , msg_en.SystemError_Description);
                } ,timeout : 30000 });
        }   
}

function getSecretSuccessData_Callback(response){
...... now do something over retrived data
...let the user go in the main page of the App after login screen
    $.mobile.changePage("#mainPage" , { transition: "slide"});
}