You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2015/08/25 11:06:46 UTC
cxf git commit: Adding a disabled JwsJson test with the unencoded
payload, to be enabled later
Repository: cxf
Updated Branches:
refs/heads/master 8b9009c27 -> f608dd750
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/f608dd75
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f608dd75
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f608dd75
Branch: refs/heads/master
Commit: f608dd7502d7851563f5681102210e2469f9849d
Parents: 8b9009c
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Tue Aug 25 10:06:25 2015 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Tue Aug 25 10:06:25 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/f608dd75/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/f608dd75/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();