Package org.forgerock.android.auth
Class FRAClient
- java.lang.Object
-
- org.forgerock.android.auth.FRAClient
-
public class FRAClient extends java.lang.ObjectThe top level FRAClient object represents the Authenticator module of the ForgeRock Mobile SDK. It is the front facing class where the configuration settings for the SDK can be found and utilized.To create a new FRAClient object use the static
builder().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFRAClient.FRAClientBuilderThe asynchronous Authenticator client builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FRAClient.FRAClientBuilderbuilder()Obtain FRAClient builder.voidcreateMechanismFromUri(java.lang.String uri, FRAListener<Mechanism> listener)Create a Mechanism using the URL extracted from the QRCode.AccountgetAccount(java.lang.String accountId)Get the Account object with its id.AccountgetAccount(Mechanism mechanism)Get the Account object with its associated Mechanism.java.util.List<Account>getAllAccounts()Get all accounts stored in the system.java.util.List<PushNotification>getAllNotifications()Get single list of notifications across all mechanisms.java.util.List<PushNotification>getAllNotifications(Mechanism mechanism)Get all of the notifications that belong to aPushMechanismobject.MechanismgetMechanism(PushNotification notification)Get the Mechanism object associated with the PushNotification object.PushNotificationgetNotification(java.lang.String notificationId)Get the PushNotification object with its id.PushNotificationhandleMessage(com.google.firebase.messaging.RemoteMessage message)Receives a FCM remote message and covert into aPushNotificationobject, which allows accept or deny Push Authentication requests.PushNotificationhandleMessage(java.lang.String messageId, java.lang.String message)Receives the parameters from a FCM remote message and covert into aPushNotificationobject, which allows accept or deny Push Authentication requests.voidregisterForRemoteNotifications(java.lang.String deviceToken)This method allows to register the FCM device token to handle Push mechanisms after the SDK initialization.booleanremoveAccount(Account account)Remove from the storage theAccountthat was passed in, allMechanismobjects and anyPushNotificationobjects associated with it.booleanremoveMechanism(Mechanism mechanism)Remove from the storage theMechanismthat was passed in and any notifications associated with it.booleanremoveNotification(PushNotification notification)Remove from the storage thePushNotificationthat was passed in.booleanupdateAccount(Account account)Update theAccountobject the storage system.
-
-
-
Method Detail
-
builder
public static FRAClient.FRAClientBuilder builder()
Obtain FRAClient builder. Settings can be configured in the builder, like setting the FCM token or StorageClient implementation.- Returns:
- FRAClientBuilder the builder to initialize the FRAClient
-
createMechanismFromUri
public void createMechanismFromUri(@NonNull java.lang.String uri, @NonNull FRAListener<Mechanism> listener)Create a Mechanism using the URL extracted from the QRCode. This URL contains information about the mechanism itself, as the account. After validation the mechanism will be persisted and returned via the callback .- Parameters:
uri- The URI extracted from the QRCodelistener- Callback for receiving the mechanism registration result
-
getAllAccounts
public java.util.List<Account> getAllAccounts()
Get all accounts stored in the system. Returnsnullif no Account could be found. This method full initialize theMechanismand/orPushNotificationobjects associated with the accounts.- Returns:
- List
The complete list of accounts stored on the system
-
getAccount
public Account getAccount(@NonNull java.lang.String accountId)
Get the Account object with its id. Identifier of Account object is "- " Returns nullif Account could not be found. This method full initialize theMechanismobjects associated with the account.- Parameters:
accountId- The account unique ID- Returns:
- The account object
-
getAccount
public Account getAccount(@NonNull Mechanism mechanism)
Get the Account object with its associated Mechanism. Returnsnullif Account could not be found. This method does not initialize theMechanismand/orPushNotificationobjects associated with the account.- Parameters:
mechanism- The Mechanism object- Returns:
- The account object
-
updateAccount
public boolean updateAccount(@NonNull Account account)Update theAccountobject the storage system. Returnsfalseif it could not be found or updated.- Parameters:
account- The Account to update.- Returns:
- boolean as result of the operation
-
removeAccount
public boolean removeAccount(@NonNull Account account)Remove from the storage theAccountthat was passed in, allMechanismobjects and anyPushNotificationobjects associated with it.- Parameters:
account- The account object to delete- Returns:
- boolean as result of the operation
-
getMechanism
public Mechanism getMechanism(@NonNull PushNotification notification)
Get the Mechanism object associated with the PushNotification object. Returnsnullif Mechanism could not be found. This method full initialize thePushNotificationobjects associated with.PushMechanismtype- Parameters:
notification- The uniquely identifiable UUID for the mechanism- Returns:
- The Mechanism object
-
removeMechanism
public boolean removeMechanism(@NonNull Mechanism mechanism)Remove from the storage theMechanismthat was passed in and any notifications associated with it.- Parameters:
mechanism- The mechanism object to delete- Returns:
- boolean as result of the operation
-
getAllNotifications
public java.util.List<PushNotification> getAllNotifications()
Get single list of notifications across all mechanisms. Returnsnullif noPushNotificationcould be found.- Returns:
- The complete list of notifications
-
getAllNotifications
public java.util.List<PushNotification> getAllNotifications(@NonNull Mechanism mechanism)
Get all of the notifications that belong to aPushMechanismobject. Returnsnullif noPushNotificationcould be found or the Mechanism type is invalid. This also updates the passedPushMechanismobject with the list ofPushNotificationobjects associated with it.- Parameters:
mechanism- The Mechanism object- Returns:
- The list of notifications
-
getNotification
public PushNotification getNotification(@NonNull java.lang.String notificationId)
Get the PushNotification object with its id. Identifier of PushNotification object is "- " Returns nullif PushNotification could not be found. This method also sets theMechanismobject associated with the PushNotification.- Parameters:
notificationId- The notification unique ID- Returns:
- The PushNotification object
-
removeNotification
public boolean removeNotification(@NonNull PushNotification notification)Remove from the storage thePushNotificationthat was passed in.- Parameters:
notification- The PushNotification object to delete- Returns:
- boolean as result of the operation
-
handleMessage
public PushNotification handleMessage(@NonNull com.google.firebase.messaging.RemoteMessage message) throws InvalidNotificationException
Receives a FCM remote message and covert into aPushNotificationobject, which allows accept or deny Push Authentication requests.- Parameters:
message- FCM remote message- Returns:
- PushNotification The notification configured with the information extracted the remote message
- Throws:
InvalidNotificationException- if the remote message does not contain required information
-
handleMessage
public PushNotification handleMessage(@NonNull java.lang.String messageId, @NonNull java.lang.String message) throws InvalidNotificationException
Receives the parameters from a FCM remote message and covert into aPushNotificationobject, which allows accept or deny Push Authentication requests.- Parameters:
messageId- the 'messageId' attribute obtained from theRemoteMessageobjectmessage- the 'message' attribute obtained from theRemoteMessageobject- Returns:
- PushNotification The notification configured with the information extracted the remote message
- Throws:
InvalidNotificationException- if the remote message does not contain required information
-
registerForRemoteNotifications
public void registerForRemoteNotifications(@NonNull java.lang.String deviceToken) throws AuthenticatorExceptionThis method allows to register the FCM device token to handle Push mechanisms after the SDK initialization. Note: This method cannot be used to handle FCM device token updates received onFirebaseMessagingService.onNewToken(java.lang.String). Currently, AM does not accept deviceToken updates from the SDK. If anyPushMechanismwas registered with the previous token, this mechanism needs to be removed and registered again using this new deviceToken.- Parameters:
deviceToken- the FCM device token- Throws:
AuthenticatorException- if the SDK was already initialized with a device token
-
-