Skip to content

OTP Configuration

OTPConfigurationStep configures the httpclient. This step should be used with an authentication step (SAML, Basic, or OAuth2) and with the OTPAuthValidation.

Input Parameters

Mandatory input parameters: * authType – Specifies the authorization type. This parameter is important and should match the next step. If the authType is Basic, the next should be BasicAuthStep and so on.

  • settingsParameters – This setting is provided on the flowContext.

Optional input parameter: * OAuth2Processor – Specifies the oauth2 processor. If the user define their own processor, the OAuth2 step uses that.

Using OTPConfigurationStep

  1. Set the Context and the onboarding settings in the flowContext.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
      flowContext.setContext(callerActivity);
      try {
            OnboardingParameters onboardingParameters = new OnboardingParameters();
            onboardingParameters.setUrl(SERVICE_URL);
            onboardingParameters.setApplicationId(APPLICATION_ID);
            onboardingParameters.setApplicationVersion(APPLICATION_VERSION);
            onboardingParameters.build();
            flowContext.setOnboardingParameters(onboardingParameters);
      } catch (MalformedURLException e) {
        //error handling
      }
    
  2. In the case of OAuth authentication, set the oauth2 config:

    1
    2
    3
    4
    5
    6
    7
    8
                OAuth2Configuration.Builder builer = new OAuth2Configuration.Builder();
                config = builer.clientId("3860f7b5-2dc2-4842-8d31-7f7d8c52e9fc")
                        .responseType("code")
                        .authUrl(AUTH_ENDPOINT)
                        .tokenUrl(TOKEN_ENDPOINT)
                        .redirectUrl(OAUTH_REDIRECT_URL).build();
    
            onboardingParameters.setOAuth2Configuration(config);
    
  3. Initiate the step and set the authorization type:

    1
    2
      OTPConfigurationStep otpConfigurationStep = new OTPConfigurationStep();
      otpConfigurationStep.setAuthType(AuthType.SAML);
    
  4. Specify the flow and the execute method's FlowActionHandler parameter's "onFailure" and "onSuccess" behaviour:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
        OTPAuthValidationStep otpAuthValidationStep = new OTPAuthValidationStep();
    
        flowSteps = new Step[] {
               otpConfigurationStep, authStep, otpAuthValidationStep
        };
        flowManagerService.execute(flow, flowContext, new FlowActionHandler() {
            @Override
            public void onFailure(Throwable t) {
                //set the status, update the caller activity
            }
    
            @Override
            public void onSuccess(FlowContext result) {
                //set the status, update the caller activity
                //read the result
            }
      });