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
OnboardingInfoKey
associated with an instance ofsapcpmsSettingsParameters
in theOnboardingContext
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
Swift
public init(presenter: FioriBasicCredentialsViewControllerPresenter = FioriBasicCredentialsViewControllerPresenter(), retryCount: Int = 3)
Parameters
presenter
presenter to handle BasicCredentialsViewController presenting
retryCount
sets 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
sapURLSession
SAPURLSession
that handle the connection to the authenticationURLauthenticationURL
resource URL that needs basic authentication
credentialStore
BasicCredential
will save in the given storepresentationDelegate
delegate to present the
BasicCredentialViewController
settingsParameters
optional
SAPcpmsSettingsParameters
for initialize anSAPcpmsAuthenticationManager
as an authentication handlercompletionHandler
called 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
sapURLSession
SAPURLSession
that handle the connection to the authenticationURLauthenticationURL
resource URL that needs basic authentication
credentialStore
BasicCredential
will save in the given storepresentationDelegate
delegate to present the
BasicCredentialViewController
settingsParameters
optional
SAPcpmsSettingsParameters
for initialize anSAPcpmsAuthenticationManager
as an authentication handlercompletionHandler
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 removedcompletionHandler
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 theSAPURLSession
in 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) -> BasicAuthenticationObserver
Parameters
basicViewControllerPresenter
The
FioriBasicCredentialsViewControllerPresenter
used by the observer.credentialStore
The
CodableStoring
from theOnboardingContext
.Return Value
An instance of the
BasicAuthenticationObserver
.
-
Onboarding function with
OnboardingContext
supportDeclaration
Swift
open func onboard(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)
Parameters
context
completionHandler
called when the process finished. Step OnboardingResult filled.
-
Restore function with
OnboardingContext
supportDeclaration
Swift
open func restore(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)
Parameters
context
completionHandler
called when the process finished. Step OnboardingResult filled.
-
Background function with
OnboardingContext
supportDeclaration
Swift
open func background(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)
Parameters
context
completionHandler
called when the process finished. Step OnboardingResult filled.
-
resetPasscode function with
OnboardingContext
supportDeclaration
Swift
open func resetPasscode(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)
Parameters
context
completionHandler
called when the process finished. Step OnboardingResult filled.
-
Reset function with
OnboardingContext
supportDeclaration
Swift
open func reset(context: OnboardingContext, completionHandler: @escaping () -> Void)
Parameters
context
completionHandler
called when the process finished.