Search in sources :

Example 56 with Configuration

use of password.pwm.config.Configuration in project pwm by pwm-project.

the class PasswordRequirementsTag method doEndTag.

public int doEndTag() throws javax.servlet.jsp.JspTagException {
    try {
        final PwmRequest pwmRequest = PwmRequest.forRequest((HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
        final PwmSession pwmSession = pwmRequest.getPwmSession();
        final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
        final Configuration config = pwmApplication.getConfig();
        final Locale locale = pwmSession.getSessionStateBean().getLocale();
        pwmSession.getSessionManager().getMacroMachine(pwmApplication);
        final PwmPasswordPolicy passwordPolicy;
        if (getForm() != null && getForm().equalsIgnoreCase("newuser")) {
            final NewUserProfile newUserProfile = NewUserServlet.getNewUserProfile(pwmRequest);
            passwordPolicy = newUserProfile.getNewUserPasswordPolicy(pwmApplication, locale);
        } else {
            passwordPolicy = pwmSession.getUserInfo().getPasswordPolicy();
        }
        final String configuredRuleText = passwordPolicy.getRuleText();
        if (configuredRuleText != null && configuredRuleText.length() > 0) {
            pageContext.getOut().write(configuredRuleText);
        } else {
            final MacroMachine macroMachine = pwmSession.getSessionManager().getMacroMachine(pwmApplication);
            final String pre = prepend != null && prepend.length() > 0 ? prepend : "";
            final String sep = separator != null && separator.length() > 0 ? separator : "<br/>";
            final List<String> requirementsList = getPasswordRequirementsStrings(passwordPolicy, config, locale, macroMachine);
            final StringBuilder requirementsText = new StringBuilder();
            for (final String requirementStatement : requirementsList) {
                requirementsText.append(pre);
                requirementsText.append(requirementStatement);
                requirementsText.append(sep);
            }
            pageContext.getOut().write(requirementsText.toString());
        }
    } catch (IOException | PwmException e) {
        LOGGER.error("unexpected error during password requirements generation: " + e.getMessage(), e);
        throw new JspTagException(e.getMessage());
    }
    return EVAL_PAGE;
}
Also used : Locale(java.util.Locale) PwmApplication(password.pwm.PwmApplication) PwmRequest(password.pwm.http.PwmRequest) Configuration(password.pwm.config.Configuration) IOException(java.io.IOException) NewUserProfile(password.pwm.config.profile.NewUserProfile) PwmException(password.pwm.error.PwmException) PwmPasswordPolicy(password.pwm.config.profile.PwmPasswordPolicy) MacroMachine(password.pwm.util.macro.MacroMachine) PwmSession(password.pwm.http.PwmSession) JspTagException(javax.servlet.jsp.JspTagException)

Example 57 with Configuration

use of password.pwm.config.Configuration in project pwm by pwm-project.

the class UserSearchEngine method createExecutor.

private static ThreadPoolExecutor createExecutor(final PwmApplication pwmApplication) {
    final Configuration configuration = pwmApplication.getConfig();
    final boolean enabled = Boolean.parseBoolean(configuration.readAppProperty(AppProperty.LDAP_SEARCH_PARALLEL_ENABLE));
    if (!enabled) {
        return null;
    }
    final int endPoints;
    {
        int counter = 0;
        for (final LdapProfile ldapProfile : configuration.getLdapProfiles().values()) {
            final List<String> rootContexts = ldapProfile.readSettingAsStringArray(PwmSetting.LDAP_CONTEXTLESS_ROOT);
            counter += rootContexts.size();
        }
        endPoints = counter;
    }
    if (endPoints > 1) {
        final int factor = Integer.parseInt(configuration.readAppProperty(AppProperty.LDAP_SEARCH_PARALLEL_FACTOR));
        final int maxThreads = Integer.parseInt(configuration.readAppProperty(AppProperty.LDAP_SEARCH_PARALLEL_THREAD_MAX));
        final int threads = Math.min(maxThreads, (endPoints) * factor);
        final ThreadFactory threadFactory = JavaHelper.makePwmThreadFactory(JavaHelper.makeThreadName(pwmApplication, UserSearchEngine.class), true);
        return new ThreadPoolExecutor(threads, threads, 1, TimeUnit.MINUTES, new ArrayBlockingQueue<>(threads), threadFactory);
    }
    return null;
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) FormConfiguration(password.pwm.config.value.data.FormConfiguration) Configuration(password.pwm.config.Configuration) List(java.util.List) ArrayList(java.util.ArrayList) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) LdapProfile(password.pwm.config.profile.LdapProfile)

Example 58 with Configuration

use of password.pwm.config.Configuration in project pwm by pwm-project.

the class IntruderManager method sendIntruderNoticeEmail.

private static void sendIntruderNoticeEmail(final PwmApplication pwmApplication, final SessionLabel sessionLabel, final UserIdentity userIdentity) {
    final Locale locale = LocaleHelper.getLocaleForSessionID(pwmApplication, sessionLabel.getSessionID());
    final Configuration config = pwmApplication.getConfig();
    final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_INTRUDERNOTICE, locale);
    if (configuredEmailSetting == null) {
        return;
    }
    try {
        final UserInfo userInfo = UserInfoFactory.newUserInfoUsingProxy(pwmApplication, SessionLabel.SYSTEM_LABEL, userIdentity, locale);
        final MacroMachine macroMachine = MacroMachine.forUser(pwmApplication, sessionLabel, userInfo, null);
        pwmApplication.getEmailQueue().submitEmail(configuredEmailSetting, userInfo, macroMachine);
    } catch (PwmUnrecoverableException e) {
        LOGGER.error("error reading user info while sending intruder notice for user " + userIdentity + ", error: " + e.getMessage());
    }
}
Also used : Locale(java.util.Locale) FormConfiguration(password.pwm.config.value.data.FormConfiguration) Configuration(password.pwm.config.Configuration) EmailItemBean(password.pwm.bean.EmailItemBean) MacroMachine(password.pwm.util.macro.MacroMachine) UserInfo(password.pwm.ldap.UserInfo) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException)

Example 59 with Configuration

use of password.pwm.config.Configuration in project pwm by pwm-project.

the class ReportCsvUtility method outputToCsv.

public void outputToCsv(final OutputStream outputStream, final boolean includeHeader, final Locale locale, final ReportColumnFilter columnFilter) throws IOException, ChaiUnavailableException, ChaiOperationException, PwmUnrecoverableException, PwmOperationalException {
    final Configuration config = pwmApplication.getConfig();
    outputToCsv(outputStream, includeHeader, locale, config, columnFilter);
}
Also used : Configuration(password.pwm.config.Configuration)

Example 60 with Configuration

use of password.pwm.config.Configuration in project pwm by pwm-project.

the class ReportCsvUtility method outputToCsv.

public void outputToCsv(final OutputStream outputStream, final boolean includeHeader, final Locale locale) throws IOException, ChaiUnavailableException, ChaiOperationException, PwmUnrecoverableException, PwmOperationalException {
    final Configuration config = pwmApplication.getConfig();
    final ReportColumnFilter columnFilter = new ReportColumnFilter();
    outputToCsv(outputStream, includeHeader, locale, config, columnFilter);
}
Also used : Configuration(password.pwm.config.Configuration)

Aggregations

Configuration (password.pwm.config.Configuration)111 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)45 FormConfiguration (password.pwm.config.value.data.FormConfiguration)37 PwmApplication (password.pwm.PwmApplication)33 ErrorInformation (password.pwm.error.ErrorInformation)33 PwmOperationalException (password.pwm.error.PwmOperationalException)25 ActionConfiguration (password.pwm.config.value.data.ActionConfiguration)23 Locale (java.util.Locale)22 PwmSession (password.pwm.http.PwmSession)21 PwmException (password.pwm.error.PwmException)17 EmailItemBean (password.pwm.bean.EmailItemBean)16 SearchConfiguration (password.pwm.ldap.search.SearchConfiguration)16 UserInfo (password.pwm.ldap.UserInfo)15 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)14 IOException (java.io.IOException)14 ArrayList (java.util.ArrayList)13 MacroMachine (password.pwm.util.macro.MacroMachine)13 LinkedHashMap (java.util.LinkedHashMap)12 Instant (java.time.Instant)11 UserIdentity (password.pwm.bean.UserIdentity)10