Interface PasswordChanger
- All Superinterfaces:
PasswordPolicyProvider
The object in charge of password change. It must be implemented by the developer
of the SDK.
PasswordChanger passwordChanger = (context, handler) -> { 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) { handler.passwords(oldPassword, newPassword); } else { handler.cancel(); } }; /** * Asks the user to provide the old password. If the user cancels the operation, * returnsnull
. * @return the old password ornull
if user cancels the operation. */ private char[] askUserForOldPassword() { [...] } /** * Asks the user to provide the new password. If the user cancels the operation, * returnsnull
. * @return the new password ornull
if user cancels the operation. */ private char[] askUserForNewPassword() { [...] }
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Returns the object defining the constraints of the password (minimum length, required special characters, etc.) to be changed.
-
Method Details
-
changePassword
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 thePasswordChangeHandler.cancel()
), or till the password authenticator is permanently locked because the user provided too many times an invalid password.- Parameters:
context
- the contexthandler
- 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 interfacePasswordPolicyProvider
- Returns:
- the
PasswordPolicy
-