Add an "alias" to the password provider so that we can provide passwords for multiple aliases/certs
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/948fd800 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/948fd800 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/948fd800 Branch: refs/heads/master Commit: 948fd8001e710e5c42924324d8dc00cf41aa4ebd Parents: 95bf2ad Author: Colm O hEigeartaigh <cohei...@apache.org> Authored: Mon Oct 26 15:20:13 2015 +0000 Committer: Colm O hEigeartaigh <cohei...@apache.org> Committed: Mon Oct 26 16:21:07 2015 +0000 ---------------------------------------------------------------------- .../apache/cxf/rs/security/jose/common/KeyManagementUtils.java | 2 +- .../cxf/rs/security/jose/common/PrivateKeyPasswordProvider.java | 2 +- .../main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java | 3 ++- .../apache/cxf/systest/jaxrs/security/jwt/JAXRSJweJwsTest.java | 2 +- .../jaxrs/security/jwt/PrivateKeyPasswordProviderImpl.java | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/948fd800/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/KeyManagementUtils.java ---------------------------------------------------------------------- diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/KeyManagementUtils.java b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/KeyManagementUtils.java index 9207e65..57929c2 100644 --- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/KeyManagementUtils.java +++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/KeyManagementUtils.java @@ -146,7 +146,7 @@ public final class KeyManagementUtils { String keyPswd = props.getProperty(JoseConstants.RSSEC_KEY_PSWD); String theAlias = alias != null ? alias : getKeyId(m, props, JoseConstants.RSSEC_KEY_STORE_ALIAS, keyOper); - char[] keyPswdChars = provider != null ? provider.getPassword(props) + char[] keyPswdChars = provider != null ? provider.getPassword(theAlias, props) : keyPswd != null ? keyPswd.toCharArray() : null; return CryptoUtils.loadPrivateKey(keyStore, keyPswdChars, theAlias); } http://git-wip-us.apache.org/repos/asf/cxf/blob/948fd800/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/PrivateKeyPasswordProvider.java ---------------------------------------------------------------------- diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/PrivateKeyPasswordProvider.java b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/PrivateKeyPasswordProvider.java index fc58ee5..86fb0e5 100644 --- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/PrivateKeyPasswordProvider.java +++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/PrivateKeyPasswordProvider.java @@ -21,5 +21,5 @@ package org.apache.cxf.rs.security.jose.common; import java.util.Properties; public interface PrivateKeyPasswordProvider { - char[] getPassword(Properties storeProperties); + char[] getPassword(String alias, Properties storeProperties); } http://git-wip-us.apache.org/repos/asf/cxf/blob/948fd800/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java ---------------------------------------------------------------------- diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java index 60d3c83..b45b4bc 100644 --- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java +++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java @@ -266,7 +266,8 @@ public final class JwkUtils { public static JsonWebKeys loadJwkSet(Properties props, Bus bus, PrivateKeyPasswordProvider cb, JwkReaderWriter reader) { JweDecryptionProvider decryption = cb != null - ? new AesCbcHmacJweDecryption(new PbesHmacAesWrapKeyDecryptionAlgorithm(cb.getPassword(props))) : null; + ? new AesCbcHmacJweDecryption(new PbesHmacAesWrapKeyDecryptionAlgorithm( + cb.getPassword(null, props))) : null; return loadJwkSet(props, bus, decryption, reader); } public static JsonWebKeys loadJwkSet(Properties props, Bus bus, JweDecryptionProvider jwe, JwkReaderWriter reader) { http://git-wip-us.apache.org/repos/asf/cxf/blob/948fd800/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/JAXRSJweJwsTest.java ---------------------------------------------------------------------- diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/JAXRSJweJwsTest.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/JAXRSJweJwsTest.java index 21e6634..cfdfa43 100644 --- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/JAXRSJweJwsTest.java +++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/JAXRSJweJwsTest.java @@ -438,7 +438,7 @@ public class JAXRSJweJwsTest extends AbstractBusClientServerTestBase { this.password = password; } @Override - public char[] getPassword(Properties storeProperties) { + public char[] getPassword(String alias, Properties storeProperties) { return password.toCharArray(); } http://git-wip-us.apache.org/repos/asf/cxf/blob/948fd800/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/PrivateKeyPasswordProviderImpl.java ---------------------------------------------------------------------- diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/PrivateKeyPasswordProviderImpl.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/PrivateKeyPasswordProviderImpl.java index d9d7153..f01ea93 100644 --- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/PrivateKeyPasswordProviderImpl.java +++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/PrivateKeyPasswordProviderImpl.java @@ -32,7 +32,7 @@ public class PrivateKeyPasswordProviderImpl implements PrivateKeyPasswordProvide this.password = password; } @Override - public char[] getPassword(Properties storeProperties) { + public char[] getPassword(String alias, Properties storeProperties) { return password.toCharArray(); }