use of password.pwm.config.Configuration in project pwm by pwm-project.
the class ChangePasswordServlet method nextStep.
public void nextStep(final PwmRequest pwmRequest) throws IOException, PwmUnrecoverableException, ServletException {
final ChangePasswordBean changePasswordBean = pwmRequest.getPwmApplication().getSessionStateService().getBean(pwmRequest, ChangePasswordBean.class);
final PwmSession pwmSession = pwmRequest.getPwmSession();
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
final Configuration config = pwmApplication.getConfig();
if (changePasswordBean.getChangeProgressTracker() != null) {
forwardToWaitPage(pwmRequest);
return;
}
if (ChangePasswordServletUtil.warnPageShouldBeShown(pwmRequest, changePasswordBean)) {
LOGGER.trace(pwmRequest, "password expiration is within password warn period, forwarding user to warning page");
pwmRequest.forwardToJsp(JspUrl.PASSWORD_WARN);
return;
}
final String agreementMsg = pwmApplication.getConfig().readSettingAsLocalizedString(PwmSetting.PASSWORD_CHANGE_AGREEMENT_MESSAGE, pwmRequest.getLocale());
if (agreementMsg != null && agreementMsg.length() > 0 && !changePasswordBean.isAgreementPassed()) {
final MacroMachine macroMachine = pwmSession.getSessionManager().getMacroMachine(pwmApplication);
final String expandedText = macroMachine.expandMacros(agreementMsg);
pwmRequest.setAttribute(PwmRequestAttribute.AgreementText, expandedText);
pwmRequest.forwardToJsp(JspUrl.PASSWORD_AGREEMENT);
return;
}
if (ChangePasswordServletUtil.determineIfCurrentPasswordRequired(pwmApplication, pwmSession) && !changePasswordBean.isCurrentPasswordPassed()) {
forwardToFormPage(pwmRequest);
return;
}
if (!config.readSettingAsForm(PwmSetting.PASSWORD_REQUIRE_FORM).isEmpty() && !changePasswordBean.isFormPassed()) {
forwardToFormPage(pwmRequest);
return;
}
changePasswordBean.setAllChecksPassed(true);
forwardToChangePage(pwmRequest);
}
use of password.pwm.config.Configuration in project pwm by pwm-project.
the class CommandServlet method processNext.
@ActionHandler(action = "next")
private ProcessStatus processNext(final PwmRequest pwmRequest) throws IOException, PwmUnrecoverableException, ServletException {
final PwmSession pwmSession = pwmRequest.getPwmSession();
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
final Configuration config = pwmApplication.getConfig();
if (pwmRequest.isAuthenticated()) {
if (AuthenticationFilter.forceRequiredRedirects(pwmRequest) == ProcessStatus.Halt) {
return ProcessStatus.Halt;
}
// log the user out if our finish action is currently set to log out.
final boolean forceLogoutOnChange = config.readSettingAsBoolean(PwmSetting.LOGOUT_AFTER_PASSWORD_CHANGE);
if (forceLogoutOnChange && pwmSession.getSessionStateBean().isPasswordModified()) {
LOGGER.trace(pwmSession, "logging out user; password has been modified");
pwmRequest.sendRedirect(PwmServletDefinition.Logout);
return ProcessStatus.Halt;
}
}
redirectToForwardURL(pwmRequest);
return ProcessStatus.Halt;
}
use of password.pwm.config.Configuration in project pwm by pwm-project.
the class ConfigEditorServlet method restSmsHealthCheck.
@ActionHandler(action = "smsHealthCheck")
private ProcessStatus restSmsHealthCheck(final PwmRequest pwmRequest) throws IOException, PwmUnrecoverableException {
final Instant startTime = Instant.now();
final ConfigManagerBean configManagerBean = getBean(pwmRequest);
LOGGER.debug(pwmRequest, "beginning restSmsHealthCheck");
final List<HealthRecord> returnRecords = new ArrayList<>();
final Configuration config = new Configuration(configManagerBean.getStoredConfiguration());
if (!SmsQueueManager.smsIsConfigured(config)) {
returnRecords.add(new HealthRecord(HealthStatus.INFO, HealthTopic.SMS, "SMS not configured"));
} else {
final Map<String, String> testParams = pwmRequest.readBodyAsJsonStringMap();
final SmsItemBean testSmsItem = new SmsItemBean(testParams.get("to"), testParams.get("message"), pwmRequest.getSessionLabel());
try {
final String responseBody = SmsQueueManager.sendDirectMessage(pwmRequest.getPwmApplication(), config, pwmRequest.getSessionLabel(), testSmsItem);
returnRecords.add(new HealthRecord(HealthStatus.INFO, HealthTopic.SMS, "message sent"));
returnRecords.add(new HealthRecord(HealthStatus.INFO, HealthTopic.SMS, "response body: \n" + StringUtil.escapeHtml(responseBody)));
} catch (PwmException e) {
returnRecords.add(new HealthRecord(HealthStatus.WARN, HealthTopic.SMS, "unable to send message: " + e.getMessage()));
}
}
final HealthData healthData = HealthRecord.asHealthDataBean(config, pwmRequest.getLocale(), returnRecords);
final RestResultBean restResultBean = RestResultBean.withData(healthData);
pwmRequest.outputJsonResult(restResultBean);
LOGGER.debug(pwmRequest, "completed restSmsHealthCheck in " + TimeDuration.fromCurrent(startTime).asCompactString());
return ProcessStatus.Halt;
}
use of password.pwm.config.Configuration in project pwm by pwm-project.
the class ForgottenUsernameServlet method sendUsername.
private void sendUsername(final PwmApplication pwmApplication, final PwmSession pwmSession, final UserInfo forgottenUserInfo) throws PwmOperationalException, PwmUnrecoverableException {
final Locale userLocale = pwmSession.getSessionStateBean().getLocale();
final Configuration configuration = pwmApplication.getConfig();
final MessageSendMethod messageSendMethod = configuration.readSettingAsEnum(PwmSetting.FORGOTTEN_USERNAME_SEND_USERNAME_METHOD, MessageSendMethod.class);
final EmailItemBean emailItemBean = configuration.readSettingAsEmail(PwmSetting.EMAIL_SEND_USERNAME, userLocale);
final String smsMessage = configuration.readSettingAsLocalizedString(PwmSetting.SMS_FORGOTTEN_USERNAME_TEXT, userLocale);
if (messageSendMethod == null || messageSendMethod == MessageSendMethod.NONE) {
return;
}
sendMessageViaMethod(pwmApplication, pwmSession.getLabel(), forgottenUserInfo, messageSendMethod, emailItemBean, smsMessage);
}
use of password.pwm.config.Configuration in project pwm by pwm-project.
the class ForgottenUsernameServlet method processAction.
protected void processAction(final PwmRequest pwmRequest) throws ServletException, IOException, PwmUnrecoverableException {
final Configuration config = pwmRequest.getConfig();
if (!config.readSettingAsBoolean(PwmSetting.FORGOTTEN_USERNAME_ENABLE)) {
pwmRequest.respondWithError(PwmError.ERROR_SERVICE_NOT_AVAILABLE.toInfo());
return;
}
final ForgottenUsernameAction action = readProcessAction(pwmRequest);
if (action != null) {
pwmRequest.validatePwmFormID();
switch(action) {
case search:
handleSearchRequest(pwmRequest);
return;
default:
JavaHelper.unhandledSwitchStatement(action);
}
}
forwardToFormJsp(pwmRequest);
}
Aggregations