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();
}
};
securityTest="wl_unprotected"
. Secondly, it's not very clear whatwindow.location.hash = "#logout";
is (and why it seems to happen even when doing submitsuccess), or whatCurrentSessionId
is. – Nathan H