if (!currentUserDetails.isDetailsUpdateable()) {
return new ForbiddenView();
}
if (submit == null || submit.length() == 0) {
return new ChangePasswordView();
}
ValidationContext validationContext = new ValidationContext();
if (password1 == null || password1.length() == 0) {
validationContext.addError("Password can not be empty");
} else if (!password1.equals(password2)) {
validationContext.addError("Passwords do not match");
}
if (!validationContext.hasErrors()) {
realm.changePassword(currentUserDetails.getUsername(), password1);
return new PasswordChangedView();
}
getModel().put("validationContext", validationContext);
return new ChangePasswordView();
} catch (SecurityRealmException e) {
throw new ServletException(e);
}
}