public void notifyPassword(String userName, HttpServletRequest request) throws UserAccountException {
// Lookup the user record, and check if user account exists.
MemberVO auth = userAccountDao.getUserAccountByUserName(userName);
if (auth == null) {
throw new UserAccountException(NotLoginException.USER_NOT_FOUND);
}
// Locked
if (auth.getMemberStatus().equals(BaseConstants.ACCOUNT_LOCKED)){
throw new UserAccountException(NotLoginException.ACCOUNT_LOCKED);
}
// deactivated
if (auth.getMemberStatus().equals(BaseConstants.ACCOUNT_DEACTIVATED)){
throw new UserAccountException(NotLoginException.ACCOUNT_DEACTIVATED);
}
//unapproved
if (auth.getMemberStatus().equals(BaseConstants.ACCOUNT_UNAPPROVED)){
throw new UserAccountException(NotLoginException.ACCOUNT_UNAPPROVED);
}
SystemConfigVO sysConfigVO = sysConfigDao.getSystemConfig();
try {
// For security reasons, we generate a new random password for the user.
// User should be forced to change this on next logon.
String newPasswd = PasswordGenerator.createPassword(8);
// then use an email template to send the notification.
SendMailUtil.sendPasswordReminderMail(auth.getEmail(), auth.getFullName(), newPasswd, sysConfigVO);
// update the system with the new user password(encrypted),
// and insert a trail for that.
userAccountDao.resetUserPassword(userName, Encoder.getMD5_Base64(newPasswd));
} catch (Exception ex) {
throw new UserAccountException(ex.getMessage());
}
}