mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
Restored semantics of auth*Supported in SMTP authentication code
Also, display a debug message if a certain authentication method was selected by the user but the server didn't advertise support for it in the EHLO response.
This commit is contained in:
parent
80f60a06ca
commit
e8a1a9a466
@ -229,18 +229,13 @@ public class SmtpTransport extends Transport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
boolean useAuthLogin = AUTH_LOGIN.equals(mAuthType);
|
||||||
* result contains the results of the EHLO in concatenated form
|
boolean useAuthPlain = AUTH_PLAIN.equals(mAuthType);
|
||||||
*/
|
boolean useAuthCramMD5 = AUTH_CRAM_MD5.equals(mAuthType);
|
||||||
|
|
||||||
boolean authLoginSupported = false;
|
boolean authLoginSupported = false;
|
||||||
boolean authPlainSupported = false;
|
boolean authPlainSupported = false;
|
||||||
boolean authCramMD5Supported = false;
|
boolean authCramMD5Supported = false;
|
||||||
if (mAuthType != null) {
|
|
||||||
authLoginSupported = mAuthType.equals(AUTH_LOGIN);
|
|
||||||
authPlainSupported = mAuthType.equals(AUTH_PLAIN);
|
|
||||||
authCramMD5Supported = mAuthType.equals(AUTH_CRAM_MD5);
|
|
||||||
}
|
|
||||||
if (mAuthType == null || mAuthType.equals(AUTH_AUTOMATIC)) {
|
|
||||||
for (String result : results) {
|
for (String result : results) {
|
||||||
if (result.matches(".*AUTH.*LOGIN.*$")) {
|
if (result.matches(".*AUTH.*LOGIN.*$")) {
|
||||||
authLoginSupported = true;
|
authLoginSupported = true;
|
||||||
@ -261,15 +256,26 @@ public class SmtpTransport extends Transport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (mUsername != null && mUsername.length() > 0 && mPassword != null
|
if (mUsername != null && mUsername.length() > 0 &&
|
||||||
&& mPassword.length() > 0) {
|
mPassword != null && mPassword.length() > 0) {
|
||||||
if (authCramMD5Supported) {
|
if (useAuthCramMD5 || authCramMD5Supported) {
|
||||||
|
if (!authCramMD5Supported && K9.DEBUG && K9.DEBUG_PROTOCOL_SMTP) {
|
||||||
|
Log.d(K9.LOG_TAG, "Using CRAM_MD5 as authentication method although the " +
|
||||||
|
"server didn't advertise support for it in EHLO response.");
|
||||||
|
}
|
||||||
saslAuthCramMD5(mUsername, mPassword);
|
saslAuthCramMD5(mUsername, mPassword);
|
||||||
} else if (authPlainSupported) {
|
} else if (useAuthPlain || authPlainSupported) {
|
||||||
|
if (!authPlainSupported && K9.DEBUG && K9.DEBUG_PROTOCOL_SMTP) {
|
||||||
|
Log.d(K9.LOG_TAG, "Using PLAIN as authentication method although the " +
|
||||||
|
"server didn't advertise support for it in EHLO response.");
|
||||||
|
}
|
||||||
saslAuthPlain(mUsername, mPassword);
|
saslAuthPlain(mUsername, mPassword);
|
||||||
} else if (authLoginSupported) {
|
} else if (useAuthLogin || 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.");
|
||||||
|
}
|
||||||
saslAuthLogin(mUsername, mPassword);
|
saslAuthLogin(mUsername, mPassword);
|
||||||
} else {
|
} else {
|
||||||
throw new MessagingException("No valid authentication mechanism found.");
|
throw new MessagingException("No valid authentication mechanism found.");
|
||||||
|
Loading…
Reference in New Issue
Block a user