@Override
public void validate(Object o, Errors errors) {
PasswordForm passwordForm = (PasswordForm) o;
User user = userService.getUserFromSecurityContext();
if (isPasswordEmpty(passwordForm.getOriginalPassword())) {
errors.rejectValue(ORIGINAL_PASSWORD_FIELD, "passwordValidator.emptyOriginalPassword");
} else if (!passwordEncoder.isPasswordValid(user.getPassword(), passwordForm.getOriginalPassword(), user.getUsername())) {
errors.rejectValue(ORIGINAL_PASSWORD_FIELD, "passwordValidator.originalPasswordMismatch");
}
if (!isPasswordValid(passwordForm.getFirstNewPassword())) {
errors.rejectValue(FIRST_NEW_PASSWORD_FIELD, "passwordValidator.password.invalid");