【问题标题】:IBM worklight adapter based authentication基于 IBM Worklight 适配器的身份验证
【发布时间】:2015-03-17 07:51:46
【问题描述】:

我已关注This Link

这对我很有用。我在所有这三个适配器中都有 3 个适配器我对所有程序都使用相同的安全测试领域。在我提供适配器的某些超时后,我返回登录失败,这是正确的。但是我在应用程序超时后出现以下错误 -

控制台错误 - AUTHENTICATION_ERROR,错误消息:使用 loginModule AdapterAuthLoginModule 执行身份验证时出错,用户身份不可用。

应用程序错误 - handler.handleFailure 不是函数

我无法得到上述 worklight.js 中的错误

是什么导致了这个错误?我想在超时后调用注销功能。但由于上述错误,我无法打电话。

adapter.xml

<wl:adapter xmlns:wl="http://www.worklight.com/integration" xmlns:http="http://www.worklight.com/integration/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="AuthenticationAdapter">

<displayName>AuthenticationAdapter</displayName>
<description>AuthenticationAdapter</description>
<connectivity>
    <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
        <protocol>http</protocol>
        <domain>rss.cnn.com</domain>
        <port>80</port> 

    </connectionPolicy>
    <loadConstraints maxConcurrentConnectionsPerNode="2"/>
</connectivity>

<procedure name="submitAuthentication"/>
<procedure name="getSecretData" securityTest="AuthenticationAdapter-securityTest"/>

</wl:adapter>

adapterAuthRealmChallengeHandler.js

adapterAuthRealmChallengeHandler.isCustomResponse = function(response) {
    if (!response || !response.responseJSON || response.responseText === null) {
    return false;
}
if (typeof(response.responseJSON.authRequired) !== 'undefined'){
    return true;
} else {
    return false;
}
};   


adapterAuthRealmChallengeHandler.handleChallenge = function(response){
    var authRequired = response.responseJSON.authRequired;

if (authRequired == true){
    navigator.notification.alert("Your session has timed out!");


        logoutfunction(); //logout function call



} else if (authRequired == false){

    if(CurrentSessionId == "" || CurrentSessionId == null){

        logoutfunction(); //logout function call
    }
    else{
        var invocationData = {
                            adapter : "API_Adapter",
                            procedure : "storeSession",
                            parameters : [userID],
                            compressResponse : true
                        };

                        WL.Client.invokeProcedure(invocationData, {
                            onSuccess : function Lsuccess(res){},
                            onFailure : function Lfaulure(res){},               
                            timeout: timeout
                        });

    }

    adapterAuthRealmChallengeHandler.submitSuccess();
   }
};

【问题讨论】:

  • 您能提供您的适配器 XML 文件和质询处理程序实现吗?
  • @IdanAdar 您好,我已更新... adapter.xml 和挑战处理程序 js 文件。我在其他适配器中使用了该安全测试。登录有效,但在超时后我没有遇到上述错误。
  • 你在哪里声明“CurrentSessionId”?
  • 首先,尝试使您的 submitAuthentication 方法受以下保护:securityTest="wl_unprotected"。其次,不清楚window.location.hash = "#logout"; 是什么(以及为什么即使在提交成功时也会发生这种情况),或者CurrentSessionId 是什么。
  • @IdanAdar CurrentSessionId 是我在登录方法之后获得的全局变量。当该方法成功时,我调用了 submitAuthentication 方法。

标签: ibm-mobilefirst worklight-adapters worklight-server worklight-security


【解决方案1】:

在 Idan Adar 的帮助下,我得到了解决方案

我把下面的函数放在adapterAuthRealmChallengeHandler.js中

adapterAuthRealmChallengeHandler.handleFailure = function(response) {

    adapterAuthRealmChallengeHandler.startChallengeHandling();

};

调用上述函数后,在adapterAuthRealmChallengeHandler.handleChallenge 中,我检查了成功登录后设置的标志值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多