1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Eliminate WebDAV STARTTLS security choice

STARTTLS doesn't really apply to WebDAV and should never have been made
available as an option.

Pre-existing settings will be re-mapped to SSL/TLS.
This commit is contained in:
Joe Steele 2014-02-26 17:59:29 -05:00
parent 14a0a7a2a7
commit 9dc5338501
2 changed files with 16 additions and 30 deletions

View File

@ -68,6 +68,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
private ArrayAdapter<AuthType> mAuthTypeAdapter; private ArrayAdapter<AuthType> mAuthTypeAdapter;
private String mDefaultPort = ""; private String mDefaultPort = "";
private String mDefaultSslPort = ""; private String mDefaultSslPort = "";
private ConnectionSecurity[] mConnectionSecurityChoices = ConnectionSecurity.values();
public static void actionIncomingSettings(Activity context, Account account, boolean makeDefault) { public static void actionIncomingSettings(Activity context, Account account, boolean makeDefault) {
Intent i = new Intent(context, AccountSetupIncoming.class); Intent i = new Intent(context, AccountSetupIncoming.class);
@ -124,11 +125,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
} }
}); });
ArrayAdapter<ConnectionSecurity> securityTypesAdapter = new ArrayAdapter<ConnectionSecurity>(this,
android.R.layout.simple_spinner_item, ConnectionSecurity.values());
securityTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSecurityTypeView.setAdapter(securityTypesAdapter);
mAuthTypeAdapter = AuthType.getArrayAdapter(this); mAuthTypeAdapter = AuthType.getArrayAdapter(this);
mAuthTypeView.setAdapter(mAuthTypeAdapter); mAuthTypeView.setAdapter(mAuthTypeAdapter);
@ -189,9 +185,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
int position = mAuthTypeAdapter.getPosition(settings.authenticationType); int position = mAuthTypeAdapter.getPosition(settings.authenticationType);
mAuthTypeView.setSelection(position, false); mAuthTypeView.setSelection(position, false);
// Select currently configured security type
mSecurityTypeView.setSelection(settings.connectionSecurity.ordinal(), false);
mStoreType = settings.type; mStoreType = settings.type;
if (Pop3Store.STORE_TYPE.equals(settings.type)) { if (Pop3Store.STORE_TYPE.equals(settings.type)) {
serverLabelView.setText(R.string.account_setup_incoming_pop_server_label); serverLabelView.setText(R.string.account_setup_incoming_pop_server_label);
@ -231,6 +224,9 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
serverLabelView.setText(R.string.account_setup_incoming_webdav_server_label); serverLabelView.setText(R.string.account_setup_incoming_webdav_server_label);
mDefaultPort = WEBDAV_PORT; mDefaultPort = WEBDAV_PORT;
mDefaultSslPort = WEBDAV_SSL_PORT; mDefaultSslPort = WEBDAV_SSL_PORT;
mConnectionSecurityChoices = new ConnectionSecurity[] {
ConnectionSecurity.NONE,
ConnectionSecurity.SSL_TLS_REQUIRED };
// Hide the unnecessary fields // Hide the unnecessary fields
findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE); findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
@ -258,6 +254,14 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
throw new Exception("Unknown account type: " + mAccount.getStoreUri()); throw new Exception("Unknown account type: " + mAccount.getStoreUri());
} }
ArrayAdapter<ConnectionSecurity> securityTypesAdapter = new ArrayAdapter<ConnectionSecurity>(this,
android.R.layout.simple_spinner_item, mConnectionSecurityChoices);
securityTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSecurityTypeView.setAdapter(securityTypesAdapter);
// Select currently configured security type
mSecurityTypeView.setSelection(settings.connectionSecurity.ordinal(), false);
/* /*
* Updates the port when the user changes the security type. This allows * Updates the port when the user changes the security type. This allows
* us to show a reasonable default which the user can change. * us to show a reasonable default which the user can change.
@ -325,19 +329,8 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
String port; String port;
switch (securityType) { switch (securityType) {
case NONE: case NONE:
port = mDefaultPort;
break;
case STARTTLS_REQUIRED: case STARTTLS_REQUIRED:
if (WebDavStore.STORE_TYPE.equals(mStoreType)) { port = mDefaultPort;
/*
* The concept of STARTTLS is not really applicable for WebDav and should never
* have been made a user-selectable option. But now we must support the setting
* if it exists.
*/
port = mDefaultSslPort;
} else {
port = mDefaultPort;
}
break; break;
case SSL_TLS_REQUIRED: case SSL_TLS_REQUIRED:
port = mDefaultSslPort; port = mDefaultSslPort;

View File

@ -83,7 +83,6 @@ public class WebDavStore extends Store {
* <p>Possible forms:</p> * <p>Possible forms:</p>
* <pre> * <pre>
* webdav://user:password@server:port ConnectionSecurity.NONE * webdav://user:password@server:port ConnectionSecurity.NONE
* webdav+tls+://user:password@server:port ConnectionSecurity.STARTTLS_REQUIRED
* webdav+ssl+://user:password@server:port ConnectionSecurity.SSL_TLS_REQUIRED * webdav+ssl+://user:password@server:port ConnectionSecurity.SSL_TLS_REQUIRED
* </pre> * </pre>
*/ */
@ -110,21 +109,19 @@ public class WebDavStore extends Store {
/* /*
* Currently available schemes are: * Currently available schemes are:
* webdav * webdav
* webdav+tls+
* webdav+ssl+ * webdav+ssl+
* *
* The following are obsolete schemes that may be found in pre-existing * The following are obsolete schemes that may be found in pre-existing
* settings from earlier versions or that may be found when imported. We * settings from earlier versions or that may be found when imported. We
* continue to recognize them and re-map them appropriately: * continue to recognize them and re-map them appropriately:
* webdav+tls * webdav+tls
* webdav+tls+
* webdav+ssl * webdav+ssl
*/ */
if (scheme.equals("webdav")) { if (scheme.equals("webdav")) {
connectionSecurity = ConnectionSecurity.NONE; connectionSecurity = ConnectionSecurity.NONE;
} else if (scheme.startsWith("webdav+ssl")) { } else if (scheme.startsWith("webdav+")) {
connectionSecurity = ConnectionSecurity.SSL_TLS_REQUIRED; connectionSecurity = ConnectionSecurity.SSL_TLS_REQUIRED;
} else if (scheme.startsWith("webdav+tls")) {
connectionSecurity = ConnectionSecurity.STARTTLS_REQUIRED;
} else { } else {
throw new IllegalArgumentException("Unsupported protocol (" + scheme + ")"); throw new IllegalArgumentException("Unsupported protocol (" + scheme + ")");
} }
@ -212,9 +209,6 @@ public class WebDavStore extends Store {
case SSL_TLS_REQUIRED: case SSL_TLS_REQUIRED:
scheme = "webdav+ssl+"; scheme = "webdav+ssl+";
break; break;
case STARTTLS_REQUIRED:
scheme = "webdav+tls+";
break;
default: default:
case NONE: case NONE:
scheme = "webdav"; scheme = "webdav";
@ -366,8 +360,7 @@ public class WebDavStore extends Store {
private String getRoot() { private String getRoot() {
String root; String root;
if (mConnectionSecurity == ConnectionSecurity.STARTTLS_REQUIRED || if (mConnectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) {
mConnectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) {
root = "https"; root = "https";
} else { } else {
root = "http"; root = "http";