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,47 +229,53 @@ 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) {
|
for (String result : results) {
|
||||||
authLoginSupported = mAuthType.equals(AUTH_LOGIN);
|
if (result.matches(".*AUTH.*LOGIN.*$")) {
|
||||||
authPlainSupported = mAuthType.equals(AUTH_PLAIN);
|
authLoginSupported = true;
|
||||||
authCramMD5Supported = mAuthType.equals(AUTH_CRAM_MD5);
|
}
|
||||||
}
|
if (result.matches(".*AUTH.*PLAIN.*$")) {
|
||||||
if (mAuthType == null || mAuthType.equals(AUTH_AUTOMATIC)) {
|
authPlainSupported = true;
|
||||||
for (String result : results) {
|
}
|
||||||
if (result.matches(".*AUTH.*LOGIN.*$")) {
|
if (result.matches(".*AUTH.*CRAM-MD5.*$")) {
|
||||||
authLoginSupported = true;
|
authCramMD5Supported = true;
|
||||||
}
|
}
|
||||||
if (result.matches(".*AUTH.*PLAIN.*$")) {
|
if (result.matches(".*SIZE \\d*$")) {
|
||||||
authPlainSupported = true;
|
try {
|
||||||
}
|
mLargestAcceptableMessage = Integer.parseInt(result.substring(result.lastIndexOf(' ') + 1));
|
||||||
if (result.matches(".*AUTH.*CRAM-MD5.*$")) {
|
} catch (Exception e) {
|
||||||
authCramMD5Supported = true;
|
if (K9.DEBUG && K9.DEBUG_PROTOCOL_SMTP) {
|
||||||
}
|
Log.d(K9.LOG_TAG, "Tried to parse " + result + " and get an int out of the last word: " + e);
|
||||||
if (result.matches(".*SIZE \\d*$")) {
|
|
||||||
try {
|
|
||||||
mLargestAcceptableMessage = Integer.parseInt(result.substring(result.lastIndexOf(' ') + 1));
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (K9.DEBUG && K9.DEBUG_PROTOCOL_SMTP) {
|
|
||||||
Log.d(K9.LOG_TAG, "Tried to parse " + result + " and get an int out of the last word: " + e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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