Class DefaultChangePasswordFormValidator
java.lang.Object
com.broadleafcommerce.auth.user.validation.DefaultChangePasswordFormValidator
- All Implemented Interfaces:
ChangePasswordFormValidator
public class DefaultChangePasswordFormValidator
extends Object
implements ChangePasswordFormValidator
- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
ConstructorDescriptionDefaultChangePasswordFormValidator
(PasswordRequestValidator passwordValidator, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.security.crypto.password.PasswordEncoder
protected PasswordRequestValidator
protected PasswordValidatorProperties
void
setPasswordValidatorProperties
(PasswordValidatorProperties passwordValidatorProperties) void
validate
(User currentUser, ChangePasswordForm changePasswordForm, org.springframework.validation.Errors errors) Verifies that all of the supplied fields in the givenChangePasswordForm
are correct, placing any errors into the givenErrors
.protected void
validateCurrentPassword
(@NonNull User currentUser, @NonNull ChangePasswordForm changePasswordForm, String currentPasswordFieldName, @NonNull org.springframework.validation.Errors errors) protected void
validatedNewPasswordIsNotReused
(@NonNull User user, String password, @NonNull org.springframework.validation.Errors errors) Validates that the new password does not match any of thehistorical passwords
.protected void
validateNewPassword
(@NonNull ChangePasswordForm changePasswordForm, String newPasswordFieldName, @NonNull org.springframework.validation.Errors errors) protected void
validatePasswordConfirmationMatches
(@NonNull ChangePasswordForm changePasswordForm, String newPasswordConfirmField, @NonNull org.springframework.validation.Errors errors)
-
Constructor Details
-
DefaultChangePasswordFormValidator
public DefaultChangePasswordFormValidator(PasswordRequestValidator passwordValidator, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder)
-
-
Method Details
-
validate
public void validate(@NonNull User currentUser, @NonNull ChangePasswordForm changePasswordForm, @NonNull org.springframework.validation.Errors errors) Description copied from interface:ChangePasswordFormValidator
Verifies that all of the supplied fields in the givenChangePasswordForm
are correct, placing any errors into the givenErrors
.- Specified by:
validate
in interfaceChangePasswordFormValidator
- Parameters:
currentUser
- this should be the current (already authenticated) user who is attempting to change their passwordchangePasswordForm
- the change password form, as submitted by the usererrors
- the errors object in which any validation errors should be registered
-
validateCurrentPassword
protected void validateCurrentPassword(@NonNull @NonNull User currentUser, @NonNull @NonNull ChangePasswordForm changePasswordForm, String currentPasswordFieldName, @NonNull @NonNull org.springframework.validation.Errors errors) -
validateNewPassword
protected void validateNewPassword(@NonNull @NonNull ChangePasswordForm changePasswordForm, String newPasswordFieldName, @NonNull @NonNull org.springframework.validation.Errors errors) -
validatePasswordConfirmationMatches
protected void validatePasswordConfirmationMatches(@NonNull @NonNull ChangePasswordForm changePasswordForm, String newPasswordConfirmField, @NonNull @NonNull org.springframework.validation.Errors errors) -
validatedNewPasswordIsNotReused
protected void validatedNewPasswordIsNotReused(@NonNull @NonNull User user, String password, @NonNull @NonNull org.springframework.validation.Errors errors) Validates that the new password does not match any of thehistorical passwords
. The number of passwords to compare to is managed byPasswordValidatorProperties.getPreviousPasswordsToRemember()
. If that is zero, then this method does nothing.- Parameters:
user
- The user whose password is changing.password
- The new password. Plaintext.
-
getPasswordValidator
-
getPasswordEncoder
protected org.springframework.security.crypto.password.PasswordEncoder getPasswordEncoder() -
getPasswordValidatorProperties
-
setPasswordValidatorProperties
@Autowired public void setPasswordValidatorProperties(PasswordValidatorProperties passwordValidatorProperties)
-