com.worklight.wlclient.api.challengehandler

Class ChallengeHandler

  • All Implemented Interfaces:
    WLResponseListener


    public abstract class ChallengeHandler
    extends BaseChallengeHandler
    implements WLResponseListener
    You use this abstract base class to create custom Challenge Handlers. You must extend this class to implement your own Challenge Handler logic. You use this class mainly to create custom user authentication.
    • Constructor Detail

      • ChallengeHandler

        public ChallengeHandler(java.lang.String realm)
    • Method Detail

      • submitSuccess

        protected void submitSuccess(WLResponse response)
        You must call this method when the challenge is answered successfully, for example after the user successfully submits the login form. Then, this method sends the original request. Calling this method informs IBM MobileFirst Platform that the challenge was successfully handled. This method can also be used to inform IBM MobileFirst Platform that the response that was received is not a custom response that your challenge handler can handle. In this case, control is returned to IBM MobileFirst Platform to handle the response.
        Parameters:
        response - The received WLResponse.
      • isCustomResponse

        public abstract boolean isCustomResponse(WLResponse response)
        This method must be overridden by extending the ChallengeHandler class. In most cases, this method is called to test whether there is a custom challenge to be handled in the response. If the method returns true, the IBM MobileFirst Platform framework calls the BaseChallengeHandler.handleChallenge(org.apache.commons.json.JSONObject) method.
        Parameters:
        response - The response to be tested.
        Returns:
        Boolean true or false.
      • submitLoginForm

        protected void submitLoginForm(java.lang.String requestURL,
                           java.util.Hashtable requestParameters,
                           java.util.Hashtable requestHeaders,
                           java.lang.String requestMethod)
        You use this method to send collected credentials to a specific URL. You can also specify request parameters, headers, and timeout.
        The success/failure delegate for this method is the instance itself (the instance of ChallengeHandler), so you must override the onSuccess / onFailure methods.
        Parameters:
        requestURL - Absolute URL if the user sends an absolute URL that starts with http:// or https:// Otherwise, URL relative to the IBM MobileFirst Platform Server.
        requestParameters - The request parameters.
        requestHeaders - The request headers.
        requestMethod - The HTTP method that you must use.
        Acceptable values are GET, POST.
      • submitAdapterAuthentication

        public void submitAdapterAuthentication(WLProcedureInvocationData invocationData,
                                       WLRequestOptions requestOptions)
        You use this method to invoke a procedure from the ChallengeHandler.
        Parameters:
        invocationData - The invocation data, for example the name of the procedure or the name of the method.
        requestOptions - It contains the following options.invocationContext – Object: An object that is returned with WLResponse to the delegate methods. You can use this object to distinguish different invokeProcedure calls.


© Copyright IBM Corp. 2006, 2015. All Rights Reserved.