This is an automated email from the ASF dual-hosted git repository. coheigea pushed a commit to branch 3.6.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 35ea3dab5547d972f39bc97443e94525196428ed Author: Colm O hEigeartaigh <[email protected]> AuthorDate: Tue Dec 1 16:03:20 2026 +0000 Recording .gitmergeinfo Changes --- .../utils/crypto/ModelEncryptionSupport.java | 5 --- .../oauth2/utils/crypto/CryptoUtilsTest.java | 50 ---------------------- 2 files changed, 55 deletions(-) diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/ModelEncryptionSupport.java b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/ModelEncryptionSupport.java index 5c31c024c3e..8b08a040cf0 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/ModelEncryptionSupport.java +++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/ModelEncryptionSupport.java @@ -20,7 +20,6 @@ package org.apache.cxf.rs.security.oauth2.utils.crypto; import java.security.Key; -import java.util.Arrays; import java.util.HashMap; import java.util.HexFormat; import java.util.LinkedList; @@ -54,10 +53,6 @@ public final class ModelEncryptionSupport { private static final int CLIENT_PARTS = 14; private static final int CODE_GRANT_PARTS = 10; - private static final String DEFAULT_TRANSFORMATION = "AES/GCM/NoPadding"; - private static final int DEFAULT_IV_SIZE = 12; - private static final int DEFAULT_AUTH_TAG_LENGTH = 128; - private ModelEncryptionSupport() { } diff --git a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtilsTest.java b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtilsTest.java index 008666328d5..a2794d13b4c 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtilsTest.java +++ b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtilsTest.java @@ -112,56 +112,6 @@ public class CryptoUtilsTest { compareAccessTokens(token, token2); } - @Test - public void testModelEncryptionDefaultIsNonDeterministic() throws Exception { - AccessTokenRegistration atr = prepareTokenRegistration(); - BearerAccessToken token = p.createAccessTokenInternal(atr); - SecretKey secretKey = CryptoUtils.getSecretKey("AES"); - - String encrypted1 = ModelEncryptionSupport.encryptAccessToken(token, secretKey); - String encrypted2 = ModelEncryptionSupport.encryptAccessToken(token, secretKey); - // AES/GCM with a random IV: encrypting the same token twice must not - // produce the same ciphertext (the old AES/ECB default was deterministic) - assertNotEquals(encrypted1, encrypted2); - - token.setTokenKey(encrypted1); - ServerAccessToken token2 = ModelEncryptionSupport.decryptAccessToken(p, encrypted1, secretKey); - compareAccessTokens(token, token2); - } - - @Test(expected = SecurityException.class) - public void testModelEncryptionDefaultRejectsTamperedToken() throws Exception { - AccessTokenRegistration atr = prepareTokenRegistration(); - BearerAccessToken token = p.createAccessTokenInternal(atr); - SecretKey secretKey = CryptoUtils.getSecretKey("AES"); - - String encrypted = ModelEncryptionSupport.encryptAccessToken(token, secretKey); - // flip one character of the ciphertext: authenticated encryption must reject it - char[] chars = encrypted.toCharArray(); - int pos = chars.length - 2; - chars[pos] = chars[pos] == 'A' ? 'B' : 'A'; - ModelEncryptionSupport.decryptAccessToken(p, new String(chars), secretKey); - } - - @Test - public void testModelEncryptionExplicitLegacyPropertiesRoundTrip() throws Exception { - AccessTokenRegistration atr = prepareTokenRegistration(); - BearerAccessToken token = p.createAccessTokenInternal(atr); - SecretKey secretKey = CryptoUtils.getSecretKey("AES"); - KeyProperties legacyProps = new KeyProperties("AES"); - - String encrypted = ModelEncryptionSupport.encryptAccessToken(token, secretKey, legacyProps); - token.setTokenKey(encrypted); - ServerAccessToken decrypted = ModelEncryptionSupport.decryptAccessToken( - p, encrypted, secretKey, legacyProps); - compareAccessTokens(token, decrypted); - - String encodedSecretKey = CryptoUtils.encodeSecretKey(secretKey); - ServerAccessToken decryptedWithEncodedKey = ModelEncryptionSupport.decryptAccessToken( - p, encrypted, encodedSecretKey, legacyProps); - compareAccessTokens(token, decryptedWithEncodedKey); - } - @Test public void testSubjectWithSeparatorCharactersRoundTrip() throws Exception { String[] logins = {"admin.x", "[email protected]", "bob. .[admin]", "a|b", "100%", "c=d,e{f}", " ", ""};
