ONGUserClient Class Reference

Inherits from NSObject
Declared in ONGUserClient.h

Overview

This is the main entry point into the SDK. The public API of the SDK consists of this client and an authorization delegate. The client must be instantiated early in the App lifecycle and thereafter only referred to by it’s shared instance.

+ sharedInstance

Access to the initialized and configured instance of the ONGUserClient. Before calling this method You have to initialize SDK by calling [ONGClientBuilder build].

+ (ONGUserClient *)sharedInstance

Return Value

instance of the configured ONGUserClient.

Discussion

Warning: If the SDK is not initialized via [ONGClientBuilder build] this method throws an exception.

See Also

  • ONGClientBuilder, [ONGClient userClient]

Declared In

ONGUserClient.h

– init

Developers should not try to instantiate SDK on their own. The only valid way to get ONGUserClient instance is by calling [ONGUserClient sharedInstance].

- (instancetype)init

See Also

Declared In

ONGUserClient.h

– authenticateUser:delegate:

Main entry point into the authentication process.

- (void)authenticateUser:(ONGUserProfile *)userProfile delegate:(id<ONGAuthenticationDelegate>)delegate

Parameters

userProfile

profile to authenticate

delegate

authentication delegate, ONGUserClient keeps weak reference on delegate to avoid retain cycles

Declared In

ONGUserClient.h

– registerUser:delegate:

Main entry point into the registration process.

- (void)registerUser:(nullable NSArray<NSString*> *)scopes delegate:(id<ONGRegistrationDelegate>)delegate

Parameters

scopes

array of scopes

delegate

registration delegate, ONGUserClient keeps weak reference on delegate to avoid retain cycles

Declared In

ONGUserClient.h

– reauthenticateUser:delegate:

Forces profiles reauthentication.

- (void)reauthenticateUser:(ONGUserProfile *)userProfile delegate:(id<ONGAuthenticationDelegate>)delegate

Parameters

userProfile

profile to reauthenticate

delegate

authentication delegate, ONGUserClient keeps weak reference on delegate to avoid retain cycles

Declared In

ONGUserClient.h

– changePin:

Initiates the PIN change sequence. If no refresh token is registered then the sequence is cancelled. This will invoke a call to the ONGAuthorizationDelegate - (void)askForPinChange:(NSUInteger)pinSize;

- (void)changePin:(id<ONGChangePinDelegate>)delegate

Parameters

delegate

Object handling change pin callbacks

Declared In

ONGUserClient.h

– authenticatedUserProfile

Return currently authenticated user.

- (nullable ONGUserProfile *)authenticatedUserProfile

Return Value

authenticated user

Declared In

ONGUserClient.h

– validatePinWithPolicy:completion:

Checks if the pin satisfies all pin policy constraints.

- (void)validatePinWithPolicy:(NSString *)pin completion:(void ( ^ ) ( BOOL valid , NSError *_Nullable error ))completion

Parameters

pin

pincode to validate against pin policy constraints

error

pin policy validation error

Return Value

true if all pin policy constraints are satisfied

Discussion

The returned error will be either within the ONGGenericErrorDomain or the ONGPinValidationErrorDomain.

Declared In

ONGUserClient.h

– handleApplicationURL:

Method responsible for handling URLs opened by the application that are directed to Onegini SDK. If URL not directed to the SDK is passed to this method, ONGUserClient will ignore the URL and return NO. ONGUserClient is capable of distinguishing between URL directed to SDK and those that arent.

- (BOOL)handleApplicationURL:(NSURL *)url

Parameters

url

application url

Return Value

value indicating if URL was directed to the SDK or not

Discussion

This methods should be called from application:openURL:options:, application:handleOpenURL: OR application:openURL:sourceApplication:annotation: method of your UIApplicationDelegate delegate.

Declared In

ONGUserClient.h

– logoutUser:

Performs a user logout, by invalidating the access token. The refresh token and client credentials remain untouched.

- (void)logoutUser:(nullable void ( ^ ) ( ONGUserProfile *userProfile , NSError *_Nullable error ))completion

Parameters

completion

completion block that is going to be invoked upon logout completion.

Discussion

The returned error will be either within the ONGGenericErrorDomain or the ONGLogoutErrorDomain.

Declared In

ONGUserClient.h

– storeDevicePushTokenInSession:

Stores the device token for the current session.

- (void)storeDevicePushTokenInSession:(nullable NSData *)deviceToken

Parameters

deviceToken

device token to store

Discussion

This should be invoked from the UIApplicationDelegate - (void)application:(UIApplication )application didRegisterForRemoteNotificationsWithDeviceToken:(NSData )deviceToken

Declared In

ONGUserClient.h

– enrollForMobileAuthentication:

Enrolls the currently connected device for mobile push authentication.

- (void)enrollForMobileAuthentication:(void ( ^ ) ( BOOL enrolled , NSError *_Nullable error ))completion

Parameters

completion

delegate handling mobile enrollment callbacks

Discussion

The device push token must be stored in the session before invoking this method.

See Also

Declared In

ONGUserClient.h

– handleMobileAuthenticationRequest:delegate:

When a push notification is received by the application, the notificaton must be forwarded to the client. The client will then fetch the actual encrypted payload and invoke the delegate with the embedded message.

- (BOOL)handleMobileAuthenticationRequest:(NSDictionary *)userInfo delegate:(id<ONGMobileAuthenticationRequestDelegate>)delegate

Parameters

userInfo

userInfo of received push notification

delegate

delegate responsinble for handling push messages

Return Value

true, if the notification is processed by the Onegini SDK

Discussion

This should be invoked from the UIApplicationDelegate - (void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo

Declared In

ONGUserClient.h

– canHandleMobileAuthenticationRequest:

Ensures that a push notification that is received by the application can be handled by the SDK. It is useful to check whether the SDK can handle it or not for various use reasons. In contrast to handleMobileAuthenticationRequest:delegate: the -canHandleMobileAuthenticationRequest: does not start any handling of the noticiation (no side-effects). It might be useful when you’re building a queue of mobile authentication request handling to prevent interferences between simultaneously received / running requests.

- (BOOL)canHandleMobileAuthenticationRequest:(NSDictionary *)userInfo

Parameters

userInfo

the userInfo of the received push notification

Return Value

true, if the notification can be processed by the Onegini SDK

Declared In

ONGUserClient.h

– userProfiles

List of enrolled users stored locally

- (NSSet<ONGUserProfile*> *)userProfiles

Return Value

Enrolled users

Declared In

ONGUserClient.h

– deregisterUser:completion:

Delete user locally and revoke it from token server

- (void)deregisterUser:(ONGUserProfile *)userProfile completion:(nullable void ( ^ ) ( BOOL deregistered , NSError *_Nullable error ))completion

Parameters

userProfile

user to disconnect.

completion

completion block that will be invoke upon deregistration completion.

Discussion

The returned error will be either within the ONGGenericErrorDomain or the ONGDeregistrationErrorDomain.

Declared In

ONGUserClient.h

– fetchResource:completion:

Perform an authenticated network request. It requires passing an instance of the ONGResourceRequest as parameter. In case of a malformed request no task will be returned and the completion block is called immediatelly (sychronously). The User needs to be authenticated, otherwise SDK will return the ONGFetchResourceErrorUserNotAuthenticated error.

- (nullable ONGNetworkTask *)fetchResource:(ONGResourceRequest *)request completion:(nullable void ( ^ ) ( ONGResourceResponse *_Nullable response , NSError *_Nullable error ))completion

Parameters

request

instance of ONGResourceRequest instantiated manually or by using ONGRequestBuilder

completion

block that will be called either upon request completion or immediatelly in case if validation error.

Return Value

instance of ONGNetworkTask or nil. By utilizing ONGNetworkTask developer may observe and control execution of the request.

Discussion

The returned errors will be within the ONGGenericErrorDomain, ONGFetchResourceErrorDomain or NSURLErrorDomain.

Declared In

ONGUserClient.h

  accessToken

Returns a access token for the currently authenticated user, or nil if no user is currently authenticated.

@property (nonatomic, readonly, nullable) NSString *accessToken

Return Value

String with access token or nil

Discussion

Warning: Do not use this method if you want to fetch resources from your resource gateway: use the resource methods instead.

Declared In

ONGUserClient.h

– nonRegisteredAuthenticatorsForUser:

Returns a set of authenticators which are supported both, client and server side, and are not yet registered.

- (NSSet<ONGAuthenticator*> *)nonRegisteredAuthenticatorsForUser:(ONGUserProfile *)userProfile

Parameters

userProfile

user profile for which authenticators are fetched

Return Value

set of non registered authenticators

Declared In

ONGUserClient.h

– registeredAuthenticatorsForUser:

Returns a set of registered authenticators.

- (NSSet<ONGAuthenticator*> *)registeredAuthenticatorsForUser:(ONGUserProfile *)userProfile

Parameters

userProfile

user profile for which authenticators are fetched

Return Value

set of registered authenticators

Declared In

ONGUserClient.h

– allAuthenticatorsForUser:

Returns a set of both registered and nonregistered authenticators.

- (NSSet<ONGAuthenticator*> *)allAuthenticatorsForUser:(ONGUserProfile *)userProfile

Parameters

userProfile

user profile for which authenticators are fetched

Return Value

set of registered authenticators

Declared In

ONGUserClient.h

– registerAuthenticator:delegate:

Registers an authenticator. Use one of the non registered authenticators returned by nonRegisteredAuthenticatorsForUser: method. Registering an authenticator may require user authentication which is handled by the delegate.

- (void)registerAuthenticator:(ONGAuthenticator *)authenticator delegate:(id<ONGAuthenticatorRegistrationDelegate>)delegate

Parameters

authenticator

to be registered authenticator

delegate

delegate authenticating user

Discussion

The returned errors will be within the ONGGenericErrorDomain, ONGAuthenticatorRegistrationErrorDomain or ONGAuthenticationErrorDomain.

Declared In

ONGUserClient.h

– deregisterAuthenticator:completion:

Deregisters an authenticator. Use one of the registered authenticators returned by registeredAuthenticatorsForUser: method.

- (void)deregisterAuthenticator:(ONGAuthenticator *)authenticator completion:(nullable void ( ^ ) ( BOOL deregistered , NSError *_Nullable error ))completion

Parameters

authenticator

to be deregistered authenticator

completion

block returning result of deregistration action or any encountered error

Discussion

The returned errors will be within the ONGGenericErrorDomain, ONGAuthenticatorDeregistrationErrorDomain or ONGAuthenticationErrorDomain.

Declared In

ONGUserClient.h

  preferredAuthenticator

Represents preferred authenticator. By default SDK uses PIN as preferred authenticator.

@property (nonatomic) ONGAuthenticator *preferredAuthenticator

Declared In

ONGUserClient.h