cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Adding a disabled JwsJson test with the unencoded payload, to be enabled later
Date Wed, 26 Aug 2015 11:14:26 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes f18b8694d -> c7d8cac1b


Adding a disabled JwsJson test with the unencoded payload, to be enabled later


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

Branch: refs/heads/3.0.x-fixes
Commit: c7d8cac1b4e82c64f782a03addaf2cdaed9a0a62
Parents: f18b869
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Aug 25 10:06:25 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Aug 26 12:13:37 2015 +0100

----------------------------------------------------------------------
 .../cxf/rs/security/jose/jws/JwsHeaders.java    |  8 ++++++-
 .../security/jose/jws/JwsJsonProducerTest.java  | 22 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c7d8cac1/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsHeaders.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsHeaders.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsHeaders.java
index ea71ee7..6d80513 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsHeaders.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsHeaders.java
@@ -47,7 +47,7 @@ public class JwsHeaders extends JoseHeaders {
     private void init(SignatureAlgorithm sigAlgo) {
         setSignatureAlgorithm(sigAlgo);
     }
-
+    
     public void setSignatureAlgorithm(SignatureAlgorithm algo) {
         super.setAlgorithm(algo.getJwaName());
     }
@@ -56,4 +56,10 @@ public class JwsHeaders extends JoseHeaders {
         String algo = super.getAlgorithm();
         return algo == null ? null : SignatureAlgorithm.getAlgorithm(algo);
     }
+    public void setPayloadEncodingStatus(Boolean status) {
+        super.setProperty("b64", status);
+    }
+    public Boolean getPayloadEncodingStatus() {
+        return super.getBooleanProperty("b64");
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/c7d8cac1/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsJsonProducerTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsJsonProducerTest.java
b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsJsonProducerTest.java
index 10742b2..f3a24c8 100644
--- a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsJsonProducerTest.java
+++ b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsJsonProducerTest.java
@@ -20,6 +20,7 @@ package org.apache.cxf.rs.security.jose.jws;
 import org.apache.cxf.rs.security.jose.jwa.SignatureAlgorithm;
 
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class JwsJsonProducerTest extends Assert {
@@ -33,6 +34,8 @@ public class JwsJsonProducerTest extends Assert {
     public static final String UNSIGNED_PLAIN_JSON_DOCUMENT = "{"
                        + " \"from\": \"user\"," + " \"to\": \"developer\","
                        + " \"msg\": \"good job!\" " + "}";
+    
+    public static final String UNSIGNED_PLAIN_DOCUMENT = "$.02";
 
     public static final String UNSIGNED_PLAIN_JSON_DOCUMENT_AS_B64URL = "eyAiZnJvbSI6ICJ1c2VyIiwgInRvIjogI"
                        + "mRldmVsb3BlciIsICJtc2ciOiAiZ29vZCBqb2IhIiB9";
@@ -50,6 +53,11 @@ public class JwsJsonProducerTest extends Assert {
         + "\",\"protected\":\"eyJhbGciOiJIUzI1NiJ9\",\"signature\":"
         + "\"NNksREOsFCI1nUQEqzCe6XZFa-bRAge2XXMMAU2Jj2I\"}";
        
+    public static final String SIGNED_JWS_JSON_FLAT_DOCUMENT_2 = "{"
+        + "\"payload\":\"" + UNSIGNED_PLAIN_DOCUMENT + "\","
+        + "\"protected\":\"eyJhbGciOiJIUzI1NiIsImI2NCI6ZmFsc2V9\","
+        + "\"signature\":" + "\"GsyM6AQJbQHY8aQKCbZSPJHzMRWo3HKIlcDuXof7nqs\"}";
+    
     public static final String DUAL_SIGNED_JWS_JSON_DOCUMENT = "{"
                        + "\"payload\":\""
                        + UNSIGNED_PLAIN_JSON_DOCUMENT_AS_B64URL
@@ -79,6 +87,20 @@ public class JwsJsonProducerTest extends Assert {
                      producer.getJwsJsonSignedDocument());
     }
     @Test
+    @Ignore
+    public void testSignWithProtectedHeaderOnlyUnencodedPayload() {
+        JwsJsonProducer producer = new JwsJsonProducer(UNSIGNED_PLAIN_DOCUMENT, true);
+        JwsHeaders headers = new JwsHeaders();
+        headers.setSignatureAlgorithm(SignatureAlgorithm.HS256);
+        headers.setPayloadEncodingStatus(false);
+        
+               
+        producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY_1, SignatureAlgorithm.HS256),
+                          headers);
+        assertEquals(SIGNED_JWS_JSON_FLAT_DOCUMENT_2,
+                     producer.getJwsJsonSignedDocument());
+    }
+    @Test
     public void testSignWithProtectedHeaderOnlyFlat() {
         JwsJsonProducer producer = new JwsJsonProducer(UNSIGNED_PLAIN_JSON_DOCUMENT, true);
         JwsHeaders headerEntries = new JwsHeaders();


Mime
View raw message