CLASS

HaapiAccessorBuilder

Contents

@objcMembers public final class HaapiAccessorBuilder: NSObject

HaapiAccessorBuilder allows obtaining the accessors to access HAAPI from the current device, based on an initial static configuration and the device capabilities.

The preferred access strategy is to obtain HAAPI access tokens using client attestation, i.e. the device’s key attestation capabilities. If attestation is not supported, or if the Curity Identity Server deems the attestation data as invalid, an optional fallback strategy based on Dynamic Client Registration can be used.

The DCR-based fallback uses templatized client registration: the client configured in [haapiConfiguration] is used to register a dynamic client based on a template ID configured via [setDcrConfiguration]. The registration happens on the first time the fallback is used for a given template client ID. The resulting client data is stored on the device and considered by [HaapiAccessorBuilder] on subsequent runs.

The HaapiAccessor instances created by this class include:

When the DCR-based access is used, these credentials will be different from what’s supplied in the initial configuration.

The recommended way to use [HaapiAccessorBuilder] is to create a single instance and invoke build once before going through an authorization flow via HAAPI.

let haapiConfiguration: HaapiConfiguration = ...
let dcrConfiguration: DcrConfiguration = ...

let haapiAccessor = HaapiAccessorBuilder(haapiConfiguration)
   .setDcrConfiguration(dcrConfiguration)
   .build()

 // HAAPI flow
let haapiManager: HaapiManager = haapiAccessor.haapiManager
haapiManager.start()
// ... haapiManager.submit/follow ...

// Fetch token with OAuthTokenManager
let oAuthTokenManager: OAuthTokenManager = haapiAccessor.oAuthTokenManager
... oAuthTokenManager.fetch/refresh ...

Methods

init(haapiConfiguration:)

@objc public init(haapiConfiguration: HaapiConfiguration)

Creates an instance of HaapiManager based on the provided HaapiConfigurable.

Parameters

Name Description
haapiConfiguration The configuration used to build this instance.

setHaapiAccessorOption(option:)

public func setHaapiAccessorOption(option: HaapiAccessorOption) -> HaapiAccessorBuilder

Set the option that instructs which HaapiAccessor members are to be created. By defaulf value is HaapiAccessorOption.all.

Parameters

Name Description
option The new HaapiAccessorOption setting.

setDCRConfiguration(configuration:)

public func setDCRConfiguration(configuration: DCRConfiguration) -> HaapiAccessorBuilder

Set the dcr configuration to use. By default, it is set to nil.

Parameters

Name Description
configuration The dcr configuration to use.

build(shouldClearExistingDCRClient:completionHandler:)

public func build<T: HaapiManagerAccessor>(shouldClearExistingDCRClient: Bool = false,
                                           completionHandler: @escaping (Result<T, HaapiError>) -> Void)

Creates a HaapiManagerAccessor. It will check if the device supports key-attestation or not and it will return a configured HaapiAccessor.

Parameters

Name Description
shouldClearExistingDCRClient Instructs the framework to clear the existing Dcr Client. False is the default value.
completionHandler a handler that takes the (success or error) response to process it.

build(shouldClearExistingDCRClient:)

public func build<T: HaapiManagerAccessor>(shouldClearExistingDCRClient: Bool = false) async throws -> T

Creates a HaapiManagerAccessor. It will check if the device supports key-attestation or not and it will return a configured HaapiAccessor. This method should be invoked only once. If it has to be invoked multiple times for the same configuration and HaapiAccessorOption.all was configured, be sure to invoke HaapiManager.close before invoking build again.

Parameters

Name Description
shouldClearExistingDCRClient Instructs the framework to clear the existing Dcr Client. False is the default value.