1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Fixed store URI encoding/decoding in Pop3Store

This commit is contained in:
cketti 2011-10-17 05:59:36 +02:00
parent d87e25dde1
commit 6b5b4e474e

View File

@ -34,6 +34,11 @@ public class Pop3Store extends Store {
public static final int CONNECTION_SECURITY_SSL_REQUIRED = 3; public static final int CONNECTION_SECURITY_SSL_REQUIRED = 3;
public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4; 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 STLS_COMMAND = "STLS";
private static final String USER_COMMAND = "USER"; private static final String USER_COMMAND = "USER";
private static final String PASS_COMMAND = "PASS"; private static final String PASS_COMMAND = "PASS";
@ -106,7 +111,7 @@ public class Pop3Store extends Store {
port = pop3Uri.getPort(); port = pop3Uri.getPort();
} }
String authType = ""; String authType = AuthType.PLAIN.name();
if (pop3Uri.getUserInfo() != null) { if (pop3Uri.getUserInfo() != null) {
try { try {
int userIndex = 0, passwordIndex = 1; int userIndex = 0, passwordIndex = 1;
@ -173,7 +178,14 @@ public class Pop3Store extends Store {
break; break;
} }
String userInfo = userEnc + ":" + passwordEnc; try {
AuthType.valueOf(server.authenticationType);
} catch (Exception e) {
throw new IllegalArgumentException("Invalid authentication type (" +
server.authenticationType + ")");
}
String userInfo = server.authenticationType + ":" + userEnc + ":" + passwordEnc;
try { try {
return new URI(scheme, userInfo, server.host, server.port, null, null, return new URI(scheme, userInfo, server.host, server.port, null, null,
null).toString(); null).toString();
@ -187,7 +199,7 @@ public class Pop3Store extends Store {
private int mPort; private int mPort;
private String mUsername; private String mUsername;
private String mPassword; private String mPassword;
private boolean useCramMd5; private AuthType mAuthType;
private int mConnectionSecurity; private int mConnectionSecurity;
private HashMap<String, Folder> mFolders = new HashMap<String, Folder>(); private HashMap<String, Folder> mFolders = new HashMap<String, Folder>();
private Pop3Capabilities mCapabilities; private Pop3Capabilities mCapabilities;
@ -233,6 +245,7 @@ public class Pop3Store extends Store {
mUsername = settings.username; mUsername = settings.username;
mPassword = settings.password; mPassword = settings.password;
mAuthType = AuthType.valueOf(settings.authenticationType);
} }
@Override @Override
@ -352,7 +365,7 @@ public class Pop3Store extends Store {
} }
} }
if (useCramMd5) { if (mAuthType == AuthType.CRAM_MD5) {
try { try {
String b64Nonce = executeSimpleCommand("AUTH CRAM-MD5").replace("+ ", ""); String b64Nonce = executeSimpleCommand("AUTH CRAM-MD5").replace("+ ", "");