Worklight form based authentication: j_security_check not found

I've tried to implement a very simple, form based authentication with a Worklight app. However when I activate the login function, it stops with a 404 error, saying /apps/services/j_security_check can not be found. Oddly enough, when I run the form based authentication sample from IBM's developerWorks site, it works just fine. I can't figure out what the difference is, all the functions that have to do with authentication are exactly the same, yet with my own app I get this error message. Here's the relevant part from the source:

   var sampleAppRealmChallengeHandler = WL.Client.createChallengeHandler("SampleAppRealm");

sampleAppRealmChallengeHandler.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;
};

sampleAppRealmChallengeHandler.handleChallenge = function(response) {
    $.mobile.changePage($('#Login'));
    $('#passwordInputField').val('');
};

sampleAppRealmChallengeHandler.submitLoginFormCallback = function(response) {
    var isLoginFormResponse = sampleAppRealmChallengeHandler.isCustomResponse(response);
    if (isLoginFormResponse){
        sampleAppRealmChallengeHandler.handleChallenge(response);
    } else {
        $.mobile.changePage($('#page0'));
        sampleAppRealmChallengeHandler.submitSuccess();
    }
};

function proceedWithLogin() {

    console.log("proceedWithLogin");

    var reqURL = '/j_security_check';
    var options = {};
    options.parameters = {
        j_username : $('#loginEmail').val(),
        j_password : $('#loginPassword').val()
    };
    options.headers = {};
    sampleAppRealmChallengeHandler.submitLoginForm(reqURL, options, sampleAppRealmChallengeHandler.submitLoginFormCallback);
}

Any idea what could be causing this? Is there a hidden project setting that I've overlooked? Thanks!

Answers


Could it be that you try to send your credentials before the response with the form has arrived? That would explain receiving a 404 j_security_check not found.


Looks like it was a problem with the Worklight project. I've set up a new project and copied everything over and now it works. No idea what the issue was, but it went away.


I think you haven't deployed the Adapter. Can you try testing after deploying the DummyAdapter by rightcliking on it->Run As -> Deploy Adapter.


Need Your Help

How to For Each RDD Spark Streaming

java foreach apache-spark hashmap

I have one CSV file queries.txt and I am reading the file like this:

How to get work easyui js on divs which are written by another js code

javascript jquery html jquery-easyui

I have an javascript class that produces html code. I can produce html code properly, without any error. In this time I am producing some divs which are supposed to be accoridon layout for easyui

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.