Search in sources :

Example 1 with EmailItemBean

use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.

the class EmailServerUtil method applyMacrosToEmail.

static EmailItemBean applyMacrosToEmail(final EmailItemBean emailItem, final MacroMachine macroMachine) {
    final EmailItemBean expandedEmailItem;
    expandedEmailItem = new EmailItemBean(macroMachine.expandMacros(emailItem.getTo()), macroMachine.expandMacros(emailItem.getFrom()), macroMachine.expandMacros(emailItem.getSubject()), macroMachine.expandMacros(emailItem.getBodyPlain()), macroMachine.expandMacros(emailItem.getBodyHtml()));
    return expandedEmailItem;
}
Also used : EmailItemBean(password.pwm.bean.EmailItemBean)

Example 2 with EmailItemBean

use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.

the class PasswordUtility method sendNewPasswordEmail.

private static ErrorInformation sendNewPasswordEmail(final UserInfo userInfo, final PwmApplication pwmApplication, final MacroMachine macroMachine, final PasswordData newPassword, final String toAddress, final Locale userLocale) throws PwmOperationalException, PwmUnrecoverableException {
    final Configuration config = pwmApplication.getConfig();
    final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_SENDPASSWORD, userLocale);
    if (configuredEmailSetting == null) {
        final String errorMsg = "send password email contents are not configured";
        return new ErrorInformation(PwmError.ERROR_UNKNOWN, errorMsg);
    }
    final EmailItemBean emailItemBean = new EmailItemBean(configuredEmailSetting.getTo(), configuredEmailSetting.getFrom(), configuredEmailSetting.getSubject(), configuredEmailSetting.getBodyPlain().replace("%TOKEN%", newPassword.getStringValue()), configuredEmailSetting.getBodyHtml().replace("%TOKEN%", newPassword.getStringValue()));
    pwmApplication.getEmailQueue().submitEmail(emailItemBean, userInfo, macroMachine);
    LOGGER.debug("new password email to " + userInfo.getUserIdentity() + " added to send queue for " + toAddress);
    return null;
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) ActionConfiguration(password.pwm.config.value.data.ActionConfiguration) Configuration(password.pwm.config.Configuration) ChaiConfiguration(com.novell.ldapchai.provider.ChaiConfiguration) EmailItemBean(password.pwm.bean.EmailItemBean)

Example 3 with EmailItemBean

use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.

the class DeleteAccountServlet method sendProfileUpdateEmailNotice.

private static void sendProfileUpdateEmailNotice(final PwmRequest pwmRequest) throws PwmUnrecoverableException, ChaiUnavailableException {
    final Configuration config = pwmRequest.getConfig();
    final Locale locale = pwmRequest.getLocale();
    final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_DELETEACCOUNT, locale);
    if (configuredEmailSetting == null) {
        LOGGER.debug(pwmRequest, "skipping delete account notice email for '" + pwmRequest.getUserInfoIfLoggedIn() + "' no email configured");
        return;
    }
    pwmRequest.getPwmApplication().getEmailQueue().submitEmail(configuredEmailSetting, pwmRequest.getPwmSession().getUserInfo(), pwmRequest.getPwmSession().getSessionManager().getMacroMachine(pwmRequest.getPwmApplication()));
}
Also used : Locale(java.util.Locale) Configuration(password.pwm.config.Configuration) ActionConfiguration(password.pwm.config.value.data.ActionConfiguration) EmailItemBean(password.pwm.bean.EmailItemBean)

Example 4 with EmailItemBean

use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.

the class GuestRegistrationServlet method sendGuestUserEmailConfirmation.

private void sendGuestUserEmailConfirmation(final PwmRequest pwmRequest, final UserIdentity userIdentity) throws PwmUnrecoverableException {
    final PwmSession pwmSession = pwmRequest.getPwmSession();
    final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
    final Configuration config = pwmApplication.getConfig();
    final Locale locale = pwmSession.getSessionStateBean().getLocale();
    final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_GUEST, locale);
    if (configuredEmailSetting == null) {
        LOGGER.debug(pwmSession, "unable to send guest registration email for '" + userIdentity + "' no email configured");
        return;
    }
    final MacroMachine macroMachine = MacroMachine.forUser(pwmRequest, userIdentity);
    pwmApplication.getEmailQueue().submitEmail(configuredEmailSetting, null, macroMachine);
}
Also used : Locale(java.util.Locale) PwmApplication(password.pwm.PwmApplication) 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) MacroMachine(password.pwm.util.macro.MacroMachine) PwmSession(password.pwm.http.PwmSession)

Example 5 with EmailItemBean

use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.

the class ForgottenUsernameServlet method sendUsername.

private void sendUsername(final PwmApplication pwmApplication, final PwmSession pwmSession, final UserInfo forgottenUserInfo) throws PwmOperationalException, PwmUnrecoverableException {
    final Locale userLocale = pwmSession.getSessionStateBean().getLocale();
    final Configuration configuration = pwmApplication.getConfig();
    final MessageSendMethod messageSendMethod = configuration.readSettingAsEnum(PwmSetting.FORGOTTEN_USERNAME_SEND_USERNAME_METHOD, MessageSendMethod.class);
    final EmailItemBean emailItemBean = configuration.readSettingAsEmail(PwmSetting.EMAIL_SEND_USERNAME, userLocale);
    final String smsMessage = configuration.readSettingAsLocalizedString(PwmSetting.SMS_FORGOTTEN_USERNAME_TEXT, userLocale);
    if (messageSendMethod == null || messageSendMethod == MessageSendMethod.NONE) {
        return;
    }
    sendMessageViaMethod(pwmApplication, pwmSession.getLabel(), forgottenUserInfo, messageSendMethod, emailItemBean, smsMessage);
}
Also used : Locale(java.util.Locale) Configuration(password.pwm.config.Configuration) FormConfiguration(password.pwm.config.value.data.FormConfiguration) SearchConfiguration(password.pwm.ldap.search.SearchConfiguration) EmailItemBean(password.pwm.bean.EmailItemBean) MessageSendMethod(password.pwm.config.option.MessageSendMethod)

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