{
HttpServletRequest request = rc.getRequest();
HttpServletResponse response = rc.getResponse();
User user = MainService.getUser(rc, getWebContext());
Credential cred = _credentialDao.get(user.getId());
if(cred==null)
{
response.sendError(404);
return;
}
String oldPassword = request.getParameter(Constants.OLD_PASSWORD);
String newPassword = request.getParameter(Constants.NEW_PASSWORD);
String confirmPassword = request.getParameter(Constants.CONFIRM_PASSWORD);
Feedback feedback = null;
if(oldPassword==null || newPassword==null || confirmPassword==null)
feedback = Feedback.CHANGE_PASSWORD_REQUIRED;
else if(oldPassword.equals(newPassword))
feedback = Feedback.NO_CHANGES_MADE;
else if(newPassword.equals(confirmPassword))
{
if(cred.getPassword().equals(oldPassword))
{
cred.setPassword(newPassword);
if(CredentialDao.executeUpdate())
{
request.setAttribute(Constants.MSG, Feedback.PASSWORD_CHANGED.getMsg());
dispatchToView(null, rc, getWebContext());
return;