Search in sources :

Example 16 with EmailItemBean

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();
}
Also used : EmailItemBean(password.pwm.bean.EmailItemBean) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 17 with EmailItemBean

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();
}
Also used : EmailItemBean(password.pwm.bean.EmailItemBean) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 18 with EmailItemBean

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);
}
Also used : Locale(java.util.Locale) EmailItemBean(password.pwm.bean.EmailItemBean) Map(java.util.Map) EnumMap(java.util.EnumMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap)

Example 19 with EmailItemBean

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);
}
Also used : Locale(java.util.Locale) FormConfiguration(password.pwm.config.value.data.FormConfiguration) SearchConfiguration(password.pwm.ldap.search.SearchConfiguration) ActionConfiguration(password.pwm.config.value.data.ActionConfiguration) Configuration(password.pwm.config.Configuration) EmailItemBean(password.pwm.bean.EmailItemBean)

Example 20 with EmailItemBean

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()));
}
Also used : Locale(java.util.Locale) FormConfiguration(password.pwm.config.value.data.FormConfiguration) SearchConfiguration(password.pwm.ldap.search.SearchConfiguration) ActionConfiguration(password.pwm.config.value.data.ActionConfiguration) Configuration(password.pwm.config.Configuration) ChaiConfiguration(com.novell.ldapchai.provider.ChaiConfiguration) EmailItemBean(password.pwm.bean.EmailItemBean) UserInfo(password.pwm.ldap.UserInfo) PwmSession(password.pwm.http.PwmSession)

Aggregations

EmailItemBean (password.pwm.bean.EmailItemBean)25 Configuration (password.pwm.config.Configuration)16 Locale (java.util.Locale)14 FormConfiguration (password.pwm.config.value.data.FormConfiguration)11 ActionConfiguration (password.pwm.config.value.data.ActionConfiguration)9 MacroMachine (password.pwm.util.macro.MacroMachine)9 UserInfo (password.pwm.ldap.UserInfo)8 Map (java.util.Map)5 SearchConfiguration (password.pwm.ldap.search.SearchConfiguration)5 TreeMap (java.util.TreeMap)4 PwmApplication (password.pwm.PwmApplication)4 ChaiConfiguration (com.novell.ldapchai.provider.ChaiConfiguration)3 PwmSession (password.pwm.http.PwmSession)3 Instant (java.time.Instant)2 LinkedHashMap (java.util.LinkedHashMap)2 UserIdentity (password.pwm.bean.UserIdentity)2 MessageSendMethod (password.pwm.config.option.MessageSendMethod)2 ErrorInformation (password.pwm.error.ErrorInformation)2 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)2 ArrayList (java.util.ArrayList)1