You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2023/02/06 03:44:43 UTC

[cxf] branch 3.4.x-fixes updated (871c9a875b -> 52a574a17e)

This is an automated email from the ASF dual-hosted git repository.

reta pushed a change to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


    from 871c9a875b Bump plexus-utils from 3.4.2 to 3.5.0 (#1109)
     new 6dcdaa89db Update maven-processor-plugin to 4.5-jdk8
     new 52a574a17e Fix Jwe compression (#1106)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/cxf/common/util/CompressionUtils.java   |  2 +-
 parent/pom.xml                                     |  2 +-
 .../apache/cxf/rt/security/crypto/CryptoUtils.java |  4 +--
 .../cxf/rt/security/crypto/CryptoUtilsTest.java    | 41 +++++++++++-----------
 4 files changed, 24 insertions(+), 25 deletions(-)
 copy core/src/test/java/org/apache/cxf/attachment/Rfc5987UtilTest.java => rt/security/src/test/java/org/apache/cxf/rt/security/crypto/CryptoUtilsTest.java (50%)


[cxf] 01/02: Update maven-processor-plugin to 4.5-jdk8

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 6dcdaa89dbb725af582d146d532d434d91d90ccf
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sun Feb 5 13:17:33 2023 -0500

    Update maven-processor-plugin to 4.5-jdk8
    
    (cherry picked from commit 7c3a6ac48c7772983f7047b294b320e3ff8e013b)
---
 parent/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index 359538efcf..1b5d56e615 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -578,7 +578,7 @@
                 <plugin>
                     <groupId>org.bsc.maven</groupId>
                     <artifactId>maven-processor-plugin</artifactId>
-                    <version>3.3.3</version> 
+                    <version>4.5-jdk8</version>
                 </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>


[cxf] 02/02: Fix Jwe compression (#1106)

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 52a574a17e94e3866ee80a4a58f5bb831a915781
Author: Egor Puzanov <ep...@users.noreply.github.com>
AuthorDate: Sun Feb 5 17:42:13 2023 +0100

    Fix Jwe compression (#1106)
    
    CXF-8816: Deflater and Inflater initialized with different 'nowrap' value
---
 .../apache/cxf/common/util/CompressionUtils.java   |  2 +-
 .../apache/cxf/rt/security/crypto/CryptoUtils.java |  4 +-
 .../cxf/rt/security/crypto/CryptoUtilsTest.java    | 56 ++++++++++++++++++++++
 3 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/common/util/CompressionUtils.java b/core/src/main/java/org/apache/cxf/common/util/CompressionUtils.java
index ea4ce34e7b..85477f2a19 100644
--- a/core/src/main/java/org/apache/cxf/common/util/CompressionUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/util/CompressionUtils.java
@@ -35,7 +35,7 @@ public final class CompressionUtils {
     }
     public static InputStream inflate(byte[] deflatedToken, boolean nowrap)
         throws DataFormatException {
-        Inflater inflater = new Inflater(true);
+        Inflater inflater = new Inflater(nowrap);
         inflater.setInput(deflatedToken);
 
         byte[] buffer = new byte[deflatedToken.length];
diff --git a/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java b/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java
index ce3203112a..388f00e9d5 100644
--- a/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java
+++ b/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java
@@ -545,7 +545,7 @@ public final class CryptoUtils {
                                       int mode)  throws SecurityException {
         boolean compressionSupported = keyProps != null && keyProps.isCompressionSupported();
         if (compressionSupported && mode == Cipher.ENCRYPT_MODE) {
-            bytes = CompressionUtils.deflate(bytes, false);
+            bytes = CompressionUtils.deflate(bytes, true);
         }
         try {
             Cipher c = initCipher(secretKey, keyProps, mode);
@@ -576,7 +576,7 @@ public final class CryptoUtils {
                 }
             }
             if (compressionSupported && mode == Cipher.DECRYPT_MODE) {
-                result = IOUtils.readBytesFromStream(CompressionUtils.inflate(result, false));
+                result = IOUtils.readBytesFromStream(CompressionUtils.inflate(result, true));
             }
             return result;
         } catch (Exception ex) {
diff --git a/rt/security/src/test/java/org/apache/cxf/rt/security/crypto/CryptoUtilsTest.java b/rt/security/src/test/java/org/apache/cxf/rt/security/crypto/CryptoUtilsTest.java
new file mode 100644
index 0000000000..646636684c
--- /dev/null
+++ b/rt/security/src/test/java/org/apache/cxf/rt/security/crypto/CryptoUtilsTest.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.rt.security.crypto;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.crypto.SecretKey;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.junit.Assert.assertArrayEquals;
+
+@RunWith(Parameterized.class)
+public class CryptoUtilsTest {
+    private final boolean compression;
+
+    public CryptoUtilsTest(boolean compression) {
+        this.compression = compression;
+    }
+
+    @Parameterized.Parameters
+    public static Collection<Object[]> compression() {
+        return Arrays.asList(new Object[][] {{true}, {false}});
+    }
+
+    @Test
+    public void testCompression() {
+        byte[] bytes = "testString".getBytes(StandardCharsets.UTF_8);
+        KeyProperties keyProps = new KeyProperties("AES");
+        keyProps.setCompressionSupported(compression);
+        SecretKey secretKey = CryptoUtils.getSecretKey(keyProps);
+        byte[] encryptedBytes = CryptoUtils.encryptBytes(bytes, secretKey, keyProps);
+        byte[] decryptedBytes = CryptoUtils.decryptBytes(encryptedBytes, secretKey, keyProps);
+        assertArrayEquals(bytes, decryptedBytes);
+    }
+}