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
LogoutHandler
Declaration
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
SAPURLSession
for network operations.Declaration
Swift
public func set(sapURLSession: SAPURLSession)
Parameters
sapURLSession
The
SAPURLSession
instance to be used for API calls. -
Sets the
SAPcpmsSettingsParameters
parameter.Declaration
Swift
public func set(settingsParameters: SAPcpmsSettingsParameters)
Parameters
settingsParameters
The
SAPcpmsSettingsParameters
instance containing necessary settings. -
Configures the authentication type used for the logout process.
Declaration
Swift
public func set(authenticationType: AuthenticationType)
Parameters
authenticationType
The
AuthenticationType
to set, which can be either SAML or OAuth. -
Configures the authentication type for browser used for the logout process.
Declaration
Swift
public func set(authenticationTypeForBrowser: AuthenticationTypeForBrowser)
Parameters
authenticationTypeForBrowser
The
AuthenticationTypeForBrowser
to set, specifically for OAuth. -
Initiates the logout process and calls the completion handler upon completion.
Declaration
Swift
public func logout(completionHandler: @escaping (Error?) -> ())
Parameters
completionHandler
A closure that gets called with an optional
Error
after 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
session
The
SAPURLSession
instance managing the tasks.task
The
SAPURLSessionTask
that is being redirected.response
The HTTP response containing redirection information.
request
The new
URLRequest
that is being redirected to.completionHandler
A 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>)