worklight j_security_check未找到 [英] worklight j_security_check not found
问题描述
我正在使用Worklight Studio插件6.0。
I'm using Worklight Studio Plugin 6.0.
我正在努力让FormBasedAuthentication正常工作。当我运行并部署我的worklight项目时,应用程序登录页面成功显示。但是,当我单击登录按钮时,服务器控制台上会抛出一个错误:
I am trying to get FormBasedAuthentication working. When I run and deploy my worklight project, the app login page is presented successfully. However when I click on the login button, an error is thrown on the server console:
[错误] FWLSE0048E:捕获到未处理的异常:SRVE0190E:找不到文件:/ apps / services / j_security_check [project DojoTest]
SRVE0190E:找不到文件:/ apps / services / j_security_check
[ERROR ] FWLSE0048E: Unhandled exception caught: SRVE0190E: File not found: /apps/services/j_security_check [project DojoTest] SRVE0190E: File not found: /apps/services/j_security_check
项目中不存在此目录。我已经尝试创建另一个项目,但它没有添加丢失的文件夹。
This directory doesn't exist in the project. I've tried creating another project but it doesn't add the missing folder.
任何建议表示赞赏。提前谢谢。
Any advise is appreciated. Thank you in advance.
<div id=BorderDiv>
<div class=imageDiv id="imageDiv">
<center style="color:#66FF66">
Test
</center>
</div>
<fieldset id="loginFieldSet">
<legend>Login:</legend>
<div data-dojo-type="dojox/mobile/FormLayout"
data-dojo-props="columns:'auto'">
<div>
<label>User name*: </label> <input id="username" type=text
data-dojo-type="dojox.mobile.TextBox" size="50"
placeholder="Enter Username" name="username" required></input>
</div>
<div>
<label>Password*: </label> <input id="password" type=password
name="pass" placeholder="Enter Password" size="50"
data-dojo-type="dojox.mobile.TextBox" required> </input>
</div>
</div>
<div>
<center>
<input type="button" class="formButton" id="AuthSubmitButton" value="Login" /> <input type="button" class="formButton" id="AuthCancelButton" value="Cancel" />
</center>
</div>
<!-- <button data-dojo-type="dojox.mobile.Button" onclick="login()">Login</button>-->
</fieldset>
</div>
//Create the challenge object
var challengeHandler = WL.Client.createChallengeHandler("SampleAppRealm");
/*
* Read the response of the challenge. The default login form
* that the server returns contains a j_security_check string.
* If the challenge handler detects it in the response, return true
*
*/
challengeHandler.isCustomResponse = function(response) {
if (!response || response.responseText === null) {
return false;
}
var indicatorIdx = response.responseText.search('j_security_check');
if (indicatorIdx >= 0) {
return true;
}
return false;
};
//Hanlde the Challenege. In our case, we do nothing!
challengeHandler.handleChallenge = function(response) {
//do nothing
};
//Bind the login button to collect the username and the password
$('#AuthSubmitButton').bind('click', function () {
var reqURL = 'j_security_check';
var options = {};
options.parameters = {
j_username : $('#username').val(),
j_password : $('#password').val()
};
options.headers = {};
challengeHandler.submitLoginForm(reqURL, options, challengeHandler.submitLoginFormCallback);
});
$('#AuthCancelButton').bind('click', function () {
alert("Cancel Clicked");
sampleAppRealmChallengeHandler.submitFailure();
});
challengeHandler.submitLoginFormCallback = function(response) {
var isLoginFormResponse = challengeHandler.isCustomResponse(response);
if (isLoginFormResponse){
challengeHandler.handleChallenge(response);
} else {
login();
$('#password').val('');
$('#username').val('');
challengeHandler.submitSuccess();
}
};
function login(){
require([ "dojo/dom", "dijit/registry" ], function(dom, registry) {
var username = dom.byId("username");
var password = dom.byId("password");
alert("username= " + username.value + " AND password = "
+ password.value);
try {
registry.byId("mainMenuView").performTransition("myAcctView", 1,
"slide");
WL.Logger.debug("Moved to My Account view");
} catch (e) {
WL.Logger.debug("Error Caught: " + e);
}
});
}
推荐答案
在基于表单的身份验证中期望从服务器发送一个登录表单以响应连接尝试(您不需要显示服务器发送的HTML,它只是最重要的响应)。
In form-based authentication it is expected from the server to send a login form in response to a connect attempt (you are not required to display the HTML sent by the server, it's just the response that matters mostly).
基本上,如果您的应用程序的第一个屏幕是登录表单并且您单击某个登录按钮并且此按钮执行登录尝试,则它将首次出现,因为仅在第一次服务器才会从登录表单获取请求应用程序以及对该请求的响应将是挑战 - 登录表单。
Basically, if your app's first screen is the login form and you click some login button and this button does a login attempt, it will first the first time, because only in the first time will the server get a request from the app and the response to that request would be the challenge - the login form.
因此,您需要确保首先使用WL.Client.connect连接到服务器然后才允许用户进行任何登录尝试(可以是登录按钮)。这是为什么会出现上述错误的常见情况。
So you need to make sure that you first connect to the server using WL.Client.connect and only then allow the user to do any login attempts (can be a login button). This is the usual scenario why the above error is given.
另请注意,这不是Worklight项目中存在的资源;它是服务器上存在的资源。这就是为什么你找不到它。
Note also that this is not a resource that exists in your Worklight project; it's a resource that exists on the server. This is why you cannot find it.
请查看身份验证概念和基于表单的教程(及其示例)用户文档: http:// www-01。 ibm.com/support/knowledgecenter/SSZH4A_6.0.0/com.ibm.worklight.getstart.doc/start/c_gettingstarted.html?cp=SSNJXP
Please review the authentication concepts and form-based tutorial (and its sample) user documentation: http://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.0.0/com.ibm.worklight.getstart.doc/start/c_gettingstarted.html?cp=SSNJXP
这篇关于worklight j_security_check未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!