From 90fedf7125b2d644e57d3e8f6cd22d23fa075220 Mon Sep 17 00:00:00 2001 From: Joe Steele Date: Sat, 22 Feb 2014 18:52:20 -0500 Subject: [PATCH] Eliminate the LOGIN authentication option from SMTP The LOGIN option is no longer offered to users as a choice. This does *not* eliminate the SASL LOGIN authentication mechanism. Any pre-existing LOGIN setting or any imported LOGIN setting will still be recognized. In all cases, a user setting of either "Normal password" or "LOGIN" will result in the SASL PLAIN mechanism being tried first if available, otherwise SASL LOGIN will be tried if available. This mirrors similar behavior that exists for IMAP. --- .../fsck/k9/activity/setup/AccountSetupOutgoing.java | 12 +++++++----- src/com/fsck/k9/mail/transport/SmtpTransport.java | 11 +++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java b/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java index 3b221b45f..b90b1c0ab 100644 --- a/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java +++ b/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java @@ -56,6 +56,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener, private ViewGroup mRequireLoginSettingsView; private Spinner mSecurityTypeView; private Spinner mAuthTypeView; + private ArrayAdapter mAuthTypeAdapter; private Button mNextButton; private Account mAccount; private boolean mMakeDefault; @@ -125,10 +126,11 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener, securityTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSecurityTypeView.setAdapter(securityTypesAdapter); - ArrayAdapter authTypesAdapter = new ArrayAdapter(this, - android.R.layout.simple_spinner_item, AuthType.values()); - authTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - mAuthTypeView.setAdapter(authTypesAdapter); + AuthType[] acceptableAuthTypes = {AuthType.AUTOMATIC, AuthType.PLAIN, AuthType.CRAM_MD5}; + mAuthTypeAdapter = new ArrayAdapter(this, + android.R.layout.simple_spinner_item, acceptableAuthTypes); + mAuthTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mAuthTypeView.setAdapter(mAuthTypeAdapter); /* * Calls validateFields() which enables or disables the Next button @@ -196,7 +198,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener, } if (authType != null) { - int position = AuthType.valueOf(authType).ordinal(); + int position = mAuthTypeAdapter.getPosition(AuthType.valueOf(authType)); mAuthTypeView.setSelection(position, false); } diff --git a/src/com/fsck/k9/mail/transport/SmtpTransport.java b/src/com/fsck/k9/mail/transport/SmtpTransport.java index 3e029d954..e0a48441f 100644 --- a/src/com/fsck/k9/mail/transport/SmtpTransport.java +++ b/src/com/fsck/k9/mail/transport/SmtpTransport.java @@ -305,12 +305,11 @@ public class SmtpTransport extends Transport { } } - boolean useAuthLogin = AuthType.LOGIN.equals(mAuthType); - boolean useAuthPlain = AuthType.PLAIN.equals(mAuthType); + boolean useAuthPlain = AuthType.PLAIN.equals(mAuthType) || AuthType.LOGIN.equals(mAuthType); boolean useAuthCramMD5 = AuthType.CRAM_MD5.equals(mAuthType); // Automatically choose best authentication method if none was explicitly selected - boolean useAutomaticAuth = !(useAuthLogin || useAuthPlain || useAuthCramMD5); + boolean useAutomaticAuth = !(useAuthPlain || useAuthCramMD5); boolean authLoginSupported = false; boolean authPlainSupported = false; @@ -360,11 +359,7 @@ public class SmtpTransport extends Transport { throw ex; } } - } else if (useAuthLogin || (useAutomaticAuth && authLoginSupported)) { - if (!authPlainSupported && K9.DEBUG && K9.DEBUG_PROTOCOL_SMTP) { - Log.d(K9.LOG_TAG, "Using LOGIN as authentication method although the " + - "server didn't advertise support for it in EHLO response."); - } + } else if (useAutomaticAuth && authLoginSupported) { saslAuthLogin(mUsername, mPassword); } else { throw new MessagingException("No valid authentication mechanism found.");