OfflineAuthenticationHandler

open class OfflineAuthenticationHandler: AuthenticationHandler

Base class for all offline authentication handlers

Processes offline authentication.

  • Initializes and returns an OfflineAuthenticationHandler object

    Declaration

    Swift

    public override init()
  • Starts the offline authentication process.

    Called by the associated AuthenticationManager when needed.

    Declaration

    Swift

    override public func authenticate(completionHandler: @escaping (_ result: AuthenticateResult) -> Void)

    Parameters

    completionHandler

    closure called when authentication has completed.

    result

    AuthenticateResult: Success or fail, result of authentication.

  • This method is called from the AuthenticationManager to cache a user’s authorization data during online login so it is available during offline login scenarios.

    Subclasses may override this method to provide extra processing of the user’s authorization information, prior to calling super.cacheAuthorizedUser(userData: ) or could modify how the data is cached. Be aware if modifying how this data is cached, similar changes must be made in retrieveCachedUserData

    See also: retrieveCachedUserData

    See also

    retrieveCachedUserData

    Declaration

    Swift

    open func cacheAuthorizedUser(userData: [String: Any])

    Parameters

    userData

    Dictionary of user information. Usually the user’s name, role information, etc, as returned from the AuthorizationHandler

  • This method is called from the AuthenticationManager to retrieve a user’s authorization data from the cache during offline login.

    Subclasses may override this method to provide extra processing of the user’s authorization information, prior to calling super.retrieveCachedUserData() or could modify how the data is retrieved from the cache, if they made similar changes to cacheAuthorizedUser(userData: )

    See also: cacheAuthorizedUser(userData:)

    See also

    cacheAuthorizedUser(userData:)

    Declaration

    Swift

    open func retrieveCachedUserData() -> [String: Any]

    Return Value

    dictionary of user information previously stored via cacheAuthorizedUser(userData:)

  • This method will erase any existing cached user authorization data

    Subclasses may override this method to allow for proper functioning if they made substantial changes to cacheAuthorizedUser(userData: )

    See also: cacheAuthorizedUser(userData:)

    See also

    cacheAuthorizedUser(userData:)

    Declaration

    Swift

    open func eraseCachedUserData()
  • Returns the location where user’s offline information cache will be stored.

    If overridden, it is expected to return a readable and writeable URL. By default will return a local file URL, with any needed manager directories already created.

    Declaration

    Swift

    open func getCachedUserDataURL() -> URL
  • Declaration

    Swift

    override open func logout(completionHandler: @escaping () -> Void)
  • Should not be called from external consumers. The authenticate method should be used to start the authentication process.

    Accepts the user’s offline credentials as provided by the ProvideCredentialsAuthenticationHandlerDelegate and performs offline authentication.

    Default behavior will validate the provided credentials, and call the ProvideCredentialsAuthenticationHandlerDelegate‘s authenticationHandlerProvidedCredentialsWereInvalid method prior to re-calling the authenticationHandler(, provideCredentialsWithCompletionHandler:) method.

    Subclasses may override this method to provide extra processing/validation of the user’s credentials, prior to calling super.performAuthentication(userName: , password: ) or could modify the actual work of offline authentication, in which case they should call authenticationComplete(status:) with the result of that authentication.

    Declaration

    Swift

    open func performAuthentication(userName: String, password: String)