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

[ELY-1311] - Translate password before obtaining clear password spec #930

Merged
merged 1 commit into from
Jul 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

Expand Down Expand Up @@ -92,8 +93,7 @@ protected PasswordAuthentication getPasswordAuthentication() {
return null;
}
final PasswordFactory factory = PasswordFactory.getInstance(twoWayPassword.getAlgorithm(), client.getProviderSupplier(authenticationConfiguration));
final ClearPasswordSpec keySpec = factory.getKeySpec(twoWayPassword, ClearPasswordSpec.class);
password = keySpec.getEncodedPassword();
password = factory.getKeySpec(factory.translate(twoWayPassword), ClearPasswordSpec.class).getEncodedPassword();
} catch (UnsupportedCallbackException e) {
if (e.getCallback() == credentialCallback) {
// try again with a password callback
Expand All @@ -115,6 +115,9 @@ protected PasswordAuthentication getPasswordAuthentication() {
} catch (InvalidKeySpecException e){
log.trace("InvalidKeySpecException getting ClearPasswordSpec:", e);
return null;
} catch (InvalidKeyException e) {
log.trace("InvalidKeyException getting ClearPasswordSpec:", e);
return null;
}
final String name = nameCallback.getName();
if (name == null || password == null) return null;
Expand Down