Search in sources :

Example 36 with PwmApplication

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;
}
Also used : PwmApplication(password.pwm.PwmApplication) LinkedHashMap(java.util.LinkedHashMap) RestResultBean(password.pwm.ws.server.RestResultBean)

Example 37 with PwmApplication

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);
}
Also used : PwmApplication(password.pwm.PwmApplication) ShortcutItem(password.pwm.config.value.data.ShortcutItem) PwmSession(password.pwm.http.PwmSession)

Example 38 with PwmApplication

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 }));
            }
        }
    }
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) PwmDataValidationException(password.pwm.error.PwmDataValidationException) PwmApplication(password.pwm.PwmApplication) ChaiProvider(com.novell.ldapchai.provider.ChaiProvider) ChaiUser(com.novell.ldapchai.ChaiUser) FormConfiguration(password.pwm.config.value.data.FormConfiguration) ChaiOperationException(com.novell.ldapchai.exception.ChaiOperationException) PwmSession(password.pwm.http.PwmSession) Map(java.util.Map)

Example 39 with PwmApplication

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;
}
Also used : Locale(java.util.Locale) PwmApplication(password.pwm.PwmApplication) Configuration(password.pwm.config.Configuration) FormConfiguration(password.pwm.config.value.data.FormConfiguration) ActionConfiguration(password.pwm.config.value.data.ActionConfiguration) UserInfo(password.pwm.ldap.UserInfo) PwmSession(password.pwm.http.PwmSession) LdapProfile(password.pwm.config.profile.LdapProfile) ServletException(javax.servlet.ServletException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) ImpossiblePasswordPolicyException(com.novell.ldapchai.exception.ImpossiblePasswordPolicyException) PwmDataValidationException(password.pwm.error.PwmDataValidationException) ChaiOperationException(com.novell.ldapchai.exception.ChaiOperationException) PwmOperationalException(password.pwm.error.PwmOperationalException) IOException(java.io.IOException) ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException)

Example 40 with PwmApplication

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;
}
Also used : PwmApplication(password.pwm.PwmApplication) Configuration(password.pwm.config.Configuration) FormConfiguration(password.pwm.config.value.data.FormConfiguration) ActionConfiguration(password.pwm.config.value.data.ActionConfiguration) FormConfiguration(password.pwm.config.value.data.FormConfiguration)

Aggregations

PwmApplication (password.pwm.PwmApplication)120 PwmSession (password.pwm.http.PwmSession)55 ErrorInformation (password.pwm.error.ErrorInformation)54 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)49 PwmOperationalException (password.pwm.error.PwmOperationalException)36 Configuration (password.pwm.config.Configuration)33 UserIdentity (password.pwm.bean.UserIdentity)27 FormConfiguration (password.pwm.config.value.data.FormConfiguration)25 PwmException (password.pwm.error.PwmException)25 IOException (java.io.IOException)22 ServletException (javax.servlet.ServletException)18 UserInfo (password.pwm.ldap.UserInfo)18 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)17 ChaiUser (com.novell.ldapchai.ChaiUser)16 Locale (java.util.Locale)13 ActionConfiguration (password.pwm.config.value.data.ActionConfiguration)13 SearchConfiguration (password.pwm.ldap.search.SearchConfiguration)13 MacroMachine (password.pwm.util.macro.MacroMachine)12 ChaiOperationException (com.novell.ldapchai.exception.ChaiOperationException)11 Instant (java.time.Instant)10