Issue 179 and Issue 320

Puts quotes around username and password for IMAP authentication.

Also, if authentication fails, closes the connection so that it will
be retried.  Otherwise, there is no way to fix the problem, say, by
changing the password in the Incoming Settings.
This commit is contained in:
Daniel Applebaum 2009-02-25 01:50:20 +00:00
parent 0e9d1f195e
commit 2d31b4e52d
1 changed files with 12 additions and 1 deletions

View File

@ -1203,6 +1203,8 @@ public class ImapStore extends Store {
if (isOpen()) {
return;
}
boolean authSuccess = false;
mNextCommandTag = 1;
try
@ -1277,7 +1279,8 @@ public class ImapStore extends Store {
try {
// TODO eventually we need to add additional authentication
// options such as SASL
executeSimpleCommand("LOGIN " + mUsername + " " + mPassword, true);
executeSimpleCommand("LOGIN \"" + mUsername + "\" \"" + mPassword + "\"", true);
authSuccess = true;
} catch (ImapException ie) {
throw new AuthenticationFailedException(ie.getAlertText(), ie);
@ -1304,6 +1307,14 @@ public class ImapStore extends Store {
throw ce;
}
}
finally
{
if (authSuccess == false)
{
Log.e(Email.LOG_TAG, "Failed to login, closing connection");
close();
}
}
}
public boolean isOpen() {