找不到工作灯 j_security_check

worklight j_security_check not found

我正在使用 Worklight Studio 插件 6.0。

我正在尝试让 FormBasedAuthentication 正常工作。当我 运行 并部署我的 worklight 项目时,应用程序登录页面显示成功。但是,当我单击登录按钮时,服务器控制台上会抛出一个错误:

[错误] FWLSE0048E:捕获到未处理的异常:SRVE0190E:找不到文件:/apps/services/j_security_check [项目 DojoTest] SRVE0190E: 找不到文件:/apps/services/j_security_check

项目中不存在该目录。我试过创建另一个项目,但它没有添加丢失的文件夹。

如有任何建议,我们将不胜感激。提前谢谢你。

<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,这只是响应最重要)。

基本上,如果您的应用程序的第一个屏幕是登录表单并且您单击某个登录按钮并且此按钮进行登录尝试,它将是第一次,因为只有在第一次时服务器才会收到来自应用程序和对该请求的响应将是挑战 - 登录表单。

因此您需要确保首先使用 WL.Client.connect 连接到服务器,然后才允许用户进行任何登录尝试(可以是登录按钮)。这是出现上述错误的常见情况。

另请注意,这不是您的 Worklight 项目中存在的资源;它是服务器上存在的资源。这就是你找不到它的原因。

请查看身份验证概念和基于表单的教程(及其示例)用户文档:http://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.0.0/com.ibm.worklight.getstart.doc/start/c_gettingstarted.html?cp=SSNJXP