use of com.sun.identity.password.plugins.NotifyPassword in project OpenAM by OpenRock.
the class PWResetQuestionModelImpl method resetPassword.
/**
* Resets the user password.
*
* @param uuid User Id.
* @param realm Realm name.
* @param map map of user question and answer
* @throws PWResetException if unable to reset the password
*/
public void resetPassword(String uuid, String realm, Map map) throws PWResetException {
populateLockoutValues(realm);
PWResetAccountLockout pwResetLockout = new PWResetAccountLockout(this);
try {
localeContext.setOrgLocale(realm);
AMIdentity user = IdUtils.getIdentity(getSSOToken(), uuid);
sendAttemptEmail(user);
if (isUserAnswersCorrect(map, user, realm)) {
pwResetLockout.removeUserLockoutEntry(uuid);
String password = getPasswordResetValue(realm, user);
if (password != null && password.length() > 0) {
NotifyPassword passwordNotify = getNotifyPassword(realm);
if (passwordNotify != null) {
changePassword(user, password, passwordNotify, uuid, realm);
writeLog("pwResetSuccess.message", uuid);
} else {
errorMsg = getLocalizedString("passResetError.message");
}
} else {
errorMsg = getLocalizedString("passResetError.message");
}
} else {
pwResetLockout.invalidAnswer(user);
if (!isLockoutWarning(pwResetLockout, uuid)) {
errorMsg = getLocalizedString("wrongAnswer.message");
}
}
} catch (SSOException e) {
debug.warning("PWResetQuestionModelImpl.resetPassword", e);
errorMsg = getErrorString(e);
} catch (IdRepoException e) {
debug.warning("PWResetQuestionModelImpl.resetPassword", e);
errorMsg = getErrorString(e);
}
if ((errorMsg != null) && (errorMsg.length() > 0)) {
writeLog("pwResetFail.message", errorMsg, uuid);
throw new PWResetException(errorMsg);
} else if ((informationMsg != null) && (informationMsg.length() > 0)) {
writeLog("pwResetFail.message", uuid);
throw new PWResetException(informationMsg);
}
}
use of com.sun.identity.password.plugins.NotifyPassword in project OpenAM by OpenRock.
the class PWResetQuestionModelImpl method getNotifyPassword.
/**
* Gets the handler to the notify password plugin.
*
* @param realm Realm name.
* @return handler to the notify password plugin
*/
private NotifyPassword getNotifyPassword(String realm) {
NotifyPassword passwordNotify = null;
Object obj = getPluginObject(realm, PW_RESET_NOTIFICATION);
if ((obj != null) && (obj instanceof NotifyPassword)) {
passwordNotify = (NotifyPassword) obj;
}
return passwordNotify;
}
Aggregations