Custom Authentication in native Windows Phone 8 applications
This tutorial illustrates the native Windows Phone 8 client-side authentication components for custom authentication. Make sure you read Custom Authentication first.
Creating the client-side authentication components
Create a native Windows Phone 8 application and add the MobileFirst native APIs following the documentation.
CustomChallengeHandler class as a subclass of
CustomChallengeHandler should implement
isCustomResponse checks every custom response received from MobileFirst Server to see if this is the challenge we are expecting.
handleChallenge method, is called after the
isCustomResponse method returned true.
Within this method we present our login form. Different approaches may be adopted to present the login form.
From the login form , credentials are passed to the
CustomChallengeHandler class. The
submitLoginForm() method is used to send our input data to the authenticator.
Within the MainPage class connect to MobileFirst server, register your
challengeHandler and invoke the protected adapter procedure.
The procedure invocation will trigger MobileFirst server to send a challenge that will trigger our
Since the native API not protected by a defined security test, there is no login form presented during server connection.
Invoke the protected adapter procedure and the login form is presented by the
If your custom authenticator uses
WorklightProtocolAuthenticator, some simplifications can be made:
- Subclass your challenge handler using
ChallengeHandler. Note the
- You no longer need to implement
isCustomResponseas the challenge handler will automatically check that the realm name matches.
handleChallengewill receive the challenge as a parameter, not the entire response object.
- Instead of
submitChallengeAnswerto send your challenge response as a JSON.
- There is no need to call
submitFailureas the framework will do it for you.
Click to download the MobileFirst project.
Click to download the Native project.
CustomAuthproject contains a MobileFirst native API that you can deploy to your MobileFirst server.
CustomAuthWP8project contains a native WP8 application that uses a MobileFirst native API library.
- Make sure to update the
worklight.plistfile in the native project with the relevant server settings.
Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.