Ver Fonte

Updates to the multiple email server implemintation

rkeil há 7 anos atrás
pai
commit
0e08085a7d

+ 1 - 15
server/src/main/java/password/pwm/config/PwmSetting.java

@@ -255,8 +255,6 @@ public enum PwmSetting {
     AUTO_ADD_OBJECT_CLASSES(
             "ldap.addObjectClasses", PwmSettingSyntax.STRING_ARRAY, PwmSettingCategory.LDAP_ATTRIBUTES),
 
-
-
     // ldap global settings
     LDAP_PROFILE_LIST(
             "ldap.profile.list", PwmSettingSyntax.PROFILE, PwmSettingCategory.INTERNAL),
@@ -282,31 +280,19 @@ public enum PwmSetting {
             "email.smtp.addresses", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_PROFILES),
     EMAIL_SERVER_PORTS(
             "email.smtp.ports", PwmSettingSyntax.NUMERIC, PwmSettingCategory.EMAIL_PROFILES),
-    EMAIL_DEFAULT_FROM_ADDRESSES(
-            "email.default.fromAddresses", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_PROFILES),
     EMAIL_USERNAMES(
             "email.smtp.usernames", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_PROFILES),
     EMAIL_PASSWORDS(
             "email.smtp.userpasswords", PwmSettingSyntax.PASSWORD, PwmSettingCategory.EMAIL_PROFILES),
 
-    // email settings
-    EMAIL_SERVER_ADDRESS(
-            "email.smtp.address", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_SETTINGS),
-    EMAIL_SERVER_PORT(
-            "email.smtp.port", PwmSettingSyntax.NUMERIC, PwmSettingCategory.EMAIL_SETTINGS),
+    // system wide email settings
     EMAIL_DEFAULT_FROM_ADDRESS(
             "email.default.fromAddress", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_SETTINGS),
-    EMAIL_USERNAME(
-            "email.smtp.username", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_SETTINGS),
-    EMAIL_PASSWORD(
-            "email.smtp.userpassword", PwmSettingSyntax.PASSWORD, PwmSettingCategory.EMAIL_SETTINGS),
-
     EMAIL_MAX_QUEUE_AGE(
             "email.queueMaxAge", PwmSettingSyntax.DURATION, PwmSettingCategory.EMAIL_SETTINGS),
     EMAIL_ADVANCED_SETTINGS(
             "email.smtp.advancedSettings", PwmSettingSyntax.STRING_ARRAY, PwmSettingCategory.EMAIL_SETTINGS),
 
-
     // email template
     EMAIL_CHANGEPASSWORD(
             "email.changePassword", PwmSettingSyntax.EMAIL, PwmSettingCategory.EMAIL_TEMPLATES),

+ 1 - 3
server/src/main/java/password/pwm/config/PwmSettingCategory.java

@@ -88,12 +88,10 @@ public enum PwmSettingCategory {
     UI_FEATURES                 (USER_INTERFACE),
     UI_WEB                      (USER_INTERFACE),
 
-    EMAIL_PROFILES              (SETTINGS),
-    //EMAIL_SETTING               (EMAIL_PROFILES),
-
     EMAIL                       (SETTINGS),
     EMAIL_SETTINGS              (EMAIL),
     EMAIL_TEMPLATES             (EMAIL),
+    EMAIL_PROFILES              (EMAIL),
 
     SMS                         (SETTINGS),
     SMS_GATEWAY                 (SMS),

+ 5 - 7
server/src/main/java/password/pwm/util/queue/EmailQueueManager.java

@@ -85,8 +85,8 @@ public class EmailQueueManager implements PwmService {
     private static final PwmLogger LOGGER = PwmLogger.forClass(EmailQueueManager.class);
 
     private PwmApplication pwmApplication;
-    private List<EmailServerBean> emailServers = new ArrayList<EmailServerBean>();
-    private static List<EmailServerBean> staticEmailServers = new ArrayList<EmailServerBean>();
+    private List<EmailServerBean> emailServers = new ArrayList<>();
+    private static List<EmailServerBean> staticEmailServers = new ArrayList<>();
     private Properties javaMailProps = new Properties();
     private WorkQueueProcessor<EmailItemBean> workQueueProcessor;
 
@@ -127,8 +127,7 @@ public class EmailQueueManager implements PwmService {
                 } else {
                     allAvailable = false;
                 }
-                LOGGER.debug("Port value: " + port.toString());
-                final StoredValue fromAddress = storedConfiguration.readSetting(PwmSetting.EMAIL_DEFAULT_FROM_ADDRESSES, profileName);
+                final StoredValue fromAddress = storedConfiguration.readSetting(PwmSetting.EMAIL_DEFAULT_FROM_ADDRESS);
                 if (null != fromAddress) {
                     emailFromAddress = fromAddress.toString();
                 } else {
@@ -149,12 +148,11 @@ public class EmailQueueManager implements PwmService {
                 if (allAvailable) {
                     final EmailServerBean emailServerBean = new EmailServerBean(hostAddress, hostPort, emailFromAddress, emailUsername, emailPassword, false);
                     emailServers.add(emailServerBean);
+                    staticEmailServers.add(emailServerBean);
                 }
             }
-            staticEmailServers = emailServers;
         } catch (PwmUnrecoverableException ure) {
-
-
+            return;
         }
 
 

+ 0 - 2
server/src/main/resources/password/pwm/config/PwmSetting.xml

@@ -3912,8 +3912,6 @@
     <category hidden="false" key="EMAIL_PROFILES">
         <profile setting="email.profile.list"/>
     </category>
-    <category hidden="false" key="EMAIL_SETTING">
-    </category>
     <category hidden="false" key="EMAIL">
     </category>
     <category hidden="false" key="EMAIL_SETTINGS">

+ 1 - 9
server/src/main/resources/password/pwm/i18n/PwmSetting.properties

@@ -49,7 +49,6 @@ Category_Description_EMAIL=<p>Configuration settings for all sent emails.   The
 Category_Description_EMAIL_SETTINGS=
 Category_Description_EMAIL_TEMPLATES=
 Category_Description_EMAIL_PROFILES=Email Profile Settings
-Categoty_Description_EMAIL_SETTING=Email settings
 Category_Description_FORGOTTEN_USERNAME=Allows a user to search for a forgotten user name using a configurable search filter and attributes.
 Category_Description_GENERAL=General settings for the application.  Settings here control the functionality and behavior of the system overall.
 Category_Description_GUEST=Note\: The guest user registration module requires that the logged in user has sufficient permissions to create users and if so configured, to check for duplicate values.
@@ -145,7 +144,6 @@ Category_Label_EMAIL=Email
 Category_Label_EMAIL_SETTINGS=Email Settings
 Category_Label_EMAIL_TEMPLATES=Email Templates
 Category_Label_EMAIL_PROFILES=Email Profile Settings
-#Category_Label_EMAIL_SETTING=Email Settings
 Category_Label_FORGOTTEN_USERNAME=Forgotten User Name
 Category_Label_GENERAL=Application
 Category_Label_GUEST=Guest Registration
@@ -310,7 +308,7 @@ Setting_Description_email.adminAlert.toAddress=Define this template to send an e
 Setting_Description_email.challenge.token=Define this template to send an email during the forgotten password verification process.  You can use %TOKEN% to insert the token value into the email.
 Setting_Description_email.changePassword=Define this template to send an email to the users when password changes occur. @PwmAppName@ only sends this email when the users change their own passwords.
 Setting_Description_email.changePassword.helpdesk=Define this template to send an email to users when the Help Desk changes the users' passwords. @PwmAppName@ expands macros for this setting based on the user who is changing their password, not the Help Desk user. 
-Setting_Description_email.default.fromAddress=Specify a default From Address for the email templates.
+Setting_Description_email.default.fromAddress=Specify a default From Address for the email templates. This value will be used for all sent email unless indicated in the template.
 Setting_Description_email.deleteAccount=Define this template to send an email to the users after the Account Delete action.
 Setting_Description_email.guest=Define this template to send an email to newly created guest users.
 Setting_Description_email.helpdesk.token=Define this template to send an email during the Help Desk verification process.  You can use %TOKEN% to insert the token value into the email.
@@ -322,14 +320,11 @@ Setting_Description_email.pwExpirationNotice=Email sent to users to notify the u
 Setting_Description_email.queueMaxAge=Specify the maximum age (in seconds) an email can wait in the send queue.  If an email is in the send queue longer than this time, @PwmAppName@ discards it.  Emails only persist in the send queue if there is an IO or network error to the SMTP server while sending the email.
 Setting_Description_email.sendpassword=Define this template to send an email during forgotten password reset process if you enabled the send password functionality.
 Setting_Description_email.sendUsername=Define this template to send an email for the forgotten user name process.
-
 Setting_Description_email.profile.list=Email profiles for multiple email servers.
 Setting_Description_email.smtp.addresses=Specify an SMTP server address that sends the emails @PwmAppName@ generates.  Removing this setting prevents @PwmAppName@ from sending any emails.  Ensure that the server specified here allows relaying.  For best results, use a local SMTP server.
 Setting_Description_email.smtp.ports=Specify the network port number for the SMTP server.
 Setting_Description_email.smtp.usernames=Specify an SMTP user that logs in to the SMTP server so that it can send the emails @PwmAppName@ generates.  A blank value here sends SMTP messages without authentication.
 Setting_Description_email.smtp.userpasswords=Specify the password for the SMTP user.  A blank value here sends SMTP messages without authentication.
-Setting_Description_email.default.fromAddresses=Specify a default From Address for the email templates.
-
 Setting_Description_email.smtp.address=Specify an SMTP server address that sends the emails @PwmAppName@ generates.  Removing this setting prevents @PwmAppName@ from sending any emails.  Ensure that the server specified here allows relaying.  For best results, use a local SMTP server.
 Setting_Description_email.smtp.advancedSettings=Add Name/Value settings to control the behavior of the mail agent. Available settings are defined as part of the <a href\="https\://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html">JavaMail API</a>. The settings must be in "name\=value" format, where name is the key value of a valid JavaMail API setting.
 Setting_Description_email.smtp.port=Specify the network port number for the SMTP server.
@@ -813,14 +808,11 @@ Setting_Label_email.pwExpirationNotice=Password Expiration Notification Email
 Setting_Label_email.queueMaxAge=Maximum Email Queue Age
 Setting_Label_email.sendpassword=Send Password Email
 Setting_Label_email.sendUsername=Send User Name Email
-
 Setting_Label_email.profile.list=Email Profiles
 Setting_Label_email.smtp.addresses=Email Server Address
 Setting_Label_email.smtp.ports=Email Server Port
 Setting_Label_email.smtp.usernames=Email Server User Name
 Setting_Label_email.smtp.userpasswords=Email Server Password
-Setting_Label_email.default.fromAddresses=Default From Address
-
 Setting_Label_email.smtp.address=SMTP Email Server Address
 Setting_Label_email.smtp.advancedSettings=SMTP Email Advanced Settings
 Setting_Label_email.smtp.port=SMTP Email Server Port