cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Few more mior Jwe updates
Date Mon, 16 Feb 2015 16:30:41 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 5c2cd0ac3 -> 3da9230a9


Few more mior Jwe updates


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

Branch: refs/heads/3.0.x-fixes
Commit: 3da9230a972f7f70670a801a73e3d20475806327
Parents: 5c2cd0a
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Feb 16 16:25:26 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Feb 16 16:30:21 2015 +0000

----------------------------------------------------------------------
 .../cxf/rs/security/jose/jwe/AesCbcHmacJweDecryption.java   | 2 +-
 .../cxf/rs/security/jose/jwe/AesCbcHmacJweEncryption.java   | 8 ++++----
 .../java/org/apache/cxf/rs/security/jose/jwe/JweUtils.java  | 7 ++++++-
 .../cxf/rs/security/jose/jwe/JweJsonProducerTest.java       | 9 ++-------
 4 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/3da9230a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AesCbcHmacJweDecryption.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AesCbcHmacJweDecryption.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AesCbcHmacJweDecryption.java
index 6b902da..68c558f 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AesCbcHmacJweDecryption.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AesCbcHmacJweDecryption.java
@@ -25,7 +25,7 @@ import javax.crypto.spec.IvParameterSpec;
 
 import org.apache.cxf.rs.security.jose.jwa.Algorithm;
 
-public class AesCbcHmacJweDecryption extends AbstractJweDecryption {
+public class AesCbcHmacJweDecryption extends JweDecryption {
     private String supportedAlgo;
     public AesCbcHmacJweDecryption(KeyDecryptionAlgorithm keyDecryptionAlgo) {
         this(keyDecryptionAlgo, null);

http://git-wip-us.apache.org/repos/asf/cxf/blob/3da9230a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AesCbcHmacJweEncryption.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AesCbcHmacJweEncryption.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AesCbcHmacJweEncryption.java
index dc6ab44..a6a0dd2 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AesCbcHmacJweEncryption.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AesCbcHmacJweEncryption.java
@@ -29,7 +29,7 @@ import javax.crypto.spec.IvParameterSpec;
 import org.apache.cxf.common.util.crypto.HmacUtils;
 import org.apache.cxf.rs.security.jose.jwa.Algorithm;
 
-public class AesCbcHmacJweEncryption extends AbstractJweEncryption {
+public class AesCbcHmacJweEncryption extends JweEncryption {
     private static final Map<String, String> AES_HMAC_MAP;
     private static final Map<String, Integer> AES_CEK_SIZE_MAP;
     static {
@@ -49,9 +49,9 @@ public class AesCbcHmacJweEncryption extends AbstractJweEncryption {
     }
     public AesCbcHmacJweEncryption(String cekAlgoJwt, byte[] cek, 
                                    byte[] iv, KeyEncryptionAlgorithm keyEncryptionAlgorithm)
{
-        super(new AesCbcContentEncryptionAlgorithm(cek, iv, 
-                                                   validateCekAlgorithm(cekAlgoJwt)),
-              keyEncryptionAlgorithm);
+        super(keyEncryptionAlgorithm,
+              new AesCbcContentEncryptionAlgorithm(cek, iv, 
+                                                   validateCekAlgorithm(cekAlgoJwt)));
         
     }
     @Override

http://git-wip-us.apache.org/repos/asf/cxf/blob/3da9230a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweUtils.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweUtils.java
index c0a2b45..c5aba2a 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweUtils.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweUtils.java
@@ -216,8 +216,13 @@ public final class JweUtils {
                                  getContentEncryptionAlgorithm(key, key.getAlgorithm()));
     }
     public static JweEncryption getDirectKeyJweEncryption(SecretKey key, String algorithm)
{
-        return new JweEncryption(new DirectKeyEncryptionAlgorithm(), 
+        if (Algorithm.isAesCbcHmac(algorithm)) {
+            return new AesCbcHmacJweEncryption(algorithm, key.getEncoded(), 
+                                               null, new DirectKeyEncryptionAlgorithm());
+        } else {
+            return new JweEncryption(new DirectKeyEncryptionAlgorithm(), 
                                  getContentEncryptionAlgorithm(key, algorithm));
+        }
     }
     public static JweDecryption getDirectKeyJweDecryption(SecretKey key, String algorithm)
{
         return new JweDecryption(new DirectKeyDecryptionAlgorithm(key), 

http://git-wip-us.apache.org/repos/asf/cxf/blob/3da9230a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JweJsonProducerTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JweJsonProducerTest.java
b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JweJsonProducerTest.java
index 8c473c7..08b635d 100644
--- a/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JweJsonProducerTest.java
+++ b/rt/rs/security/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JweJsonProducerTest.java
@@ -231,13 +231,8 @@ public class JweJsonProducerTest extends Assert {
         JweEncryptionProvider jwe = null;
         if (wrapperKeyBytes == null) {
             headers.asMap().remove("alg");
-            if (Algorithm.isAesCbcHmac(contentEncryptionAlgo)) {
-                jwe = JweUtils.createJweEncryptionProvider(new DirectKeyEncryptionAlgorithm(),

-                                                           contentEncryptionAlgo, null);
-            } else {
-                SecretKey cekKey = CryptoUtils.createSecretKeySpec(cek, "AES");
-                jwe = JweUtils.getDirectKeyJweEncryption(cekKey, JoseConstants.A128GCM_ALGO);
-            }
+            SecretKey cekKey = CryptoUtils.createSecretKeySpec(cek, "AES");
+            jwe = JweUtils.getDirectKeyJweEncryption(cekKey, contentEncryptionAlgo);
         } else {
             SecretKey wrapperKey = CryptoUtils.createSecretKeySpec(wrapperKeyBytes, "AES");
             jwe = JweUtils.createJweEncryptionProvider(wrapperKey, headers);


Mime
View raw message