com.worklight.wlclient.api.challengehandler
Class ChallengeHandler
- java.lang.Object
-
- com.worklight.wlclient.api.challengehandler.BaseChallengeHandler
-
- com.worklight.wlclient.api.challengehandler.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.
-
-
Field Summary
-
Fields inherited from class com.worklight.wlclient.api.challengehandler.BaseChallengeHandler
activeRequest
-
-
Constructor Summary
Constructors Constructor and Description ChallengeHandler(java.lang.String realm)
-
Method Summary
Methods Modifier and Type Method and Description abstract boolean
isCustomResponse(WLResponse response)
This method must be overridden by extending theChallengeHandler
class.void
submitAdapterAuthentication(WLProcedureInvocationData invocationData, WLRequestOptions requestOptions)
You use this method to invoke a procedure from theChallengeHandler
.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.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
handleChallenge, submitFailure
-
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
-
-
-
-
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 receivedWLResponse
.
-
isCustomResponse
public abstract boolean isCustomResponse(WLResponse response)
This method must be overridden by extending theChallengeHandler
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 theBaseChallengeHandler.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 ofChallengeHandler
), 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 theChallengeHandler
.- 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.
-
-