LogoutHandler
public class LogoutHandler
extension LogoutHandler: SAPURLSessionObserving
extension LogoutHandler : AppDelegateObserving, SceneDelegateObserving
Class responsible for managing the logout process in the browser.
Example Usage:
Do not forget to set few things before calling logout:
In case of OAUth or SAML Authorization (with Presenter)
```swift
LogoutHandler.shared.set(sapURLSession: <SAPURLSession>)
LogoutHandler.shared.set(settingsParameters: <SAPcpmsSettingsParameters>)
LogoutHandler.shared.set(authenticationType: <AuthenticationType>)
```
In case of Basic Authorization
```swift
LogoutHandler.shared.set(sapURLSession: <SAPURLSession>)
```
In case of OAuth (with External Browser)
```swift
LogoutHandler.shared.set(sapURLSession: <SAPURLSession>)
LogoutHandler.shared.set(settingsParameters: <SAPcpmsSettingsParameters>)
LogoutHandler.shared.set(authenticationTypeForBrowser: <AuthenticationTypeForBrowser>)
```
Do logout:
LogoutHandler.shared.logout { error in
if error == nil {
// handle success case
} else {
// handle error case
}
}
-
Singleton object for
LogoutHandlerDeclaration
Swift
public static let shared: LogoutHandler -
An enum that includes the authentication types for which logout is supported.
See moreDeclaration
Swift
public enum AuthenticationType -
Enum for handling external browser logout for OAuth
See moreDeclaration
Swift
public enum AuthenticationTypeForBrowser -
Sets the
SAPURLSessionfor network operations.Declaration
Swift
public func set(sapURLSession: SAPURLSession)Parameters
sapURLSessionThe
SAPURLSessioninstance to be used for API calls. -
Sets the
SAPcpmsSettingsParametersparameter.Declaration
Swift
public func set(settingsParameters: SAPcpmsSettingsParameters)Parameters
settingsParametersThe
SAPcpmsSettingsParametersinstance containing necessary settings. -
Configures the authentication type used for the logout process.
Declaration
Swift
public func set(authenticationType: AuthenticationType)Parameters
authenticationTypeThe
AuthenticationTypeto set, which can be either SAML or OAuth. -
/// Configures the Revoke Level type used for the logout process.
Declaration
Swift
public func set(logoutRevokeLevel: LogoutRevokeLevel)Parameters
revokeLevelThe
revokeLevelto set, which can be eitheruserordevice, default isuser. -
Configures the authentication type for browser used for the logout process.
Declaration
Swift
public func set(authenticationTypeForBrowser: AuthenticationTypeForBrowser)Parameters
authenticationTypeForBrowserThe
AuthenticationTypeForBrowserto set, specifically for OAuth. -
Initiates the logout process and calls the completion handler upon completion.
Declaration
Swift
public func logout(completionHandler: @escaping (Error?) -> ())Parameters
completionHandlerA closure that gets called with an optional
Errorafter the logout attempt.
-
Handles HTTP redirections during the logout process. It saves the first redirect request, and calls the handler which will further load that request in the browser.
Declaration
Swift
public func sapURLSession(_ session: SAPURLSession, task: SAPURLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (SAPURLSession.HTTPRedirectDisposition) -> Void)Parameters
sessionThe
SAPURLSessioninstance managing the tasks.taskThe
SAPURLSessionTaskthat is being redirected.responseThe HTTP response containing redirection information.
requestThe new
URLRequestthat is being redirected to.completionHandlerA closure to call with the disposition of the redirect.
-
Declaration
Swift
public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool
-
Declaration
Swift
public func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>)