Search in sources :

Example 1 with NotifyPassword

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);
    }
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) NotifyPassword(com.sun.identity.password.plugins.NotifyPassword)

Example 2 with NotifyPassword

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;
}
Also used : NotifyPassword(com.sun.identity.password.plugins.NotifyPassword)

Aggregations

NotifyPassword (com.sun.identity.password.plugins.NotifyPassword)2 SSOException (com.iplanet.sso.SSOException)1 AMIdentity (com.sun.identity.idm.AMIdentity)1 IdRepoException (com.sun.identity.idm.IdRepoException)1