这是我的js代码。在这两个功能的工作,一个是ChallengeHandler.isCustomResponse,另一种是ChallengeHandler.handleChallengeChallengeHandler.isCustomResponse和handleChallenge功能在工作灯中不起作用
我在这里使用FormBasedAuthenticator
这里我用HTTP适配器程序命名为“创造challengeHandler为“sampleAppRealm”出于安全原因getValidate()”。这个过程不工作,但securityTest与securityTest,它不工作...
我不知道走错了..我在很多困惑
我使用工作灯7.0版 和jQuery版本1.11,其中 和jQuery移动1.4.5
我的js代码:
<script>
\t \t \t $(document).ready(function(){
\t \t \t \t alert("Hi");
\t \t \t });
\t \t \t function getValidate(){
\t \t \t \t alert();
\t \t \t \t var invocationData = {
\t \t \t \t \t \t adapter : 'Go2needsHTTP',
\t \t \t \t \t \t procedure : 'getValidate',
\t \t \t \t \t \t parameters : []
\t \t \t \t \t };
\t \t \t \t \t var options = {
\t \t \t \t \t \t onSuccess : getValidateSuccess,
\t \t \t \t \t \t onFailure : getValidateFailure,
\t \t \t \t \t \t invocationContext: {}
\t \t \t \t \t };
\t \t \t \t \t WL.Client.invokeProcedure(invocationData, options);
\t \t \t }
\t \t \t function getValidateSuccess(){
\t \t \t \t alert("Success");
\t \t \t }
\t \t \t function getValidateFailure(){
\t \t \t \t alert("Failure");
\t \t \t }
\t \t \t var SampleAppRealmChallengeHandler = WL.Client.createChallengeHandler("SampleAppRealm"); \t \t
\t \t \t sampleAppRealmChallengeHandler.isCustomResponse = function(response) {
\t \t \t \t alert(response);
\t \t \t \t if (!response || response.responseText === null) {
\t \t \t \t return false;
\t \t \t \t }
\t \t \t \t var indicatorIdx = response.responseText.search('j_security_check');
\t \t \t \t
\t \t \t \t if (indicatorIdx >= 0){
\t \t \t \t \t \t return true;
\t \t \t \t \t }
\t \t \t \t \t return false;
\t \t \t \t };
\t \t \t \t sampleAppRealmChallengeHandler.handleChallenge = function(response) {
\t \t \t \t \t alert("handleChallenge");
\t \t \t \t $('#AppDiv').hide();
\t \t \t \t $('#AuthDiv').show();
\t \t \t \t $('#AuthPassword').val('');
\t \t \t \t };
\t \t \t \t $(function(){
\t \t \t \t \t $('#AuthSubmitButton').bind('click', function() {
\t \t \t \t \t \t alert("AuthSubmitButton");
\t \t \t \t \t var reqURL = '/j_security_check';
\t \t \t \t \t var options = {};
\t \t \t \t \t options.parameters = {
\t \t \t \t \t j_username : $('#AuthUsername').val(),
\t \t \t \t \t j_password : $('#AuthPassword').val()
\t \t \t \t \t };
\t \t \t \t \t options.headers = {}; \t \t \t \t sampleAppRealmChallengeHandler.submitLoginForm(reqURL, options, sampleAppRealmChallengeHandler.submitLoginFormCallback);
\t \t \t \t \t });
\t \t \t \t });
\t \t \t \t $(function(){
\t \t \t \t \t $('#AuthCancelButton').bind('click', function() {
\t \t \t \t \t \t alert("AuthCancelButton");
\t \t \t \t \t sampleAppRealmChallengeHandler.submitFailure();
\t \t \t \t \t $('#AppDiv').show();
\t \t \t \t \t $('#AuthDiv').hide();
\t \t \t \t \t });
\t \t \t \t });
\t \t </script>
这是我的html代码:
我的html代码:
<div data-role="page" id="page">
\t \t \t <div data-role="content" style="padding: 15px">
\t \t \t \t <div id="AppDiv">
\t \t \t \t \t \t <input type="button" id="getSecretDataButton" value="Call protected adapter proc" onclick="getValidate()" />
\t \t \t \t \t \t <input type="button" class="appButton" value="Logout" onclick="WL.Client.logout('SampleAppRealm',{onSuccess: WL.Client.reloadApp})" />
\t \t \t \t \t \t <div id="ResponseDiv"></div>
\t \t \t \t \t </div>
\t \t \t \t <div id="AuthDiv" style="display: block;">
\t \t \t \t \t \t <p id="AuthInfo"></p>
\t \t \t \t \t \t <div id="loginForm">
\t \t \t \t \t \t \t <input type="text"`enter code here` id="AuthUsername" placeholder="Enter username" />
\t \t \t \t \t \t \t <br/>
\t \t \t \t \t \t \t <br/>
\t \t \t \t \t \t \t <input type="password" id="AuthPassword" placeholder="Enter password" />
\t \t \t \t \t \t \t <br/>
\t \t \t \t \t \t \t <input type="button" id="AuthSubmitButton" onclick="WL.Client.Login('SampleAppRealm');" class="formButton" value="Login" />
\t \t \t \t \t \t \t <input type="button" id="AuthCancelButton" class="formButton" value="Cancel" />
\t \t \t \t \t \t </div>
\t \t \t \t \t </div>
\t \t \t </div>
\t \t </div>
这是我authenticationConfig.xml文件:
<customSecurityTest name="SampleAppRealm-securityTest"> <test realm="SampleAppRealm" isInternalUserID="true"/></customSecurityTest> <loginModule name="StrongDummy" expirationInSeconds="-1"> <className>com.worklight.core.auth.ext.NonValidatingLoginModule</className> </loginModule> <realm name="SampleAppRealm" loginModule="StrongDummy"> <className>com.worklight.core.auth.ext.FormBasedAuthenticator</className> </realm>
这是我HTTPadapter prodedure:
<procedure name="getValidate" securityTest="SampleAppRealm-securityTest"></procedure>
只是测试,并告诉我在哪里做错了无法找出错误。 请帮我....
什么不起作用?错误讯息?预期的行为?实际行为?请进入更多的细节。 –
没有错误消息,控制器不会去上面的代码是ChallengeHandler.isCustomResponse不起作用。这发生在#worklight环境中。请帮助我... –
我编辑了上面的代码。请找到它 –