1
votes

I have followed This Link

Which works great for me. I am having 3 adapters in all these three adapter I am using same security test realm for all procedures. After certain timeout which i provided adapter returns me login failed which is correct. But I am getting following error after timeout in application -

Console error - AUTHENTICATION_ERROR, error message: An error occurred while performing authentication using loginModule AdapterAuthLoginModule, User Identity Not available.

Application Error - handler.handleFailure is not a function

I am not able to get this above error which is in worklight.js

What causes this error? I want to call logout function after timeout. But I cant call because of above error.

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();
   }
};
1
Can you provide your adapter XML file and challenge handler implementation?Idan Adar
@IdanAdar hi i have updated... adapter.xml and challenge handler js file. I have used that security test in rest of the adapters. login works but after timout im not getting above errors.Suhas
Where do you declare "CurrentSessionId"?Idan Adar
First, try to make your submitAuthentication method protected by: securityTest="wl_unprotected". Secondly, it's not very clear what window.location.hash = "#logout"; is (and why it seems to happen even when doing submitsuccess), or what CurrentSessionId is.Nathan H
@IdanAdar CurrentSessionId is my global variable which i get after my login method.. when that method get sucess i called submitAuthentication method.Suhas

1 Answers

0
votes

With help of Idan Adar i got solution

I put below function in adapterAuthRealmChallengeHandler.js

adapterAuthRealmChallengeHandler.handleFailure = function(response) {

    adapterAuthRealmChallengeHandler.startChallengeHandling();

};

After calling above function And in adapterAuthRealmChallengeHandler.handleChallenge i have checked the flag value which I set after getting successful login.