cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6993] Adding a disabled test
Date Thu, 29 Dec 2016 15:45:12 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes feaececcc -> d83a99912


[CXF-6993] Adding a disabled test


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

Branch: refs/heads/3.1.x-fixes
Commit: d83a99912eda32fe6545bc01aaf30a0dd54797a7
Parents: feaecec
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Dec 29 15:42:43 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Dec 29 15:44:54 2016 +0000

----------------------------------------------------------------------
 .../security/jose/jwe/JweJsonConsumerTest.java  | 48 +++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d83a9991/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JweJsonConsumerTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JweJsonConsumerTest.java
b/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JweJsonConsumerTest.java
index f8c3026..1d073c6 100644
--- a/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JweJsonConsumerTest.java
+++ b/rt/rs/security/jose-parent/jose/src/test/java/org/apache/cxf/rs/security/jose/jwe/JweJsonConsumerTest.java
@@ -20,11 +20,14 @@ package org.apache.cxf.rs.security.jose.jwe;
 
 import java.security.Security;
 import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
 
 import javax.crypto.Cipher;
 import javax.crypto.SecretKey;
 
 import org.apache.cxf.common.util.Base64UrlUtility;
+import org.apache.cxf.common.util.StringUtils;
 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;
@@ -34,6 +37,7 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class JweJsonConsumerTest extends Assert {
@@ -131,13 +135,55 @@ public class JweJsonConsumerTest extends Assert {
     
     @Test
     public void testMultipleRecipients() {
+        doTestMultipleRecipients(JweJsonProducerTest.MULTIPLE_RECIPIENTS_OUTPUT);
+    }
+    @Test
+    @Ignore
+    public void testMultipleRecipientsAutogeneratedCek() {
+        final String text = "The true sign of intelligence is not knowledge but imagination.";
+        SecretKey wrapperKey1 = CryptoUtils.createSecretKeySpec(JweJsonProducerTest.WRAPPER_BYTES1,
"AES");
+        SecretKey wrapperKey2 = CryptoUtils.createSecretKeySpec(JweJsonProducerTest.WRAPPER_BYTES2,
"AES");
+        
+        JweHeaders protectedHeaders = new JweHeaders(ContentAlgorithm.A128GCM);
+        JweHeaders sharedUnprotectedHeaders = new JweHeaders();
+        sharedUnprotectedHeaders.setJsonWebKeysUrl("https://server.example.com/keys.jwks");
+        sharedUnprotectedHeaders.setKeyEncryptionAlgorithm(KeyAlgorithm.A128KW);
+        
+        List<JweEncryptionProvider> jweProviders = new LinkedList<JweEncryptionProvider>();
+        
+        KeyEncryptionProvider keyEncryption1 = 
+            JweUtils.getSecretKeyEncryptionAlgorithm(wrapperKey1, KeyAlgorithm.A128KW);
+        ContentEncryptionProvider contentEncryption = 
+            new AesGcmContentEncryptionAlgorithm(ContentAlgorithm.A128GCM);
+            
+        JweEncryptionProvider jwe1 = new JweEncryption(keyEncryption1, contentEncryption);
+        KeyEncryptionProvider keyEncryption2 = 
+            JweUtils.getSecretKeyEncryptionAlgorithm(wrapperKey2, KeyAlgorithm.A128KW);
+        JweEncryptionProvider jwe2 = new JweEncryption(keyEncryption2, contentEncryption);
+        jweProviders.add(jwe1);
+        jweProviders.add(jwe2);
+        
+        List<JweHeaders> perRecipientHeades = new LinkedList<JweHeaders>();
+        perRecipientHeades.add(new JweHeaders("key1"));
+        perRecipientHeades.add(new JweHeaders("key2"));
+        
+        JweJsonProducer p = new JweJsonProducer(protectedHeaders,
+                                                sharedUnprotectedHeaders,
+                                                StringUtils.toBytesUTF8(text),
+                                                StringUtils.toBytesUTF8(JweJsonProducerTest.EXTRA_AAD_SOURCE),
+                                                false);
+        
+        String jweJson = p.encryptWith(jweProviders, perRecipientHeades);
+        doTestMultipleRecipients(jweJson);
+    }
+    private void doTestMultipleRecipients(String jweJson) {
         final String text = "The true sign of intelligence is not knowledge but imagination.";
         
         SecretKey wrapperKey1 = CryptoUtils.createSecretKeySpec(JweJsonProducerTest.WRAPPER_BYTES1,

                                                                "AES");
         SecretKey wrapperKey2 = CryptoUtils.createSecretKeySpec(JweJsonProducerTest.WRAPPER_BYTES2,

             "AES");
-        JweJsonConsumer consumer = new JweJsonConsumer(JweJsonProducerTest.MULTIPLE_RECIPIENTS_OUTPUT);
+        JweJsonConsumer consumer = new JweJsonConsumer(jweJson);
         KeyAlgorithm keyAlgo = consumer.getSharedUnprotectedHeader().getKeyEncryptionAlgorithm();
         ContentAlgorithm ctAlgo = consumer.getProtectedHeader().getContentEncryptionAlgorithm();
         // Recipient 1


Mime
View raw message