Package 

Class SecureCredentialsManager


  • 
    public final class SecureCredentialsManager
    extends BaseCredentialsManager
                        

    A safer alternative to the CredentialsManager class. A combination of RSA and AES keys is used to keep the values secure. On devices with a Secure LockScreen configured (PIN, Pattern, Password or Fingerprint) an extra authentication step can be required.

    • Constructor Detail

      • SecureCredentialsManager

        SecureCredentialsManager(Context context, AuthenticationAPIClient apiClient, Storage storage)
        Creates a new SecureCredentialsManager to handle Credentials
        Parameters:
        context - a valid context
        apiClient - the Auth0 Authentication API Client to handle token refreshment when needed.
        storage - the storage implementation to use
    • Method Detail

      • requireAuthentication

         final Boolean requireAuthentication(Activity activity, Integer requestCode, String title, String description)

        Require the user to authenticate using the configured LockScreen before accessing the credentials. This feature is disabled by default and will only work if the device is running on Android version 21 or up and if the user has configured a secure LockScreen (PIN, Pattern, Password or Fingerprint).

        The activity passed as first argument here must override the Activity.onActivityResult method and call SecureCredentialsManager.checkAuthenticationResult with the received parameters.

        Parameters:
        activity - a valid activity context.
        requestCode - the request code to use in the authentication request.
        title - the text to use as title in the authentication screen.
        description - the text to use as description in the authentication screen.
      • saveCredentials

         Unit saveCredentials(Credentials credentials)

        Saves the given credentials in the Storage.

        Parameters:
        credentials - the credentials to save.
      • getCredentials

         Unit getCredentials(String scope, Integer minTtl, Callback<Credentials, CredentialsManagerException> callback)

        Tries to obtain the credentials from the Storage. The callback's Callback.onSuccess method will be called with the result. If something unexpected happens, the Callback.onFailure method will be called with the error. Some devices are not compatible at all with the cryptographic implementation and will have CredentialsManagerException.isDeviceIncompatible return true.

        If a LockScreen is setup and .requireAuthentication was called, the user will be asked to authenticate before accessing the credentials. Your activity must override the Activity.onActivityResult method and call .checkAuthenticationResult with the received values.

        Parameters:
        scope - the scope to request for the access token.
        minTtl - the minimum time in seconds that the access token should last before expiration.
        callback - the callback to receive the result in.
      • hasValidCredentials

         Boolean hasValidCredentials()

        Returns whether this manager contains a valid non-expired pair of credentials.

      • hasValidCredentials

         Boolean hasValidCredentials(Long minTtl)

        Returns whether this manager contains a valid non-expired pair of credentials.

        Parameters:
        minTtl - the minimum time in seconds that the access token should last before expiration.