Challenge handling in a gateway topology

Learn about special challenge-handling considerations when using a gateway between a client application and MobileFirst Server.

When access to MobileFirst Server is protected by a security gateway, a challenge is sent for any client attempt to access a server endpoint, except for pre-approved endpoints. This rule is true also for the client's initial request to register with the server. However, because the registration stage is executed entirely in the native environment, only a challenge handler that is implemented and registered in native code is called during the client's registration. A challenge handler that is implemented and registered in cross-platform JavaScript code is not called during client registration.

To allow a hybrid application to handle challenges during its registration with the server, follow these steps to register a native challenge handler from the application's native environment:
Note: The examples are for a MyHybridApp MobileFirst hybrid application with a native iPhone environment that uses the default startup process (see MobileFirst Default startup process in iOS-based hybrid applications).
  1. Implement the registration challenge handler in the native-environment portion of your application.

    For example, in your MyApp\iPhone\native\Classes directory, add MyChallengeHandler.h and MyChallengeHandler.m files that contain your challenge-handler class (MyChallengeHandler.

  2. Register your challenge handler from the initialization method of the same native environment.
    For example, in your didFinishLaunchingWithOptions method, in MyApp\iPhone\native\Classes\MyApp.m, add a call to the WL.Client registerChallengeHandler method.
    Note: Call registerChallengeHandler before the call to initializeWebFrameworkWithDelegate.
    @implementation MyAppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
        (NSDictionary *)launchOptions
    {
        BOOL result = [super application:application didFinishLaunchingWithOptions:launchOptions];
    
        // A root view controller must be created in application:didFinishLaunchingWithOptions: 
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        UIViewController* rootViewController = [[Compatibility50ViewController alloc] init];    
    
        [self.window setRootViewController:rootViewController];
        [self.window makeKeyAndVisible];
    
        [[WL sharedInstance] showSplashScreen];
    
        // Register your challenge handler:
        [[WLClient sharedInstance] registerChallengeHandler:[[MyChallengeHandler alloc] init]];
    
        [[WL sharedInstance] initializeWebFrameworkWithDelegate:self];
    
        return result;
    }
After completing these steps, challenges that are sent by the gateway during client registration with MobileFirst Server will be handled by the registered challenge handler (MyChallengeHandler in the example).