ChallengeContext
public final class ChallengeContext
The ChallengeContext
is a container of challenge mechanisms that get invoked when an authorization challenge is returned from a request to a protected resource.
-
Get or set the session delegate that handles authentication requests. Refer to URLSessionDelegate. Default is
nil
.Declaration
Swift
public var serverTrustDelegate: URLSessionDelegate?
-
The timeout interval for the request, in seconds. The default is 30 seconds.
Declaration
Swift
public var timeoutInterval: TimeInterval
-
Returns the shared defaults object.
Declaration
Swift
public static let shared: ChallengeContext
-
Gets the list of registered mechanism identifiers.
Declaration
Swift
public var mechanismIdentifiers: [String] { get }
-
This method registers an instance of the
ChallengeProtocol
.Declaration
Swift
public func register(_ mechanism: ChallengeProtocol)
Parameters
mechanism
The mechanism
ChallengeProtocol
type. -
This method registers an array of
ChallengeProtocol
instances.Declaration
Swift
public func register(_ mechanisms: [ChallengeProtocol])
Parameters
mechanisms
An array of mechanisms to register.
-
Invokes a known policy enforcement point.
Declaration
Swift
public func invoke(_ endpointUrl: String, token: OAuthToken, completion: @escaping (ChallengeResult) -> Void)
Parameters
endpointUrl
The location of the policy endpoint.
token
The
OAuthToken
to consume with the request.completion
The function delegate that is invoked with a
ChallengeResult
. -
Submits the mechanism for verification.
Declaration
Swift
public func verify(_ endpointUrl: String, token: OAuthToken, data: [String: Any], completion: @escaping (ChallengeResult) -> Void)
Parameters
endpointUrl
The location of the policy endpoint to verify the challenge.
token
An instance of
OAuthToken
.data
The
Dictionary
representing the postback challenge data.completion
The function delegate that is invoked with a
ChallengeResult
. -
Unenroll a challenge mechanism for a device.
Declaration
Swift
public func unenroll(_ endpointUrl: String, token: OAuthToken, enrollmentType: String, completion: @escaping (UnenrollResult) -> Void)
Parameters
endpointUrl
The location of the endpoint to unenroll a challenge.
token
An instance of
OAuthToken
.enrollmentType
The type of enrollment.
completion
The function delegate that is invoked with a
UnenrollResult
. -
Enroll a challenge mechanism for a device.
Remark
The HTTP method is supplied from the
EnrollmentProtocol
and supports POST and GET only. All other values will result in an error.Declaration
Swift
public func enroll(_ endpointUrl: String, token: OAuthToken, enrollment: EnrollmentProtocol, completion: @escaping (EnrollmentResult) -> Void)
Parameters
endpointUrl
The location of the endpoint to enroll a challenge.
token
An instance of
OAuthToken
.data
The
EnrollmentProtocol
representing the enrollment object.completion
The function delegate that is invoked with a
EnrollmentResult
. -
Executes a query for pending transactions requiring a challenge.
Declaration
Swift
public func pendingTransactions(_ endpointUrl: String, token: OAuthToken, nextTransactionOnly: Bool, orderBy: ComparisonResult = .orderedDescending, completion: @escaping (PendingTransactionsResult) -> Void)
Parameters
endpointUrl
The location of the policy endpoint.
token
The
OAuthToken
to consume with the request.nextTransactionOnly
Filters the transactions only to return the next pending.
orderBy
Orders the list of transactions. Default
NSComparisonResult.OrderedDescending
.completion
The function delegate that is invoked with a
PendingTransactionsResult
. -
Executes a query for pending transactions requiring a challenge.
Declaration
Swift
public func pendingTransactions(_ endpointUrl: String, token: OAuthToken, orderBy: ComparisonResult = .orderedDescending, completion: @escaping (PendingTransactionsResult) -> Void)
Parameters
endpointUrl
The location of the policy endpoint.
token
The
OAuthToken
to consume with the request.orderBy
Orders the list of transactions. Default
NSComparisonResult.OrderedDescending
.completion
The function delegate that is invoked with a
PendingTransactionsResult
. -
Executes a query for a pending transaction requiring a challenge.
Declaration
Swift
public func pendingTransactions(_ endpointUrl: String, token: OAuthToken, transactionId: String, completion: @escaping (PendingTransactionsResult) -> Void)
Parameters
endpointUrl
The location of the policy endpoint.
token
The
OAuthToken
to consume with the request.transactionId
The unique identifer of the transaction.
completion
The function delegate that is invoked with a
PendingTransactionsResult
.