Interface PasswordPolicy
For example, the password policy can impose a minimum password length, require the use of capital letters, special characters or numbers.\
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidvalidatePasswordForEnrollment(char[] password, Runnable onSuccess, Consumer<PasswordEnrollmentError> errorConsumer) Performs validation of the password for enrollment during a registration.voidvalidatePasswordForPasswordChange(char[] password, Runnable onSuccess, Consumer<PasswordChangeRecoverableError.CustomValidationError> errorConsumer) Performs validation of the password during aPasswordChangeoperation.
-
Method Details
-
validatePasswordForEnrollment
void validatePasswordForEnrollment(@NonNull char[] password, @NonNull Runnable onSuccess, @NonNull 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 methodPasswordEnroller.enrollPassword(PasswordEnrollmentContext, PasswordEnrollmentHandler)will be invoked and the error will be returned by thePasswordEnrollmentContext.lastRecoverableError()method.The implementation must guarantee that, one (and only one) of
onSuccessanderrorConsumeris 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 validatedonSuccess- the object to be invoked if the validation is successfulerrorConsumer- the object to be invoked with the error if the validation fails- See Also:
-
validatePasswordForPasswordChange
void validatePasswordForPasswordChange(@NonNull char[] password, @NonNull Runnable onSuccess, @NonNull Consumer<PasswordChangeRecoverableError.CustomValidationError> errorConsumer) Performs validation of the password during aPasswordChangeoperation.If validation fails, the implementation must invoke the provided
Consumer<PasswordChangeRecoverableError.CustomValidationError>with the error. If an error is provided, the methodPasswordChanger.changePassword(PasswordChangeContext, PasswordChangeHandler)will be invoked and the error will be returned by thePasswordEnrollmentContext.lastRecoverableError()method.The implementation must guarantee that, one (and only one) of
onSuccessanderrorConsumeris 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 validatedonSuccess- the object to be invoked if the validation is successfulerrorConsumer- the object to be invoked with the error if the validation fails- See Also:
-