com.worklight.wlclient.api.challengehandler
Class GatewayChallengeHandler
- java.lang.Object
-
- com.worklight.wlclient.api.challengehandler.BaseChallengeHandler
-
- com.worklight.wlclient.api.challengehandler.GatewayChallengeHandler
-
- All Implemented Interfaces:
- WLResponseListener
public abstract class GatewayChallengeHandler extends BaseChallengeHandler implements WLResponseListener
You use this abstract base class to create a custom challenge handler to handle responses from a third party gateway. You must extend this class to implement your own challenge handler logic.
-
-
Field Summary
Fields Modifier and Type Field and Description static int
DEFAULT_TIMEOUT_IN_MILLISECONDS
-
Fields inherited from class com.worklight.wlclient.api.challengehandler.BaseChallengeHandler
activeRequest
-
-
Constructor Summary
Constructors Constructor and Description GatewayChallengeHandler(java.lang.String gatewayName)
Constructs an GatewayChallengeHandler with a specific 'gatewayName'.
-
Method Summary
Methods Modifier and Type Method and Description abstract boolean
canHandleResponse(WLResponse response)
This method must be overridden by extending theGatewayChallengeHandler
class.protected void
submitLoginForm(java.lang.String requestURL, java.util.Map requestParameters, java.util.Map requestHeaders, int requestTimeoutInMilliseconds, java.lang.String requestMethod)
You use this method to send collected credentials to a specific URL.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.-
Methods inherited from class com.worklight.wlclient.api.challengehandler.BaseChallengeHandler
cancel, handleChallenge
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.worklight.wlclient.api.WLResponseListener
onFailure, onSuccess
-
-
-
-
Constructor Detail
-
GatewayChallengeHandler
public GatewayChallengeHandler(java.lang.String gatewayName)
Constructs an GatewayChallengeHandler with a specific 'gatewayName'.
-
-
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 MobileFirst Platform that the challenge was successfully handled. This method can also be used to inform 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 MobileFirst Platform to handle the response.- Parameters:
response
- The receivedWLResponse
.
-
canHandleResponse
public abstract boolean canHandleResponse(WLResponse response)
This method must be overridden by extending theGatewayChallengeHandler
class. In most cases, you call this method to test whether there is a gateway challenge to be handled in the response. If the method returns true, the IBM MobileFirst Platform calls theBaseChallengeHandler.handleChallenge(Object)
method.- Parameters:
response
- The response to be tested.
-
submitLoginForm
protected void submitLoginForm(java.lang.String requestURL, java.util.Map requestParameters, java.util.Map requestHeaders, int requestTimeoutInMilliseconds, 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 ofGatewayChallengeHandler
), so you must override theWLResponseListener.onSuccess(WLResponse)
/WLResponseListener.onFailure(com.worklight.wlclient.api.WLFailResponse)
methods.- Parameters:
requestURL
- Absolute URL if the user sends an absolute URL that starts with http:// or https:// Otherwise, URL relative to the MobileFirst Platform Server.requestParameters
- The request parameters.requestHeaders
- The request headers.requestTimeoutInMilliseconds
- To supply custom timeout, use a number over 0.
If the number is under 0, the IBM MobileFirst Platform framework uses the default timeout, which is 10,000 milliseconds.requestMethod
- The HTTP method that you must use.
Acceptable values are GET, POST.
The default value is POST.
-
-