git commit: [CXF-5954] Adding a basic JWE system test where keys are loaded from JWK sets
Repository: cxf Updated Branches: refs/heads/master 9189ee95f - 279da3256 [CXF-5954] Adding a basic JWE system test where keys are loaded from JWK sets Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/279da325 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/279da325 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/279da325 Branch: refs/heads/master Commit: 279da32563c336e964a68836d3cb37abc09f38c0 Parents: 9189ee9 Author: Sergey Beryozkin sberyoz...@talend.com Authored: Fri Sep 5 13:26:03 2014 +0100 Committer: Sergey Beryozkin sberyoz...@talend.com Committed: Fri Sep 5 13:26:03 2014 +0100 -- .../cxf/rs/security/oauth2/jwk/JsonWebKey.java | 2 +- .../jaxrs/security/jwt/JAXRSJweJwsTest.java | 25 +++- .../cxf/systest/jaxrs/security/jwt/server.xml | 13 ++ .../systest/jaxrs/security/alice.jwk.properties | 21 .../systest/jaxrs/security/bob.jwk.properties | 24 +++ .../jaxrs/security/certs/jwkPrivateSet.txt | 9 +++ .../jaxrs/security/certs/jwkPublicSet.txt | 8 +++ 7 files changed, 100 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cxf/blob/279da325/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwk/JsonWebKey.java -- diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwk/JsonWebKey.java b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwk/JsonWebKey.java index bfb61eb..93c3a14 100644 --- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwk/JsonWebKey.java +++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwk/JsonWebKey.java @@ -166,7 +166,7 @@ public class JsonWebKey extends AbstractJwtObject { return CryptoUtils.getRSAPublicKey(encodedModulus, encodedPublicExponent); } public RSAPrivateKey toRSAPrivateKey() { -String encodedPublicExponent = (String)super.getValue(RSA_PUBLIC_EXP); +String encodedPublicExponent = (String)super.getValue(RSA_MODULUS); String encodedPrivateExponent = (String)super.getValue(RSA_PRIVATE_EXP); return CryptoUtils.getRSAPrivateKey(encodedPublicExponent, encodedPrivateExponent); } http://git-wip-us.apache.org/repos/asf/cxf/blob/279da325/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 8f937cc..d339a3e 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 @@ -77,7 +77,30 @@ public class JAXRSJweJwsTest extends AbstractBusClientServerTestBase { public static void unregisterBouncyCastleIfNeeded() throws Exception { Security.removeProvider(BouncyCastleProvider.class.getName()); } - +@Test +public void testJweJwk() throws Exception { +String address = https://localhost:; + PORT + /jwejwk; +JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); +SpringBusFactory bf = new SpringBusFactory(); +URL busFile = JAXRSJweJwsTest.class.getResource(client.xml); +Bus springBus = bf.createBus(busFile.toString()); +bean.setBus(springBus); +bean.setServiceClass(BookStore.class); +bean.setAddress(address); +ListObject providers = new LinkedListObject(); +JweWriterInterceptor jweWriter = new JweWriterInterceptor(); +jweWriter.setUseJweOutputStream(true); +providers.add(jweWriter); +providers.add(new JweClientResponseFilter()); +bean.setProviders(providers); +bean.getProperties(true).put(rs.security.encryption.out.properties, + org/apache/cxf/systest/jaxrs/security/bob.jwk.properties); +bean.getProperties(true).put(rs.security.encryption.in.properties, + org/apache/cxf/systest/jaxrs/security/alice.jwk.properties); +BookStore bs = bean.create(BookStore.class); +String text = bs.echoText(book); +assertEquals(book, text); +} @Test public void testJweRsaJwsRsa() throws Exception { String address = https://localhost:; + PORT + /jwejwsrsa;
git commit: [CXF-5954] Adding a basic JWE system test where keys are loaded from JWK sets
Repository: cxf Updated Branches: refs/heads/3.0.x-fixes 9cb7b0e97 - 2c731ed48 [CXF-5954] Adding a basic JWE system test where keys are loaded from JWK sets Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/2c731ed4 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/2c731ed4 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/2c731ed4 Branch: refs/heads/3.0.x-fixes Commit: 2c731ed48d85933f1881d85130a92c8040dedf82 Parents: 9cb7b0e Author: Sergey Beryozkin sberyoz...@talend.com Authored: Fri Sep 5 13:26:03 2014 +0100 Committer: Sergey Beryozkin sberyoz...@talend.com Committed: Fri Sep 5 13:29:43 2014 +0100 -- .../cxf/rs/security/oauth2/jwk/JsonWebKey.java | 2 +- .../jaxrs/security/jwt/JAXRSJweJwsTest.java | 25 +++- .../cxf/systest/jaxrs/security/jwt/server.xml | 13 ++ .../systest/jaxrs/security/alice.jwk.properties | 21 .../systest/jaxrs/security/bob.jwk.properties | 24 +++ .../jaxrs/security/certs/jwkPrivateSet.txt | 9 +++ .../jaxrs/security/certs/jwkPublicSet.txt | 8 +++ 7 files changed, 100 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cxf/blob/2c731ed4/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwk/JsonWebKey.java -- diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwk/JsonWebKey.java b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwk/JsonWebKey.java index bfb61eb..93c3a14 100644 --- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwk/JsonWebKey.java +++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwk/JsonWebKey.java @@ -166,7 +166,7 @@ public class JsonWebKey extends AbstractJwtObject { return CryptoUtils.getRSAPublicKey(encodedModulus, encodedPublicExponent); } public RSAPrivateKey toRSAPrivateKey() { -String encodedPublicExponent = (String)super.getValue(RSA_PUBLIC_EXP); +String encodedPublicExponent = (String)super.getValue(RSA_MODULUS); String encodedPrivateExponent = (String)super.getValue(RSA_PRIVATE_EXP); return CryptoUtils.getRSAPrivateKey(encodedPublicExponent, encodedPrivateExponent); } http://git-wip-us.apache.org/repos/asf/cxf/blob/2c731ed4/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 8f937cc..d339a3e 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 @@ -77,7 +77,30 @@ public class JAXRSJweJwsTest extends AbstractBusClientServerTestBase { public static void unregisterBouncyCastleIfNeeded() throws Exception { Security.removeProvider(BouncyCastleProvider.class.getName()); } - +@Test +public void testJweJwk() throws Exception { +String address = https://localhost:; + PORT + /jwejwk; +JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); +SpringBusFactory bf = new SpringBusFactory(); +URL busFile = JAXRSJweJwsTest.class.getResource(client.xml); +Bus springBus = bf.createBus(busFile.toString()); +bean.setBus(springBus); +bean.setServiceClass(BookStore.class); +bean.setAddress(address); +ListObject providers = new LinkedListObject(); +JweWriterInterceptor jweWriter = new JweWriterInterceptor(); +jweWriter.setUseJweOutputStream(true); +providers.add(jweWriter); +providers.add(new JweClientResponseFilter()); +bean.setProviders(providers); +bean.getProperties(true).put(rs.security.encryption.out.properties, + org/apache/cxf/systest/jaxrs/security/bob.jwk.properties); +bean.getProperties(true).put(rs.security.encryption.in.properties, + org/apache/cxf/systest/jaxrs/security/alice.jwk.properties); +BookStore bs = bean.create(BookStore.class); +String text = bs.echoText(book); +assertEquals(book, text); +} @Test public void testJweRsaJwsRsa() throws Exception { String address = https://localhost:; + PORT + /jwejwsrsa;