Loading build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.2.0' classpath 'com.android.tools.build:gradle:2.2.2' } } Loading k9mail-library/src/main/java/com/fsck/k9/mail/AuthType.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,13 @@ public enum AuthType { CRAM_MD5, EXTERNAL, /** * XOAUTH2 is an OAuth2.0 protocol designed/used by GMail. * * https://developers.google.com/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism */ XOAUTH2, /* * The following are obsolete authentication settings that were used with * SMTP. They are no longer presented to the user as options, but they may Loading k9mail-library/src/main/java/com/fsck/k9/mail/Authentication.java +10 −0 Original line number Diff line number Diff line package com.fsck.k9.mail; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import com.fsck.k9.mail.filter.Base64; Loading @@ -7,6 +8,7 @@ import com.fsck.k9.mail.filter.Hex; public class Authentication { private static final String US_ASCII = "US-ASCII"; private static final String XOAUTH_FORMAT = "user=%1s\001auth=Bearer %2s\001\001"; /** * Computes the response for CRAM-MD5 authentication mechanism given the user credentials and Loading Loading @@ -82,4 +84,12 @@ public class Authentication { throw new MessagingException("Something went wrong during CRAM-MD5 computation", e); } } public static String computeXoauth(String username, String authToken) throws UnsupportedEncodingException { String formattedAuthenticationString = String.format(XOAUTH_FORMAT, username, authToken); byte[] base64encodedAuthenticationString = Base64.encodeBase64(formattedAuthenticationString.getBytes()); return new String(base64encodedAuthenticationString, US_ASCII); } } k9mail-library/src/main/java/com/fsck/k9/mail/Transport.java +5 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package com.fsck.k9.mail; import android.content.Context; import com.fsck.k9.mail.oauth.OAuth2TokenProvider; import com.fsck.k9.mail.ssl.DefaultTrustedSocketFactory; import com.fsck.k9.mail.store.StoreConfig; import com.fsck.k9.mail.ServerSettings.Type; Loading @@ -19,10 +20,12 @@ public abstract class Transport { // RFC 1047 protected static final int SOCKET_READ_TIMEOUT = 300000; public synchronized static Transport getInstance(Context context, StoreConfig storeConfig) throws MessagingException { public static synchronized Transport getInstance(Context context, StoreConfig storeConfig) throws MessagingException { String uri = storeConfig.getTransportUri(); if (uri.startsWith("smtp")) { return new SmtpTransport(storeConfig, new DefaultTrustedSocketFactory(context)); OAuth2TokenProvider oauth2TokenProvider = null; return new SmtpTransport(storeConfig, new DefaultTrustedSocketFactory(context), oauth2TokenProvider); } else if (uri.startsWith("webdav")) { return new WebDavTransport(storeConfig); } else { Loading k9mail-library/src/main/java/com/fsck/k9/mail/oauth/AuthorizationException.java 0 → 100644 +11 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.oauth; public class AuthorizationException extends Exception { public AuthorizationException(String detailMessage, Throwable throwable) { super(detailMessage, throwable); } public AuthorizationException(String detailMessage) { super(detailMessage); } } Loading
build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.2.0' classpath 'com.android.tools.build:gradle:2.2.2' } } Loading
k9mail-library/src/main/java/com/fsck/k9/mail/AuthType.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,13 @@ public enum AuthType { CRAM_MD5, EXTERNAL, /** * XOAUTH2 is an OAuth2.0 protocol designed/used by GMail. * * https://developers.google.com/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism */ XOAUTH2, /* * The following are obsolete authentication settings that were used with * SMTP. They are no longer presented to the user as options, but they may Loading
k9mail-library/src/main/java/com/fsck/k9/mail/Authentication.java +10 −0 Original line number Diff line number Diff line package com.fsck.k9.mail; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import com.fsck.k9.mail.filter.Base64; Loading @@ -7,6 +8,7 @@ import com.fsck.k9.mail.filter.Hex; public class Authentication { private static final String US_ASCII = "US-ASCII"; private static final String XOAUTH_FORMAT = "user=%1s\001auth=Bearer %2s\001\001"; /** * Computes the response for CRAM-MD5 authentication mechanism given the user credentials and Loading Loading @@ -82,4 +84,12 @@ public class Authentication { throw new MessagingException("Something went wrong during CRAM-MD5 computation", e); } } public static String computeXoauth(String username, String authToken) throws UnsupportedEncodingException { String formattedAuthenticationString = String.format(XOAUTH_FORMAT, username, authToken); byte[] base64encodedAuthenticationString = Base64.encodeBase64(formattedAuthenticationString.getBytes()); return new String(base64encodedAuthenticationString, US_ASCII); } }
k9mail-library/src/main/java/com/fsck/k9/mail/Transport.java +5 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package com.fsck.k9.mail; import android.content.Context; import com.fsck.k9.mail.oauth.OAuth2TokenProvider; import com.fsck.k9.mail.ssl.DefaultTrustedSocketFactory; import com.fsck.k9.mail.store.StoreConfig; import com.fsck.k9.mail.ServerSettings.Type; Loading @@ -19,10 +20,12 @@ public abstract class Transport { // RFC 1047 protected static final int SOCKET_READ_TIMEOUT = 300000; public synchronized static Transport getInstance(Context context, StoreConfig storeConfig) throws MessagingException { public static synchronized Transport getInstance(Context context, StoreConfig storeConfig) throws MessagingException { String uri = storeConfig.getTransportUri(); if (uri.startsWith("smtp")) { return new SmtpTransport(storeConfig, new DefaultTrustedSocketFactory(context)); OAuth2TokenProvider oauth2TokenProvider = null; return new SmtpTransport(storeConfig, new DefaultTrustedSocketFactory(context), oauth2TokenProvider); } else if (uri.startsWith("webdav")) { return new WebDavTransport(storeConfig); } else { Loading
k9mail-library/src/main/java/com/fsck/k9/mail/oauth/AuthorizationException.java 0 → 100644 +11 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.oauth; public class AuthorizationException extends Exception { public AuthorizationException(String detailMessage, Throwable throwable) { super(detailMessage, throwable); } public AuthorizationException(String detailMessage) { super(detailMessage); } }