mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
Support for SMTP authentication methods that are not announced by the server.
- Added AUTOMATIC as a new authentication method that will automatically choose the best authentication method (basically old behavior with CRAM_MD5). All other options will now enforce the selected authentication method. - Added LOGIN as selectable option. - Cleaned up code so strings to the different authentication methods are only defined once.
This commit is contained in:
parent
c3480db129
commit
da38149091
@ -16,6 +16,8 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
|
|||||||
import com.fsck.k9.*;
|
import com.fsck.k9.*;
|
||||||
import com.fsck.k9.activity.K9Activity;
|
import com.fsck.k9.activity.K9Activity;
|
||||||
import com.fsck.k9.helper.Utility;
|
import com.fsck.k9.helper.Utility;
|
||||||
|
import com.fsck.k9.mail.transport.SmtpTransport;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@ -45,10 +47,13 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
|||||||
"webdav", "webdav+ssl", "webdav+ssl+", "webdav+tls", "webdav+tls+"
|
"webdav", "webdav+ssl", "webdav+ssl+", "webdav+tls", "webdav+tls+"
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static final String authTypes[] = {
|
private static final String authTypes[] = {
|
||||||
"PLAIN", "CRAM_MD5"
|
SmtpTransport.AUTH_AUTOMATIC,
|
||||||
|
SmtpTransport.AUTH_LOGIN,
|
||||||
|
SmtpTransport.AUTH_PLAIN,
|
||||||
|
SmtpTransport.AUTH_CRAM_MD5,
|
||||||
};
|
};
|
||||||
|
|
||||||
private EditText mUsernameView;
|
private EditText mUsernameView;
|
||||||
private EditText mPasswordView;
|
private EditText mPasswordView;
|
||||||
private EditText mServerView;
|
private EditText mServerView;
|
||||||
@ -117,14 +122,10 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
|||||||
new SpinnerOption(4, getString(R.string.account_setup_incoming_security_tls_label)),
|
new SpinnerOption(4, getString(R.string.account_setup_incoming_security_tls_label)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// This needs to be kept in sync with the list at the top of the file.
|
SpinnerOption authTypeSpinnerOptions[] = new SpinnerOption[authTypes.length];
|
||||||
// that makes me somewhat unhappy
|
for (int i = 0; i < authTypes.length; i++) {
|
||||||
SpinnerOption authTypeSpinnerOptions[] = {
|
authTypeSpinnerOptions[i] = new SpinnerOption(i, authTypes[i]);
|
||||||
new SpinnerOption(0, "PLAIN"),
|
}
|
||||||
new SpinnerOption(1, "CRAM_MD5")
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ArrayAdapter<SpinnerOption> securityTypesAdapter = new ArrayAdapter<SpinnerOption>(this,
|
ArrayAdapter<SpinnerOption> securityTypesAdapter = new ArrayAdapter<SpinnerOption>(this,
|
||||||
android.R.layout.simple_spinner_item, securityTypes);
|
android.R.layout.simple_spinner_item, securityTypes);
|
||||||
|
@ -39,6 +39,14 @@ public class SmtpTransport extends Transport {
|
|||||||
|
|
||||||
public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4;
|
public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4;
|
||||||
|
|
||||||
|
public static final String AUTH_PLAIN = "PLAIN";
|
||||||
|
|
||||||
|
public static final String AUTH_CRAM_MD5 = "CRAM_MD5";
|
||||||
|
|
||||||
|
public static final String AUTH_LOGIN = "LOGIN";
|
||||||
|
|
||||||
|
public static final String AUTH_AUTOMATIC = "AUTOMATIC";
|
||||||
|
|
||||||
String mHost;
|
String mHost;
|
||||||
|
|
||||||
int mPort;
|
int mPort;
|
||||||
@ -227,22 +235,29 @@ public class SmtpTransport extends Transport {
|
|||||||
boolean authLoginSupported = false;
|
boolean authLoginSupported = false;
|
||||||
boolean authPlainSupported = false;
|
boolean authPlainSupported = false;
|
||||||
boolean authCramMD5Supported = false;
|
boolean authCramMD5Supported = false;
|
||||||
for (String result : results) {
|
if (mAuthType != null) {
|
||||||
if (result.matches(".*AUTH.*LOGIN.*$")) {
|
authLoginSupported = mAuthType.equals(AUTH_LOGIN);
|
||||||
authLoginSupported = true;
|
authPlainSupported = mAuthType.equals(AUTH_PLAIN);
|
||||||
}
|
authCramMD5Supported = mAuthType.equals(AUTH_CRAM_MD5);
|
||||||
if (result.matches(".*AUTH.*PLAIN.*$")) {
|
}
|
||||||
authPlainSupported = true;
|
if (mAuthType == null || mAuthType.equals(AUTH_AUTOMATIC)) {
|
||||||
}
|
for (String result : results) {
|
||||||
if (result.matches(".*AUTH.*CRAM-MD5.*$") && mAuthType != null && mAuthType.equals("CRAM_MD5")) {
|
if (result.matches(".*AUTH.*LOGIN.*$")) {
|
||||||
authCramMD5Supported = true;
|
authLoginSupported = true;
|
||||||
}
|
}
|
||||||
if (result.matches(".*SIZE \\d*$")) {
|
if (result.matches(".*AUTH.*PLAIN.*$")) {
|
||||||
try {
|
authPlainSupported = true;
|
||||||
mLargestAcceptableMessage = Integer.parseInt(result.substring(result.lastIndexOf(' ') + 1));
|
}
|
||||||
} catch (Exception e) {
|
if (result.matches(".*AUTH.*CRAM-MD5.*$")) {
|
||||||
if (K9.DEBUG && K9.DEBUG_PROTOCOL_SMTP) {
|
authCramMD5Supported = true;
|
||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user