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 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 given ChangePasswordForm are correct, placing any errors into the given Errors.
      Specified by:
      validate in interface ChangePasswordFormValidator
      Parameters:
      currentUser - this should be the current (already authenticated) user who is attempting to change their password
      changePasswordForm - the change password form, as submitted by the user
      errors - 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 the historical passwords. The number of passwords to compare to is managed by PasswordValidatorProperties.getPreviousPasswordsToRemember(). If that is zero, then this method does nothing.
      Parameters:
      user - The user whose password is changing.
      password - The new password. Plaintext.
    • getPasswordValidator

      protected PasswordRequestValidator getPasswordValidator()
    • getPasswordEncoder

      protected org.springframework.security.crypto.password.PasswordEncoder getPasswordEncoder()
    • getPasswordValidatorProperties

      protected PasswordValidatorProperties getPasswordValidatorProperties()
    • setPasswordValidatorProperties

      @Autowired public void setPasswordValidatorProperties(PasswordValidatorProperties passwordValidatorProperties)