cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] cxf git commit: making JoseHeaders abstract and its setAlgorithm protected with lots of related changes
Date Wed, 22 Jul 2015 19:40:59 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 5d021211f -> f82e14c71


http://git-wip-us.apache.org/repos/asf/cxf/blob/f82e14c7/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/cookbook/JwsJoseCookBookTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/cookbook/JwsJoseCookBookTest.java
b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/cookbook/JwsJoseCookBookTest.java
index 2c2435d..f606beb 100644
--- a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/cookbook/JwsJoseCookBookTest.java
+++ b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/cookbook/JwsJoseCookBookTest.java
@@ -27,8 +27,6 @@ import javax.crypto.Cipher;
 import org.apache.cxf.common.util.Base64UrlUtility;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.provider.json.JsonMapObjectReaderWriter;
-import org.apache.cxf.rs.security.jose.JoseHeaders;
-import org.apache.cxf.rs.security.jose.JoseHeadersReaderWriter;
 import org.apache.cxf.rs.security.jose.jwa.AlgorithmUtils;
 import org.apache.cxf.rs.security.jose.jwa.SignatureAlgorithm;
 import org.apache.cxf.rs.security.jose.jwk.JsonWebKey;
@@ -37,6 +35,7 @@ import org.apache.cxf.rs.security.jose.jwk.JwkUtils;
 import org.apache.cxf.rs.security.jose.jws.EcDsaJwsSignatureProvider;
 import org.apache.cxf.rs.security.jose.jws.JwsCompactConsumer;
 import org.apache.cxf.rs.security.jose.jws.JwsCompactProducer;
+import org.apache.cxf.rs.security.jose.jws.JwsHeaders;
 import org.apache.cxf.rs.security.jose.jws.JwsJsonConsumer;
 import org.apache.cxf.rs.security.jose.jws.JwsJsonProducer;
 import org.apache.cxf.rs.security.jose.jws.JwsUtils;
@@ -354,10 +353,10 @@ public class JwsJoseCookBookTest {
     @Test
     public void testRSAv15Signature() throws Exception {
         JwsCompactProducer compactProducer = new JwsCompactProducer(PAYLOAD);
-        compactProducer.getJoseHeaders().setAlgorithm(AlgorithmUtils.RS_SHA_256_ALGO);
-        compactProducer.getJoseHeaders().setKeyId(RSA_KID_VALUE);
+        compactProducer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.RS256);
+        compactProducer.getJwsHeaders().setKeyId(RSA_KID_VALUE);
         JsonMapObjectReaderWriter reader = new JsonMapObjectReaderWriter();
-        assertEquals(reader.toJson(compactProducer.getJoseHeaders().asMap()), RSA_V1_5_SIGNATURE_PROTECTED_HEADER_JSON);
+        assertEquals(reader.toJson(compactProducer.getJwsHeaders().asMap()), RSA_V1_5_SIGNATURE_PROTECTED_HEADER_JSON);
         assertEquals(compactProducer.getUnsignedEncodedJws(),
                 RSA_V1_5_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD);
         JsonWebKeys jwks = readKeySet("cookbookPrivateSet.txt");
@@ -376,8 +375,8 @@ public class JwsJoseCookBookTest {
         JwsJsonProducer jsonProducer = new JwsJsonProducer(PAYLOAD);
         assertEquals(jsonProducer.getPlainPayload(), PAYLOAD);
         assertEquals(jsonProducer.getUnsignedEncodedPayload(), ENCODED_PAYLOAD);
-        JoseHeaders protectedHeader = new JoseHeaders();
-        protectedHeader.setAlgorithm(AlgorithmUtils.RS_SHA_256_ALGO);
+        JwsHeaders protectedHeader = new JwsHeaders();
+        protectedHeader.setSignatureAlgorithm(SignatureAlgorithm.RS256);
         protectedHeader.setKeyId(RSA_KID_VALUE);
         jsonProducer.signWith(JwsUtils.getSignatureProvider(rsaKey, 
                                                             SignatureAlgorithm.RS256), protectedHeader);
@@ -400,10 +399,10 @@ public class JwsJoseCookBookTest {
         }
 
         JwsCompactProducer compactProducer = new JwsCompactProducer(PAYLOAD);
-        compactProducer.getJoseHeaders().setAlgorithm(AlgorithmUtils.PS_SHA_384_ALGO);
-        compactProducer.getJoseHeaders().setKeyId(RSA_KID_VALUE);
+        compactProducer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.PS384);
+        compactProducer.getJwsHeaders().setKeyId(RSA_KID_VALUE);
         JsonMapObjectReaderWriter reader = new JsonMapObjectReaderWriter();
-        assertEquals(reader.toJson(compactProducer.getJoseHeaders().asMap()), RSA_PSS_SIGNATURE_PROTECTED_HEADER_JSON);
+        assertEquals(reader.toJson(compactProducer.getJwsHeaders().asMap()), RSA_PSS_SIGNATURE_PROTECTED_HEADER_JSON);
         assertEquals(compactProducer.getUnsignedEncodedJws(),
                 RSA_PSS_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD);
         JsonWebKeys jwks = readKeySet("cookbookPrivateSet.txt");
@@ -421,8 +420,8 @@ public class JwsJoseCookBookTest {
         JwsJsonProducer jsonProducer = new JwsJsonProducer(PAYLOAD);
         assertEquals(jsonProducer.getPlainPayload(), PAYLOAD);
         assertEquals(jsonProducer.getUnsignedEncodedPayload(), ENCODED_PAYLOAD);
-        JoseHeaders protectedHeader = new JoseHeaders();
-        protectedHeader.setAlgorithm(AlgorithmUtils.PS_SHA_384_ALGO);
+        JwsHeaders protectedHeader = new JwsHeaders();
+        protectedHeader.setSignatureAlgorithm(SignatureAlgorithm.PS384);
         protectedHeader.setKeyId(RSA_KID_VALUE);
         jsonProducer.signWith(JwsUtils.getSignatureProvider(rsaKey, SignatureAlgorithm.PS384),
protectedHeader);
         assertEquals(jsonProducer.getJwsJsonSignedDocument().length(), RSA_PSS_JSON_GENERAL_SERIALIZATION.length());
@@ -447,10 +446,10 @@ public class JwsJoseCookBookTest {
         }
         try {
             JwsCompactProducer compactProducer = new JwsCompactProducer(PAYLOAD);
-            compactProducer.getJoseHeaders().setAlgorithm(AlgorithmUtils.ES_SHA_512_ALGO);
-            compactProducer.getJoseHeaders().setKeyId(ECDSA_KID_VALUE);
+            compactProducer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.ES512);
+            compactProducer.getJwsHeaders().setKeyId(ECDSA_KID_VALUE);
             JsonMapObjectReaderWriter reader = new JsonMapObjectReaderWriter();
-            assertEquals(reader.toJson(compactProducer.getJoseHeaders().asMap()), 
+            assertEquals(reader.toJson(compactProducer.getJwsHeaders().asMap()), 
                          ECDSA_SIGNATURE_PROTECTED_HEADER_JSON);
             assertEquals(compactProducer.getUnsignedEncodedJws(),
                     ECSDA_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD);
@@ -475,10 +474,10 @@ public class JwsJoseCookBookTest {
     @Test
     public void testHMACSignature() throws Exception {
         JwsCompactProducer compactProducer = new JwsCompactProducer(PAYLOAD);
-        compactProducer.getJoseHeaders().setAlgorithm(AlgorithmUtils.HMAC_SHA_256_ALGO);
-        compactProducer.getJoseHeaders().setKeyId(HMAC_KID_VALUE);
+        compactProducer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.HS256);
+        compactProducer.getJwsHeaders().setKeyId(HMAC_KID_VALUE);
         JsonMapObjectReaderWriter reader = new JsonMapObjectReaderWriter();
-        assertEquals(reader.toJson(compactProducer.getJoseHeaders().asMap()), HMAC_SIGNATURE_PROTECTED_HEADER_JSON);
+        assertEquals(reader.toJson(compactProducer.getJwsHeaders().asMap()), HMAC_SIGNATURE_PROTECTED_HEADER_JSON);
         assertEquals(compactProducer.getUnsignedEncodedJws(),
                 HMAC_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD);
         JsonWebKeys jwks = readKeySet("cookbookSecretSet.txt");
@@ -493,8 +492,8 @@ public class JwsJoseCookBookTest {
         JwsJsonProducer jsonProducer = new JwsJsonProducer(PAYLOAD);
         assertEquals(jsonProducer.getPlainPayload(), PAYLOAD);
         assertEquals(jsonProducer.getUnsignedEncodedPayload(), ENCODED_PAYLOAD);
-        JoseHeaders protectedHeader = new JoseHeaders();
-        protectedHeader.setAlgorithm(AlgorithmUtils.HMAC_SHA_256_ALGO);
+        JwsHeaders protectedHeader = new JwsHeaders();
+        protectedHeader.setSignatureAlgorithm(SignatureAlgorithm.HS256);
         protectedHeader.setKeyId(HMAC_KID_VALUE);
         jsonProducer.signWith(JwsUtils.getSignatureProvider(key, SignatureAlgorithm.HS256),
protectedHeader);
         assertEquals(jsonProducer.getJwsJsonSignedDocument(), HMAC_JSON_GENERAL_SERIALIZATION);
@@ -510,10 +509,10 @@ public class JwsJoseCookBookTest {
     @Test
     public void testDetachedHMACSignature() throws Exception {
         JwsCompactProducer compactProducer = new JwsCompactProducer(PAYLOAD);
-        compactProducer.getJoseHeaders().setAlgorithm(AlgorithmUtils.HMAC_SHA_256_ALGO);
-        compactProducer.getJoseHeaders().setKeyId(HMAC_KID_VALUE);
+        compactProducer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.HS256);
+        compactProducer.getJwsHeaders().setKeyId(HMAC_KID_VALUE);
         JsonMapObjectReaderWriter reader = new JsonMapObjectReaderWriter();
-        assertEquals(reader.toJson(compactProducer.getJoseHeaders().asMap()), HMAC_SIGNATURE_PROTECTED_HEADER_JSON);
+        assertEquals(reader.toJson(compactProducer.getJwsHeaders().asMap()), HMAC_SIGNATURE_PROTECTED_HEADER_JSON);
         assertEquals(compactProducer.getUnsignedEncodedJws(),
                 HMAC_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD);
         JsonWebKeys jwks = readKeySet("cookbookSecretSet.txt");
@@ -528,8 +527,8 @@ public class JwsJoseCookBookTest {
         JwsJsonProducer jsonProducer = new JwsJsonProducer(PAYLOAD);
         assertEquals(jsonProducer.getPlainPayload(), PAYLOAD);
         assertEquals(jsonProducer.getUnsignedEncodedPayload(), ENCODED_PAYLOAD);
-        JoseHeaders protectedHeader = new JoseHeaders();
-        protectedHeader.setAlgorithm(AlgorithmUtils.HMAC_SHA_256_ALGO);
+        JwsHeaders protectedHeader = new JwsHeaders();
+        protectedHeader.setSignatureAlgorithm(SignatureAlgorithm.HS256);
         protectedHeader.setKeyId(HMAC_KID_VALUE);
         jsonProducer.signWith(JwsUtils.getSignatureProvider(key, SignatureAlgorithm.HS256),
protectedHeader);
         assertEquals(jsonProducer.getJwsJsonSignedDocument(true), HMAC_DETACHED_JSON_GENERAL_SERIALIZATION);
@@ -548,9 +547,9 @@ public class JwsJoseCookBookTest {
         JwsJsonProducer jsonProducer = new JwsJsonProducer(PAYLOAD);
         assertEquals(jsonProducer.getPlainPayload(), PAYLOAD);
         assertEquals(jsonProducer.getUnsignedEncodedPayload(), ENCODED_PAYLOAD);
-        JoseHeaders protectedHeader = new JoseHeaders();
-        protectedHeader.setAlgorithm(AlgorithmUtils.HMAC_SHA_256_ALGO);
-        JoseHeaders unprotectedHeader = new JoseHeaders();
+        JwsHeaders protectedHeader = new JwsHeaders();
+        protectedHeader.setSignatureAlgorithm(SignatureAlgorithm.HS256);
+        JwsHeaders unprotectedHeader = new JwsHeaders();
         unprotectedHeader.setKeyId(HMAC_KID_VALUE);
         JsonWebKeys jwks = readKeySet("cookbookSecretSet.txt");
         List<JsonWebKey> keys = jwks.getKeys();
@@ -576,8 +575,8 @@ public class JwsJoseCookBookTest {
         JwsJsonProducer jsonProducer = new JwsJsonProducer(PAYLOAD);
         assertEquals(jsonProducer.getPlainPayload(), PAYLOAD);
         assertEquals(jsonProducer.getUnsignedEncodedPayload(), ENCODED_PAYLOAD);
-        JoseHeaders unprotectedHeader = new JoseHeaders();
-        unprotectedHeader.setAlgorithm(AlgorithmUtils.HMAC_SHA_256_ALGO);
+        JwsHeaders unprotectedHeader = new JwsHeaders();
+        unprotectedHeader.setSignatureAlgorithm(SignatureAlgorithm.HS256);
         unprotectedHeader.setKeyId(HMAC_KID_VALUE);
         JsonWebKeys jwks = readKeySet("cookbookSecretSet.txt");
         List<JsonWebKey> keys = jwks.getKeys();
@@ -609,9 +608,9 @@ public class JwsJoseCookBookTest {
             JwsJsonProducer jsonProducer = new JwsJsonProducer(PAYLOAD);
             assertEquals(jsonProducer.getPlainPayload(), PAYLOAD);
             assertEquals(jsonProducer.getUnsignedEncodedPayload(), ENCODED_PAYLOAD);
-            JoseHeaders firstSignerProtectedHeader = new JoseHeaders();
-            firstSignerProtectedHeader.setAlgorithm(AlgorithmUtils.RS_SHA_256_ALGO);
-            JoseHeaders firstSignerUnprotectedHeader = new JoseHeaders();
+            JwsHeaders firstSignerProtectedHeader = new JwsHeaders();
+            firstSignerProtectedHeader.setSignatureAlgorithm(SignatureAlgorithm.RS256);
+            JwsHeaders firstSignerUnprotectedHeader = new JwsHeaders();
             firstSignerUnprotectedHeader.setKeyId(RSA_KID_VALUE);
             JsonWebKeys jwks = readKeySet("cookbookPrivateSet.txt");
             List<JsonWebKey> keys = jwks.getKeys();
@@ -621,20 +620,20 @@ public class JwsJoseCookBookTest {
             assertEquals(jsonProducer.getSignatureEntries().get(0).toJson(),
                     FIRST_SIGNATURE_ENTRY_MULTIPLE_SIGNATURES);
 
-            JoseHeaders secondSignerUnprotectedHeader = new JoseHeaders();
-            secondSignerUnprotectedHeader.setAlgorithm(AlgorithmUtils.ES_SHA_512_ALGO);
+            JwsHeaders secondSignerUnprotectedHeader = new JwsHeaders();
+            secondSignerUnprotectedHeader.setSignatureAlgorithm(SignatureAlgorithm.ES512);
             secondSignerUnprotectedHeader.setKeyId(ECDSA_KID_VALUE);
             JsonWebKey ecKey = keys.get(0);
             jsonProducer.signWith(JwsUtils.getSignatureProvider(ecKey, SignatureAlgorithm.ES512),
                     null, secondSignerUnprotectedHeader);
-            assertEquals(new JoseHeadersReaderWriter().toJson(
+            assertEquals(new JsonMapObjectReaderWriter().toJson(
                 jsonProducer.getSignatureEntries().get(1).getUnprotectedHeader()),
                     SECOND_SIGNATURE_UNPROTECTED_HEADER_MULTIPLE_SIGNATURES);
             assertEquals(jsonProducer.getSignatureEntries().get(1).toJson().length(),
                     SECOND_SIGNATURE_ENTRY_MULTIPLE_SIGNATURES.length());
 
-            JoseHeaders thirdSignerProtectedHeader = new JoseHeaders();
-            thirdSignerProtectedHeader.setAlgorithm(AlgorithmUtils.HMAC_SHA_256_ALGO);
+            JwsHeaders thirdSignerProtectedHeader = new JwsHeaders();
+            thirdSignerProtectedHeader.setSignatureAlgorithm(SignatureAlgorithm.HS256);
             thirdSignerProtectedHeader.setKeyId(HMAC_KID_VALUE);
             JsonWebKeys secretJwks = readKeySet("cookbookSecretSet.txt");
             List<JsonWebKey> secretKeys = secretJwks.getKeys();

http://git-wip-us.apache.org/repos/asf/cxf/blob/f82e14c7/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JwePbeHmacAesWrapTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JwePbeHmacAesWrapTest.java
b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JwePbeHmacAesWrapTest.java
index cdbde8a..8c8ef41 100644
--- a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JwePbeHmacAesWrapTest.java
+++ b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JwePbeHmacAesWrapTest.java
@@ -20,7 +20,6 @@ package org.apache.cxf.rs.security.jose.jwe;
 
 import java.security.Security;
 
-import org.apache.cxf.rs.security.jose.jwa.AlgorithmUtils;
 import org.apache.cxf.rs.security.jose.jwa.ContentAlgorithm;
 import org.apache.cxf.rs.security.jose.jwa.KeyAlgorithm;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
@@ -68,7 +67,7 @@ public class JwePbeHmacAesWrapTest extends Assert {
         }
         final String specPlainText = "Live long and prosper.";
         JweHeaders headers = new JweHeaders();
-        headers.setAlgorithm(AlgorithmUtils.PBES2_HS256_A128KW_ALGO);
+        headers.setKeyEncryptionAlgorithm(KeyAlgorithm.PBES2_HS256_A128KW);
         headers.setContentEncryptionAlgorithm(ContentAlgorithm.A128GCM);
         final String password = "Thus from my lips, by yours, my sin is purged."; 
         KeyEncryptionProvider keyEncryption = 

http://git-wip-us.apache.org/repos/asf/cxf/blob/f82e14c7/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactHeaderTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactHeaderTest.java
b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactHeaderTest.java
index 4894811..39c6d3c 100644
--- a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactHeaderTest.java
+++ b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactHeaderTest.java
@@ -21,7 +21,6 @@ package org.apache.cxf.rs.security.jose.jws;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.cxf.rs.security.jose.jwa.AlgorithmUtils;
 import org.apache.cxf.rs.security.jose.jwa.SignatureAlgorithm;
 
 import org.junit.Assert;
@@ -166,10 +165,10 @@ public class JwsCompactHeaderTest extends Assert {
         String criticalValue2 = "criticalValue2";
         String criticalValue3 = "criticalValue3";
         JwsCompactProducer producer = new JwsCompactProducer(payload);
-        producer.getJoseHeaders().setAlgorithm(AlgorithmUtils.HMAC_SHA_512_ALGO);
+        producer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.HS512);
         List<String> criticalHeader = new ArrayList<String>();
         criticalHeader.add(criticalParameter1);
-        producer.getJoseHeaders().setCritical(criticalHeader);
+        producer.getJwsHeaders().setCritical(criticalHeader);
         producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY, SignatureAlgorithm.HS256));
         String signedJws = producer.getSignedEncodedJws();
         JwsCompactConsumer consumer = new JwsCompactConsumer(signedJws);
@@ -178,11 +177,11 @@ public class JwsCompactHeaderTest extends Assert {
         criticalHeader.add(criticalParameter2);
         criticalHeader.add(criticalParameter3);
         producer = new JwsCompactProducer(payload);
-        producer.getJoseHeaders().setAlgorithm(AlgorithmUtils.HMAC_SHA_512_ALGO);
-        producer.getJoseHeaders().setCritical(criticalHeader);
-        producer.getJoseHeaders().setHeader(criticalParameter1, criticalValue1);
-        producer.getJoseHeaders().setHeader(criticalParameter2, criticalValue2);
-        producer.getJoseHeaders().setHeader(criticalParameter3, criticalValue3);
+        producer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.HS512);
+        producer.getJwsHeaders().setCritical(criticalHeader);
+        producer.getJwsHeaders().setHeader(criticalParameter1, criticalValue1);
+        producer.getJwsHeaders().setHeader(criticalParameter2, criticalValue2);
+        producer.getJwsHeaders().setHeader(criticalParameter3, criticalValue3);
         producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY, SignatureAlgorithm.HS256));
         signedJws = producer.getSignedEncodedJws();
         consumer = new JwsCompactConsumer(signedJws);
@@ -192,9 +191,9 @@ public class JwsCompactHeaderTest extends Assert {
         criticalHeader.add(criticalParameter);
         criticalHeader.add(criticalParameter);
         producer = new JwsCompactProducer(payload);
-        producer.getJoseHeaders().setAlgorithm(AlgorithmUtils.HMAC_SHA_512_ALGO);
-        producer.getJoseHeaders().setHeader(criticalParameter, criticalValue);
-        producer.getJoseHeaders().setCritical(criticalHeader);
+        producer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.HS512);
+        producer.getJwsHeaders().setHeader(criticalParameter, criticalValue);
+        producer.getJwsHeaders().setCritical(criticalHeader);
         producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY, SignatureAlgorithm.HS256));
         signedJws = producer.getSignedEncodedJws();
         consumer = new JwsCompactConsumer(signedJws);

http://git-wip-us.apache.org/repos/asf/cxf/blob/f82e14c7/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactReaderWriterTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactReaderWriterTest.java
b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactReaderWriterTest.java
index d2367b1..49bacd9 100644
--- a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactReaderWriterTest.java
+++ b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jws/JwsCompactReaderWriterTest.java
@@ -31,7 +31,6 @@ import java.util.Map;
 import org.apache.cxf.rs.security.jose.JoseConstants;
 import org.apache.cxf.rs.security.jose.JoseHeaders;
 import org.apache.cxf.rs.security.jose.JoseType;
-import org.apache.cxf.rs.security.jose.jwa.AlgorithmUtils;
 import org.apache.cxf.rs.security.jose.jwa.SignatureAlgorithm;
 import org.apache.cxf.rs.security.jose.jwk.JsonWebKey;
 import org.apache.cxf.rs.security.jose.jwk.KeyOperation;
@@ -97,9 +96,9 @@ public class JwsCompactReaderWriterTest extends Assert {
         "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0";
     @Test
     public void testWriteJwsSignedByMacSpecExample() throws Exception {
-        JoseHeaders headers = new JoseHeaders();
+        JwsHeaders headers = new JwsHeaders();
         headers.setType(JoseType.JWT);
-        headers.setAlgorithm(SignatureAlgorithm.HS256.getJwaName());
+        headers.setSignatureAlgorithm(SignatureAlgorithm.HS256);
         JwsCompactProducer jws = initSpecJwtTokenWriter(headers);
         jws.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY, SignatureAlgorithm.HS256));
         
@@ -109,8 +108,8 @@ public class JwsCompactReaderWriterTest extends Assert {
     
     @Test
     public void testWriteReadJwsUnsigned() throws Exception {
-        JoseHeaders headers = new JoseHeaders(JoseType.JWT);
-        headers.setAlgorithm(AlgorithmUtils.PLAIN_TEXT_ALGO);
+        JwsHeaders headers = new JwsHeaders(JoseType.JWT);
+        headers.setSignatureAlgorithm(SignatureAlgorithm.NONE);
         
         JwtClaims claims = new JwtClaims();
         claims.setIssuer("https://jwt-idp.example.com");
@@ -136,9 +135,9 @@ public class JwsCompactReaderWriterTest extends Assert {
         assertTrue(jws.verifySignatureWith(new HmacJwsSignatureVerifier(ENCODED_MAC_KEY,
                                                                         SignatureAlgorithm.HS256)));
         JwtToken token = jws.getJwtToken();
-        JoseHeaders headers = token.getHeaders();
+        JwsHeaders headers = new JwsHeaders(token.getHeaders());
         assertEquals(JoseType.JWT, headers.getType());
-        assertEquals(SignatureAlgorithm.HS256.getJwaName(), headers.getAlgorithm());
+        assertEquals(SignatureAlgorithm.HS256, headers.getSignatureAlgorithm());
         validateSpecClaim(token.getClaims());
     }
     
@@ -184,9 +183,9 @@ public class JwsCompactReaderWriterTest extends Assert {
         assertTrue(jws.verifySignatureWith(new HmacJwsSignatureVerifier(ENCODED_MAC_KEY,
                                                                         SignatureAlgorithm.HS256)));
         JwtToken token = jws.getJwtToken();
-        JoseHeaders headers = token.getHeaders();
+        JwsHeaders headers = new JwsHeaders(token.getHeaders());
         assertEquals(JoseType.JWT, headers.getType());
-        assertEquals(SignatureAlgorithm.HS256.getJwaName(), headers.getAlgorithm());
+        assertEquals(SignatureAlgorithm.HS256, headers.getSignatureAlgorithm());
         
         JsonWebKey key = headers.getJsonWebKey();
         assertEquals(KeyType.OCTET, key.getKeyType());
@@ -206,8 +205,8 @@ public class JwsCompactReaderWriterTest extends Assert {
     
     @Test
     public void testWriteJwsSignedByPrivateKey() throws Exception {
-        JoseHeaders headers = new JoseHeaders();
-        headers.setAlgorithm(SignatureAlgorithm.RS256.getJwaName());
+        JwsHeaders headers = new JwsHeaders();
+        headers.setSignatureAlgorithm(SignatureAlgorithm.RS256);
         JwsCompactProducer jws = initSpecJwtTokenWriter(headers);
         PrivateKey key = CryptoUtils.getRSAPrivateKey(RSA_MODULUS_ENCODED, RSA_PRIVATE_EXPONENT_ENCODED);
         jws.signWith(new PrivateKeyJwsSignatureProvider(key, SignatureAlgorithm.RS256));
@@ -218,8 +217,8 @@ public class JwsCompactReaderWriterTest extends Assert {
     public void testJwsPsSha() throws Exception {
         Security.addProvider(new BouncyCastleProvider());    
         try {
-            JoseHeaders outHeaders = new JoseHeaders();
-            outHeaders.setAlgorithm(AlgorithmUtils.PS_SHA_256_ALGO);
+            JwsHeaders outHeaders = new JwsHeaders();
+            outHeaders.setSignatureAlgorithm(SignatureAlgorithm.PS256);
             JwsCompactProducer producer = initSpecJwtTokenWriter(outHeaders);
             PrivateKey privateKey = CryptoUtils.getRSAPrivateKey(RSA_MODULUS_ENCODED, RSA_PRIVATE_EXPONENT_ENCODED);
             String signed = producer.signWith(
@@ -229,8 +228,9 @@ public class JwsCompactReaderWriterTest extends Assert {
             RSAPublicKey key = CryptoUtils.getRSAPublicKey(RSA_MODULUS_ENCODED, RSA_PUBLIC_EXPONENT_ENCODED);
             assertTrue(jws.verifySignatureWith(new PublicKeyJwsSignatureVerifier(key, SignatureAlgorithm.PS256)));
             JwtToken token = jws.getJwtToken();
-            JoseHeaders inHeaders = token.getHeaders();
-            assertEquals(AlgorithmUtils.PS_SHA_256_ALGO, inHeaders.getAlgorithm());
+            JwsHeaders inHeaders = new JwsHeaders(token.getHeaders());
+            assertEquals(SignatureAlgorithm.PS256, 
+                         inHeaders.getSignatureAlgorithm());
             validateSpecClaim(token.getClaims());
         } finally {
             Security.removeProvider(BouncyCastleProvider.class.getName());
@@ -239,8 +239,8 @@ public class JwsCompactReaderWriterTest extends Assert {
     
     @Test
     public void testWriteReadJwsSignedByESPrivateKey() throws Exception {
-        JoseHeaders headers = new JoseHeaders();
-        headers.setAlgorithm(SignatureAlgorithm.ES256.getJwaName());
+        JwsHeaders headers = new JwsHeaders();
+        headers.setSignatureAlgorithm(SignatureAlgorithm.ES256);
         JwsCompactProducer jws = initSpecJwtTokenWriter(headers);
         ECPrivateKey privateKey = CryptoUtils.getECPrivateKey(JsonWebKey.EC_CURVE_P256,
                                                               EC_PRIVATE_KEY_ENCODED);
@@ -254,8 +254,8 @@ public class JwsCompactReaderWriterTest extends Assert {
         assertTrue(jwsConsumer.verifySignatureWith(new EcDsaJwsSignatureVerifier(publicKey,
                                                    SignatureAlgorithm.ES256)));
         JwtToken token = jwsConsumer.getJwtToken();
-        JoseHeaders headersReceived = token.getHeaders();
-        assertEquals(SignatureAlgorithm.ES256.getJwaName(), headersReceived.getAlgorithm());
+        JwsHeaders headersReceived = new JwsHeaders(token.getHeaders());
+        assertEquals(SignatureAlgorithm.ES256, headersReceived.getSignatureAlgorithm());
         validateSpecClaim(token.getClaims());
     }
     
@@ -265,8 +265,8 @@ public class JwsCompactReaderWriterTest extends Assert {
         RSAPublicKey key = CryptoUtils.getRSAPublicKey(RSA_MODULUS_ENCODED, RSA_PUBLIC_EXPONENT_ENCODED);
         assertTrue(jws.verifySignatureWith(new PublicKeyJwsSignatureVerifier(key, SignatureAlgorithm.RS256)));
         JwtToken token = jws.getJwtToken();
-        JoseHeaders headers = token.getHeaders();
-        assertEquals(SignatureAlgorithm.RS256.getJwaName(), headers.getAlgorithm());
+        JwsHeaders headers = new JwsHeaders(token.getHeaders());
+        assertEquals(SignatureAlgorithm.RS256, headers.getSignatureAlgorithm());
         validateSpecClaim(token.getClaims());
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/f82e14c7/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 00b8ed7..10742b2 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
@@ -17,8 +17,6 @@
  * under the License.
  */
 package org.apache.cxf.rs.security.jose.jws;
-import org.apache.cxf.rs.security.jose.JoseHeaders;
-import org.apache.cxf.rs.security.jose.jwa.AlgorithmUtils;
 import org.apache.cxf.rs.security.jose.jwa.SignatureAlgorithm;
 
 import org.junit.Assert;
@@ -72,8 +70,8 @@ public class JwsJsonProducerTest extends Assert {
     @Test
     public void testSignWithProtectedHeaderOnly() {
         JwsJsonProducer producer = new JwsJsonProducer(UNSIGNED_PLAIN_JSON_DOCUMENT);
-        JoseHeaders headerEntries = new JoseHeaders();
-        headerEntries.setAlgorithm(AlgorithmUtils.HMAC_SHA_256_ALGO);
+        JwsHeaders headerEntries = new JwsHeaders();
+        headerEntries.setSignatureAlgorithm(SignatureAlgorithm.HS256);
                
         producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY_1, SignatureAlgorithm.HS256),
                           headerEntries);
@@ -83,8 +81,8 @@ public class JwsJsonProducerTest extends Assert {
     @Test
     public void testSignWithProtectedHeaderOnlyFlat() {
         JwsJsonProducer producer = new JwsJsonProducer(UNSIGNED_PLAIN_JSON_DOCUMENT, true);
-        JoseHeaders headerEntries = new JoseHeaders();
-        headerEntries.setAlgorithm(AlgorithmUtils.HMAC_SHA_256_ALGO);
+        JwsHeaders headerEntries = new JwsHeaders();
+        headerEntries.setSignatureAlgorithm(SignatureAlgorithm.HS256);
                
         producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY_1, SignatureAlgorithm.HS256),
                           headerEntries);
@@ -94,8 +92,8 @@ public class JwsJsonProducerTest extends Assert {
     @Test
     public void testDualSignWithProtectedHeaderOnly() {
         JwsJsonProducer producer = new JwsJsonProducer(UNSIGNED_PLAIN_JSON_DOCUMENT);
-        JoseHeaders headerEntries = new JoseHeaders();
-        headerEntries.setAlgorithm(AlgorithmUtils.HMAC_SHA_256_ALGO);
+        JwsHeaders headerEntries = new JwsHeaders();
+        headerEntries.setSignatureAlgorithm(SignatureAlgorithm.HS256);
                
         producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY_1, SignatureAlgorithm.HS256),
                           headerEntries);


Mime
View raw message