use of password.pwm.PwmApplication in project pwm by pwm-project.
the class AdminServlet method processReportSummary.
@ActionHandler(action = "reportSummary")
private ProcessStatus processReportSummary(final PwmRequest pwmRequest) throws ChaiUnavailableException, PwmUnrecoverableException, IOException {
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
final LinkedHashMap<String, Object> returnMap = new LinkedHashMap<>();
returnMap.put("raw", pwmApplication.getReportService().getSummaryData());
returnMap.put("presentable", pwmApplication.getReportService().getSummaryData().asPresentableCollection(pwmApplication.getConfig(), pwmRequest.getPwmSession().getSessionStateBean().getLocale()));
final RestResultBean restResultBean = RestResultBean.withData(returnMap);
pwmRequest.outputJsonResult(restResultBean);
return ProcessStatus.Halt;
}
use of password.pwm.PwmApplication in project pwm by pwm-project.
the class ShortcutServlet method handleUserSelection.
private void handleUserSelection(final PwmRequest pwmRequest, final ShortcutsBean shortcutsBean) throws PwmUnrecoverableException, ChaiUnavailableException, IOException, ServletException {
final PwmSession pwmSession = pwmRequest.getPwmSession();
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
final String link = pwmRequest.readParameterAsString("link");
final Map<String, ShortcutItem> visibleItems = shortcutsBean.getVisibleItems();
if (link != null && visibleItems.keySet().contains(link)) {
final ShortcutItem item = visibleItems.get(link);
pwmApplication.getStatisticsManager().incrementValue(Statistic.SHORTCUTS_SELECTED);
LOGGER.trace(pwmSession, "shortcut link selected: " + link + ", setting link for 'forwardURL' to " + item.getShortcutURI());
pwmSession.getSessionStateBean().setForwardURL(item.getShortcutURI().toString());
pwmRequest.sendRedirectToContinue();
return;
}
LOGGER.error(pwmSession, "unknown/unexpected link requested to " + link);
pwmRequest.forwardToJsp(JspUrl.SHORTCUT);
}
use of password.pwm.PwmApplication in project pwm by pwm-project.
the class ActivateUserUtils method validateParamsAgainstLDAP.
static void validateParamsAgainstLDAP(final PwmRequest pwmRequest, final Map<FormConfiguration, String> formValues, final UserIdentity userIdentity) throws ChaiUnavailableException, PwmDataValidationException, PwmUnrecoverableException {
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
final PwmSession pwmSession = pwmRequest.getPwmSession();
final String searchFilter = figureLdapSearchFilter(pwmRequest);
final ChaiProvider chaiProvider = pwmApplication.getProxyChaiProvider(userIdentity.getLdapProfileID());
final ChaiUser chaiUser = chaiProvider.getEntryFactory().newChaiUser(userIdentity.getUserDN());
for (final Map.Entry<FormConfiguration, String> entry : formValues.entrySet()) {
final FormConfiguration formItem = entry.getKey();
final String attrName = formItem.getName();
final String tokenizedAttrName = "%" + attrName + "%";
if (searchFilter.contains(tokenizedAttrName)) {
LOGGER.trace(pwmSession, "skipping validation of ldap value for '" + attrName + "' because it is in search filter");
} else {
final String value = entry.getValue();
try {
if (!chaiUser.compareStringAttribute(attrName, value)) {
final String errorMsg = "incorrect value for '" + attrName + "'";
final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_ACTIVATION_VALIDATIONFAIL, errorMsg, new String[] { attrName });
LOGGER.debug(pwmSession.getLabel(), errorInfo.toDebugStr());
throw new PwmDataValidationException(errorInfo);
}
LOGGER.trace(pwmSession.getLabel(), "successful validation of ldap value for '" + attrName + "'");
} catch (ChaiOperationException e) {
LOGGER.error(pwmSession.getLabel(), "error during param validation of '" + attrName + "', error: " + e.getMessage());
throw new PwmDataValidationException(new ErrorInformation(PwmError.ERROR_ACTIVATION_VALIDATIONFAIL, "ldap error testing value for '" + attrName + "'", new String[] { attrName }));
}
}
}
}
use of password.pwm.PwmApplication in project pwm by pwm-project.
the class ActivateUserUtils method sendPostActivationSms.
static boolean sendPostActivationSms(final PwmRequest pwmRequest) throws PwmUnrecoverableException, ChaiUnavailableException {
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
final PwmSession pwmSession = pwmRequest.getPwmSession();
final Configuration config = pwmApplication.getConfig();
final UserInfo userInfo = pwmSession.getUserInfo();
final Locale locale = pwmSession.getSessionStateBean().getLocale();
final LdapProfile ldapProfile = userInfo.getUserIdentity().getLdapProfile(config);
final String message = config.readSettingAsLocalizedString(PwmSetting.SMS_ACTIVATION_TEXT, locale);
final String toSmsNumber;
try {
toSmsNumber = userInfo.readStringAttribute(ldapProfile.readSettingAsString(PwmSetting.SMS_USER_PHONE_ATTRIBUTE));
} catch (Exception e) {
LOGGER.debug(pwmSession.getLabel(), "error reading SMS attribute from user '" + pwmSession.getUserInfo().getUserIdentity() + "': " + e.getMessage());
return false;
}
if (toSmsNumber == null || toSmsNumber.length() < 1) {
LOGGER.debug(pwmSession.getLabel(), "skipping send activation SMS for '" + pwmSession.getUserInfo().getUserIdentity() + "' no SMS number configured");
return false;
}
pwmApplication.sendSmsUsingQueue(toSmsNumber, message, pwmRequest.getSessionLabel(), pwmSession.getSessionManager().getMacroMachine(pwmApplication));
return true;
}
use of password.pwm.PwmApplication in project pwm by pwm-project.
the class ActivateUserUtils method figureLdapSearchFilter.
static String figureLdapSearchFilter(final PwmRequest pwmRequest) throws PwmUnrecoverableException {
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
final Configuration config = pwmApplication.getConfig();
final List<FormConfiguration> configuredActivationForm = config.readSettingAsForm(PwmSetting.ACTIVATE_USER_FORM);
final String configuredSearchFilter = config.readSettingAsString(PwmSetting.ACTIVATE_USER_SEARCH_FILTER);
final String searchFilter;
if (configuredSearchFilter == null || configuredSearchFilter.isEmpty()) {
searchFilter = FormUtility.ldapSearchFilterForForm(pwmApplication, configuredActivationForm);
LOGGER.trace(pwmRequest, "auto generated search filter based on activation form: " + searchFilter);
} else {
searchFilter = configuredSearchFilter;
}
return searchFilter;
}
Aggregations