CLASS
HaapiManager
Contents
- Properties
isSupporteddpop
- Methods
init(haapiConfiguration:)deinitclose()start(completionHandler:)start()submitForm(_:parameters:completionHandler:)submitForm(_:parameters:)followLink(_:completionHandler:)followLink(_:)
public final class HaapiManager: NSObject
HaapiManager manages the communication flow between a client and the Curity Identity Server by providing data models objects
for the different steps of the flow, which can be used in the UI components of the client application.
A HAAPI flow can be initiated by calling the start function, which will provide a first result. Afterwards, use
either submitForm or followLink to move forward. All these methods return an HaapiResult, which encloses a HaapiRepresentation, a ProblemRepresentation or an Error.
A HaapiRepresentation represents a new step in the flow.
A ProblemRepresentation indicates that a problem has occurred.
An Error encloses an exception, in which case the flow should be stopped.
The purpose of using this class is to obtain an OAuthAuthorizationResponseStep that contains the authorization response details.
- SeeAlso:
OAuthTokenManager
Properties
isSupported
public static var isSupported: Bool
A Boolean that indicates whether HAAPI is supported on a particular device.
dpop
public var dpop: Dpop?
Returns the last used Dpop.
- Note: It is required when reaching the end of the Haapi flow and fetching the access token by invoking
OAuthTokenManager.fetchAccessToken.
Methods
init(haapiConfiguration:)
public init(haapiConfiguration: HaapiConfigurable) throws
Creates an instance of HaapiManager based on the provided HaapiConfigurable.
- Parameters:
- haapiConfiguration: The configuration used to build this instance.
- Throws:
HaapiErrorif the configuration is incorrect
Parameters
| Name | Description |
|---|---|
| haapiConfiguration | The configuration used to build this instance. |
deinit
deinit
close()
public func close()
Closes this instance, which closes the underlying HaapiTokenManager instance.
start(completionHandler:)
public func start(completionHandler: @escaping HaapiCompletionHandler)
Starts the HAAPI flow by performing an authorization request.
The client_id, response_type and redirect_uri parameters are always added based on the configuration values.
- Parameters:
- completionHandler: A completion handler that is called when
startis complete.
- completionHandler: A completion handler that is called when
Parameters
| Name | Description |
|---|---|
| completionHandler | A completion handler that is called when start is complete. |
start()
public func start() async -> HaapiResult
Starts the HAAPI flow by performing an authorization request.
The client_id, response_type and redirect_uri parameters are always added based on the configuration values.
- Returns: An HaapiResult.
submitForm(_:parameters:completionHandler:)
public func submitForm(_ form: FormActionModel,
parameters: [String: Any],
completionHandler: @escaping HaapiCompletionHandler)
Submits a form action to move forward in the HAAPI flow.
The parameters supplied to this method override the field values present in the form. If the parameters don't include a value for a given form field name, the original value in the form is used. Parameters whose key is not included in the form fields names are not included in the request
- Parameters:
- form: The form action to be submitted
- parameters: Parameters to be sent in the form. Keys should match the corresponding form field names.
- completionHandler: A completion handler that is called when
submitFormis complete.
- Note: This method disallows FormActionModel.type == "GET" when
parametersis not of type Dictionary<String, String>.
Parameters
| Name | Description |
|---|---|
| form | The form action to be submitted |
| parameters | Parameters to be sent in the form. Keys should match the corresponding form field names. |
| completionHandler | A completion handler that is called when submitForm is complete. |
submitForm(_:parameters:)
public func submitForm(_ form: FormActionModel,
parameters: [String: Any]) async -> HaapiResult
Submits a form action to move forward in the HAAPI flow.
The parameters supplied to this method override the field values present in the form. If the parameters don't include a value for a given form field name, the original value in the form is used. Parameters whose key is not included in the form fields names are not included in the request
- Parameters:
- form: The form action to be submitted
- parameters: Parameters to be sent in the form. Keys should match the corresponding form field names.
- completionHandler: A completion handler that is called when
submitFormis complete.
- Returns: An HaapiResult.
- Note: This method disallows FormActionModel.type == "GET" when
parametersis not of type Dictionary<String, String>.
Parameters
| Name | Description |
|---|---|
| form | The form action to be submitted |
| parameters | Parameters to be sent in the form. Keys should match the corresponding form field names. |
| completionHandler | A completion handler that is called when submitForm is complete. |
followLink(_:completionHandler:)
public func followLink(_ link: Link, completionHandler: @escaping HaapiCompletionHandler)
Follows a link to an alternative HAAPI flow.
Links are always followed using a GET request.
- Parameters:
- link: The link to be followed.
- completionHandler: A completion handler that is called when
followLinkis complete.
followLink(_:)
public func followLink(_ link: Link) async -> HaapiResult
Follows a link to an alternative HAAPI flow.
Links are always followed using a GET request.
- Parameters:
- link: The link to be followed.
- Returns: An HaapiResult.
Parameters
| Name | Description |
|---|---|
| link | The link to be followed. |