Provide better information w/ 500 error in EAS validation

* HTTP error 500 occurs with Exchange 2003 when the user tries to
  authenticate with wrong credentials; we report this as "Cannot
  connect to server", which is wrong
* Error 500 is supposed to mean "internal server error", but since
  we know that an authentication error can cause this, we now put
  up a better error message

Bug: 2933381
Change-Id: I9319a5ed6fbf4c92739f305b42b6b1cad7036a4b
This commit is contained in:
Marc Blank 2010-09-30 09:44:36 -07:00
parent 1f28e33234
commit 14a5d8d947
4 changed files with 16 additions and 0 deletions

View File

@ -590,6 +590,11 @@ save attachment.</string>
<!-- "Setup could not finish" dialog text; e.g., Cannot safely connect to server\n(TLS Not Supported) -->
<string name="account_setup_failed_dlg_certificate_message_fmt">Cannot safely connect to server.\n(<xliff:g id="error">%s</xliff:g>)</string>
<!-- Dialog text for ambiguous setup failure; server error/bad credentials [CHAR LIMIT=none] -->
<string name="account_setup_failed_check_credentials_message">
The server responded with an error; please check your username and password
and try again.</string>
<!-- "Setup could not finish" dialog text; e.g., Cannot connect to server -->
<string name="account_setup_failed_dlg_server_message">Cannot connect to server.</string>
<!-- "Setup could not finish" dialog text; e.g., Cannot connect to server\n(Connection timed out) -->

View File

@ -580,6 +580,9 @@ public class AccountCheckSettingsFragment extends Fragment {
? R.string.account_setup_failed_dlg_auth_message
: R.string.account_setup_failed_dlg_auth_message_fmt;
break;
case MessagingException.AUTHENTICATION_FAILED_OR_SERVER_ERROR:
id = R.string.account_setup_failed_check_credentials_message;
break;
case MessagingException.IOERROR:
id = R.string.account_setup_failed_ioerror;
break;

View File

@ -59,6 +59,8 @@ public class MessagingException extends Exception {
public static final int AUTODISCOVER_AUTHENTICATION_FAILED = 11;
/** Autodiscover completed with a result (non-error) */
public static final int AUTODISCOVER_AUTHENTICATION_RESULT = 12;
/** Ambiguous failure; server error or bad credentials */
public static final int AUTHENTICATION_FAILED_OR_SERVER_ERROR = 13;
protected int mExceptionType;

View File

@ -142,6 +142,8 @@ public class EasSyncService extends AbstractSyncService {
static private final String AUTO_DISCOVER_PAGE = "/autodiscover/autodiscover.xml";
static private final int AUTO_DISCOVER_REDIRECT_CODE = 451;
static private final int INTERNAL_SERVER_ERROR_CODE = 500;
static public final String EAS_12_POLICY_TYPE = "MS-EAS-Provisioning-WBXML";
static public final String EAS_2_POLICY_TYPE = "MS-WAP-Provisioning-XML";
@ -466,6 +468,10 @@ public class EasSyncService extends AbstractSyncService {
} else if (isAuthError(code)) {
userLog("Authentication failed");
resultCode = MessagingException.AUTHENTICATION_FAILED;
} else if (code == INTERNAL_SERVER_ERROR_CODE) {
// For Exchange 2003, this could mean an authenticiation failure OR a server error
userLog("Internal server error");
resultCode = MessagingException.AUTHENTICATION_FAILED_OR_SERVER_ERROR;
} else {
// TODO Need to catch other kinds of errors (e.g. policy) For now, report the code.
userLog("Validation failed, reporting I/O error: ", code);