use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.
the class EmailValue method validateValue.
public List<String> validateValue(final PwmSetting pwmSetting) {
if (pwmSetting.isRequired()) {
if (values == null || values.isEmpty() || values.values().iterator().next() == null) {
return Collections.singletonList("required value missing");
}
}
for (final Map.Entry<String, EmailItemBean> entry : values.entrySet()) {
final String loopLocale = entry.getKey();
final EmailItemBean emailItemBean = entry.getValue();
if (emailItemBean.getSubject() == null || emailItemBean.getSubject().length() < 1) {
return Collections.singletonList("subject field is required " + (loopLocale.length() > 0 ? " for locale " + loopLocale : ""));
}
if (emailItemBean.getFrom() == null || emailItemBean.getFrom().length() < 1) {
return Collections.singletonList("from field is required" + (loopLocale.length() > 0 ? " for locale " + loopLocale : ""));
}
if (emailItemBean.getBodyPlain() == null || emailItemBean.getBodyPlain().length() < 1) {
return Collections.singletonList("plain body field is required" + (loopLocale.length() > 0 ? " for locale " + loopLocale : ""));
}
}
return Collections.emptyList();
}
use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.
the class EmailValue method toDebugString.
public String toDebugString(final Locale locale) {
if (values == null) {
return "No Email Item";
}
final StringBuilder sb = new StringBuilder();
for (final Map.Entry<String, EmailItemBean> entry : values.entrySet()) {
final String localeKey = entry.getKey();
final EmailItemBean emailItemBean = entry.getValue();
sb.append("EmailItem ").append(LocaleHelper.debugLabel(LocaleHelper.parseLocaleString(localeKey))).append(": \n");
sb.append(" To:").append(emailItemBean.getTo()).append("\n");
sb.append("From:").append(emailItemBean.getFrom()).append("\n");
sb.append("Subj:").append(emailItemBean.getSubject()).append("\n");
sb.append("Body:").append(emailItemBean.getBodyPlain()).append("\n");
sb.append("Html:").append(emailItemBean.getBodyHtml()).append("\n");
}
return sb.toString();
}
use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.
the class Configuration method readSettingAsEmail.
public EmailItemBean readSettingAsEmail(final PwmSetting setting, final Locale locale) {
if (PwmSettingSyntax.EMAIL != setting.getSyntax()) {
throw new IllegalArgumentException("may not read EMAIL value for setting: " + setting.toString());
}
final Map<String, EmailItemBean> storedValues = (Map<String, EmailItemBean>) readStoredValue(setting).toNativeObject();
final Map<Locale, EmailItemBean> availableLocaleMap = new LinkedHashMap<>();
for (final Map.Entry<String, EmailItemBean> entry : storedValues.entrySet()) {
final String localeStr = entry.getKey();
availableLocaleMap.put(LocaleHelper.parseLocaleString(localeStr), entry.getValue());
}
final Locale matchedLocale = LocaleHelper.localeResolver(locale, availableLocaleMap.keySet());
return availableLocaleMap.get(matchedLocale);
}
use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.
the class GuestRegistrationServlet method sendUpdateGuestEmailConfirmation.
private void sendUpdateGuestEmailConfirmation(final PwmRequest pwmRequest, final UserInfo guestUserInfo) throws PwmUnrecoverableException {
final Configuration config = pwmRequest.getConfig();
final Locale locale = pwmRequest.getLocale();
final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_UPDATEGUEST, locale);
if (configuredEmailSetting == null) {
LOGGER.debug(pwmRequest, "unable to send updated guest user email: no email configured");
return;
}
pwmRequest.getPwmApplication().getEmailQueue().submitEmail(configuredEmailSetting, guestUserInfo, null);
}
use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.
the class NewUserUtils method sendNewUserEmailConfirmation.
private static void sendNewUserEmailConfirmation(final PwmRequest pwmRequest) throws PwmUnrecoverableException, ChaiUnavailableException {
final PwmSession pwmSession = pwmRequest.getPwmSession();
final UserInfo userInfo = pwmSession.getUserInfo();
final Configuration config = pwmRequest.getConfig();
final Locale locale = pwmSession.getSessionStateBean().getLocale();
final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_NEWUSER, locale);
if (configuredEmailSetting == null) {
NewUserUtils.LOGGER.debug(pwmSession, "skipping send of new user email for '" + userInfo.getUserIdentity().getUserDN() + "' no email configured");
return;
}
pwmRequest.getPwmApplication().getEmailQueue().submitEmail(configuredEmailSetting, pwmSession.getUserInfo(), pwmSession.getSessionManager().getMacroMachine(pwmRequest.getPwmApplication()));
}
Aggregations