Class FRAClient


  • public class FRAClient
    extends java.lang.Object
    The 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().

    • 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 QRCode
        listener - Callback for receiving the mechanism registration result
      • getAllAccounts

        public java.util.List<Account> getAllAccounts()
        Get all accounts stored in the system. Returns null if no Account could be found. This method full initialize the Mechanism and/or PushNotification objects 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 null if Account could not be found. This method full initialize the Mechanism objects 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. Returns null if Account could not be found. This method does not initialize the Mechanism and/or PushNotification objects associated with the account.
        Parameters:
        mechanism - The Mechanism object
        Returns:
        The account object
      • updateAccount

        public boolean updateAccount​(@NonNull
                                     Account account)
        Update the Account object the storage system. Returns false if 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 the Account that was passed in, all Mechanism objects and any PushNotification objects 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. Returns null if Mechanism could not be found. This method full initialize the PushNotification objects associated with. PushMechanism type
        Parameters:
        notification - The uniquely identifiable UUID for the mechanism
        Returns:
        The Mechanism object
      • removeMechanism

        public boolean removeMechanism​(@NonNull
                                       Mechanism mechanism)
        Remove from the storage the Mechanism that 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. Returns null if no PushNotification could 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 a PushMechanism object. Returns null if no PushNotification could be found or the Mechanism type is invalid. This also updates the passed PushMechanism object with the list of PushNotification objects 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 null if PushNotification could not be found. This method also sets the Mechanism object 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 the PushNotification that 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 a PushNotification object, 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 a PushNotification object, which allows accept or deny Push Authentication requests.
        Parameters:
        messageId - the 'messageId' attribute obtained from the RemoteMessage object
        message - the 'message' attribute obtained from the RemoteMessage object
        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 AuthenticatorException
        This 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 on FirebaseMessagingService.onNewToken(java.lang.String). Currently, AM does not accept deviceToken updates from the SDK. If any PushMechanism was 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