CLASS

HaapiTokenManager.Builder

Contents

public class Builder

The HaapiTokenManager Builder is used to instantiate a HaapiTokenManager with the settings that are appropriate for your environment by using the Builder pattern.

An example use of the Builder to create a default HaapiTokenManager could look like this:

let urlSession = URLSession(configuration: configuration, delegate: trustAllCertsDelegate, delegateQueue: nil)

haapiTokenManager = HaapiTokenManager.Builder(
   tokenEndpoint: "https://my.curity.example.com/oauth/token",
   clientId: "my-haapi-client"
)
.setInternalUrlSession(urlSession)
.build()

Methods

init(tokenEndpoint:clientId:)

public init (tokenEndpoint: URL,
             clientId: String)

Initialize the Builder with the mandatory tokenEndpoint and clientId parameters

setName(_:)

public func setName(_ name: String) -> Builder

Set a name for the HaapiTokenManager. The name is used as prefix in identifying the storage location where the HaapiTokenManager persists state.

When nothing is set, a default of "haapi" is used as name.

You can not use two HaapiTokenManager instances with the same name.

setStorage(_:)

public func setStorage(_ storage: Storage) -> Builder

Set the storage instance responsible for persisting state of the HaapiTokenManager. When nothing is set, a Keychain storage manager will be used.

setInternalUrlSession(_:)

public func setInternalUrlSession(_ urlSession: URLSession) -> Builder

Set the URLSession instance that is used to make requests to the HAAPI services (e.g. the token endpoint and the HAAPI-enabled endpoints of the server)

When nothing is set, a URLSession with default settings is used.

setHaapiTokenMinTtl(_:)

public func setHaapiTokenMinTtl(_ minTtl: TimeInterval) -> Builder

Set the minimum time to live (in seconds) that the HAAPI Token must be valid for. If the token expires before then, the HaapiTokenManager will try to refresh it.

When nothing is set, a value of 10 is used as minimum time to live

disableDeviceCheckAttestation()

public func disableDeviceCheckAttestation() -> Builder

Allows the created HaapiTokenManager to run on a similator by turning off DeviceCheck attestation/-assertion.

When the compilation target is a simulator, DeviceCheck attestation/-assertion is automatically disabled.

This feature requires the server to be configured to have attestation validation disabled for this client.

build()

public func build() -> HaapiTokenManager

Build a new HaapiTokenManager instance from the state that is created inside the Builder

This method can abort your application if the desired name for a HaapiTokenManager already exists within the current context.