Search in sources :

Example 46 with Configuration

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

the class PeopleSearchClientConfigBean method fromConfig.

static PeopleSearchClientConfigBean fromConfig(final PwmApplication pwmApplication, final PeopleSearchConfiguration peopleSearchConfiguration, final Locale locale, final UserIdentity userIdentity, final SessionLabel sessionLabel) throws PwmUnrecoverableException {
    final Configuration configuration = pwmApplication.getConfig();
    final Map<String, String> searchColumns = new LinkedHashMap<>();
    final List<FormConfiguration> searchForm = configuration.readSettingAsForm(PwmSetting.PEOPLE_SEARCH_RESULT_FORM);
    for (final FormConfiguration formConfiguration : searchForm) {
        searchColumns.put(formConfiguration.getName(), formConfiguration.getLabel(locale));
    }
    final PeopleSearchClientConfigBean peopleSearchClientConfigBean = new PeopleSearchClientConfigBean();
    peopleSearchClientConfigBean.setSearchColumns(searchColumns);
    peopleSearchClientConfigBean.setEnablePhoto(peopleSearchConfiguration.isPhotosEnabled(userIdentity, sessionLabel));
    peopleSearchClientConfigBean.setOrgChartEnabled(peopleSearchConfiguration.isOrgChartEnabled());
    peopleSearchClientConfigBean.setOrgChartShowChildCount(peopleSearchConfiguration.isOrgChartShowChildCount());
    peopleSearchClientConfigBean.setOrgChartMaxParents(peopleSearchConfiguration.getOrgChartMaxParents());
    return peopleSearchClientConfigBean;
}
Also used : Configuration(password.pwm.config.Configuration) FormConfiguration(password.pwm.config.value.data.FormConfiguration) FormConfiguration(password.pwm.config.value.data.FormConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Example 47 with Configuration

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

the class UpdateProfileUtil method sendProfileUpdateEmailNotice.

static void sendProfileUpdateEmailNotice(final PwmApplication pwmApplication, final MacroMachine macroMachine, final UserInfo userInfo, final Locale locale, final SessionLabel sessionLabel) throws PwmUnrecoverableException, ChaiUnavailableException {
    final Configuration config = pwmApplication.getConfig();
    final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_UPDATEPROFILE, locale);
    pwmApplication.getEmailQueue().submitEmail(configuredEmailSetting, userInfo, macroMachine);
    if (configuredEmailSetting == null) {
        LOGGER.debug(sessionLabel, "skipping send profile update email for '" + userInfo.getUserIdentity().toDisplayString() + "' no email configured");
    }
}
Also used : Configuration(password.pwm.config.Configuration) FormConfiguration(password.pwm.config.value.data.FormConfiguration) ActionConfiguration(password.pwm.config.value.data.ActionConfiguration) EmailItemBean(password.pwm.bean.EmailItemBean)

Example 48 with Configuration

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

the class JspThrowableHandlerTag method jspOutput.

private String jspOutput(final String errorReference) {
    Locale userLocale = PwmConstants.DEFAULT_LOCALE;
    Configuration configuration = null;
    try {
        final PwmRequest pwmRequest = PwmRequest.forRequest((HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
        userLocale = pwmRequest.getLocale();
        configuration = pwmRequest.getConfig();
    } catch (Exception e) {
        LOGGER.error("error during pwmFormIDTag output of pwmFormID: " + e.getMessage());
    }
    final String[] strArgs = new String[] { errorReference };
    return LocaleHelper.getLocalizedMessage(userLocale, Display.Display_ErrorReference, configuration, strArgs);
}
Also used : Locale(java.util.Locale) PwmRequest(password.pwm.http.PwmRequest) Configuration(password.pwm.config.Configuration) IOException(java.io.IOException)

Example 49 with Configuration

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

the class PeopleSearchConfiguration method fromConfiguration.

public static PeopleSearchConfiguration fromConfiguration(final PwmApplication pwmApplication) {
    final Configuration configuration = pwmApplication.getConfig();
    final PeopleSearchConfiguration config = new PeopleSearchConfiguration(pwmApplication);
    config.orgChartAssistantAttr = configuration.readSettingAsString(PwmSetting.PEOPLE_SEARCH_ORGCHART_ASSISTANT_ATTRIBUTE);
    config.orgChartParentAttr = configuration.readSettingAsString(PwmSetting.PEOPLE_SEARCH_ORGCHART_PARENT_ATTRIBUTE);
    config.orgChartChildAttr = configuration.readSettingAsString(PwmSetting.PEOPLE_SEARCH_ORGCHART_CHILD_ATTRIBUTE);
    config.orgChartEnabled = config.orgChartParentAttr != null && !config.orgChartParentAttr.isEmpty() && config.orgChartChildAttr != null && !config.orgChartChildAttr.isEmpty();
    config.orgChartShowChildCount = Boolean.parseBoolean(configuration.readAppProperty(AppProperty.PEOPLESEARCH_ORGCHART_ENABLE_CHILD_COUNT));
    config.orgChartMaxParents = Integer.parseInt(configuration.readAppProperty(AppProperty.PEOPLESEARCH_ORGCHART_MAX_PARENTS));
    return config;
}
Also used : Configuration(password.pwm.config.Configuration)

Example 50 with Configuration

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

the class TokenUtil method initializeAndSendToken.

public static void initializeAndSendToken(final PwmRequest pwmRequest, final TokenInitAndSendRequest tokenInitAndSendRequest) throws PwmUnrecoverableException {
    final Configuration config = pwmRequest.getConfig();
    final UserInfo userInfo = tokenInitAndSendRequest.getUserInfo();
    final Map<String, String> tokenMapData = new LinkedHashMap<>();
    final MacroMachine macroMachine;
    {
        if (tokenInitAndSendRequest.getMacroMachine() != null) {
            macroMachine = tokenInitAndSendRequest.getMacroMachine();
        } else if (tokenInitAndSendRequest.getUserInfo() != null) {
            macroMachine = MacroMachine.forUser(pwmRequest, userInfo.getUserIdentity(), makeTokenDestStringReplacer(tokenInitAndSendRequest.getTokenDestinationItem()));
        } else {
            macroMachine = null;
        }
    }
    if (userInfo != null) {
        final Instant userLastPasswordChange = userInfo.getPasswordLastModifiedTime();
        if (userLastPasswordChange != null) {
            final String userChangeString = JavaHelper.toIsoDate(userLastPasswordChange);
            tokenMapData.put(PwmConstants.TOKEN_KEY_PWD_CHG_DATE, userChangeString);
        }
    }
    if (tokenInitAndSendRequest.getInputTokenData() != null) {
        tokenMapData.putAll(tokenInitAndSendRequest.getInputTokenData());
    }
    final String tokenKey;
    final TokenPayload tokenPayload;
    {
        final TimeDuration tokenLifetime = tokenInitAndSendRequest.getTokenLifetime() == null ? new TimeDuration(config.readSettingAsLong(PwmSetting.TOKEN_LIFETIME), TimeUnit.SECONDS) : tokenInitAndSendRequest.getTokenLifetime();
        try {
            tokenPayload = pwmRequest.getPwmApplication().getTokenService().createTokenPayload(tokenInitAndSendRequest.getTokenType(), tokenLifetime, tokenMapData, userInfo == null ? null : userInfo.getUserIdentity(), tokenInitAndSendRequest.getTokenDestinationItem());
            tokenKey = pwmRequest.getPwmApplication().getTokenService().generateNewToken(tokenPayload, pwmRequest.getSessionLabel());
        } catch (PwmOperationalException e) {
            throw new PwmUnrecoverableException(e.getErrorInformation());
        }
    }
    final EmailItemBean emailItemBean = tokenInitAndSendRequest.getEmailToSend() == null ? null : config.readSettingAsEmail(tokenInitAndSendRequest.getEmailToSend(), pwmRequest.getLocale());
    final String smsMessage = tokenInitAndSendRequest.getSmsToSend() == null ? null : config.readSettingAsLocalizedString(tokenInitAndSendRequest.getSmsToSend(), pwmRequest.getLocale());
    TokenService.TokenSender.sendToken(TokenService.TokenSendInfo.builder().pwmApplication(pwmRequest.getPwmApplication()).userInfo(userInfo).macroMachine(macroMachine).configuredEmailSetting(emailItemBean).tokenDestinationItem(tokenInitAndSendRequest.getTokenDestinationItem()).smsMessage(smsMessage).tokenKey(tokenKey).sessionLabel(pwmRequest.getSessionLabel()).build());
}
Also used : Configuration(password.pwm.config.Configuration) EmailItemBean(password.pwm.bean.EmailItemBean) Instant(java.time.Instant) MacroMachine(password.pwm.util.macro.MacroMachine) UserInfo(password.pwm.ldap.UserInfo) TimeDuration(password.pwm.util.java.TimeDuration) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) LinkedHashMap(java.util.LinkedHashMap) PwmOperationalException(password.pwm.error.PwmOperationalException)

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