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:53:23 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes e5ac7504f -> 553b11172


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/553b1117
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/553b1117
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/553b1117

Branch: refs/heads/3.0.x-fixes
Commit: 553b11172aed3c3575e6d4f5d9530f8484e21f80
Parents: e5ac750
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:53:02 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/553b1117/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/553b1117/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 7292a52..4624dd4 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
@@ -130,6 +130,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