am 35ffcc3a: am bf98b875: am d82ae435: am 461d3e74: am 1182e1f9: Merge "Fix handling AOL\'s login rejection" into ub-gmail-ur14-dev

* commit '35ffcc3a0bed9e59679d978a9d56a0c26c8597a9':
  Fix handling AOL's login rejection
This commit is contained in:
Tony Mantler 2014-11-02 19:03:18 +00:00 committed by Android Git Automerger
commit b208347a77
3 changed files with 20 additions and 3 deletions

View File

@ -344,6 +344,7 @@ class ImapConnection {
if (!response.isOk()) { if (!response.isOk()) {
final String toString = response.toString(); final String toString = response.toString();
final String status = response.getStatusOrEmpty().getString();
final String alert = response.getAlertTextOrEmpty().getString(); final String alert = response.getAlertTextOrEmpty().getString();
final String responseCode = response.getResponseCodeOrEmpty().getString(); final String responseCode = response.getResponseCodeOrEmpty().getString();
destroyResponses(); destroyResponses();
@ -353,7 +354,7 @@ class ImapConnection {
throw new MessagingException(MessagingException.SERVER_ERROR, alert); throw new MessagingException(MessagingException.SERVER_ERROR, alert);
} }
throw new ImapException(toString, alert, responseCode); throw new ImapException(toString, status, alert, responseCode);
} }
return responses; return responses;
} }
@ -505,12 +506,14 @@ class ImapConnection {
LogUtils.d(Logging.LOG_TAG, ie, "ImapException"); LogUtils.d(Logging.LOG_TAG, ie, "ImapException");
} }
final String status = ie.getStatus();
final String code = ie.getResponseCode(); final String code = ie.getResponseCode();
final String alertText = ie.getAlertText(); final String alertText = ie.getAlertText();
// if the response code indicates expired or bad credentials, throw a special exception // if the response code indicates expired or bad credentials, throw a special exception
if (ImapConstants.AUTHENTICATIONFAILED.equals(code) || if (ImapConstants.AUTHENTICATIONFAILED.equals(code) ||
ImapConstants.EXPIRED.equals(code)) { ImapConstants.EXPIRED.equals(code) ||
(ImapConstants.NO.equals(status) && TextUtils.isEmpty(code))) {
throw new AuthenticationFailedException(alertText, ie); throw new AuthenticationFailedException(alertText, ie);
} }

View File

@ -661,15 +661,22 @@ public class ImapStore extends Store {
static class ImapException extends MessagingException { static class ImapException extends MessagingException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final String mStatus;
private final String mAlertText; private final String mAlertText;
private final String mResponseCode; private final String mResponseCode;
public ImapException(String message, String alertText, String responseCode) { public ImapException(String message, String status, String alertText,
String responseCode) {
super(message); super(message);
mStatus = status;
mAlertText = alertText; mAlertText = alertText;
mResponseCode = responseCode; mResponseCode = responseCode;
} }
public String getStatus() {
return mStatus;
}
public String getAlertText() { public String getAlertText() {
return mAlertText; return mAlertText;
} }

View File

@ -120,6 +120,13 @@ public class ImapResponse extends ImapList {
return getStringOrEmpty(getElementOrNone(1).isList() ? 2 : 1); return getStringOrEmpty(getElementOrNone(1).isList() ? 2 : 1);
} }
public ImapString getStatusOrEmpty() {
if (!isStatusResponse()) {
return ImapString.EMPTY;
}
return getStringOrEmpty(0);
}
@Override @Override
public String toString() { public String toString() {
String tag = mTag; String tag = mTag;