Alon Bar-Lev has uploaded a new change for review.

Change subject: notifier: handle port correctly
......................................................................

notifier: handle port correctly

1. separate between plain and ssl ports.
2. actually set plain port.

Change-Id: Ibcfa79849856dc3c2b3aaa9d0dd8652be04c788b
Signed-off-by: Alon Bar-Lev <alo...@redhat.com>
---
M 
backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java
M 
backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/JavaMailSender.java
M packaging/etc/notifier/notifier.conf
3 files changed, 11 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/75/14375/1

diff --git 
a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java
 
b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java
index e65fe6a..12255ae 100644
--- 
a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java
+++ 
b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java
@@ -21,6 +21,7 @@
      */
     public static final String MAIL_SERVER = "MAIL_SERVER";
     public static final String MAIL_PORT = "MAIL_PORT";
+    public static final String MAIL_PORT_SSL = "MAIL_PORT_SSL";
     public static final String MAIL_USER = "MAIL_USER";
     public static final String MAIL_PASSWORD = "MAIL_PASSWORD";
     public static final String MAIL_ENABLE_SSL = "MAIL_ENABLE_SSL";
diff --git 
a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/JavaMailSender.java
 
b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/JavaMailSender.java
index 4776fb6..e5006a8 100644
--- 
a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/JavaMailSender.java
+++ 
b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/JavaMailSender.java
@@ -42,22 +42,26 @@
     public JavaMailSender(Map<String, String> aMailProps) {
         Properties mailSessionProps = setCommonProperties(aMailProps);
 
+        mailSessionProps.put("mail.smtp.host", 
aMailProps.get(NotificationProperties.MAIL_SERVER));
         // enable SSL
         if 
(Boolean.valueOf(aMailProps.get(NotificationProperties.MAIL_ENABLE_SSL))) {
             mailSessionProps.put("mail.transport.protocol", "smtps");
-            mailSessionProps.put("mail.smtps.auth", "true");
-            mailSessionProps.put("mail.smtps.host", 
aMailProps.get(NotificationProperties.MAIL_SERVER));
-            String portString = 
aMailProps.get(NotificationProperties.MAIL_PORT);
+            String portString = 
aMailProps.get(NotificationProperties.MAIL_PORT_SSL);
             if (StringUtils.isNotEmpty(portString)) {
-                mailSessionProps.put("mail.smtps.socketFactory.port", 
Integer.valueOf(portString));
+                mailSessionProps.put("mail.smtps.socketFactory.port", 
portString);
+                mailSessionProps.put("mail.smtp.port", portString);
             }
+            mailSessionProps.put("mail.smtps.auth", "true");
             mailSessionProps.put("mail.smtps.socketFactory.class", 
"javax.net.ssl.SSLSocketFactory");
             mailSessionProps.put("mail.smtps.socketFactory.fallback", false);
 
             this.isSSL = true;
         } else {
             mailSessionProps.put("mail.transport.protocol", "smtp");
-            mailSessionProps.put("mail.smtp.host", 
aMailProps.get(NotificationProperties.MAIL_SERVER));
+            String portString = 
aMailProps.get(NotificationProperties.MAIL_PORT);
+            if (StringUtils.isNotEmpty(portString)) {
+                mailSessionProps.put("mail.smtp.port", portString);
+            }
         }
 
         String password = aMailProps.get(NotificationProperties.MAIL_PASSWORD);
diff --git a/packaging/etc/notifier/notifier.conf 
b/packaging/etc/notifier/notifier.conf
index adc40c2..9fa3ea9 100644
--- a/packaging/etc/notifier/notifier.conf
+++ b/packaging/etc/notifier/notifier.conf
@@ -14,6 +14,7 @@
 
 # The default port of non-secured SMTP server is 25, for secured (ssl enabled) 
465.
 #MAIL_PORT=25
+#MAIL_PORT_SSL=465
 
 # Required if SSL enabled to authenticate the user. Used also to specify 
'from' user address if mail server
 # supports, when MAIL_FROM is not set. Address is in RFC822 format


--
To view, visit http://gerrit.ovirt.org/14375
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibcfa79849856dc3c2b3aaa9d0dd8652be04c788b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to