diff --git a/res/values/strings.xml b/res/values/strings.xml index 98ab1e85b..8e592c38a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -385,6 +385,10 @@ Please submit bug reports, contribute new features and ask questions at IMAP Exchange (WebDAV) + Automatic + Normal password + Encrypted password + Incoming server settings Username Password diff --git a/src/com/fsck/k9/activity/setup/AccountSetupIncoming.java b/src/com/fsck/k9/activity/setup/AccountSetupIncoming.java index e58fc8846..cdb91eea9 100644 --- a/src/com/fsck/k9/activity/setup/AccountSetupIncoming.java +++ b/src/com/fsck/k9/activity/setup/AccountSetupIncoming.java @@ -18,6 +18,7 @@ import com.fsck.k9.*; import com.fsck.k9.activity.K9Activity; import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection; import com.fsck.k9.helper.Utility; +import com.fsck.k9.mail.AuthType; import com.fsck.k9.mail.ConnectionSecurity; import com.fsck.k9.mail.ServerSettings; import com.fsck.k9.mail.Store; @@ -58,11 +59,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener ConnectionSecurity.STARTTLS_REQUIRED }; - private static final String[] AUTH_TYPES = { - "PLAIN", "CRAM_MD5" - }; - - private int[] mAccountPorts; private String mStoreType; private EditText mUsernameView; @@ -83,6 +79,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener private CheckBox mCompressionWifi; private CheckBox mCompressionOther; private CheckBox mSubscribedFoldersOnly; + private ArrayAdapter mAuthTypeAdapter; public static void actionIncomingSettings(Activity context, Account account, boolean makeDefault) { Intent i = new Intent(context, AccountSetupIncoming.class); @@ -149,22 +146,16 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener 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. - // that makes me somewhat unhappy - SpinnerOption authTypeSpinnerOptions[] = { - new SpinnerOption(0, AUTH_TYPES[0]), - new SpinnerOption(1, AUTH_TYPES[1]) - }; - ArrayAdapter securityTypesAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, securityTypes); securityTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSecurityTypeView.setAdapter(securityTypesAdapter); - ArrayAdapter authTypesAdapter = new ArrayAdapter(this, - android.R.layout.simple_spinner_item, authTypeSpinnerOptions); - authTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - mAuthTypeView.setAdapter(authTypesAdapter); + AuthType[] acceptableAuthTypes = {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 @@ -217,13 +208,9 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener mPasswordView.setText(settings.password); } - if (settings.authenticationType != null) { - for (int i = 0; i < AUTH_TYPES.length; i++) { - if (AUTH_TYPES[i].equals(settings.authenticationType)) { - SpinnerOption.setSpinnerOptionValue(mAuthTypeView, i); - } - } - } + // The first item is selected if settings.authenticationType is null or is not in mAuthTypeAdapter + int position = mAuthTypeAdapter.getPosition(settings.authenticationType); + mAuthTypeView.setSelection(position, false); mStoreType = settings.type; if (Pop3Store.STORE_TYPE.equals(settings.type)) { @@ -407,7 +394,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener String username = mUsernameView.getText().toString(); String password = mPasswordView.getText().toString(); - String authType = ((SpinnerOption)mAuthTypeView.getSelectedItem()).label; + AuthType authType = (AuthType) mAuthTypeView.getSelectedItem(); String host = mServerView.getText().toString(); int port = Integer.parseInt(mPortView.getText().toString()); diff --git a/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java b/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java index 6d1af8bc0..3b221b45f 100644 --- a/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java +++ b/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java @@ -17,7 +17,7 @@ import com.fsck.k9.*; import com.fsck.k9.activity.K9Activity; import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection; import com.fsck.k9.helper.Utility; -import com.fsck.k9.mail.transport.SmtpTransport; +import com.fsck.k9.mail.AuthType; import java.io.UnsupportedEncodingException; import java.net.URI; @@ -48,13 +48,6 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener, "webdav", "webdav+ssl", "webdav+ssl+", "webdav+tls", "webdav+tls+" }; */ - private static final String authTypes[] = { - SmtpTransport.AUTH_AUTOMATIC, - SmtpTransport.AUTH_LOGIN, - SmtpTransport.AUTH_PLAIN, - SmtpTransport.AUTH_CRAM_MD5, - }; - private EditText mUsernameView; private EditText mPasswordView; private EditText mServerView; @@ -127,18 +120,13 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener, new SpinnerOption(4, getString(R.string.account_setup_incoming_security_tls_label)), }; - SpinnerOption authTypeSpinnerOptions[] = new SpinnerOption[authTypes.length]; - for (int i = 0; i < authTypes.length; i++) { - authTypeSpinnerOptions[i] = new SpinnerOption(i, authTypes[i]); - } - ArrayAdapter securityTypesAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, securityTypes); securityTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSecurityTypeView.setAdapter(securityTypesAdapter); - ArrayAdapter authTypesAdapter = new ArrayAdapter(this, - android.R.layout.simple_spinner_item, authTypeSpinnerOptions); + 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); @@ -208,11 +196,8 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener, } if (authType != null) { - for (int i = 0; i < authTypes.length; i++) { - if (authTypes[i].equals(authType)) { - SpinnerOption.setSpinnerOptionValue(mAuthTypeView, i); - } - } + int position = AuthType.valueOf(authType).ordinal(); + mAuthTypeView.setSelection(position, false); } // Select currently configured security type @@ -305,7 +290,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener, String passwordEnc = URLEncoder.encode(mPasswordView.getText().toString(), "UTF-8"); String userInfo = null; - String authType = ((SpinnerOption)mAuthTypeView.getSelectedItem()).label; + String authType = ((AuthType) mAuthTypeView.getSelectedItem()).name(); if (mRequireLoginView.isChecked()) { userInfo = usernameEnc + ":" + passwordEnc + ":" + authType; } diff --git a/src/com/fsck/k9/mail/AuthType.java b/src/com/fsck/k9/mail/AuthType.java new file mode 100644 index 000000000..9c2425e3c --- /dev/null +++ b/src/com/fsck/k9/mail/AuthType.java @@ -0,0 +1,32 @@ +package com.fsck.k9.mail; + +import com.fsck.k9.K9; +import com.fsck.k9.R; + +public enum AuthType { + + /* + * The names of these auth. types are saved as strings when settings are + * exported, and are also saved as part of the Server URI saved in the + * account settings. + */ + AUTOMATIC(R.string.account_setup_auth_type_automatic), + PLAIN(R.string.account_setup_auth_type_normal_password), + CRAM_MD5(R.string.account_setup_auth_type_encrypted_password), + LOGIN(0); + + private final int mResourceId; + + private AuthType(int id) { + mResourceId = id; + } + + @Override + public String toString() { + if (mResourceId == 0) { + return name(); + } else { + return K9.app.getString(mResourceId); + } + } +} diff --git a/src/com/fsck/k9/mail/ServerSettings.java b/src/com/fsck/k9/mail/ServerSettings.java index 9ba43556e..50207863d 100644 --- a/src/com/fsck/k9/mail/ServerSettings.java +++ b/src/com/fsck/k9/mail/ServerSettings.java @@ -48,7 +48,7 @@ public class ServerSettings { * * {@code null} if not applicable for the store or transport. */ - public final String authenticationType; + public final AuthType authenticationType; /** * The username part of the credentials needed to authenticate to the server. @@ -91,7 +91,7 @@ public class ServerSettings { * see {@link ServerSettings#password} */ public ServerSettings(String type, String host, int port, - ConnectionSecurity connectionSecurity, String authenticationType, String username, + ConnectionSecurity connectionSecurity, AuthType authenticationType, String username, String password) { this.type = type; this.host = host; @@ -124,7 +124,7 @@ public class ServerSettings { * see {@link ServerSettings#extra} */ public ServerSettings(String type, String host, int port, - ConnectionSecurity connectionSecurity, String authenticationType, String username, + ConnectionSecurity connectionSecurity, AuthType authenticationType, String username, String password, Map extra) { this.type = type; this.host = host; diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index f557a852e..a30023421 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -69,6 +69,7 @@ import com.fsck.k9.helper.StringUtils; import com.fsck.k9.helper.Utility; import com.fsck.k9.helper.power.TracingPowerManager; import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock; +import com.fsck.k9.mail.AuthType; import com.fsck.k9.mail.Authentication; import com.fsck.k9.mail.AuthenticationFailedException; import com.fsck.k9.mail.Body; @@ -117,8 +118,6 @@ public class ImapStore extends Store { public static final int CONNECTION_SECURITY_SSL_REQUIRED = 3; public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4; - public enum AuthType { PLAIN, CRAM_MD5 } - private static final int IDLE_READ_TIMEOUT_INCREMENT = 5 * 60 * 1000; private static final int IDLE_FAILURE_COUNT_LIMIT = 10; private static int MAX_DELAY_TIME = 5 * 60 * 1000; // 5 minutes @@ -163,7 +162,7 @@ public class ImapStore extends Store { String host; int port; ConnectionSecurity connectionSecurity; - String authenticationType = null; + AuthType authenticationType = null; String username = null; String password = null; String pathPrefix = null; @@ -209,14 +208,14 @@ public class ImapStore extends Store { if (userinfo.endsWith(":")) { // Password is empty. This can only happen after an account was imported. - authenticationType = AuthType.valueOf(userInfoParts[0]).name(); + authenticationType = AuthType.valueOf(userInfoParts[0]); username = URLDecoder.decode(userInfoParts[1], "UTF-8"); } else if (userInfoParts.length == 2) { - authenticationType = AuthType.PLAIN.name(); + authenticationType = AuthType.PLAIN; username = URLDecoder.decode(userInfoParts[0], "UTF-8"); password = URLDecoder.decode(userInfoParts[1], "UTF-8"); } else { - authenticationType = AuthType.valueOf(userInfoParts[0]).name(); + authenticationType = AuthType.valueOf(userInfoParts[0]); username = URLDecoder.decode(userInfoParts[1], "UTF-8"); password = URLDecoder.decode(userInfoParts[2], "UTF-8"); } @@ -291,15 +290,9 @@ public class ImapStore extends Store { break; } - AuthType authType; - try { - authType = AuthType.valueOf(server.authenticationType); - } catch (Exception e) { - throw new IllegalArgumentException("Invalid authentication type: " + - server.authenticationType); - } + AuthType authType = server.authenticationType; - String userInfo = authType.toString() + ":" + userEnc + ":" + passwordEnc; + String userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc; try { Map extra = server.getExtra(); String path = null; @@ -334,7 +327,7 @@ public class ImapStore extends Store { public final String pathPrefix; protected ImapStoreSettings(String host, int port, ConnectionSecurity connectionSecurity, - String authenticationType, String username, String password, + AuthType authenticationType, String username, String password, boolean autodetectNamespace, String pathPrefix) { super(STORE_TYPE, host, port, connectionSecurity, authenticationType, username, password); @@ -485,7 +478,7 @@ public class ImapStore extends Store { break; } - mAuthType = AuthType.valueOf(settings.authenticationType); + mAuthType = settings.authenticationType; mUsername = settings.username; mPassword = settings.password; diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index 0751d287a..9a4f9fb9e 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -43,11 +43,6 @@ public class Pop3Store extends Store { public static final int CONNECTION_SECURITY_SSL_REQUIRED = 3; public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4; - private enum AuthType { - PLAIN, - CRAM_MD5 - } - private static final String STLS_COMMAND = "STLS"; private static final String USER_COMMAND = "USER"; private static final String PASS_COMMAND = "PASS"; @@ -120,7 +115,7 @@ public class Pop3Store extends Store { port = pop3Uri.getPort(); } - String authType = AuthType.PLAIN.name(); + AuthType authType = AuthType.PLAIN; if (pop3Uri.getUserInfo() != null) { try { int userIndex = 0, passwordIndex = 1; @@ -131,7 +126,7 @@ public class Pop3Store extends Store { // after an account was imported (so authType and username are present). userIndex++; passwordIndex++; - authType = userInfoParts[0]; + authType = AuthType.valueOf(userInfoParts[0]); } username = URLDecoder.decode(userInfoParts[userIndex], "UTF-8"); if (userInfoParts.length > passwordIndex) { @@ -190,14 +185,7 @@ public class Pop3Store extends Store { break; } - try { - AuthType.valueOf(server.authenticationType); - } catch (Exception e) { - throw new IllegalArgumentException("Invalid authentication type (" + - server.authenticationType + ")"); - } - - String userInfo = server.authenticationType + ":" + userEnc + ":" + passwordEnc; + String userInfo = server.authenticationType.name() + ":" + userEnc + ":" + passwordEnc; try { return new URI(scheme, userInfo, server.host, server.port, null, null, null).toString(); @@ -257,7 +245,7 @@ public class Pop3Store extends Store { mUsername = settings.username; mPassword = settings.password; - mAuthType = AuthType.valueOf(settings.authenticationType); + mAuthType = settings.authenticationType; } @Override diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java index 01b45655a..df352cd2b 100644 --- a/src/com/fsck/k9/mail/store/WebDavStore.java +++ b/src/com/fsck/k9/mail/store/WebDavStore.java @@ -270,7 +270,7 @@ public class WebDavStore extends Store { public final String mailboxPath; protected WebDavStoreSettings(String host, int port, ConnectionSecurity connectionSecurity, - String authenticationType, String username, String password, String alias, + AuthType authenticationType, String username, String password, String alias, String path, String authPath, String mailboxPath) { super(STORE_TYPE, host, port, connectionSecurity, authenticationType, username, password); diff --git a/src/com/fsck/k9/mail/transport/SmtpTransport.java b/src/com/fsck/k9/mail/transport/SmtpTransport.java index 4ae69df85..3e029d954 100644 --- a/src/com/fsck/k9/mail/transport/SmtpTransport.java +++ b/src/com/fsck/k9/mail/transport/SmtpTransport.java @@ -39,15 +39,6 @@ public class SmtpTransport extends Transport { public static final int CONNECTION_SECURITY_SSL_REQUIRED = 3; 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"; - - /** * Decodes a SmtpTransport URI. * @@ -64,7 +55,7 @@ public class SmtpTransport extends Transport { String host; int port; ConnectionSecurity connectionSecurity; - String authenticationType = AUTH_AUTOMATIC; + AuthType authType = AuthType.AUTOMATIC; String username = null; String password = null; @@ -109,7 +100,7 @@ public class SmtpTransport extends Transport { password = URLDecoder.decode(userInfoParts[1], "UTF-8"); } if (userInfoParts.length > 2) { - authenticationType = userInfoParts[2]; + authType = AuthType.valueOf(userInfoParts[2]); } } catch (UnsupportedEncodingException enc) { // This shouldn't happen since the encoding is hardcoded to UTF-8 @@ -118,7 +109,7 @@ public class SmtpTransport extends Transport { } return new ServerSettings(TRANSPORT_TYPE, host, port, connectionSecurity, - authenticationType, username, password); + authType, username, password); } /** @@ -165,15 +156,11 @@ public class SmtpTransport extends Transport { break; } - String authType = server.authenticationType; - if (!(AUTH_AUTOMATIC.equals(authType) || - AUTH_LOGIN.equals(authType) || - AUTH_PLAIN.equals(authType) || - AUTH_CRAM_MD5.equals(authType))) { - throw new IllegalArgumentException("Invalid authentication type: " + authType); + String userInfo = userEnc + ":" + passwordEnc; + AuthType authType = server.authenticationType; + if (authType != null) { + userInfo += ":" + authType.name(); } - - String userInfo = userEnc + ":" + passwordEnc + ":" + authType; try { return new URI(scheme, userInfo, server.host, server.port, null, null, null).toString(); @@ -187,7 +174,7 @@ public class SmtpTransport extends Transport { int mPort; String mUsername; String mPassword; - String mAuthType; + AuthType mAuthType; int mConnectionSecurity; Socket mSocket; PeekableInputStream mIn; @@ -318,9 +305,9 @@ public class SmtpTransport extends Transport { } } - boolean useAuthLogin = AUTH_LOGIN.equals(mAuthType); - boolean useAuthPlain = AUTH_PLAIN.equals(mAuthType); - boolean useAuthCramMD5 = AUTH_CRAM_MD5.equals(mAuthType); + boolean useAuthLogin = AuthType.LOGIN.equals(mAuthType); + boolean useAuthPlain = AuthType.PLAIN.equals(mAuthType); + boolean useAuthCramMD5 = AuthType.CRAM_MD5.equals(mAuthType); // Automatically choose best authentication method if none was explicitly selected boolean useAutomaticAuth = !(useAuthLogin || useAuthPlain || useAuthCramMD5); diff --git a/src/com/fsck/k9/mail/transport/imap/ImapSettings.java b/src/com/fsck/k9/mail/transport/imap/ImapSettings.java index 63c22f6d9..b68c42f89 100644 --- a/src/com/fsck/k9/mail/transport/imap/ImapSettings.java +++ b/src/com/fsck/k9/mail/transport/imap/ImapSettings.java @@ -1,7 +1,7 @@ package com.fsck.k9.mail.transport.imap; +import com.fsck.k9.mail.AuthType; import com.fsck.k9.mail.store.ImapStore; -import com.fsck.k9.mail.store.ImapStore.AuthType; import com.fsck.k9.mail.store.ImapStore.ImapConnection; /** diff --git a/src/com/fsck/k9/preferences/SettingsExporter.java b/src/com/fsck/k9/preferences/SettingsExporter.java index 2497376aa..b09ef359d 100644 --- a/src/com/fsck/k9/preferences/SettingsExporter.java +++ b/src/com/fsck/k9/preferences/SettingsExporter.java @@ -230,7 +230,7 @@ public class SettingsExporter { writeElement(serializer, PORT_ELEMENT, Integer.toString(incoming.port)); } writeElement(serializer, CONNECTION_SECURITY_ELEMENT, incoming.connectionSecurity.name()); - writeElement(serializer, AUTHENTICATION_TYPE_ELEMENT, incoming.authenticationType); + writeElement(serializer, AUTHENTICATION_TYPE_ELEMENT, incoming.authenticationType.name()); writeElement(serializer, USERNAME_ELEMENT, incoming.username); // XXX For now we don't export the password //writeElement(serializer, PASSWORD_ELEMENT, incoming.password); @@ -257,7 +257,7 @@ public class SettingsExporter { writeElement(serializer, PORT_ELEMENT, Integer.toString(outgoing.port)); } writeElement(serializer, CONNECTION_SECURITY_ELEMENT, outgoing.connectionSecurity.name()); - writeElement(serializer, AUTHENTICATION_TYPE_ELEMENT, outgoing.authenticationType); + writeElement(serializer, AUTHENTICATION_TYPE_ELEMENT, outgoing.authenticationType.name()); writeElement(serializer, USERNAME_ELEMENT, outgoing.username); // XXX For now we don't export the password //writeElement(serializer, PASSWORD_ELEMENT, outgoing.password); diff --git a/src/com/fsck/k9/preferences/SettingsImporter.java b/src/com/fsck/k9/preferences/SettingsImporter.java index c9fd6557c..9a77614b0 100644 --- a/src/com/fsck/k9/preferences/SettingsImporter.java +++ b/src/com/fsck/k9/preferences/SettingsImporter.java @@ -23,6 +23,7 @@ import com.fsck.k9.Identity; import com.fsck.k9.K9; import com.fsck.k9.Preferences; import com.fsck.k9.helper.Utility; +import com.fsck.k9.mail.AuthType; import com.fsck.k9.mail.ConnectionSecurity; import com.fsck.k9.mail.ServerSettings; import com.fsck.k9.mail.Store; @@ -971,7 +972,8 @@ public class SettingsImporter { } else if (SettingsExporter.CONNECTION_SECURITY_ELEMENT.equals(element)) { server.connectionSecurity = getText(xpp); } else if (SettingsExporter.AUTHENTICATION_TYPE_ELEMENT.equals(element)) { - server.authenticationType = getText(xpp); + String text = getText(xpp); + server.authenticationType = AuthType.valueOf(text); } else if (SettingsExporter.USERNAME_ELEMENT.equals(element)) { server.username = getText(xpp); } else if (SettingsExporter.PASSWORD_ELEMENT.equals(element)) { @@ -1140,7 +1142,7 @@ public class SettingsImporter { public String host; public String port; public String connectionSecurity; - public String authenticationType; + public AuthType authenticationType; public String username; public String password; public ImportedSettings extras; diff --git a/tests/src/com/fsck/k9/mail/store/ImapStoreUriTest.java b/tests/src/com/fsck/k9/mail/store/ImapStoreUriTest.java index 4f5f7129e..442b443ce 100644 --- a/tests/src/com/fsck/k9/mail/store/ImapStoreUriTest.java +++ b/tests/src/com/fsck/k9/mail/store/ImapStoreUriTest.java @@ -2,6 +2,8 @@ package com.fsck.k9.mail.store; import java.util.HashMap; import java.util.Map; + +import com.fsck.k9.mail.AuthType; import com.fsck.k9.mail.ConnectionSecurity; import com.fsck.k9.mail.ServerSettings; import com.fsck.k9.mail.Store; @@ -13,7 +15,7 @@ public class ImapStoreUriTest extends TestCase { String uri = "imap://PLAIN:user:pass@server:143/0%7CcustomPathPrefix"; ServerSettings settings = Store.decodeStoreUri(uri); - assertEquals("PLAIN", settings.authenticationType); + assertEquals(AuthType.PLAIN, settings.authenticationType); assertEquals("user", settings.username); assertEquals("pass", settings.password); assertEquals("server", settings.host); @@ -26,7 +28,7 @@ public class ImapStoreUriTest extends TestCase { String uri = "imap://PLAIN:user:pass@server:143/"; ServerSettings settings = Store.decodeStoreUri(uri); - assertEquals("PLAIN", settings.authenticationType); + assertEquals(AuthType.PLAIN, settings.authenticationType); assertEquals("user", settings.username); assertEquals("pass", settings.password); assertEquals("server", settings.host); @@ -38,7 +40,7 @@ public class ImapStoreUriTest extends TestCase { String uri = "imap://PLAIN:user:pass@server:143/customPathPrefix"; ServerSettings settings = Store.decodeStoreUri(uri); - assertEquals("PLAIN", settings.authenticationType); + assertEquals(AuthType.PLAIN, settings.authenticationType); assertEquals("user", settings.username); assertEquals("pass", settings.password); assertEquals("server", settings.host); @@ -51,7 +53,7 @@ public class ImapStoreUriTest extends TestCase { String uri = "imap://PLAIN:user:pass@server:143/0%7C"; ServerSettings settings = Store.decodeStoreUri(uri); - assertEquals("PLAIN", settings.authenticationType); + assertEquals(AuthType.PLAIN, settings.authenticationType); assertEquals("user", settings.username); assertEquals("pass", settings.password); assertEquals("server", settings.host); @@ -64,7 +66,7 @@ public class ImapStoreUriTest extends TestCase { String uri = "imap://PLAIN:user:pass@server:143/1%7CcustomPathPrefix"; ServerSettings settings = Store.decodeStoreUri(uri); - assertEquals("PLAIN", settings.authenticationType); + assertEquals(AuthType.PLAIN, settings.authenticationType); assertEquals("user", settings.username); assertEquals("pass", settings.password); assertEquals("server", settings.host); @@ -80,7 +82,7 @@ public class ImapStoreUriTest extends TestCase { extra.put("pathPrefix", "customPathPrefix"); ServerSettings settings = new ServerSettings(ImapStore.STORE_TYPE, "server", 143, - ConnectionSecurity.NONE, "PLAIN", "user", "pass", extra); + ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass", extra); String uri = Store.createStoreUri(settings); @@ -93,7 +95,7 @@ public class ImapStoreUriTest extends TestCase { extra.put("pathPrefix", ""); ServerSettings settings = new ServerSettings(ImapStore.STORE_TYPE, "server", 143, - ConnectionSecurity.NONE, "PLAIN", "user", "pass", extra); + ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass", extra); String uri = Store.createStoreUri(settings); @@ -102,7 +104,7 @@ public class ImapStoreUriTest extends TestCase { public void testCreateStoreUriImapNoExtra() { ServerSettings settings = new ServerSettings(ImapStore.STORE_TYPE, "server", 143, - ConnectionSecurity.NONE, "PLAIN", "user", "pass"); + ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass"); String uri = Store.createStoreUri(settings); @@ -114,7 +116,7 @@ public class ImapStoreUriTest extends TestCase { extra.put("autoDetectNamespace", "true"); ServerSettings settings = new ServerSettings(ImapStore.STORE_TYPE, "server", 143, - ConnectionSecurity.NONE, "PLAIN", "user", "pass", extra); + ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass", extra); String uri = Store.createStoreUri(settings);