Interface PasswordChanger

All Superinterfaces:
PasswordPolicyProvider

public interface PasswordChanger extends PasswordPolicyProvider
The object in charge of password change. It must be implemented by the developer of the SDK.
 private void changePassword() {
     PasswordChanger pinChanger = (context, consumer) -> {
         PasswordAuthenticatorLockState lockState = context.protectionStatus().lockState();
         if (lockState == PasswordAuthenticatorLockState.FAILED_ATTEMPT_COOLDOWN) {
             // Inform the user that the password authenticator is locked temporarily
         } else if (lockState == PasswordAuthenticatorLockState.FAILED_ATTEMPT_RETRIES) {
             int remainingRetries = context.protectionStatus().remainingRetries();
             // Inform the user of the remaining retries before the password gets locked
             // forever
         }
         if (context.lastRecoverableError().isPresent()) {
             // Display error informing that the previously provided passwords were not valid
         }
         char[] oldPassword = askUserForOldPassword();
         char[] newPassword = askUserForNewPassword();
         if (oldPassword != null && newPassword != null) {
             consumer.pins(oldPassword, newPassword);
         }
         else {
             consumer.cancel();
         }
     };
 }

 /**
  * Asks the user to provide the old password. If the user cancels the operation,
  * returns null.
  * @return the old password or null if user cancels the operation.
  */
 private char[] askUserForOldPassword() {
     [...]
 }

 /**
  * Asks the user to provide the new password. If the user cancels the operation,
  * returns null.
  * @return the new password or null if user cancels the operation.
  */
 private char[] askUserForNewPassword() {
     [...]
 }
 
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    The method that will be invoked till either the user provides the old password and a new password that conforms to the format expected by the SDK (i.e.
    Returns the object defining the constraints of the password (minimum length, required special characters, etc.) to be changed.
  • Method Details

    • changePassword

      void changePassword(PasswordChangeContext context, PasswordChangeHandler handler)
      The method that will be invoked till either the user provides the old password and a new password that conforms to the format expected by the SDK (i.e. a 6 digit password), or till the operation is canceled (through the PasswordChangeHandler.cancel()), or till the password authenticator is permanently locked because the user provided too many times an invalid password.
      Parameters:
      context - the context
      handler - the object that must be invoked with the new and old passwords
    • passwordPolicy

      PasswordPolicy passwordPolicy()
      Returns the object defining the constraints of the password (minimum length, required special characters, etc.) to be changed.
      Specified by:
      passwordPolicy in interface PasswordPolicyProvider
      Returns:
      the PasswordPolicy