Developer

Registration Process Flow

The registration and log on process varies, depending on device status and the password policy.

Log on process flow:

  • Is the device registered:
    • OnNavigatedTo - Windows Store applications
    • Event handler for the Windows Loaded event - Windows desktop applications
    OnNavigatedTo is called when a page is about to appear in a frame, which is an ideal time to check whether a device is registered. This is done by calling InitWithApplicationIdAsync. When a fully initialized logonCore is returned, the application attempts to create a DataVault on the registered device. If a DataVault already exists, the application tries to unlock the DataVault with no password. If successful, RegistrationContext is loaded. If the DataVault does not exist, a new LogonContext is created with default values:
    • If the state of the device is registered, the application unlocks the DataVault by passing in NULL as the password. If that fails, the user is prompted to enter a password for the DataVault.
    • If the state of the device is not registered, call RegisterWithContextAsync to register the device with SAP Mobile Platform Server.
  • How to check if the device is registered:
    Call the method InitWithApplicationIdAsync. This returns a fully initialized logonCore. The State.IsRegistered property of the logonCore object is queried to determine if device is registered or not, as this code illustrates:
    var logonCore = await SAP.Logon.Core.LogonCore.InitWithApplicationIdAsync("application id");  
    if (logonCore.State.IsRegistered)
    {
        await logonCore.UnlockSecureStoreAsync(null or passcode);
    }
    else
    {
       // device is not registered
    }
    
  • Call RegisterWithContextAsync only if the device is not registered. This registers the device on the SAP Mobile Platform Server:
    await logonCore.RegisterWithContextAsync(logonContext); 
     
    var logonContext = new SAP.Logon.Core.LogonContext
    {
        RegistrationContext = new SAP.Logon.Core.RegistrationContext
        {
            ApplicationId = “App Id", ServerHost = “IP Address Or Hostname", IsHttps = false, ServerPort = 8080
        }
    };
    
  • The PasswordPolicy.IsEnabled property of the logonContext object is queried to determine if a password is enabled or not:
    if (logonContext.PasswordPolicy.IsEnabled)
    {
       // Prompt the user for passcode.  Call the PersistRegistrationAsync method with the passcode that the user entered
       await logonCore.PersistRegistrationAsync(passcode, logonContext);
    }
    else
    {
       // No need to prompt the user for passcode.  Simply call PersistRegistrationAsync method by passing null for passcode
       await logonCore.PersistRegistrationAsync(null, logonContext);
    }