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;
}
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");
}
}
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);
}
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;
}
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());
}
Aggregations