Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If selected, send client certificate before password auth #780

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ public static ImapStoreSettings decodeUri(String uri) {
if (imapUri.getUserInfo() != null) {
String userinfo = imapUri.getUserInfo();
String[] userInfoParts = userinfo.split(":");

if (userinfo.endsWith(":")) {
if (userinfo.endsWith("::")) {
// Password is empty. This can only happen after an account was imported.
authenticationType = AuthType.valueOf(userInfoParts[0]);
username = decodeUtf8(userInfoParts[1]);
Expand All @@ -185,6 +184,11 @@ public static ImapStoreSettings decodeUri(String uri) {
} else {
password = decodeUtf8(userInfoParts[2]);
}
} else if (userInfoParts.length == 4) {
authenticationType = AuthType.valueOf(userInfoParts[0]);
username = decodeUtf8(userInfoParts[1]);
password = decodeUtf8(userInfoParts[2]);
clientCertificateAlias = decodeUtf8(userInfoParts[3]);
}
}

Expand Down Expand Up @@ -247,7 +251,7 @@ public static String createUri(ServerSettings server) {
if (authType == AuthType.EXTERNAL) {
userInfo = authType.name() + ":" + userEnc + ":" + clientCertificateAliasEnc;
} else {
userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc;
userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc + ":" + clientCertificateAliasEnc;
}
try {
Map<String, String> extra = server.getExtra();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ public static ServerSettings decodeUri(String uri) {
} else {
password = decodeUtf8(userInfoParts[1]);
}
}
} else if (userInfoParts.length == 4) {
authType = AuthType.valueOf(userInfoParts[2]);
username = decodeUtf8(userInfoParts[0]);
password = decodeUtf8(userInfoParts[1]);
clientCertificateAlias = decodeUtf8(userInfoParts[3]);
}
}

return new ServerSettings(ServerSettings.Type.SMTP, host, port, connectionSecurity,
Expand Down Expand Up @@ -157,7 +162,7 @@ public static String createUri(ServerSettings server) {
if (AuthType.EXTERNAL == authType) {
userInfo = userEnc + ":" + clientCertificateAliasEnc + ":" + authType.name();
} else {
userInfo = userEnc + ":" + passwordEnc + ":" + authType.name();
userInfo = userEnc + ":" + passwordEnc + ":" + authType.name() + ":" + clientCertificateAliasEnc;
}
} else {
userInfo = userEnc + ":" + passwordEnc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ private void updateViewFromAuthType() {
// show password fields, hide client certificate fields
mPasswordView.setVisibility(View.VISIBLE);
mPasswordLabelView.setVisibility(View.VISIBLE);
mClientCertificateLabelView.setVisibility(View.GONE);
mClientCertificateSpinner.setVisibility(View.GONE);
mClientCertificateLabelView.setVisibility(View.VISIBLE);
mClientCertificateSpinner.setVisibility(View.VISIBLE);
}
}

Expand Down Expand Up @@ -515,6 +515,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (AuthType.EXTERNAL == authType) {
clientCertificateAlias = mClientCertificateSpinner.getAlias();
} else {
clientCertificateAlias = mClientCertificateSpinner.getAlias();
password = mPasswordView.getText().toString();
}

Expand Down Expand Up @@ -549,6 +550,7 @@ protected void onNext() {
if (authType == AuthType.EXTERNAL) {
clientCertificateAlias = mClientCertificateSpinner.getAlias();
} else {
clientCertificateAlias = mClientCertificateSpinner.getAlias();
password = mPasswordView.getText().toString();
}
String host = mServerView.getText().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ private void updateViewFromAuthType() {
// show password fields, hide client certificate fields
mPasswordView.setVisibility(View.VISIBLE);
mPasswordLabelView.setVisibility(View.VISIBLE);
mClientCertificateLabelView.setVisibility(View.GONE);
mClientCertificateSpinner.setVisibility(View.GONE);
mClientCertificateLabelView.setVisibility(View.VISIBLE);
mClientCertificateSpinner.setVisibility(View.VISIBLE);
}
}

Expand Down Expand Up @@ -460,6 +460,7 @@ protected void onNext() {
if (AuthType.EXTERNAL == authType) {
clientCertificateAlias = mClientCertificateSpinner.getAlias();
} else {
clientCertificateAlias = mClientCertificateSpinner.getAlias();
password = mPasswordView.getText().toString();
}
}
Expand Down