commits@javamail.java.net

[javamail~mercurial:526] Update all logging classes to use annotations, generics, autoboxing and v

From: <shannon_at_kenai.com>
Date: Sat, 2 Mar 2013 22:12:41 +0000

Project: javamail
Repository: mercurial
Revision: 526
Author: shannon
Date: 2013-03-01 23:56:51 UTC
Link:

Log Message:
------------
use proper relative reference for spec license.
Document JavaMail 1.5 compatibility issues.
Update documentation for mail.mime.encode/decodeparameters for JavaMail 1.5.
Update example and refer to latest spec.
Update Oracle-specific path. Update to JavaMail 1.5 spec.
Use new Message.getSession() method, instead of accessing the session directly,
allowing a Message subclass to usefully override the getSession method.
NullPointerException when accessing the content of a message/rfc822 attachment
- bug 5829
IMAPProtocol.sasllogin uses old constructor for IMAPSaslAuthenticator;
ditto SMTPTransport - bug 5830
Change version from "1.5" to "1.5.0", for consistency and to prevent confusion.
Update all logging classes to use annotations, generics, autoboxing and varargs.

MailHandler directly access ThreadLocal.remove.
MailHandler add links to code point version of Character.isISOControl
MailHandlerTest add compile time test for raw type comparators.
MailHandlerTest fix init test to include comparator check.
MailHandlerDemo use Arrays.toString.
SummaryNameFormatter use code points when checking pattern.
README.txt update the Java SE link.

(From Jason)


Revisions:
----------
517
518
519
520
521
522
523
524
525
526


Modified Paths:
---------------
javadoc/pom.xml
doc/release/COMPAT.txt
mail/src/main/java/javax/mail/internet/package.html
mail/src/main/java/javax/mail/package.html
mail/src/main/java/overview.html
assembly.xml
mail/src/main/java/javax/mail/MessageContext.java
doc/release/CHANGES.txt
mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
mail/src/main/java/com/sun/mail/imap/IMAPNestedMessage.java
mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java
mail/src/test/java/com/sun/mail/imap/IMAPHandler.java
mail/src/test/java/com/sun/mail/smtp/SMTPHandler.java
client/pom.xml
demo/pom.xml
dsn/pom.xml
gimap/pom.xml
imap/pom.xml
logging/pom.xml
mail/pom.xml
mailapi/pom.xml
mailapijar/pom.xml
mbox/dist/pom.xml
mbox/native/pom.xml
mbox/pom.xml
oldmail/pom.xml
outlook/pom.xml
parent-distrib/pom.xml
pom.xml
pop3/pom.xml
servlet/pom.xml
smtp/pom.xml
taglib/pom.xml
webapp/pom.xml
logging/src/main/java/FileErrorManager.java
logging/src/main/java/MailHandlerDemo.java
logging/src/main/java/README.txt
logging/src/main/java/SummaryFormatter.java
logging/src/main/java/SummaryNameFormatter.java
mail/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java
mail/src/main/java/com/sun/mail/util/logging/MailHandler.java
mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.java
mail/src/test/java/com/sun/mail/util/logging/MailHandlerTest.java


Added Paths:
------------
mail/src/test/java/com/sun/mail/imap/IMAPSaslHandler.java
mail/src/test/java/com/sun/mail/imap/IMAPSaslLoginTest.java
mail/src/test/java/com/sun/mail/smtp/SMTPSaslHandler.java
mail/src/test/java/com/sun/mail/smtp/SMTPSaslLoginTest.java


Diffs:
------
diff -r 2504e013086f -r b4e7e1efed69 javadoc/pom.xml
--- a/javadoc/pom.xml Mon Feb 11 16:19:17 2013 -0800
+++ b/javadoc/pom.xml Fri Feb 22 15:30:52 2013 -0800
@@ -167,7 +167,7 @@
     <a href="http://www.oracle.com">Oracle</a>
     and/or its affiliates. All Rights Reserved.
     Use is subject to
- <a href="doc-files/speclicense.html" target="_top">license terms</a>.
+ <a href="{_at_docRoot}/doc-files/speclicense.html" target="_top">license terms</a>.
 ]]>
                             </bottom>
                             <groups>


diff -r b4e7e1efed69 -r e6f46d76b506 doc/release/COMPAT.txt
--- a/doc/release/COMPAT.txt Fri Feb 22 15:30:52 2013 -0800
+++ b/doc/release/COMPAT.txt Fri Feb 22 16:01:04 2013 -0800
@@ -4,14 +4,59 @@
                     JavaMail(TM) API ${mail.version} release
                     ------------------------------
 
-The JavaMail 1.4 specification is fully compatible with the JavaMail
-1.3 specification. However, changes in the implementation may impact
+The JavaMail 1.5 specification is fully compatible with the JavaMail
+1.4 specification, with the exceptions listed below.
+
+In addition, changes in the implementation may impact
 applications that depend on behavior beyond what is defined by the
-JavaMail specification, or that use features specific to the Sun
+JavaMail specification, or that use features specific to the reference
 implementation. This note summarizes potential compatibility issues
 with this release of the JavaMail API.
 
 
+-- JavaMail 1.5 --
+
+- RFC 2231 parameter encoding/decoding enabled by default
+
+ The System properties "mail.mime.decodeparameters" and
+ "mail.mime.encodeparameters" now default to true instead of false.
+ Now that most mailers support RFC 2231, this is expected to
+ increase interoperability, although in rare cases, and especially
+ when dealing with older mailers, this may cause problems.
+ Parameters may appear encoded, and with a different name,
+ than what the receiver is expecting.
+
+- ContentType.toString and ContentDisposition.toString never return null
+
+ These methods were previously documented to return null in
+ error cases when the fields of the class were not valid.
+ These methods now return an empty string in these cases, to
+ be consistent with the general contract of Object.toString.
+
+- additional classes, methods, and fields
+
+ JavaMail 1.5 adds classes to existing packages, methods to
+ existing classes, and fields to existing classes. All of
+ these changes have the potential to break source compatibility
+ for applications using the JavaMail API.
+
+- JDK 1.5 or newer required
+
+ The JavaMail reference implementation now requires JDK 1.5
+ or newer. It is expected that the large majority of users
+ are already using JDK 1.6 or newer.
+
+- protected fields in final classes in javax.mail.search made private
+
+ Some of the final classes in the javax.mail.search package
+ contained protected fields. Since these classes were final
+ and couldn't be subclassed, the "protected" access qualifier
+ had no effect. These fields are now private. It's hard to
+ imagine how this change could impact any applications other
+ than perhaps those using reflection to access these classes.
+
+
+
 -- JavaMail 1.4.4 --
 
 - authorization ID may be null
@@ -62,7 +107,7 @@
         (if the property isn't specified) has changed so that JavaMail
         will wait for the response from the server before dropping the
         connection. In some cases, with some servers, this additional
- wait time may be noticable.
+ wait time may be noticeable.
 
 
 - MessagingException.getMessage output changed


diff -r e6f46d76b506 -r c64e021aacb0 mail/src/main/java/javax/mail/internet/package.html
--- a/mail/src/main/java/javax/mail/internet/package.html Fri Feb 22 16:01:04 2013 -0800
+++ b/mail/src/main/java/javax/mail/internet/package.html Fri Feb 22 16:05:14 2013 -0800
@@ -163,11 +163,11 @@
 <TD>mail.mime.decodeparameters</TD>
 <TD>boolean</TD>
 <TD>
-If set to <code>"true"</code>, non-ASCII parameters in a
+If set to <code>"false"</code>, non-ASCII parameters in a
 <code>ParameterList</code>, e.g., in a Content-Type header,
-will be decoded as specified by
+will <b>not</b> be decoded as specified by
 <A HREF="http://www.ietf.org/rfc/rfc2231.txt" TARGET="_top">RFC 2231</A>.
-The default is false.
+The default is true.
 </TD>
 </TR>
 
@@ -175,11 +175,11 @@
 <TD>mail.mime.encodeparameters</TD>
 <TD>boolean</TD>
 <TD>
-If set to <code>"true"</code>, non-ASCII parameters in a
+If set to <code>"false"</code>, non-ASCII parameters in a
 <code>ParameterList</code>, e.g., in a Content-Type header,
-will be encoded as specified by
+will <b>not</b> be encoded as specified by
 <A HREF="http://www.ietf.org/rfc/rfc2231.txt" TARGET="_top">RFC 2231</A>.
-The default is false.
+The default is true.
 </TD>
 </TR>
 


diff -r c64e021aacb0 -r ea569cf25661 mail/src/main/java/javax/mail/package.html
--- a/mail/src/main/java/javax/mail/package.html Fri Feb 22 16:05:14 2013 -0800
+++ b/mail/src/main/java/javax/mail/package.html Fri Feb 22 16:20:28 2013 -0800
@@ -5,7 +5,7 @@
 
     DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
- Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
 
     The contents of this file are subject to the terms of either the GNU
     General Public License Version 2 only ("GPL") or the Common Development
@@ -55,7 +55,7 @@
 The JavaMail API includes the <code>javax.mail</code> package and subpackages.
 <P>
 For an overview of the JavaMail API, read the JavaMail specification
-<A HREF="../../../JavaMail-1.4.pdf" TARGET="_top">
+<A HREF="../../../JavaMail-1.5.pdf" TARGET="_top">
 included in the download bundle</A> or
 <A HREF="http://www.oracle.com/technetwork/java/javamail-1-149769.pdf" TARGET="_top">
 available on the JavaMail web site</A>.
@@ -64,18 +64,17 @@
 <PRE>
     Properties props = new Properties();
     props.put("mail.smtp.host", "my-mail-server");
- props.put("mail.from", "me_at_example.com");
     Session session = Session.getInstance(props, null);
 
     try {
         MimeMessage msg = new MimeMessage(session);
- msg.setFrom();
+ msg.setFrom("me_at_example.com");
         msg.setRecipients(Message.RecipientType.TO,
                           "you_at_example.com");
         msg.setSubject("JavaMail hello world example");
         msg.setSentDate(new Date());
         msg.setText("Hello, world!\n");
- Transport.send(msg);
+ Transport.send(msg, "me_at_example.com", "my-password");
     } catch (MessagingException mex) {
         System.out.println("send failed, exception: " + mex);
     }

diff -r c64e021aacb0 -r ea569cf25661 mail/src/main/java/overview.html
--- a/mail/src/main/java/overview.html Fri Feb 22 16:05:14 2013 -0800
+++ b/mail/src/main/java/overview.html Fri Feb 22 16:20:28 2013 -0800
@@ -5,7 +5,7 @@
 
     DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
- Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
 
     The contents of this file are subject to the terms of either the GNU
     General Public License Version 2 only ("GPL") or the Common Development
@@ -55,7 +55,7 @@
 The JavaMail API includes the <code>javax.mail</code> package and subpackages.
 <P>
 For an overview of the JavaMail API, read the JavaMail specification
-<A HREF="../JavaMail-1.4.pdf" TARGET="_top">
+<A HREF="../JavaMail-1.5.pdf" TARGET="_top">
 included in the download bundle</A> or
 <A HREF="http://www.oracle.com/technetwork/java/javamail-1-149769.pdf" TARGET="_top">
 available on the JavaMail web site</A>.
@@ -64,18 +64,17 @@
 <PRE>
     Properties props = new Properties();
     props.put("mail.smtp.host", "my-mail-server");
- props.put("mail.from", "me_at_example.com");
     Session session = Session.getInstance(props, null);
 
     try {
         MimeMessage msg = new MimeMessage(session);
- msg.setFrom();
+ msg.setFrom("me_at_example.com");
         msg.setRecipients(Message.RecipientType.TO,
                           "you_at_example.com");
         msg.setSubject("JavaMail hello world example");
         msg.setSentDate(new Date());
         msg.setText("Hello, world!\n");
- Transport.send(msg);
+ Transport.send(msg, "me_at_example.com", "my-password");
     } catch (MessagingException mex) {
         System.out.println("send failed, exception: " + mex);
     }


diff -r ea569cf25661 -r aa197cec6694 assembly.xml
--- a/assembly.xml Fri Feb 22 16:20:28 2013 -0800
+++ b/assembly.xml Mon Feb 25 17:00:15 2013 -0800
@@ -3,7 +3,7 @@
 
     DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
- Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
 
     The contents of this file are subject to the terms of either the GNU
     General Public License Version 2 only ("GPL") or the Common Development
@@ -233,10 +233,10 @@
         </fileSet>
         <fileSet>
             <!-- only works within Sun -->
- <directory>/net/anybodys.sfbay/export6/javamail/spec</directory>
+ <directory>/net/anybodys.us.oracle.com/export6/javamail/spec</directory>
             <outputDirectory>docs</outputDirectory>
             <includes>
- <include>JavaMail-1.4.pdf</include>
+ <include>JavaMail-1.5.pdf</include>
                 <include>Providers.pdf</include>
             </includes>
         </fileSet>


diff -r aa197cec6694 -r e07e6a48957d mail/src/main/java/javax/mail/MessageContext.java
--- a/mail/src/main/java/javax/mail/MessageContext.java Mon Feb 25 17:00:15 2013 -0800
+++ b/mail/src/main/java/javax/mail/MessageContext.java Tue Feb 26 12:13:32 2013 -0800
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -117,6 +117,6 @@
      */
     public Session getSession() {
         Message msg = getMessage();
- return msg != null ? msg.session : null;
+ return msg != null ? msg.getSession() : null;
     }
 }


diff -r e07e6a48957d -r 68e2f6dc5679 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Tue Feb 26 12:13:32 2013 -0800
+++ b/doc/release/CHANGES.txt Tue Feb 26 13:29:55 2013 -0800
@@ -35,6 +35,7 @@
 K 5770 make MimeMultipart fields protected to allow subclassing
 K 5818 need simple way to override MIME type and encoding of attachment
 K 5819 enable RFC 2231 support by default
+K 5829 NullPointerException when accessing the content of a message attachment
 
 
                   CHANGES IN THE 1.4.6 RELEASE

diff -r e07e6a48957d -r 68e2f6dc5679 mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Tue Feb 26 12:13:32 2013 -0800
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Tue Feb 26 13:29:55 2013 -0800
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -233,11 +233,13 @@
     }
 
     // Return the block size for FETCH requests
+ // MUST be overridden by IMAPNestedMessage
     protected int getFetchBlockSize() {
         return ((IMAPStore)folder.getStore()).getFetchBlockSize();
     }
 
     // Return the block size for FETCH requests
+ // MUST be overridden by IMAPNestedMessage
     protected boolean ignoreBodyStructureSize() {
         return ((IMAPStore)folder.getStore()).ignoreBodyStructureSize();
     }

diff -r e07e6a48957d -r 68e2f6dc5679 mail/src/main/java/com/sun/mail/imap/IMAPNestedMessage.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPNestedMessage.java Tue Feb 26 12:13:32 2013 -0800
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPNestedMessage.java Tue Feb 26 13:29:55 2013 -0800
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -125,6 +125,13 @@
     }
 
     /*
+ * Get the enclosing message's ignoreBodyStructureSize.
+ */
+ protected boolean ignoreBodyStructureSize() {
+ return msg.ignoreBodyStructureSize();
+ }
+
+ /*
      * IMAPMessage uses RFC822.SIZE. We use the "size" field from
      * our BODYSTRUCTURE.
      */


diff -r 68e2f6dc5679 -r 609223192896 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Tue Feb 26 13:29:55 2013 -0800
+++ b/doc/release/CHANGES.txt Fri Mar 01 15:35:03 2013 -0800
@@ -18,24 +18,25 @@
                   --------------------------
 The following bugs have been fixed in the 1.5 release.
 
-K 5682 add FetchProfile.Item.SIZE
-K 5683 fix protected fields in final classes in javax.mail.search
-K 5684 add MimeMultipart(String subtype, BodyPart... bps) constructor
-K 5685 exceptions should support exception chaining
-K 5686 ParameterList needs to support use by IMAP
-K 5687 ContentType.toString & ContentDisposition.toString shouldn't return null
-K 5689 add Transport.send(msg, username, password) method
-K 5690 add MimeMessage.setFrom(String) method
-K 5691 add Message.getSession() method
-K 5692 MimeBodyPart.attachFile should set the disposition to ATTACHMENT
-K 5693 add MimeMessage.reply(replyToAll, setAnswered) method
-K 5694 add "next" methods to HeaderTokenizer to help parsing bad headers
-K 5743 add @MailSessionDefinition and @MailSessionDefinitions for Java EE 7
-K 5769 make cachedContent field protected in MimeMessage and MimeBodyPart
-K 5770 make MimeMultipart fields protected to allow subclassing
-K 5818 need simple way to override MIME type and encoding of attachment
-K 5819 enable RFC 2231 support by default
-K 5829 NullPointerException when accessing the content of a message attachment
+K 5682 add FetchProfile.Item.SIZE
+K 5683 fix protected fields in final classes in javax.mail.search
+K 5684 add MimeMultipart(String subtype, BodyPart... bps) constructor
+K 5685 exceptions should support exception chaining
+K 5686 ParameterList needs to support use by IMAP
+K 5687 ContentType.toString & ContentDisposition.toString shouldn't return null
+K 5689 add Transport.send(msg, username, password) method
+K 5690 add MimeMessage.setFrom(String) method
+K 5691 add Message.getSession() method
+K 5692 MimeBodyPart.attachFile should set the disposition to ATTACHMENT
+K 5693 add MimeMessage.reply(replyToAll, setAnswered) method
+K 5694 add "next" methods to HeaderTokenizer to help parsing bad headers
+K 5743 add @MailSessionDefinition and @MailSessionDefinitions for Java EE 7
+K 5769 make cachedContent field protected in MimeMessage and MimeBodyPart
+K 5770 make MimeMultipart fields protected to allow subclassing
+K 5818 need simple way to override MIME type and encoding of attachment
+K 5819 enable RFC 2231 support by default
+K 5829 NullPointerException when accessing the content of a message attachment
+K 5830 IMAPProtocol.sasllogin uses old constructor for IMAPSaslAuthenticator
 
 
                   CHANGES IN THE 1.4.6 RELEASE

diff -r 68e2f6dc5679 -r 609223192896 mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Tue Feb 26 13:29:55 2013 -0800
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Fri Mar 01 15:35:03 2013 -0800
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -719,8 +719,7 @@
                                         IMAPProtocol.class,
                                         String.class,
                                         Properties.class,
- Boolean.TYPE,
- PrintStream.class,
+ MailLogger.class,
                                         String.class
                                         });
                 saslAuthenticator = (SaslAuthenticator)c.newInstance(

diff -r 68e2f6dc5679 -r 609223192896 mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java
--- a/mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java Tue Feb 26 13:29:55 2013 -0800
+++ b/mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java Fri Mar 01 15:35:03 2013 -0800
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -982,8 +982,7 @@
                                         SMTPTransport.class,
                                         String.class,
                                         Properties.class,
- Boolean.TYPE,
- PrintStream.class,
+ MailLogger.class,
                                         String.class
                                         });
                 saslAuthenticator = (SaslAuthenticator)c.newInstance(

diff -r 68e2f6dc5679 -r 609223192896 mail/src/test/java/com/sun/mail/imap/IMAPHandler.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPHandler.java Tue Feb 26 13:29:55 2013 -0800
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPHandler.java Fri Mar 01 15:35:03 2013 -0800
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 2009-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -60,7 +60,7 @@
 public class IMAPHandler implements Runnable, Cloneable {
 
     /** Logger for this class. */
- private static final Logger LOGGER =
+ protected static final Logger LOGGER =
         Logger.getLogger(IMAPHandler.class.getName());
 
     /** Client socket. */
@@ -183,6 +183,16 @@
     }
 
     /**
+ * Send a tagged NO response with a message.
+ *
+ * @param msg the message to send
+ * @throws IOException unable to read/write to socket
+ */
+ public void no(final String msg) throws IOException {
+ tagged("NO " + (msg != null ? msg : ""));
+ }
+
+ /**
      * Send a tagged BAD response with a message.
      *
      * @param msg the message to send
@@ -202,6 +212,15 @@
     }
 
     /**
+ * Send a "continue" command with a message.
+ *
+ * @throws IOException unable to read/write to socket
+ */
+ public void cont(String msg) throws IOException {
+ println("+ " + (msg != null ? msg : ""));
+ }
+
+ /**
      * Handle command.
      *
      * @throws IOException unable to read/write to socket
@@ -227,6 +246,8 @@
 
         if (commandName.equals("LOGIN")) {
             login();
+ } else if (commandName.equals("AUTHENTICATE")) {
+ authenticate(currentLine);
         } else if (commandName.equals("NOOP")) {
             noop();
         } else if (commandName.equals("SELECT")) {
@@ -257,6 +278,15 @@
     }
 
     /**
+ * AUTHENTICATE command.
+ *
+ * @throws IOException unable to read/write to socket
+ */
+ public void authenticate(String line) throws IOException {
+ bad("AUTHENTICATE not supported");
+ }
+
+ /**
      * SELECT command.
      *
      * @throws IOException unable to read/write to socket
@@ -289,15 +319,19 @@
         ok();
     }
 
- protected void idleWait() throws IOException {
+ protected String readLine() throws IOException {
         currentLine = reader.readLine();
-
         if (currentLine == null) {
             LOGGER.severe("Current line is null!");
             exit();
- return;
         }
- if (!currentLine.equalsIgnoreCase("DONE")) {
+ return currentLine;
+ }
+
+ protected void idleWait() throws IOException {
+ String line = readLine();
+
+ if (line != null && !line.equalsIgnoreCase("DONE")) {
             LOGGER.severe("Didn't get DONE response to IDLE");
             exit();
             return;

diff -r 68e2f6dc5679 -r 609223192896 mail/src/test/java/com/sun/mail/imap/IMAPSaslHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPSaslHandler.java Fri Mar 01 15:35:03 2013 -0800
@@ -0,0 +1,183 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2009-2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.mail.imap;
+
+import java.io.IOException;
+import java.util.StringTokenizer;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+import javax.security.sasl.*;
+import javax.security.auth.callback.*;
+
+import com.sun.mail.util.BASE64EncoderStream;
+import com.sun.mail.util.BASE64DecoderStream;
+import com.sun.mail.util.ASCIIUtility;
+
+/**
+ * Handle IMAP connection with SASL authentication.
+ *
+ * @author Bill Shannon
+ */
+public class IMAPSaslHandler extends IMAPHandler {
+
+ public IMAPSaslHandler() {
+ capabilities += " LOGINDISABLED AUTH=DIGEST-MD5";
+ }
+
+ /**
+ * AUTHENTICATE command.
+ *
+ * @throws IOException unable to read/write to socket
+ */
+ public void authenticate(String line) throws IOException {
+ StringTokenizer ct = new StringTokenizer(line, " ");
+ String tag = ct.nextToken();
+ String commandName = ct.nextToken().toUpperCase();
+ String mech = ct.nextToken().toUpperCase();
+
+ final String u = "test";
+ final String p = "test";
+ final String realm = "test";
+
+ CallbackHandler cbh = new CallbackHandler() {
+ public void handle(Callback[] callbacks) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.fine("SASL callback length: " + callbacks.length);
+ for (int i = 0; i < callbacks.length; i++) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.fine("SASL callback " + i + ": " + callbacks[i]);
+ if (callbacks[i] instanceof NameCallback) {
+ NameCallback ncb = (NameCallback)callbacks[i];
+ ncb.setName(u);
+ } else if (callbacks[i] instanceof PasswordCallback) {
+ PasswordCallback pcb = (PasswordCallback)callbacks[i];
+ pcb.setPassword(p.toCharArray());
+ } else if (callbacks[i] instanceof AuthorizeCallback) {
+ AuthorizeCallback ac = (AuthorizeCallback)callbacks[i];
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.fine("SASL authorize: " +
+ "authn: " + ac.getAuthenticationID() + ", " +
+ "authz: " + ac.getAuthorizationID() + ", " +
+ "authorized: " + ac.getAuthorizedID());
+ ac.setAuthorized(true);
+ } else if (callbacks[i] instanceof RealmCallback) {
+ RealmCallback rcb = (RealmCallback)callbacks[i];
+ rcb.setText(realm != null ?
+ realm : rcb.getDefaultText());
+ } else if (callbacks[i] instanceof RealmChoiceCallback) {
+ RealmChoiceCallback rcb =
+ (RealmChoiceCallback)callbacks[i];
+ if (realm == null)
+ rcb.setSelectedIndex(rcb.getDefaultChoice());
+ else {
+ // need to find specified realm in list
+ String[] choices = rcb.getChoices();
+ for (int k = 0; k < choices.length; k++) {
+ if (choices[k].equals(realm)) {
+ rcb.setSelectedIndex(k);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ SaslServer ss;
+ try {
+ ss = Sasl.createSaslServer(mech, "imap", "localhost", null, cbh);
+ } catch (SaslException sex) {
+ LOGGER.log(Level.FINE, "Failed to create SASL server", sex);
+ no("Failed to create SASL server");
+ return;
+ }
+ if (ss == null) {
+ LOGGER.fine("No SASL support");
+ no("No SASL support");
+ return;
+ }
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.fine("SASL server " + ss.getMechanismName());
+
+ byte[] response = new byte[0];
+ while (!ss.isComplete()) {
+ try {
+ byte[] chal = ss.evaluateResponse(response);
+ if (ss.isComplete()) {
+ break;
+ } else {
+ // send challenge
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.fine("SASL challenge: " +
+ ASCIIUtility.toString(chal, 0, chal.length));
+ byte[] ba = BASE64EncoderStream.encode(chal);
+ if (ba.length > 0)
+ cont(ASCIIUtility.toString(ba, 0, ba.length));
+ else
+ cont();
+ // read response
+ String resp = readLine();
+ response = resp.getBytes();
+ response = BASE64DecoderStream.decode(response);
+ }
+ } catch (SaslException ex) {
+ no(ex.toString());
+ break;
+ }
+ }
+
+ if (ss.isComplete() /*&& status == SUCCESS*/) {
+ String qop = (String)ss.getNegotiatedProperty(Sasl.QOP);
+ if (qop != null && (qop.equalsIgnoreCase("auth-int") ||
+ qop.equalsIgnoreCase("auth-conf"))) {
+ // XXX - NOT SUPPORTED!!!
+ LOGGER.fine(
+ "SASL Mechanism requires integrity or confidentiality");
+ no("SASL Mechanism requires integrity or confidentiality");
+ return;
+ }
+ }
+
+ ok("[CAPABILITY " + capabilities + "]");
+ }
+}

diff -r 68e2f6dc5679 -r 609223192896 mail/src/test/java/com/sun/mail/imap/IMAPSaslLoginTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPSaslLoginTest.java Fri Mar 01 15:35:03 2013 -0800
@@ -0,0 +1,101 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2009-2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.mail.imap;
+
+import java.io.*;
+import java.util.Properties;
+
+import javax.mail.Session;
+import javax.mail.Store;
+import javax.mail.MessagingException;
+
+import org.junit.Test;
+import static org.junit.Assert.fail;
+
+/**
+ * Test login using a SASL mechanism.
+ */
+public final class IMAPSaslLoginTest {
+
+ /**
+ * Test that login using a SASL mechanism works.
+ */
+ @Test
+ public void testSaslLogin() {
+ IMAPServer server = null;
+ try {
+ IMAPHandler handler = new IMAPSaslHandler();
+ server = new IMAPServer(handler, 26422);
+ server.start();
+ Thread.sleep(1000);
+
+ Properties properties = new Properties();
+ properties.setProperty("mail.imap.host", "localhost");
+ properties.setProperty("mail.imap.port", "26422");
+ properties.setProperty("mail.imap.sasl.enable", "true");
+ properties.setProperty("mail.imap.sasl.mechanisms", "DIGEST-MD5");
+ Session session = Session.getInstance(properties);
+ //session.setDebug(true);
+
+ Store store = session.getStore("imap");
+ try {
+ store.connect("test", "test");
+ // success!
+ } catch (MessagingException mex) {
+ fail("login failed");
+ } catch (Exception ex) {
+ System.out.println(ex);
+ //ex.printStackTrace();
+ fail(ex.toString());
+ } finally {
+ store.close();
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } finally {
+ if (server != null) {
+ server.quit();
+ }
+ }
+ }
+}

diff -r 68e2f6dc5679 -r 609223192896 mail/src/test/java/com/sun/mail/smtp/SMTPHandler.java
--- a/mail/src/test/java/com/sun/mail/smtp/SMTPHandler.java Tue Feb 26 13:29:55 2013 -0800
+++ b/mail/src/test/java/com/sun/mail/smtp/SMTPHandler.java Fri Mar 01 15:35:03 2013 -0800
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 2009-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -61,7 +61,7 @@
 public class SMTPHandler implements Runnable, Cloneable {
 
     /** Logger for this class. */
- private static final Logger LOGGER =
+ protected static final Logger LOGGER =
         Logger.getLogger(SMTPHandler.class.getName());
 
     /** Client socket. */
@@ -184,13 +184,23 @@
         } else if (commandName.equals("QUIT")) {
             quit();
         } else if (commandName.equals("AUTH")) {
- auth();
+ auth(currentLine);
         } else {
             LOGGER.log(Level.SEVERE, "ERROR command unknown: {0}", commandName);
             println("-ERR unknown command");
         }
     }
 
+ protected String readLine() throws IOException {
+ currentLine = reader.readLine();
+
+ if (currentLine == null) {
+ LOGGER.severe("Current line is null!");
+ exit();
+ }
+ return currentLine;
+ }
+
     /**
      * HELO command.
      *
@@ -284,7 +294,7 @@
      * @throws IOException
      * unable to read/write to socket
      */
- public void auth() throws IOException {
+ public void auth(String line) throws IOException {
         println("235 Authorized");
     }
 

diff -r 68e2f6dc5679 -r 609223192896 mail/src/test/java/com/sun/mail/smtp/SMTPSaslHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/src/test/java/com/sun/mail/smtp/SMTPSaslHandler.java Fri Mar 01 15:35:03 2013 -0800
@@ -0,0 +1,195 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2009-2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.mail.smtp;
+
+import java.io.IOException;
+import java.util.StringTokenizer;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+import javax.security.sasl.*;
+import javax.security.auth.callback.*;
+
+import com.sun.mail.util.BASE64EncoderStream;
+import com.sun.mail.util.BASE64DecoderStream;
+import com.sun.mail.util.ASCIIUtility;
+
+/**
+ * Handle connection with SASL authentication.
+ *
+ * @author Bill Shannon
+ */
+public class SMTPSaslHandler extends SMTPHandler {
+
+ /**
+ * EHLO command.
+ *
+ * @throws IOException
+ * unable to read/write to socket
+ */
+ public void ehlo() throws IOException {
+ println("250-hello");
+ println("250 AUTH DIGEST-MD5");
+ }
+
+ /**
+ * AUTH command.
+ *
+ * @throws IOException
+ * unable to read/write to socket
+ */
+ public void auth(String line) throws IOException {
+ StringTokenizer ct = new StringTokenizer(line, " ");
+ String commandName = ct.nextToken().toUpperCase();
+ String mech = ct.nextToken().toUpperCase();
+ String ir = "";
+ if (ct.hasMoreTokens())
+ ir = ct.nextToken();
+
+ final String u = "test";
+ final String p = "test";
+ final String realm = "test";
+
+ CallbackHandler cbh = new CallbackHandler() {
+ public void handle(Callback[] callbacks) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.fine("SASL callback length: " + callbacks.length);
+ for (int i = 0; i < callbacks.length; i++) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.fine("SASL callback " + i + ": " + callbacks[i]);
+ if (callbacks[i] instanceof NameCallback) {
+ NameCallback ncb = (NameCallback)callbacks[i];
+ ncb.setName(u);
+ } else if (callbacks[i] instanceof PasswordCallback) {
+ PasswordCallback pcb = (PasswordCallback)callbacks[i];
+ pcb.setPassword(p.toCharArray());
+ } else if (callbacks[i] instanceof AuthorizeCallback) {
+ AuthorizeCallback ac = (AuthorizeCallback)callbacks[i];
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.fine("SASL authorize: " +
+ "authn: " + ac.getAuthenticationID() + ", " +
+ "authz: " + ac.getAuthorizationID() + ", " +
+ "authorized: " + ac.getAuthorizedID());
+ ac.setAuthorized(true);
+ } else if (callbacks[i] instanceof RealmCallback) {
+ RealmCallback rcb = (RealmCallback)callbacks[i];
+ rcb.setText(realm != null ?
+ realm : rcb.getDefaultText());
+ } else if (callbacks[i] instanceof RealmChoiceCallback) {
+ RealmChoiceCallback rcb =
+ (RealmChoiceCallback)callbacks[i];
+ if (realm == null)
+ rcb.setSelectedIndex(rcb.getDefaultChoice());
+ else {
+ // need to find specified realm in list
+ String[] choices = rcb.getChoices();
+ for (int k = 0; k < choices.length; k++) {
+ if (choices[k].equals(realm)) {
+ rcb.setSelectedIndex(k);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ SaslServer ss;
+ try {
+ ss = Sasl.createSaslServer(mech, "smtp", "localhost", null, cbh);
+ } catch (SaslException sex) {
+ LOGGER.log(Level.FINE, "Failed to create SASL server", sex);
+ println("501 Failed to create SASL server");
+ return;
+ }
+ if (ss == null) {
+ LOGGER.fine("No SASL support");
+ println("501 No SASL support");
+ return;
+ }
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.fine("SASL server " + ss.getMechanismName());
+
+ byte[] response = ir.getBytes();
+ while (!ss.isComplete()) {
+ try {
+ byte[] chal = ss.evaluateResponse(response);
+ if (ss.isComplete()) {
+ break;
+ } else {
+ // send challenge
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.fine("SASL challenge: " +
+ ASCIIUtility.toString(chal, 0, chal.length));
+ byte[] ba = BASE64EncoderStream.encode(chal);
+ if (ba.length > 0)
+ println("334 " +
+ ASCIIUtility.toString(ba, 0, ba.length));
+ else
+ println("334");
+ // read response
+ String resp = readLine();
+ response = resp.getBytes();
+ response = BASE64DecoderStream.decode(response);
+ }
+ } catch (SaslException ex) {
+ println("501 " + ex.toString());
+ break;
+ }
+ }
+
+ if (ss.isComplete() /*&& status == SUCCESS*/) {
+ String qop = (String)ss.getNegotiatedProperty(Sasl.QOP);
+ if (qop != null && (qop.equalsIgnoreCase("auth-int") ||
+ qop.equalsIgnoreCase("auth-conf"))) {
+ // XXX - NOT SUPPORTED!!!
+ LOGGER.fine(
+ "SASL Mechanism requires integrity or confidentiality");
+ println("501 " +
+ "SASL Mechanism requires integrity or confidentiality");
+ return;
+ }
+ }
+
+ println("235 Authenticated");
+ }
+}

diff -r 68e2f6dc5679 -r 609223192896 mail/src/test/java/com/sun/mail/smtp/SMTPSaslLoginTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/src/test/java/com/sun/mail/smtp/SMTPSaslLoginTest.java Fri Mar 01 15:35:03 2013 -0800
@@ -0,0 +1,95 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2009-2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.mail.smtp;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.mail.Session;
+import javax.mail.Transport;
+
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Test login using a SASL mechanism.
+ */
+public class SMTPSaslLoginTest {
+
+ @Test
+ public void test() {
+ SMTPServer server = null;
+ try {
+ server = new SMTPServer(new SMTPSaslHandler(), 26423);
+ server.start();
+ Thread.sleep(1000);
+
+ Properties properties = new Properties();
+ properties.setProperty("mail.smtp.host", "localhost");
+ properties.setProperty("mail.smtp.port", "26423");
+ properties.setProperty("mail.smtp.sasl.enable", "true");
+ properties.setProperty("mail.smtp.sasl.mechanisms", "DIGEST-MD5");
+ properties.setProperty("mail.smtp.auth.digest-md5.disable", "true");
+ Session session = Session.getInstance(properties);
+ //session.setDebug(true);
+
+ Transport t = session.getTransport("smtp");
+ try {
+ t.connect("test", "test");
+ // success!
+ } catch (Exception ex) {
+ // expect an exception when connect times out
+ fail(ex.toString());
+ } finally {
+ t.close();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } finally {
+ if (server != null) {
+ server.quit();
+ server.interrupt();
+ }
+ }
+ }
+}


diff -r 609223192896 -r 31e024e4f40d client/pom.xml
--- a/client/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/client/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 609223192896 -r 31e024e4f40d demo/pom.xml
--- a/demo/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/demo/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 609223192896 -r 31e024e4f40d doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Fri Mar 01 15:35:03 2013 -0800
+++ b/doc/release/CHANGES.txt Fri Mar 01 15:46:38 2013 -0800
@@ -14,9 +14,9 @@
         https://kenai.com/bugzilla/
 
 
- CHANGES IN THE 1.5 RELEASE
- --------------------------
-The following bugs have been fixed in the 1.5 release.
+ CHANGES IN THE 1.5.0 RELEASE
+ ----------------------------
+The following bugs have been fixed in the 1.5.0 release.
 
 K 5682 add FetchProfile.Item.SIZE
 K 5683 fix protected fields in final classes in javax.mail.search

diff -r 609223192896 -r 31e024e4f40d dsn/pom.xml
--- a/dsn/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/dsn/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 609223192896 -r 31e024e4f40d gimap/pom.xml
--- a/gimap/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/gimap/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 609223192896 -r 31e024e4f40d imap/pom.xml
--- a/imap/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/imap/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>parent-distrib</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
         <relativePath>../parent-distrib/pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

diff -r 609223192896 -r 31e024e4f40d javadoc/pom.xml
--- a/javadoc/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/javadoc/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,13 +48,13 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>
     <artifactId>javadoc</artifactId>
     <packaging>pom</packaging>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     <name>JavaMail API javadocs</name>
     <description>${project.name}</description>
 

diff -r 609223192896 -r 31e024e4f40d logging/pom.xml
--- a/logging/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/logging/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 609223192896 -r 31e024e4f40d mail/pom.xml
--- a/mail/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/mail/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 609223192896 -r 31e024e4f40d mailapi/pom.xml
--- a/mailapi/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/mailapi/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -56,7 +56,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 609223192896 -r 31e024e4f40d mailapijar/pom.xml
--- a/mailapijar/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/mailapijar/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -55,7 +55,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>javax.mail</groupId>

diff -r 609223192896 -r 31e024e4f40d mbox/dist/pom.xml
--- a/mbox/dist/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/mbox/dist/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
         <relativePath>../../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

diff -r 609223192896 -r 31e024e4f40d mbox/native/pom.xml
--- a/mbox/native/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/mbox/native/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
         <relativePath>../../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

diff -r 609223192896 -r 31e024e4f40d mbox/pom.xml
--- a/mbox/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/mbox/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 609223192896 -r 31e024e4f40d oldmail/pom.xml
--- a/oldmail/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/oldmail/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -53,7 +53,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>javax.mail</groupId>

diff -r 609223192896 -r 31e024e4f40d outlook/pom.xml
--- a/outlook/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/outlook/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 609223192896 -r 31e024e4f40d parent-distrib/pom.xml
--- a/parent-distrib/pom.xml Fri Mar 01 15:35:03 2013 -0800
+++ b/parent-distrib/pom.xml Fri Mar 01 15:46:38 2013 -0800
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5-SNAPSHOT</version>
+ <version>1.5.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</mode
[truncated due to length]