Search code examples
javascriptcordovaibm-mobilefirst

submitLoginForm() does not send the data to the authentication server - MobileFirst Cordova client


I am trying to write a cordova hybrid application test application on MobileFirst platform. In my challenge handler, I have included a code to send a login information to my authentication server using submitLoginForm() java script API.

I check using wireshark if any auth request to my authentication server is getting generated, but it does not.

Can you please help me identify the issue with my code?

I can see the alert until Inside handleChallenge3, but does not see the alert for Closing Challenge Handler.

One more thing, I am trying to use isCustomResponse() API just to see what kind of challenge/response is coming to my challenge handler, but it seems not to be getting triggered. Has this been deprecated in MobileFirst Platform 8?

Thanks

var LtpaAuthChallengeHandler = function(){
      LtpaAuthChallengeHandler = WL.Client.createWLChallengeHandler("LtpaBasedSSO");

      LtpaAuthChallengeHandler.isCustomResponse = function(transport) {
        alert ("Inside isCustomResponse");
        return true;
      };

      LtpaAuthChallengeHandler.loginResponse = function(response) {
        alert ("Inside loginResponse");
        LtpaAuthChallengeHandler.submitSuccess();
        alert ("After loginResponse");
      };
      // handleFailure
      LtpaAuthChallengeHandler.handleFailure = function(error) {
         // WL.Logger.debug("Challenge Handler Failure!");
          if(error.failure !== null && error.failure !== undefined){
             alert(error.failure);
          }
          else {
             alert("Unknown error");
          }
      };

      LtpaAuthChallengeHandler.handleChallenge = function(challenge) {
        alert ("Inside handleChallenge");
        var msg = "";
    alert ("Inside handleChallenge1");
        var options = {
          "headers"     : {},
          "parameters"  : {
            "username" : "admin",
            "password" : "admin",
            'login-form-type' : 'pwd'
          }
        };
    alert ("Inside handleChallenge2");
        var loginUrl = "<URI for forms based auth of auth server>";
    alert ("Inside handleChallenge3");
        LtpaAuthChallengeHandler.submitLoginForm (loginUrl, options, LtpaAuthChallengeHandler.loginResponse);

        alert ("Closing Challenge Handler");
      };
    };

Solution

  • Once the credentials have been collected from the UI, use WLChallengeHandler's submitChallengeAnswer() to send an answer back to the security check.

    isCustomResponse() is not applicable from MFP 8.0.

    Refer to the Authentication and Security topic here.