BasicAuthenticationStep

open class BasicAuthenticationStep : OnboardingStep

Onboarding step implementation of Basic Authentication Used in the onboarding/restoring flow, this step is responsible to configure the app’s URLSession to be able to communicate with basic authentication protected resources. Creates and registers the BasicAuthenticationObserver to the SAPURLSession, then sends a validation request which will trigger an authentication flow.

Customization

During the onboarding flow, if there is a splash screen which shows a text, that text can be changed/localized.

// The customized WelcomeStep can be created like the following code snippet
func customBasicAuthStep() -> OnboardingStep {
   let basicAuthenticationBundle = Bundle(for: BasicAuthenticationStep.self)

   let localizedInfoScreenText = NSLocalizedString("BasicInfoScreenText", tableName: "Example Table name", bundle: basicAuthenticationBundle, value: "Validating Basic credentials", comment: "")
   let localizedCancelButtonText = NSLocalizedString("CancelButtonText", tableName: "Example Table name", bundle: basicAuthenticationBundle, value: "Cancel", comment: "")
   let localizedInformationLabelText = NSLocalizedString("BasicInformationLabelTextKey", tableName: "Example Table name", bundle: basicAuthenticationBundle, value: "Authentication", comment: "")
   let localizedHeadLineLabelText = NSLocalizedString("BasicHeadLineLabelTextKey", tableName: "Example Table name", bundle: basicAuthenticationBundle, value: "Please enter your credentials", comment: "")
   let localizedSignInButtonText = NSLocalizedString("BasicSignInButtonText", tableName: "Example Table name", bundle: basicAuthenticationBundle, value: "Sign In", comment: "")
   let localizedUsernamePlaceholderText = NSLocalizedString("BasicUsernamePlaceholderTextKey", tableName: "Example Table name", bundle: basicAuthenticationBundle, value: "Username", comment: "")
   let localizedPasswordPlaceholderText = NSLocalizedString("BasicPasswordPlaceholderTextKey", tableName: "Example Table name", bundle: basicAuthenticationBundle, value: "Password", comment: "")

   let presenter = FioriBasicCredentialsViewControllerPresenter()
   presenter.basicViewControllerConfigurationHandler = { basicView in
        basicView.headlineLabel.text = localizedHeadLineLabelText
        basicView.informationLabel.text = localizedInformationLabelText
        basicView.signInButton.titleLabel?.text = localizedSignInButtonText
        basicView.usernameTextField.emailTextField.placeholder = localizedUsernamePlaceholderText
        basicView.passwordTextField.emailTextField.placeholder = localizedPasswordPlaceholderText
        basicView.navigationItem.leftBarButtonItem?.title = localizedCancelButtonText
   }
   let step = BasicAuthenticationStep(presenter: presenter)
   step.infoScreenText = localizedInfoScreenText

   return step
}
  • RetryCount to set how many retry possibilities has the user to enter username/password

    Declaration

    Swift

    public var retryCount: Int
  • Property to set the title of info screen

    Declaration

    Swift

    public var infoScreenText: String
  • Tells the authentication step whether offline restore should be supported. If the property is true, the authentication step gracefully handles network conditions when restoring while offline. By default this property is true.

    Declaration

    Swift

    public var isAllowingOfflineRestore: Bool
  • The OnboardingInfoKey associated with an instance of sapcpmsSettingsParameters in the OnboardingContext info. Used for creating the SAPcpmsAuthenticationManager is the AuthenticationDelegate is present.

    Declaration

    Swift

    public var settingsParametersInfoKey: OnboardingInfoKey
  • The delegate which is called by SAPcpmsAuthenticationManager. If this property is nil, then the SAPcpmsAuthenticationManager will not be created.

    Declaration

    Swift

    public weak var authenticationDelegate: AuthenticationDelegate?
  • Designated initializer

    Declaration

    Parameters

    presenter

    presenter to handle BasicCredentialsViewController presenting

    retryCount

    sets how many retry possibilities has the user to enter username/password

  • Onboards to the given URL

    Declaration

    Swift

    open func onboard(sapURLSession: SAPURLSession, authenticationURL: URL, credentialStore: CodableStoring, presentationDelegate: FlowPresentationDelegate, settingsParameters: SAPcpmsSettingsParameters? = nil, completionHandler: @escaping (Error?) -> Void)

    Parameters

    sapURLSession

    SAPURLSession that handle the connection to the authenticationURL

    authenticationURL

    resource URL that needs basic authentication

    credentialStore

    BasicCredential will save in the given store

    presentationDelegate

    delegate to present the BasicCredentialViewController

    settingsParameters

    optional SAPcpmsSettingsParameters for initialize an SAPcpmsAuthenticationManager as an authentication handler

    completionHandler

    called when the process finished. Error filled on failure.

  • Restore the previous state of onboarding

    Declaration

    Swift

    open func restore(sapURLSession: SAPURLSession, authenticationURL: URL, credentialStore: CodableStoring, presentationDelegate: FlowPresentationDelegate, settingsParameters: SAPcpmsSettingsParameters? = nil, completionHandler: @escaping (Error?) -> Void)

    Parameters

    sapURLSession

    SAPURLSession that handle the connection to the authenticationURL

    authenticationURL

    resource URL that needs basic authentication

    credentialStore

    BasicCredential will save in the given store

    presentationDelegate

    delegate to present the BasicCredentialViewController

    settingsParameters

    optional SAPcpmsSettingsParameters for initialize an SAPcpmsAuthenticationManager as an authentication handler

    completionHandler

    called when the process finished. Error filled on failure.

  • Resets the modifications of step

    Declaration

    Swift

    open func reset(sapURLSession: SAPURLSession, completionHandler: @escaping () -> Void)

    Parameters

    sapURLSession

    SAPURLSession on which the basic authentication observer has to be removed

    completionHandler

    called when the process finished.

  • Create a store to keep the credential

    Declaration

    Swift

    open func createBasicCredentialStore(using credentialsStore: CodableStoring) -> BasicCredentialStoring

    Parameters

    credentialsStore

    The provided base store.

    Return Value

    An instance of BasicCredential.

  • This method creates the BasicAuthenticationObserver instance used on the SAPURLSession in the OnboardingContext. The step user may override this method to supply a custom BasicAuthenticationObserver. This can be needed if custom basic authentication screen required.

    Declaration

    Swift

    open func createBasicAuthenticationObserver(presenter: FioriBasicCredentialsViewControllerPresenter, credentialStore store: BasicCredentialStoring) -> BasicAuthenticationObserver

    Parameters

    basicViewControllerPresenter
    credentialStore

    The CodableStoring from the OnboardingContext.

    Return Value

    An instance of the BasicAuthenticationObserver.