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;
}
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);
}
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;
}
Aggregations