Custom Authenticator and Login Module in native iOS applications
This tutorial explains how to implement the client-side of custom authenticator and login module in native iOS.
Prerequisite: Make sure that you read Custom Authenticator and Login Module first.
Implementing the client-side authentication
Create a native iOS application and add the MobileFirst native APIs as explained in Configuring a native iOS application with the MobileFirst Platform SDK.
In your storyboard, add a ViewController containing a login form.
- Create a
MyChallengeHandlerclass as a subclass of
- Call the
- Add implementation of the following
ChallengeHandlermethods to handle the custom authenticator and login module challenge:
isCustomResponsemethod is invoked each time a response is received from the MobileFirst Server. It is used to detect whether the response contains data that is related to this challenge handler. It must return either
true, the framework calls the
handleChallengemethod. This function is used to perform required actions, such as hiding the application screen and showing the login screen.
At the end of the authentication flow,
onFailurewill be triggered
submitSuccessmethod in order to inform the framework that the authentication process completed successfully and for the
onSuccesshandler of the invocation to be called.
submitFailuremethod in order to inform the framework that the authentication process failed and for the
onFailurehandler of the invocation to be called.
In your login View Controller, when the user taps to submit the credentials, call the
submitLoginForm method to send the credentials to the MobileFirst Server.
Registering the challenge handler
Before calling the protected adapter, in order to listen to incoming challenges, make sure to register the challenge handler by using the
registerChallengeHandler method of the