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 istrue.Declaration
Swift
public var isAllowingOfflineRestore: Bool -
The
OnboardingInfoKeyassociated with an instance ofsapcpmsSettingsParametersin theOnboardingContextinfo. 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
Swift
public init(presenter: FioriBasicCredentialsViewControllerPresenter = FioriBasicCredentialsViewControllerPresenter(), retryCount: Int = 3)Parameters
presenterpresenter to handle BasicCredentialsViewController presenting
retryCountsets how many retry possibilities has the user to enter username/password
-
onboard(sapURLSession:authenticationURL:credentialStore:presentationDelegate:settingsParameters:completionHandler:)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
sapURLSessionSAPURLSessionthat handle the connection to the authenticationURLauthenticationURLresource URL that needs basic authentication
credentialStoreBasicCredentialwill save in the given storepresentationDelegatedelegate to present the
BasicCredentialViewControllersettingsParametersoptional
SAPcpmsSettingsParametersfor initialize anSAPcpmsAuthenticationManageras an authentication handlercompletionHandlercalled when the process finished. Error filled on failure.
-
restore(sapURLSession:authenticationURL:credentialStore:presentationDelegate:settingsParameters:completionHandler:)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
sapURLSessionSAPURLSessionthat handle the connection to the authenticationURLauthenticationURLresource URL that needs basic authentication
credentialStoreBasicCredentialwill save in the given storepresentationDelegatedelegate to present the
BasicCredentialViewControllersettingsParametersoptional
SAPcpmsSettingsParametersfor initialize anSAPcpmsAuthenticationManageras an authentication handlercompletionHandlercalled when the process finished. Error filled on failure.
-
Resets the modifications of step
Declaration
Swift
open func reset(sapURLSession: SAPURLSession, completionHandler: @escaping () -> Void)Parameters
sapURLSessionSAPURLSessionon which the basic authentication observer has to be removedcompletionHandlercalled when the process finished.
-
Create a store to keep the credential
Declaration
Swift
open func createBasicCredentialStore(using credentialsStore: CodableStoring) -> BasicCredentialStoringParameters
credentialsStoreThe provided base store.
Return Value
An instance of
BasicCredential. -
This method creates the
BasicAuthenticationObserverinstance used on theSAPURLSessionin theOnboardingContext. The step user may override this method to supply a customBasicAuthenticationObserver. This can be needed if custom basic authentication screen required.Declaration
Swift
open func createBasicAuthenticationObserver(presenter: FioriBasicCredentialsViewControllerPresenter, credentialStore store: BasicCredentialStoring) -> BasicAuthenticationObserverParameters
basicViewControllerPresenterThe
FioriBasicCredentialsViewControllerPresenterused by the observer.credentialStoreThe
CodableStoringfrom theOnboardingContext.Return Value
An instance of the
BasicAuthenticationObserver.
-
Onboarding function with
OnboardingContextsupportDeclaration
Swift
open func onboard(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)Parameters
contextcompletionHandlercalled when the process finished. Step OnboardingResult filled.
-
Restore function with
OnboardingContextsupportDeclaration
Swift
open func restore(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)Parameters
contextcompletionHandlercalled when the process finished. Step OnboardingResult filled.
-
Background function with
OnboardingContextsupportDeclaration
Swift
open func background(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)Parameters
contextcompletionHandlercalled when the process finished. Step OnboardingResult filled.
-
resetPasscode function with
OnboardingContextsupportDeclaration
Swift
open func resetPasscode(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)Parameters
contextcompletionHandlercalled when the process finished. Step OnboardingResult filled.
-
Reset function with
OnboardingContextsupportDeclaration
Swift
open func reset(context: OnboardingContext, completionHandler: @escaping () -> Void)Parameters
contextcompletionHandlercalled when the process finished.