cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: More updates to JwsCompactConsumer
Date Wed, 28 Oct 2015 15:51:10 GMT
Repository: cxf
Updated Branches:
  refs/heads/master ee6125fc8 -> 5f4c6f8f4


More updates to JwsCompactConsumer


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/5f4c6f8f
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5f4c6f8f
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5f4c6f8f

Branch: refs/heads/master
Commit: 5f4c6f8f45ec0bc5cbadaba7ea035f9130cfb4bd
Parents: ee6125f
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed Oct 28 15:50:47 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Oct 28 15:50:47 2015 +0000

----------------------------------------------------------------------
 .../cxf/rs/security/jose/jws/JwsCompactProducer.java    |  5 ++++-
 .../security/jose/jws/JwsCompactReaderWriterTest.java   | 12 ++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5f4c6f8f/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactProducer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactProducer.java
b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactProducer.java
index 5b4c760..8ed3dc6 100644
--- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactProducer.java
+++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactProducer.java
@@ -109,6 +109,9 @@ public class JwsCompactProducer {
     }
     
     public String signWith(JwsSignatureProvider signer) {
+        if (headers.getSignatureAlgorithm() == null) {
+            headers.setSignatureAlgorithm(signer.getAlgorithm());
+        }
         byte[] bytes = StringUtils.toBytesUTF8(getSigningInput());
         byte[] sig = signer.sign(getJwsHeaders(), bytes);
         return setSignatureBytes(sig);
@@ -135,7 +138,7 @@ public class JwsCompactProducer {
         return getJwsHeaders().getSignatureAlgorithm();
     }
     private void checkAlgorithm() {
-        if (getAlgorithm() == null) {
+        if (getAlgorithm() == null && PhaseInterceptorChain.getCurrentMessage() !=
null) {
             Message m = PhaseInterceptorChain.getCurrentMessage();
             Properties props = KeyManagementUtils.loadStoreProperties(m, false, 
                                                                       JoseConstants.RSSEC_SIGNATURE_OUT_PROPS,


http://git-wip-us.apache.org/repos/asf/cxf/blob/5f4c6f8f/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactReaderWriterTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactReaderWriterTest.java
b/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactReaderWriterTest.java
index de733c5..ed10a10 100644
--- a/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactReaderWriterTest.java
+++ b/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactReaderWriterTest.java
@@ -124,6 +124,18 @@ public class JwsCompactReaderWriterTest extends Assert {
             new HmacJwsSignatureVerifier(ENCODED_MAC_KEY, SignatureAlgorithm.HS256)));
     }
     @Test
+    public void testNoneSignature() throws Exception {
+        JwtClaims claims = new JwtClaims();
+        claims.setClaim("a", "b");
+        JwsJwtCompactProducer producer = new JwsJwtCompactProducer(claims);
+        producer.signWith(new NoneJwsSignatureProvider());
+                
+        JwsJwtCompactConsumer consumer = new JwsJwtCompactConsumer(producer.getSignedEncodedJws());
+        assertTrue(consumer.verifySignatureWith(new NoneJwsSignatureVerifier()));
+        JwtClaims claims2 = consumer.getJwtClaims();
+        assertEquals(claims, claims2);
+    }
+    @Test
     public void testWriteReadJwsUnsigned() throws Exception {
         JwsHeaders headers = new JwsHeaders(JoseType.JWT);
         headers.setSignatureAlgorithm(SignatureAlgorithm.NONE);


Mime
View raw message