Interface PasswordPolicy


public interface PasswordPolicy
The object defining whether the password provided by a user during enrollment or when changing it is valid.

For example, the password policy can impose a minimum password length, require the use of capital letters, special characters or numbers.\

See Also:
  • Method Details

    • validatePasswordForEnrollment

      void validatePasswordForEnrollment(char[] password, Runnable onSuccess, Consumer<PasswordEnrollmentError> errorConsumer)
      Performs validation of the password for enrollment during a registration.

      If validation fails, the implementation must invoke the provided Consumer<PasswordEnrollmentError> with the error. If an error is provided, the method PasswordEnroller.enrollPassword(PasswordEnrollmentContext, PasswordEnrollmentHandler) will be invoked and the error will be returned by the PasswordEnrollmentContext.lastRecoverableError() method.

      The implementation must guarantee that, one (and only one) of onSuccess and errorConsumer is invoked, and that the one invoked is invoked only once.

      This method will be invoked in the main/UI thread.

      Synchronous implementation example that requires password to have at least 8 characters:

       @Override
       public void validatePasswordForEnrollment(char[] password, Runnable onSuccess, Consumer<PasswordEnrollmentError> errorConsumer) {
           if (password.length < 8) {
               errorConsumer.accept(PasswordEnrollmentError.builder()
                        .description("The password has less than 8 characters.")
                        .build());
            }
            else {
                onSuccess.run();
            }
       }
       
      Parameters:
      password - the password to be validated
      onSuccess - the object to be invoked if the validation is successful
      errorConsumer - the object to be invoked with the error if the validation fails
      See Also:
    • validatePasswordForPasswordChange

      void validatePasswordForPasswordChange(char[] password, Runnable onSuccess, Consumer<PasswordChangeRecoverableError.CustomValidationError> errorConsumer)
      Performs validation of the password during a PasswordChange operation.

      If validation fails, the implementation must invoke the provided Consumer<PasswordChangeRecoverableError.CustomValidationError> with the error. If an error is provided, the method PasswordChanger.changePassword(PasswordChangeContext, PasswordChangeHandler) will be invoked and the error will be returned by the PasswordEnrollmentContext.lastRecoverableError() method.

      The implementation must guarantee that, one (and only one) of onSuccess and errorConsumer is invoked, and that the one invoked is invoked only once.

      This method will be invoked in the main/UI thread.

      Synchronous implementation example that requires password to have at least 8 characters:

       @Override
       public void validatePasswordForPasswordChange(char[] password, Runnable onSuccess, Consumer<PasswordChangeRecoverableError.CustomValidationError> errorConsumer) {
           if (password.length < 8) {
               errorConsumer.accept(PasswordChangeRecoverableError.CustomValidationError.builder()
                        .description("The password has less than 8 characters.")
                        .build());
            }
            else {
                onSuccess.run();
            }
       }
       
      Parameters:
      password - the password to be validated
      onSuccess - the object to be invoked if the validation is successful
      errorConsumer - the object to be invoked with the error if the validation fails
      See Also: