diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml
index 2759c3c97..d6c88a688 100644
--- a/res/values-ca/strings.xml
+++ b/res/values-ca/strings.xml
@@ -389,10 +389,6 @@ Si us plau, envia\'ns els errors, contribueix a millorar-lo a
Possible forms:
*- * imap://auth:user:password@server:port CONNECTION_SECURITY_NONE - * imap+tls://auth:user:password@server:port CONNECTION_SECURITY_TLS_OPTIONAL - * imap+tls+://auth:user:password@server:port CONNECTION_SECURITY_TLS_REQUIRED - * imap+ssl+://auth:user:password@server:port CONNECTION_SECURITY_SSL_REQUIRED - * imap+ssl://auth:user:password@server:port CONNECTION_SECURITY_SSL_OPTIONAL + * imap://auth:user:password@server:port ConnectionSecurity.NONE + * imap+tls+://auth:user:password@server:port ConnectionSecurity.STARTTLS_REQUIRED + * imap+ssl+://auth:user:password@server:port ConnectionSecurity.SSL_TLS_REQUIRED **/ public static ImapStoreSettings decodeUri(String uri) { @@ -171,21 +169,27 @@ public class ImapStore extends Store { } String scheme = imapUri.getScheme(); + /* + * Currently available schemes are: + * imap + * imap+tls+ + * imap+ssl+ + * + * The following are obsolete schemes that may be found in pre-existing + * settings from earlier versions or that may be found when imported. We + * continue to recognize them and re-map them appropriately: + * imap+tls + * imap+ssl + */ if (scheme.equals("imap")) { connectionSecurity = ConnectionSecurity.NONE; port = 143; - } else if (scheme.equals("imap+tls")) { - connectionSecurity = ConnectionSecurity.STARTTLS_OPTIONAL; - port = 143; - } else if (scheme.equals("imap+tls+")) { + } else if (scheme.startsWith("imap+tls")) { connectionSecurity = ConnectionSecurity.STARTTLS_REQUIRED; port = 143; - } else if (scheme.equals("imap+ssl+")) { + } else if (scheme.startsWith("imap+ssl")) { connectionSecurity = ConnectionSecurity.SSL_TLS_REQUIRED; port = 993; - } else if (scheme.equals("imap+ssl")) { - connectionSecurity = ConnectionSecurity.SSL_TLS_OPTIONAL; - port = 993; } else { throw new IllegalArgumentException("Unsupported protocol (" + scheme + ")"); } @@ -267,15 +271,9 @@ public class ImapStore extends Store { String scheme; switch (server.connectionSecurity) { - case SSL_TLS_OPTIONAL: - scheme = "imap+ssl"; - break; case SSL_TLS_REQUIRED: scheme = "imap+ssl+"; break; - case STARTTLS_OPTIONAL: - scheme = "imap+tls"; - break; case STARTTLS_REQUIRED: scheme = "imap+tls+"; break; @@ -2420,15 +2418,13 @@ public class ImapStore extends Store { SocketAddress socketAddress = new InetSocketAddress(addresses[i], mSettings.getPort()); - if (connectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED || - connectionSecurity == ConnectionSecurity.SSL_TLS_OPTIONAL) { + if (connectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) { SSLContext sslContext = SSLContext.getInstance("TLS"); - boolean secure = connectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED; sslContext .init(null, new TrustManager[] { TrustManagerFactory.get( mSettings.getHost(), - mSettings.getPort(), secure) }, + mSettings.getPort(), true) }, new SecureRandom()); mSocket = TrustedSocketFactory.createSocket(sslContext); } else { @@ -2473,19 +2469,17 @@ public class ImapStore extends Store { } } - if (mSettings.getConnectionSecurity() == ConnectionSecurity.STARTTLS_OPTIONAL - || mSettings.getConnectionSecurity() == ConnectionSecurity.STARTTLS_REQUIRED) { + if (mSettings.getConnectionSecurity() == ConnectionSecurity.STARTTLS_REQUIRED) { if (hasCapability("STARTTLS")) { // STARTTLS executeSimpleCommand("STARTTLS"); SSLContext sslContext = SSLContext.getInstance("TLS"); - boolean secure = mSettings.getConnectionSecurity() == ConnectionSecurity.STARTTLS_REQUIRED; sslContext.init(null, new TrustManager[] { TrustManagerFactory.get( mSettings.getHost(), - mSettings.getPort(), secure) }, + mSettings.getPort(), true) }, new SecureRandom()); mSocket = TrustedSocketFactory.createSocket(sslContext, mSocket, mSettings.getHost(), mSettings.getPort(), true); @@ -2502,7 +2496,7 @@ public class ImapStore extends Store { if (responses.size() != 2) { throw new MessagingException("Invalid CAPABILITY response received"); } - } else if (mSettings.getConnectionSecurity() == ConnectionSecurity.STARTTLS_REQUIRED) { + } else { throw new MessagingException("TLS not supported but required"); } } diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index 8acc7e079..e59cbb4ed 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -62,11 +62,9 @@ public class Pop3Store extends Store { * *
Possible forms:
*- * pop3://user:password@server:port CONNECTION_SECURITY_NONE - * pop3+tls://user:password@server:port CONNECTION_SECURITY_TLS_OPTIONAL - * pop3+tls+://user:password@server:port CONNECTION_SECURITY_TLS_REQUIRED - * pop3+ssl+://user:password@server:port CONNECTION_SECURITY_SSL_REQUIRED - * pop3+ssl://user:password@server:port CONNECTION_SECURITY_SSL_OPTIONAL + * pop3://user:password@server:port ConnectionSecurity.NONE + * pop3+tls+://user:password@server:port ConnectionSecurity.STARTTLS_REQUIRED + * pop3+ssl+://user:password@server:port ConnectionSecurity.SSL_TLS_REQUIRED **/ public static ServerSettings decodeUri(String uri) { @@ -84,21 +82,27 @@ public class Pop3Store extends Store { } String scheme = pop3Uri.getScheme(); + /* + * Currently available schemes are: + * pop3 + * pop3+tls+ + * pop3+ssl+ + * + * The following are obsolete schemes that may be found in pre-existing + * settings from earlier versions or that may be found when imported. We + * continue to recognize them and re-map them appropriately: + * pop3+tls + * pop3+ssl + */ if (scheme.equals("pop3")) { connectionSecurity = ConnectionSecurity.NONE; port = 110; - } else if (scheme.equals("pop3+tls")) { - connectionSecurity = ConnectionSecurity.STARTTLS_OPTIONAL; - port = 110; - } else if (scheme.equals("pop3+tls+")) { + } else if (scheme.startsWith("pop3+tls")) { connectionSecurity = ConnectionSecurity.STARTTLS_REQUIRED; port = 110; - } else if (scheme.equals("pop3+ssl+")) { + } else if (scheme.startsWith("pop3+ssl")) { connectionSecurity = ConnectionSecurity.SSL_TLS_REQUIRED; port = 995; - } else if (scheme.equals("pop3+ssl")) { - connectionSecurity = ConnectionSecurity.SSL_TLS_OPTIONAL; - port = 995; } else { throw new IllegalArgumentException("Unsupported protocol (" + scheme + ")"); } @@ -161,15 +165,9 @@ public class Pop3Store extends Store { String scheme; switch (server.connectionSecurity) { - case SSL_TLS_OPTIONAL: - scheme = "pop3+ssl"; - break; case SSL_TLS_REQUIRED: scheme = "pop3+ssl+"; break; - case STARTTLS_OPTIONAL: - scheme = "pop3+tls"; - break; case STARTTLS_REQUIRED: scheme = "pop3+tls+"; break; @@ -299,13 +297,11 @@ public class Pop3Store extends Store { try { SocketAddress socketAddress = new InetSocketAddress(mHost, mPort); - if (mConnectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED || - mConnectionSecurity == ConnectionSecurity.SSL_TLS_OPTIONAL) { + if (mConnectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) { SSLContext sslContext = SSLContext.getInstance("TLS"); - final boolean secure = mConnectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED; sslContext.init(null, new TrustManager[] { TrustManagerFactory.get(mHost, - mPort, secure) }, new SecureRandom()); + mPort, true) }, new SecureRandom()); mSocket = TrustedSocketFactory.createSocket(sslContext); } else { mSocket = new Socket(); @@ -323,17 +319,15 @@ public class Pop3Store extends Store { String serverGreeting = executeSimpleCommand(null); mCapabilities = getCapabilities(); - if (mConnectionSecurity == ConnectionSecurity.STARTTLS_OPTIONAL - || mConnectionSecurity == ConnectionSecurity.STARTTLS_REQUIRED) { + if (mConnectionSecurity == ConnectionSecurity.STARTTLS_REQUIRED) { if (mCapabilities.stls) { executeSimpleCommand(STLS_COMMAND); SSLContext sslContext = SSLContext.getInstance("TLS"); - boolean secure = mConnectionSecurity == ConnectionSecurity.STARTTLS_REQUIRED; sslContext.init(null, new TrustManager[] { TrustManagerFactory.get( - mHost, mPort, secure) }, + mHost, mPort, true) }, new SecureRandom()); mSocket = TrustedSocketFactory.createSocket(sslContext, mSocket, mHost, mPort, true); @@ -344,7 +338,7 @@ public class Pop3Store extends Store { throw new MessagingException("Unable to connect socket"); } mCapabilities = getCapabilities(); - } else if (mConnectionSecurity == ConnectionSecurity.STARTTLS_REQUIRED) { + } else { throw new MessagingException("TLS not supported but required"); } } diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java index b0af15ef2..2e11e6c8f 100644 --- a/src/com/fsck/k9/mail/store/WebDavStore.java +++ b/src/com/fsck/k9/mail/store/WebDavStore.java @@ -82,11 +82,9 @@ public class WebDavStore extends Store { * *
Possible forms:
*- * webdav://user:password@server:port CONNECTION_SECURITY_NONE - * webdav+tls://user:password@server:port CONNECTION_SECURITY_TLS_OPTIONAL - * webdav+tls+://user:password@server:port CONNECTION_SECURITY_TLS_REQUIRED - * webdav+ssl+://user:password@server:port CONNECTION_SECURITY_SSL_REQUIRED - * webdav+ssl://user:password@server:port CONNECTION_SECURITY_SSL_OPTIONAL + * webdav://user:password@server:port ConnectionSecurity.NONE + * webdav+tls+://user:password@server:port ConnectionSecurity.STARTTLS_REQUIRED + * webdav+ssl+://user:password@server:port ConnectionSecurity.SSL_TLS_REQUIRED **/ public static WebDavStoreSettings decodeUri(String uri) { @@ -109,15 +107,23 @@ public class WebDavStore extends Store { } String scheme = webDavUri.getScheme(); + /* + * Currently available schemes are: + * webdav + * webdav+tls+ + * webdav+ssl+ + * + * The following are obsolete schemes that may be found in pre-existing + * settings from earlier versions or that may be found when imported. We + * continue to recognize them and re-map them appropriately: + * webdav+tls + * webdav+ssl + */ if (scheme.equals("webdav")) { connectionSecurity = ConnectionSecurity.NONE; - } else if (scheme.equals("webdav+ssl")) { - connectionSecurity = ConnectionSecurity.SSL_TLS_OPTIONAL; - } else if (scheme.equals("webdav+ssl+")) { + } else if (scheme.startsWith("webdav+ssl")) { connectionSecurity = ConnectionSecurity.SSL_TLS_REQUIRED; - } else if (scheme.equals("webdav+tls")) { - connectionSecurity = ConnectionSecurity.STARTTLS_OPTIONAL; - } else if (scheme.equals("webdav+tls+")) { + } else if (scheme.startsWith("webdav+tls")) { connectionSecurity = ConnectionSecurity.STARTTLS_REQUIRED; } else { throw new IllegalArgumentException("Unsupported protocol (" + scheme + ")"); @@ -203,15 +209,9 @@ public class WebDavStore extends Store { String scheme; switch (server.connectionSecurity) { - case SSL_TLS_OPTIONAL: - scheme = "webdav+ssl"; - break; case SSL_TLS_REQUIRED: scheme = "webdav+ssl+"; break; - case STARTTLS_OPTIONAL: - scheme = "webdav+tls"; - break; case STARTTLS_REQUIRED: scheme = "webdav+tls+"; break; @@ -367,9 +367,7 @@ public class WebDavStore extends Store { private String getRoot() { String root; if (mConnectionSecurity == ConnectionSecurity.STARTTLS_REQUIRED || - mConnectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED || - mConnectionSecurity == ConnectionSecurity.STARTTLS_OPTIONAL || - mConnectionSecurity == ConnectionSecurity.SSL_TLS_OPTIONAL) { + mConnectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) { root = "https"; } else { root = "http"; diff --git a/src/com/fsck/k9/mail/transport/SmtpTransport.java b/src/com/fsck/k9/mail/transport/SmtpTransport.java index 9c8142b4c..6f96fe430 100644 --- a/src/com/fsck/k9/mail/transport/SmtpTransport.java +++ b/src/com/fsck/k9/mail/transport/SmtpTransport.java @@ -38,11 +38,9 @@ public class SmtpTransport extends Transport { * *
Possible forms:
*- * smtp://user:password@server:port CONNECTION_SECURITY_NONE - * smtp+tls://user:password@server:port CONNECTION_SECURITY_TLS_OPTIONAL - * smtp+tls+://user:password@server:port CONNECTION_SECURITY_TLS_REQUIRED - * smtp+ssl+://user:password@server:port CONNECTION_SECURITY_SSL_REQUIRED - * smtp+ssl://user:password@server:port CONNECTION_SECURITY_SSL_OPTIONAL + * smtp://user:password@server:port ConnectionSecurity.NONE + * smtp+tls+://user:password@server:port ConnectionSecurity.STARTTLS_REQUIRED + * smtp+ssl+://user:password@server:port ConnectionSecurity.SSL_TLS_REQUIRED **/ public static ServerSettings decodeUri(String uri) { @@ -61,21 +59,27 @@ public class SmtpTransport extends Transport { } String scheme = smtpUri.getScheme(); + /* + * Currently available schemes are: + * smtp + * smtp+tls+ + * smtp+ssl+ + * + * The following are obsolete schemes that may be found in pre-existing + * settings from earlier versions or that may be found when imported. We + * continue to recognize them and re-map them appropriately: + * smtp+tls + * smtp+ssl + */ if (scheme.equals("smtp")) { connectionSecurity = ConnectionSecurity.NONE; port = 587; - } else if (scheme.equals("smtp+tls")) { - connectionSecurity = ConnectionSecurity.STARTTLS_OPTIONAL; - port = 587; - } else if (scheme.equals("smtp+tls+")) { + } else if (scheme.startsWith("smtp+tls")) { connectionSecurity = ConnectionSecurity.STARTTLS_REQUIRED; port = 587; - } else if (scheme.equals("smtp+ssl+")) { + } else if (scheme.startsWith("smtp+ssl")) { connectionSecurity = ConnectionSecurity.SSL_TLS_REQUIRED; port = 465; - } else if (scheme.equals("smtp+ssl")) { - connectionSecurity = ConnectionSecurity.SSL_TLS_OPTIONAL; - port = 465; } else { throw new IllegalArgumentException("Unsupported protocol (" + scheme + ")"); } @@ -132,15 +136,9 @@ public class SmtpTransport extends Transport { String scheme; switch (server.connectionSecurity) { - case SSL_TLS_OPTIONAL: - scheme = "smtp+ssl"; - break; case SSL_TLS_REQUIRED: scheme = "smtp+ssl+"; break; - case STARTTLS_OPTIONAL: - scheme = "smtp+tls"; - break; case STARTTLS_REQUIRED: scheme = "smtp+tls+"; break; @@ -202,13 +200,11 @@ public class SmtpTransport extends Transport { for (int i = 0; i < addresses.length; i++) { try { SocketAddress socketAddress = new InetSocketAddress(addresses[i], mPort); - if (mConnectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED || - mConnectionSecurity == ConnectionSecurity.SSL_TLS_OPTIONAL) { + if (mConnectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) { SSLContext sslContext = SSLContext.getInstance("TLS"); - boolean secure = mConnectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED; sslContext.init(null, new TrustManager[] { TrustManagerFactory.get( - mHost, mPort, secure) }, + mHost, mPort, true) }, new SecureRandom()); mSocket = TrustedSocketFactory.createSocket(sslContext); mSocket.connect(socketAddress, SOCKET_CONNECT_TIMEOUT); @@ -260,16 +256,14 @@ public class SmtpTransport extends Transport { m8bitEncodingAllowed = extensions.containsKey("8BITMIME"); - if (mConnectionSecurity == ConnectionSecurity.STARTTLS_OPTIONAL - || mConnectionSecurity == ConnectionSecurity.STARTTLS_REQUIRED) { + if (mConnectionSecurity == ConnectionSecurity.STARTTLS_REQUIRED) { if (extensions.containsKey("STARTTLS")) { executeSimpleCommand("STARTTLS"); SSLContext sslContext = SSLContext.getInstance("TLS"); - boolean secure = mConnectionSecurity == ConnectionSecurity.STARTTLS_REQUIRED; sslContext.init(null, new TrustManager[] { TrustManagerFactory.get(mHost, - mPort, secure) }, new SecureRandom()); + mPort, true) }, new SecureRandom()); mSocket = TrustedSocketFactory.createSocket(sslContext, mSocket, mHost, mPort, true); mIn = new PeekableInputStream(new BufferedInputStream(mSocket.getInputStream(), @@ -281,7 +275,7 @@ public class SmtpTransport extends Transport { */ extensions = sendHello(localHost); secureConnection = true; - } else if (mConnectionSecurity == ConnectionSecurity.STARTTLS_REQUIRED) { + } else { throw new MessagingException("TLS not supported but required"); } }