mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 13:12:25 -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,6 +235,12 @@ public class SmtpTransport extends Transport {
|
|||||||
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;
|
||||||
@ -234,7 +248,7 @@ public class SmtpTransport extends Transport {
|
|||||||
if (result.matches(".*AUTH.*PLAIN.*$")) {
|
if (result.matches(".*AUTH.*PLAIN.*$")) {
|
||||||
authPlainSupported = true;
|
authPlainSupported = true;
|
||||||
}
|
}
|
||||||
if (result.matches(".*AUTH.*CRAM-MD5.*$") && mAuthType != null && mAuthType.equals("CRAM_MD5")) {
|
if (result.matches(".*AUTH.*CRAM-MD5.*$")) {
|
||||||
authCramMD5Supported = true;
|
authCramMD5Supported = true;
|
||||||
}
|
}
|
||||||
if (result.matches(".*SIZE \\d*$")) {
|
if (result.matches(".*SIZE \\d*$")) {
|
||||||
@ -247,6 +261,7 @@ public class SmtpTransport extends Transport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mUsername != null && mUsername.length() > 0 && mPassword != null
|
if (mUsername != null && mUsername.length() > 0 && mPassword != null
|
||||||
&& mPassword.length() > 0) {
|
&& mPassword.length() > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user