NMAAuthentication
@objc
public protocol NMAAuthentication : NMAHttpOperation
The object that can be used to trigger an authentication operation.
Usage example:
@interface NMAAuthenticatorSelectorImpl : NSObject <NMAAuthenticatorSelector>
@end
@implementation NMAAuthenticatorSelectorImpl
- (void)selectAuthenticatorWithContext:(id<NMAAuthenticatorSelectionContext> _Nonnull)context handler:(id<NMAAuthenticatorSelectionHandler> _Nonnull)handler {
[handler aaid:aaid];
}
@end
@interface NMABiometricUserVerifierImpl : NSObject <NMABiometricUserVerifier>
@end
@implementation NMABiometricUserVerifierImpl
- (void)verifyBiometricWithContext:(id<NMABiometricUserVerificationContext> _Nonnull)context handler:(id<NMABiometricUserVerificationHandler> _Nonnull)handler {
[handler verify];
}
@end
@interface NMADevicePasscodeUserVerifierImpl : NSObject <NMADevicePasscodeUserVerifier>
@end
@implementation NMADevicePasscodeUserVerifierImpl
- (void)verifyDevicePasscodeWithContext:(id<NMADevicePasscodeUserVerificationContext> _Nonnull)context handler:(id<NMADevicePasscodeUserVerificationHandler> _Nonnull)handler {
[handler verify];
}
@end
@interface NMAPinUserVerifierImpl : NSObject<NMAPinUserVerifier>
@end
@implementation NMAPinUserVerifierImpl
- (void)verifyPinWithContext:(id<NMAPinUserVerificationContext> _Nonnull)context handler:(id<NMAPinUserVerificationHandler> _Nonnull)handler {
[handler verify:pin];
}
@end
@interface NMAPasswordUserVerifierImpl : NSObject<NMAPasswordUserVerifier>
@end
@implementation NMAPasswordUserVerifierImpl
- (void)verifyPasswordWithContext:(id<NMAPasswordUserVerificationContext> _Nonnull)context handler:(id<NMAPasswordUserVerificationHandler> _Nonnull)handler {
[handler verify:password];
}
@end
id<NMAAuthentication> authentication = [[client operations] authentication];
[authentication username:username];
[authentication authenticatorSelector:[[NMAAuthenticatorSelectorImpl alloc] init]];
[authentication biometricUserVerifier:[[NMABiometricUserVerifierImpl alloc] init]];
[authentication devicePasscodeUserVerifier:[[NMADevicePasscodeUserVerifierImpl alloc] init]];
[authentication pinUserVerifier:[[NMAPinUserVerifierImpl alloc] init]];
[authentication passwordUserVerifier:[[NMAPasswordUserVerifierImpl alloc] init]];
[authentication onSuccess:^(id<NMAAuthorizationProvider> _Nullable authorizationProvider) {...}];
[authentication onError:^(NMAOperationError * _Nonnull error) {...}];
[authentication execute];
-
Specifies the username that must be used to authenticate.
Important
Providing the username is required.Declaration
Swift
@discardableResult func username(_ username: String) -> NMAAuthentication
Parameters
username
the username.
Return Value
the
NMAAuthentication
builder. -
Specifies the session provider that must be used to authenticate.
Declaration
Swift
@discardableResult func sessionProvider(_ sessionProvider: NMASessionProvider) -> NMAAuthentication
Parameters
sessionProvider
Return Value
the
NMAAuthentication
builder. -
The retry policy to be used to obtain an
NMAAuthorizationProvider
after the user authenticates successfully. If obtaining anNMAAuthorizationProvider
fails on the first try, the SDK will retry according to the providedNMARetryPolicy
.Declaration
Swift
@discardableResult func retryPolicyObtainingAuthorizationProvider(_ retryPolicy: NMARetryPolicy) -> NMAAuthentication
Parameters
retryPolicy
the retry policy to be used when retrieving the
NMAAuthorizationProvider
. By default, the code will retry 3 times with a time interval of 1 second between tries.Return Value
the
NMAAuthentication
builder. -
Specifies the object that will take care of the selection of the authenticator to be used.
Important
Providing the authenticator selector is required.Declaration
Swift
@discardableResult func authenticatorSelector(_ authenticatorSelector: NMAAuthenticatorSelector) -> NMAAuthentication
Parameters
authenticatorSelector
Return Value
the
NMAAuthentication
builder. -
Specifies the object that will take care of the biometric user verification.
Important
Providing at least one of theNMABiometricUserVerifier
,NMADevicePasscodeUserVerifier
,NMAPinUserVerifier
orNMAPasswordUserVerifier
is required.Declaration
Swift
@discardableResult func biometricUserVerifier(_ biometricUserVerifier: NMABiometricUserVerifier) -> NMAAuthentication
Parameters
biometricUserVerifier
Return Value
the
NMAAuthentication
builder. -
Specifies the object that will take care of the device passcode user verification.
Important
Providing at least one of theNMABiometricUserVerifier
,NMADevicePasscodeUserVerifier
,NMAPinUserVerifier
orNMAPasswordUserVerifier
is required.Declaration
Swift
@discardableResult func devicePasscodeUserVerifier(_ devicePasscodeUserVerifier: NMADevicePasscodeUserVerifier) -> NMAAuthentication
Parameters
devicePasscodeUserVerifier
Return Value
the
NMAAuthentication
builder. -
Specifies the object that will take care of the PIN user verification.
Important
Providing at least one of theNMABiometricUserVerifier
,NMADevicePasscodeUserVerifier
,NMAPinUserVerifier
orNMAPasswordUserVerifier
is required.Declaration
Swift
@discardableResult func pinUserVerifier(_ pinUserVerifier: NMAPinUserVerifier) -> NMAAuthentication
Parameters
pinUserVerifier
the
NMAPinUserVerifier
.Return Value
the
NMAAuthentication
builder. -
Specifies the object that will take care of the password user verification.
Important
Providing at least one of theNMABiometricUserVerifier
,NMADevicePasscodeUserVerifier
,NMAPinUserVerifier
orNMAPasswordUserVerifier
is required.Declaration
Swift
@discardableResult func passwordUserVerifier(_ passwordUserVerifier: NMAPasswordUserVerifier) -> NMAAuthentication
Parameters
passwordUserVerifier
Return Value
the
NMAAuthentication
builder. -
Specifies the block to execute if the authentication was successful.
Important
Providing theonSuccess
block is required.Declaration
Swift
@discardableResult func onSuccess(_ onSuccess: @escaping (NMAAuthorizationProvider?) -> ()) -> NMAAuthentication
Parameters
onSuccess
the block to execute on successful authentication, receives an optional
NMAAuthorizationProvider
.Return Value
the
NMAAuthentication
builder. -
Specifies the block to execute if the authentication failed.
Important
Providing theonError
block is required.Declaration
Swift
@discardableResult func onError(_ onError: @escaping (NMAAuthenticationError) -> ()) -> NMAAuthentication
Parameters
onError
the block to execute on failed authentication, receives an
NMAAuthenticationError
.Return Value
the
NMAAuthentication
builder.