You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by ks...@apache.org on 2013/04/29 17:21:53 UTC
svn commit: r1477147 -
/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
Author: kstam
Date: Mon Apr 29 15:21:53 2013
New Revision: 1477147
URL: http://svn.apache.org/r1477147
Log:
JUDDI-591 adding authentication support
Modified:
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java?rev=1477147&r1=1477146&r2=1477147&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java Mon Apr 29 15:21:53 2013
@@ -8,6 +8,7 @@ import java.util.Properties;
import javax.mail.Address;
import javax.mail.Message.RecipientType;
+import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
@@ -37,7 +38,7 @@ public class SMTPNotifier implements Not
private final static String[] mailProps = {"mail.smtp.from", "mail.smtp.host", "mail.smtp.port",
"mail.smtp.socketFactory.class", "mail.smtp.socketFactory.fallback", "mail.smtp.starttls.enable",
- "mail.smtp.socketFactory.port","mail.smtp.auth"};
+ "mail.smtp.socketFactory.port","mail.smtp.auth","mail.smtp.user","mail.smtp.password"};
protected Properties getEMailProperties() throws ConfigurationException {
if (properties==null) {
@@ -88,10 +89,20 @@ public class SMTPNotifier implements Not
if (!accessPointUrl.startsWith("mailto:")) {
log.warn("smtp accessPointUrl for bindingTemplate " + bindingTemplate.getEntityKey() +
" should start with 'mailto'");
- //TODO maybe update the user's bindingTemplate with the error?
+ //TODO maybe update the user's bindingTemplate with the error?, and also validate setting onsave
} else {
notificationEmailAddress = accessPointUrl.substring(accessPointUrl.indexOf(":")+1);
- session = Session.getInstance(getEMailProperties());
+ if (Boolean.getBoolean(properties.getProperty("mail.smtp.starttls.enable"))) {
+ final String username = properties.getProperty("mail.smtp.username");
+ final String password = properties.getProperty("mail.smtp.password");
+ session = Session.getInstance(getEMailProperties(), new javax.mail.Authenticator() {
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(username, password);
+ }
+ });
+ } else {
+ session = Session.getInstance(getEMailProperties());
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org