Search in sources :

Example 1 with PasswordChangeProgressChecker

use of password.pwm.ldap.PasswordChangeProgressChecker in project pwm by pwm-project.

the class ChangePasswordServlet method processCompleteAction.

@ActionHandler(action = "complete")
public ProcessStatus processCompleteAction(final PwmRequest pwmRequest) throws ServletException, PwmUnrecoverableException, IOException {
    final ChangePasswordBean cpb = pwmRequest.getPwmApplication().getSessionStateService().getBean(pwmRequest, ChangePasswordBean.class);
    final PasswordChangeProgressChecker.ProgressTracker progressTracker = cpb.getChangeProgressTracker();
    boolean isComplete = true;
    if (progressTracker != null) {
        final PasswordChangeProgressChecker checker = new PasswordChangeProgressChecker(pwmRequest.getPwmApplication(), pwmRequest.getPwmSession().getUserInfo().getUserIdentity(), pwmRequest.getSessionLabel(), pwmRequest.getLocale());
        final PasswordChangeProgressChecker.PasswordChangeProgress passwordChangeProgress = checker.figureProgress(progressTracker);
        isComplete = passwordChangeProgress.isComplete();
    }
    if (isComplete) {
        if (progressTracker != null) {
            final TimeDuration totalTime = TimeDuration.fromCurrent(progressTracker.getBeginTime());
            try {
                pwmRequest.getPwmApplication().getStatisticsManager().updateAverageValue(Statistic.AVG_PASSWORD_SYNC_TIME, totalTime.getTotalMilliseconds());
                LOGGER.trace(pwmRequest, "password sync process marked completed (" + totalTime.asCompactString() + ")");
            } catch (Exception e) {
                LOGGER.error(pwmRequest, "unable to update average password sync time statistic: " + e.getMessage());
            }
        }
        cpb.setChangeProgressTracker(null);
        final Locale locale = pwmRequest.getLocale();
        final String completeMessage = pwmRequest.getConfig().readSettingAsLocalizedString(PwmSetting.PASSWORD_COMPLETE_MESSAGE, locale);
        pwmRequest.getPwmApplication().getSessionStateService().clearBean(pwmRequest, ChangePasswordBean.class);
        if (completeMessage != null && !completeMessage.isEmpty()) {
            final MacroMachine macroMachine = pwmRequest.getPwmSession().getSessionManager().getMacroMachine(pwmRequest.getPwmApplication());
            final String expandedText = macroMachine.expandMacros(completeMessage);
            pwmRequest.setAttribute(PwmRequestAttribute.CompleteText, expandedText);
            pwmRequest.forwardToJsp(JspUrl.PASSWORD_COMPLETE);
        } else {
            pwmRequest.getPwmResponse().forwardToSuccessPage(Message.Success_PasswordChange);
        }
    } else {
        forwardToWaitPage(pwmRequest);
    }
    return ProcessStatus.Halt;
}
Also used : Locale(java.util.Locale) ChangePasswordBean(password.pwm.http.bean.ChangePasswordBean) MacroMachine(password.pwm.util.macro.MacroMachine) TimeDuration(password.pwm.util.java.TimeDuration) PasswordChangeProgressChecker(password.pwm.ldap.PasswordChangeProgressChecker) ServletException(javax.servlet.ServletException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) PwmDataValidationException(password.pwm.error.PwmDataValidationException) PwmOperationalException(password.pwm.error.PwmOperationalException) ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) IOException(java.io.IOException)

Example 2 with PasswordChangeProgressChecker

use of password.pwm.ldap.PasswordChangeProgressChecker in project pwm by pwm-project.

the class ChangePasswordServletUtil method executeChangePassword.

static void executeChangePassword(final PwmRequest pwmRequest, final PasswordData newPassword) throws ChaiUnavailableException, PwmUnrecoverableException, PwmOperationalException {
    final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
    final PwmSession pwmSession = pwmRequest.getPwmSession();
    // password accepted, setup change password
    final ChangePasswordBean cpb = pwmApplication.getSessionStateService().getBean(pwmRequest, ChangePasswordBean.class);
    // change password
    PasswordUtility.setActorPassword(pwmSession, pwmApplication, newPassword);
    // init values for progress screen
    {
        final PasswordChangeProgressChecker.ProgressTracker tracker = new PasswordChangeProgressChecker.ProgressTracker();
        final PasswordChangeProgressChecker checker = new PasswordChangeProgressChecker(pwmApplication, pwmSession.getUserInfo().getUserIdentity(), pwmSession.getLabel(), pwmSession.getSessionStateBean().getLocale());
        cpb.setChangeProgressTracker(tracker);
        cpb.setChangePasswordMaxCompletion(checker.maxCompletionTime(tracker));
    }
    // send user an email confirmation
    ChangePasswordServletUtil.sendChangePasswordEmailNotice(pwmSession, pwmApplication);
    // send audit event
    pwmApplication.getAuditManager().submit(AuditEvent.CHANGE_PASSWORD, pwmSession.getUserInfo(), pwmSession);
}
Also used : ChangePasswordBean(password.pwm.http.bean.ChangePasswordBean) PwmApplication(password.pwm.PwmApplication) PwmSession(password.pwm.http.PwmSession) PasswordChangeProgressChecker(password.pwm.ldap.PasswordChangeProgressChecker)

Example 3 with PasswordChangeProgressChecker

use of password.pwm.ldap.PasswordChangeProgressChecker in project pwm by pwm-project.

the class ChangePasswordServlet method processCheckProgressAction.

@ActionHandler(action = "checkProgress")
ProcessStatus processCheckProgressAction(final PwmRequest pwmRequest) throws ServletException, PwmUnrecoverableException, IOException {
    final ChangePasswordBean changePasswordBean = pwmRequest.getPwmApplication().getSessionStateService().getBean(pwmRequest, ChangePasswordBean.class);
    final PasswordChangeProgressChecker.ProgressTracker progressTracker = changePasswordBean.getChangeProgressTracker();
    final PasswordChangeProgressChecker.PasswordChangeProgress passwordChangeProgress;
    if (progressTracker == null) {
        passwordChangeProgress = PasswordChangeProgressChecker.PasswordChangeProgress.COMPLETE;
    } else {
        final PasswordChangeProgressChecker checker = new PasswordChangeProgressChecker(pwmRequest.getPwmApplication(), pwmRequest.getPwmSession().getUserInfo().getUserIdentity(), pwmRequest.getSessionLabel(), pwmRequest.getLocale());
        passwordChangeProgress = checker.figureProgress(progressTracker);
    }
    final RestResultBean restResultBean = RestResultBean.withData(passwordChangeProgress);
    LOGGER.trace(pwmRequest, "returning result for restCheckProgress: " + JsonUtil.serialize(restResultBean));
    pwmRequest.outputJsonResult(restResultBean);
    return ProcessStatus.Halt;
}
Also used : ChangePasswordBean(password.pwm.http.bean.ChangePasswordBean) PasswordChangeProgressChecker(password.pwm.ldap.PasswordChangeProgressChecker) RestResultBean(password.pwm.ws.server.RestResultBean)

Aggregations

ChangePasswordBean (password.pwm.http.bean.ChangePasswordBean)3 PasswordChangeProgressChecker (password.pwm.ldap.PasswordChangeProgressChecker)3 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)1 IOException (java.io.IOException)1 Locale (java.util.Locale)1 ServletException (javax.servlet.ServletException)1 PwmApplication (password.pwm.PwmApplication)1 PwmDataValidationException (password.pwm.error.PwmDataValidationException)1 PwmOperationalException (password.pwm.error.PwmOperationalException)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1 PwmSession (password.pwm.http.PwmSession)1 TimeDuration (password.pwm.util.java.TimeDuration)1 MacroMachine (password.pwm.util.macro.MacroMachine)1 RestResultBean (password.pwm.ws.server.RestResultBean)1