Author: sebb Date: Fri Mar 24 16:19:38 2017 New Revision: 1788497 URL: http://svn.apache.org/viewvc?rev=1788497&view=rev Log: NET-633 Add XOAUTH2 to IMAP and SMTP\nThis fixes #2
Modified: commons/proper/net/trunk/src/changes/changes.xml commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java Modified: commons/proper/net/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1788497&r1=1788496&r2=1788497&view=diff ============================================================================== --- commons/proper/net/trunk/src/changes/changes.xml [utf-8] (original) +++ commons/proper/net/trunk/src/changes/changes.xml [utf-8] Fri Mar 24 16:19:38 2017 @@ -71,6 +71,9 @@ This is mainly a bug-fix release. See fu However it is not source compatible with releases before 3.4, as some methods were added to the interface NtpV3Packet in 3.4 "> + <action issue="NET-633" type="update" dev="sebb" due-to="n0rm1e"> + Add XOAUTH2 to IMAP and SMTP + </action> <action issue="NET-632" type="update" dev="sebb" due-to="prakapenka"> FTPHTTPClient - support for encoding other than UTF-8 </action> Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java?rev=1788497&r1=1788496&r2=1788497&view=diff ============================================================================== --- commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java (original) +++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java Fri Mar 24 16:19:38 2017 @@ -204,6 +204,7 @@ public class AuthenticatingIMAPClient ex return result == IMAPReply.OK; } case XOAUTH: + case XOAUTH2: { int result = sendData(username); if (result == IMAPReply.OK) @@ -248,7 +249,9 @@ public class AuthenticatingIMAPClient ex /** The unstandarised Microsoft LOGIN method, which sends the password unencrypted (insecure). */ LOGIN("LOGIN"), /** XOAUTH */ - XOAUTH("XOAUTH"); + XOAUTH("XOAUTH"), + /** XOAUTH 2 */ + XOAUTH2("XOAUTH2"); private final String authName; Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java?rev=1788497&r1=1788496&r2=1788497&view=diff ============================================================================== --- commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java (original) +++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java Fri Mar 24 16:19:38 2017 @@ -190,10 +190,10 @@ public class AuthenticatingSMTPClient ex * * @param method the method to use, one of the {@link AuthenticatingSMTPClient.AUTH_METHOD} enum values * @param username the user name. - * If the method is XOAUTH, then this is used as the plain text oauth protocol parameter string + * If the method is XOAUTH/XOAUTH2, then this is used as the plain text oauth protocol parameter string * which is Base64-encoded for transmission. * @param password the password for the username. - * Ignored for XOAUTH. + * Ignored for XOAUTH/XOAUTH2. * * @return True if successfully completed, false if not. * @throws SMTPConnectionClosedException @@ -257,7 +257,7 @@ public class AuthenticatingSMTPClient ex return SMTPReply.isPositiveCompletion(sendCommand( Base64.encodeBase64StringUnChunked(password.getBytes(getCharset())))); } - else if (method.equals(AUTH_METHOD.XOAUTH)) + else if (method.equals(AUTH_METHOD.XOAUTH) || method.equals(AUTH_METHOD.XOAUTH2)) { return SMTPReply.isPositiveIntermediate(sendCommand( Base64.encodeBase64StringUnChunked(username.getBytes(getCharset())) @@ -299,7 +299,9 @@ public class AuthenticatingSMTPClient ex /** The unstandarised Microsoft LOGIN method, which sends the password unencrypted (insecure). */ LOGIN, /** XOAuth method which accepts a signed and base64ed OAuth URL. */ - XOAUTH; + XOAUTH, + /** XOAuth 2 method which accepts a signed and base64ed OAuth JSON. */ + XOAUTH2; /** * Gets the name of the given authentication method suitable for the server. @@ -316,6 +318,8 @@ public class AuthenticatingSMTPClient ex return "LOGIN"; } else if (method.equals(AUTH_METHOD.XOAUTH)) { return "XOAUTH"; + } else if (method.equals(AUTH_METHOD.XOAUTH2)) { + return "XOAUTH2"; } else { return null; }