ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r707368 - in /ant/core/trunk: ./ docs/manual/ docs/manual/CoreTasks/ src/main/org/apache/tools/ant/listener/ src/main/org/apache/tools/ant/taskdefs/email/
Date Thu, 23 Oct 2008 13:13:36 GMT
Author: bodewig
Date: Thu Oct 23 06:13:36 2008
New Revision: 707368

URL: http://svn.apache.org/viewvc?rev=707368&view=rev
Log:
Add STARTTLS support to MimeMailer and use it in MailLogger and <mail>.  Part of PR
46063.

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/contributors.xml
    ant/core/trunk/docs/manual/CoreTasks/mail.html
    ant/core/trunk/docs/manual/listeners.html
    ant/core/trunk/src/main/org/apache/tools/ant/listener/MailLogger.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=707368&r1=707367&r2=707368&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=707368&r1=707367&r2=707368&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Oct 23 06:13:36 2008
@@ -482,6 +482,10 @@
    <cvschangelog>.
    Bugzilla Report 27419.
 
+ * MailLogger and <mail> can now optionally enable support for
+   STARTTLS.
+   Bugzilla Report 46063.
+
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================
 

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=707368&r1=707367&r2=707368&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Thu Oct 23 06:13:36 2008
@@ -221,6 +221,10 @@
   </name>
   <name>
     <first>Craig</first>
+    <last>Richardson</last>
+  </name>
+  <name>
+    <first>Craig</first>
     <last>Sandvik</last>
   </name>
   <name>

Modified: ant/core/trunk/docs/manual/CoreTasks/mail.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/mail.html?rev=707368&r1=707367&r2=707368&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/mail.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/mail.html Thu Oct 23 06:13:36 2008
@@ -179,6 +179,14 @@
       fail if neither is reachable.  <em>Since Ant 1.8.0</em>.</td>
     <td align="center" valign="top">No, default is false</td>
   </tr>
+  <tr>
+    <td valign="top">enableStartTLS</td>
+    <td valign="top">"true", "on" or "yes" accepted here<br></br>
+      whether the STARTTLS command used to switch to an encrypted
+      connection for authentication should be supported.  Requires
+      JavaMail.  <em>Since Ant 1.8.0</em></td>
+    <td valign="center">No</td>
+  </tr>
 </table>
 
 <h3>Note regarding the attributes containing email addresses</h3>

Modified: ant/core/trunk/docs/manual/listeners.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/listeners.html?rev=707368&r1=707367&r2=707368&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/listeners.html (original)
+++ ant/core/trunk/docs/manual/listeners.html Thu Oct 23 06:13:36 2008
@@ -246,6 +246,12 @@
     <td width="63%">No</td>
   </tr>
   <tr>
+    <td width="337">MailLogger.starttls.enable</td>
+    <td width="63%">on or true if STARTTLS should be supported
+    (requires JavaMail).  <em>Since Ant 1.8.0</em></td>
+    <td width="63%">No, default is false</td>
+  </tr>
+  <tr>
     <td width="337">MailLogger.properties.file </td>
     <td width="63%">Filename of properties file that will override other values.</td>
     <td width="63%">No</td>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/listener/MailLogger.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/listener/MailLogger.java?rev=707368&r1=707367&r2=707368&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/listener/MailLogger.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/listener/MailLogger.java Thu Oct 23 06:13:36
2008
@@ -73,6 +73,8 @@
  *    mail body for a successful build, default is to send the logfile</li>
  *    <li> MailLogger.mimeType [default: text/plain] - MIME-Type of email</li>
  *    <li> MailLogger.charset [no default] - character set of email</li>
+ *    <li> Maillogger.starttls.enable [default: false] - on or true if
+ *    STARTTLS should be supported (requires JavaMail)</li>
  *    <li> MailLogger.properties.file [no default] - Filename of
  *    properties file that will override other values.</li>
  *  </ul>
@@ -142,6 +144,8 @@
                 .password(getValue(properties, "password", ""))
                 .ssl(Project.toBoolean(getValue(properties,
                                                 "ssl", "off")))
+                .starttls(Project.toBoolean(getValue(properties,
+                                                     "starttls.enable", "off")))
                 .from(getValue(properties, "from", null))
                 .replytoList(getValue(properties, "replyto", ""))
                 .toList(getValue(properties, prefix + ".to", null))
@@ -153,7 +157,7 @@
                              (success) ? "Build Success" : "Build Failure"));
             if (values.user().equals("")
                 && values.password().equals("")
-                && !values.ssl()) {
+                && !values.ssl() && !values.starttls()) {
                 sendMail(values, buffer.substring(0));
             } else {
                 sendMimeMail(
@@ -262,6 +266,14 @@
             this.body = body;
             return this;
         }
+        private boolean starttls;
+        public boolean starttls() {
+            return starttls;
+        }
+        public Values starttls(boolean starttls) {
+            this.starttls = starttls;
+            return this;
+        }
     }
 
     /**
@@ -365,6 +377,7 @@
         mailer.setUser(values.user());
         mailer.setPassword(values.password());
         mailer.setSSL(values.ssl());
+        mailer.setEnableStartTLS(values.ssl());
         Message mymessage =
             new Message(values.body().length() > 0 ? values.body() : message);
         mymessage.setProject(project);

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java?rev=707368&r1=707367&r2=707368&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java Thu Oct 23
06:13:36 2008
@@ -102,6 +102,8 @@
     private String password = null;
     /** indicate if the user wishes SSL-TLS */
     private boolean ssl = false;
+    /** indicate if the user wishes support for STARTTLS */
+    private boolean starttls = false;
 
     /** ignore invalid recipients? */
     private boolean ignoreInvalidRecipients = false;
@@ -134,6 +136,16 @@
     }
 
     /**
+     * Set whether to allow authentication to switch to a TLS
+     * connection via STARTTLS.
+     * @param b boolean; if true STARTTLS will be supported.
+     * @since Ant 1.8.0
+     */
+    public void setEnableStartTLS(boolean b) {
+        this.starttls = b;
+    }
+
+    /**
      * Set the preferred encoding method.
      *
      * @param encoding The encoding (one of AUTO, MIME, UU, PLAIN).
@@ -454,9 +466,10 @@
                 throw new BuildException("SMTP auth only possible with MIME mail");
             }
             // SSL only allowed with MIME mail
-            if (!autoFound  && (ssl)
+            if (!autoFound  && (ssl || starttls)
                 && (encoding.equals(UU) || encoding.equals(PLAIN))) {
-                throw new BuildException("SSL only possible with MIME mail");
+                throw new BuildException("SSL and STARTTLS only possible with"
+                                         + " MIME mail");
             }
             // try UU format
             if (encoding.equals(UU)
@@ -537,6 +550,7 @@
             mailer.setUser(user);
             mailer.setPassword(password);
             mailer.setSSL(ssl);
+            mailer.setEnableStartTLS(starttls);
             mailer.setMessage(message);
             mailer.setFrom(from);
             mailer.setReplyToList(replyToList);

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java?rev=707368&r1=707367&r2=707368&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java Thu Oct 23 06:13:36
2008
@@ -49,6 +49,7 @@
     protected Vector headers = null;
     // CheckStyle:VisibilityModifier ON
     private boolean ignoreInvalidRecipients = false;
+    private boolean starttls = false;
 
     /**
      * Set the mail server.
@@ -99,6 +100,20 @@
     }
 
     /**
+     * Set whether to allow authentication to switch to a TLS
+     * connection via STARTTLS.
+     * @param b boolean; if true STARTTLS will be supported.
+     * @since Ant 1.8.0
+     */
+    public void setEnableStartTLS(boolean b) {
+        this.starttls = b;
+    }
+
+    protected boolean isStartTLSEnabled() {
+        return starttls;
+    }
+
+    /**
      * Set the message.
      *
      * @param m the message content.

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java?rev=707368&r1=707367&r2=707368&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java Thu Oct 23
06:13:36 2008
@@ -161,6 +161,9 @@
                 props.put("mail.smtp.auth", "true");
                 auth = new SimpleAuthenticator(user, password);
             }
+            if (isStartTLSEnabled()) {
+                props.put("mail.smtp.starttls.enable", "true");
+            }
             sesh = Session.getInstance(props, auth);
 
             //create the message



Mime
View raw message