无法在域中更改已登录用户的身份

时间:2016-05-26 14:02:16

标签: android authentication ibm-mobilefirst mobilefirst-adapters

我尝试了一个离线身份验证演示应用程序,可以在这里找到:

https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/advanced-topics/offline-authentication/

我的适配器调用有问题。 在onlineAuthentication()中,myCustomRealmChallengeHandler.submitAdapterAuthentication失败。 我之前甚至添加了一个注销,我在服务器上有这个错误消息:

  

FWLSE0099E:调用过程[项目时发生错误   OfflineAuthentication] authenticationAdapter / submitAuthentication   FWLSE0100E:参数:[project OfflineAuthentication]无法更改   在领域'xxxxxx'中已登录用户的身份。该   应用程序必须先注销。

在注销后的客户端上,wl.client.isUserAuthenticated为false。 我还尝试了WLAuthorizationManager.getUserIdentity()来了解适配器是否必须执行setActiveUser

在main.js中:

   

WL.Client.logout("spgRealm", {onSuccess:logoutSuccess, onFailure:logoutFailure});
WLAuthorizationManager.getUserIdentity().then(function(){

    var invocationData = {

        adapter : "authenticationAdapter",
        procedure : "submitAuthentication",
        parameters : [$("#usr").val(), $("#pwd").val(), usrInfo.sid, true ]
    };

    alert('sans ecran login '+JSON.stringify(invocationData));
    spgRCH.submitAdapterAuthentication( invocationData, {

        onSuccess:onlineAuthenticationSuccess, 
        onFailure:onlineAuthenticationFailure 
    });
})

在适配器中:

function submitAuthentication(username, password, sid, isIdentified){
    var i = {
        method : 'get',
        returnedContentType : 'json',
        path : '/mobapp/auth.php',
        parameters :  {'USR' : username, 'PWD' : password, 'SID' : sid}
    };
    var o = WL.Server.invokeHttp(i);

    if (isIdentified == false) {

        var userIdentity = {
            userId: username,
            displayName: username, 
            attributes: { 'mobile' : true }
        };

        WL.Server.setActiveUser("spgRealm", userIdentity);
    }
    return { 

        authRequired: false,
        'httprsp' : o 
    };

    return onAuthRequired(null, "SRVE001");
}

我也尝试:

WL.Server.setActiveUser("spgRealm", null);

然而,结果是无限循环。

我使用Android Studio和Android应用程序进行测试。

案件: 首先,登录在线, 其次,退出安全区域而不注销 第三,登录离线 然后离线访问用户商店在线安全区域 身份验证失败。

错误:

  

FWLSE0100E:参数:[project OfflineAuthentication]无法更改   在领域'xxxxxx'中已登录用户的身份。该   应用程序必须先注销。

问题在于代码的这一部分(main.js):

// If logging-in while offline and Internet connectivity is then available, login to the realm without showing the login form.
} else if (username) {
    var invocationData = {
        adapter : "authenticationAdapter",
        procedure : "submitAuthentication",
        parameters : [$("#username").val(), $("#password").val()]
    };

    myCustomRealmChallengeHandler.submitAdapterAuthentication(invocationData, {
        onSuccess:onlineAuthenticationSuccess,
        onFailure:onlineAuthenticationFailure 
    });


0 个答案:

没有答案