Session Worklight:质询处理程序未按预期工作
我使用了基于表单的身份验证模块附带的示例质询处理程序。我按照我的要求修改了它。在我的应用程序中,我有一个登录(主页)页面,在那里我有一个登录页面的链接。现在我想让它在用户点击登录按钮时运行我在这里面临各种问题:Session Worklight:质询处理程序未按预期工作,session,authentication,timeout,ibm-mobilefirst,Session,Authentication,Timeout,Ibm Mobilefirst,我使用了基于表单的身份验证模块附带的示例质询处理程序。我按照我的要求修改了它。在我的应用程序中,我有一个登录(主页)页面,在那里我有一个登录页面的链接。现在我想让它在用户点击登录按钮时运行我在这里面临各种问题: var aahadAppRealmChallengeHandler = WL.Client.createChallengeHandler("myAppRealm"); var isLandingPage=false , islogout=false; aahadAppRealmChall
var aahadAppRealmChallengeHandler = WL.Client.createChallengeHandler("myAppRealm");
var isLandingPage=false , islogout=false;
aahadAppRealmChallengeHandler.isCustomResponse = function(response) {
WL.Logger.debug("I am here >> 1");
if (!response || response.responseText === null) { return false; }
var indicatorIdx = response.responseText.search('j_security_check');
if (indicatorIdx >= 0){ WL.Logger.debug("return true "); return true; }
else {
if(isLandingPage && $.trim($('#fldloginUserID').val()) !="" && $.trim($('#fldloginUserPassword').val()) !="" ) {
WL.Logger.debug("WL.Client.isUserAuthenticated()=" + WL.Client.isUserAuthenticated("myAppRealm"));
if(WL.Client.isUserAuthenticated("myAppRealm")) { WL.Logger.debug("return false "); return false; }
else { WL.Logger.debug("return true "); return true; }
}
WL.Logger.debug("return false "); return false;
}
};
aahadAppRealmChallengeHandler.handleChallenge = function(response) {
WL.Logger.debug("I am here >> 2");
var indicatorIdx = response.responseText.search('j_security_check');
var suc = response.responseText.search('success');
WL.Logger.debug("I am here >> 3 - indicatorIdx =" + indicatorIdx + " Success =" + suc + " - isLandingPage=" + isLandingPage +" islogout=" +islogout);
if (isLandingPage){
if (suc >= 0 ){
WL.Logger.debug("I am here >> 4 - isLandingPage=" + isLandingPage +" suc="+suc);
var reqURL = '/j_security_check'; var options = {};
options.parameters = {
j_username : $.trim($('#fldloginUserID').val().toLowerCase()),
j_password : $.trim($('#fldloginUserPassword').val())
};
options.headers = {};
aahadAppRealmChallengeHandler.submitLoginForm(reqURL, options, aahadAppRealmChallengeHandler.submitLoginFormCallback);
}else {
WL.Logger.debug("I am here >> 5");
WL.SimpleDialog.show(DialogMessages_en.SessionExpired_Tile, DialogMessages_en.SessionExpired_Description ,
[ { text : 'Close', handler : function () {
if(busyIndicator.isVisible())
busyIndicator.hide();
isLandingPage = false; userLogout();islogout=true;
$.mobile.changePage("#landingPage" , { transition: "slide"});
} } ]);
}
}
else {
WL.Logger.debug("I am here >> 6 - isLandingPage=" + isLandingPage +" re-Login Again");
if(indicatorIdx < 1) {
var reqURL = '/j_security_check'; var options = {};
options.parameters = {
j_username : $.trim($('#fldloginUserID').val().toLowerCase()),
j_password : $.trim($('#fldloginUserPassword').val())
};
options.headers = {};
aahadAppRealmChallengeHandler.submitLoginForm(reqURL, options, aahadAppRealmChallengeHandler.submitLoginFormCallback);
}
}
};
aahadAppRealmChallengeHandler.submitLoginFormCallback = function(response) {
var isLoginFormResponse = aahadAppRealmChallengeHandler.isCustomResponse(response);
if (isLoginFormResponse){ isLandingPage=false; aahadAppRealmChallengeHandler.handleChallenge(response); }
else {isLandingPage=true; aahadAppRealmChallengeHandler.submitSuccess(); WL.Logger.debug("aahadAppRealmChallengeHandler.submitSuccess()"); }
};
$('#logindone').bind('click', function () {
WL.Logger.debug(" Button Clicked -Before isLandingPage=" +isLandingPage);
isLandingPage=true;
var reqURL = '/j_security_check'; var options = {};
options.parameters = {
j_username : $.trim($('#fldloginUserID').val().toLowerCase()),
j_password : $.trim($('#fldloginUserPassword').val())
};
options.headers = {};
aahadAppRealmChallengeHandler.submitLoginForm(reqURL, options, aahadAppRealmChallengeHandler.submitLoginFormCallback);
loginAuthenticateUser();
});
var aahadAppRealmChallengeHandler = WL.Client.createChallengeHandler("myAppRealm");
var isLandingPage=false , islogout=false;
aahadAppRealmChallengeHandler.isCustomResponse = function(response) {
WL.Logger.debug("I am here >> 1");
if (!response || response.responseText === null) { return false; }
var indicatorIdx = response.responseText.search('j_security_check');
if (indicatorIdx >= 0){ WL.Logger.debug("return true "); return true; }
else {
if(isLandingPage && $.trim($('#fldloginUserID').val()) !="" && $.trim($('#fldloginUserPassword').val()) !="" ) {
WL.Logger.debug("WL.Client.isUserAuthenticated()=" + WL.Client.isUserAuthenticated("myAppRealm"));
if(WL.Client.isUserAuthenticated("myAppRealm")) { WL.Logger.debug("return false "); return false; }
else { WL.Logger.debug("return true "); return true; }
}
WL.Logger.debug("return false "); return false;
}
};
aahadAppRealmChallengeHandler.handleChallenge = function(response) {
WL.Logger.debug("I am here >> 2");
var indicatorIdx = response.responseText.search('j_security_check');
var suc = response.responseText.search('success');
WL.Logger.debug("I am here >> 3 - indicatorIdx =" + indicatorIdx + " Success =" + suc + " - isLandingPage=" + isLandingPage +" islogout=" +islogout);
if (isLandingPage){
if (suc >= 0 ){
WL.Logger.debug("I am here >> 4 - isLandingPage=" + isLandingPage +" suc="+suc);
var reqURL = '/j_security_check'; var options = {};
options.parameters = {
j_username : $.trim($('#fldloginUserID').val().toLowerCase()),
j_password : $.trim($('#fldloginUserPassword').val())
};
options.headers = {};
aahadAppRealmChallengeHandler.submitLoginForm(reqURL, options, aahadAppRealmChallengeHandler.submitLoginFormCallback);
}else {
WL.Logger.debug("I am here >> 5");
WL.SimpleDialog.show(DialogMessages_en.SessionExpired_Tile, DialogMessages_en.SessionExpired_Description ,
[ { text : 'Close', handler : function () {
if(busyIndicator.isVisible())
busyIndicator.hide();
isLandingPage = false; userLogout();islogout=true;
$.mobile.changePage("#landingPage" , { transition: "slide"});
} } ]);
}
}
else {
WL.Logger.debug("I am here >> 6 - isLandingPage=" + isLandingPage +" re-Login Again");
if(indicatorIdx < 1) {
var reqURL = '/j_security_check'; var options = {};
options.parameters = {
j_username : $.trim($('#fldloginUserID').val().toLowerCase()),
j_password : $.trim($('#fldloginUserPassword').val())
};
options.headers = {};
aahadAppRealmChallengeHandler.submitLoginForm(reqURL, options, aahadAppRealmChallengeHandler.submitLoginFormCallback);
}
}
};
aahadAppRealmChallengeHandler.submitLoginFormCallback = function(response) {
var isLoginFormResponse = aahadAppRealmChallengeHandler.isCustomResponse(response);
if (isLoginFormResponse){ isLandingPage=false; aahadAppRealmChallengeHandler.handleChallenge(response); }
else {isLandingPage=true; aahadAppRealmChallengeHandler.submitSuccess(); WL.Logger.debug("aahadAppRealmChallengeHandler.submitSuccess()"); }
};
$('#logindone').bind('click', function () {
WL.Logger.debug(" Button Clicked -Before isLandingPage=" +isLandingPage);
isLandingPage=true;
var reqURL = '/j_security_check'; var options = {};
options.parameters = {
j_username : $.trim($('#fldloginUserID').val().toLowerCase()),
j_password : $.trim($('#fldloginUserPassword').val())
};
options.headers = {};
aahadAppRealmChallengeHandler.submitLoginForm(reqURL, options, aahadAppRealmChallengeHandler.submitLoginFormCallback);
loginAuthenticateUser();
});
注销功能
function loginAuthenticateUser() {
WL.Logger.debug("Calling loginAuthenticateUser()....");
busyIndicator.show();
if ($.trim( $("#fldloginUserID").val()) !="" && $.trim( $("#fldloginUserPassword").val()) !="") {
authenticateLDAPUsers( $.trim( $("#fldloginUserID").val().toLowerCase() ) , $.trim( $("#fldloginUserPassword").val() ));
}else {
if(busyIndicator.isVisible())
busyIndicator.hide();
simpleDialogDemo(DialogMessages_en.LoginFailed_MsgTitle , DialogMessages_en.LoginFailed_MsgDescription);
}
}
function userLogout() {
WL.Logger.debug("Logout....");
WL.TabBar.setVisible(false);
WL.Client.logout('myAppRealm', {onSuccess: function(){} });
$.mobile.changePage("#landingPage" , { transition: "slide"});
var options = {onSuccess: function() {WL.Logger.debug("collection closed");}, onFailure: function() { WL.Logger.debug("collection closing failed"); } };
WL.JSONStore.closeAll(options);
}
authenticationConfig.xml(领域)
请提供任何建议。
谢谢如果是基于表单的身份验证,您需要在实际提交凭据之前触发身份验证。因此,您需要在应用程序中调用WL.Client.login(“域名”)
如果身份验证需要在应用程序启动时立即执行,请在wlEnvInit或wlCommonInit函数中调用WL.Client.login(..)。如果后期需要,请在需要时致电。您能否提供有关您使用的服务器的任何反馈?网络跟踪有助于了解封面下的情况(如Wireshark和TCPMon)。@Mike,至少感谢您的回复:)。我使用的是IBM WAS v8、WL Server 5.0.5、Oracle和Windows操作系统。对于跟踪日志,我应该共享设备日志吗?我可以打印挑战处理程序的isCustomResponse和handleChallenge函数中的所有“响应”。或者你需要的是日志?
serverSessionTimeout=5