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
The following commit(s) were added to refs/heads/3.6.x-fixes by this push:
new c5f2aefad12 Fixing backport error
c5f2aefad12 is described below
commit c5f2aefad12ac89c855144b5da6ee1b745fdbdba
Author: Colm O hEigeartaigh <[email protected]>
AuthorDate: Tue Dec 1 16:25:03 2026 +0000
Fixing backport error
---
.../oauth2/utils/crypto/ModelEncryptionSupport.java | 16 ++++++----------
1 file changed, 6 insertions(+), 10 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 8b08a040cf0..dfca5446f3b 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
@@ -21,7 +21,6 @@ package org.apache.cxf.rs.security.oauth2.utils.crypto;
import java.security.Key;
import java.util.HashMap;
-import java.util.HexFormat;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -47,7 +46,7 @@ public final class ModelEncryptionSupport {
public static final String SEP = "|";
private static final String ESCAPED_CHARS = "%|.,=[]{} ";
- private static final HexFormat HEX_FORMAT = HexFormat.of().withUpperCase();
+ private static final String HEX_DIGITS = "0123456789ABCDEF";
private static final int ACCESS_TOKEN_PARTS = 13;
private static final int REFRESH_TOKEN_PARTS = ACCESS_TOKEN_PARTS + 1;
private static final int CLIENT_PARTS = 14;
@@ -588,8 +587,7 @@ public final class ModelEncryptionSupport {
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (ESCAPED_CHARS.indexOf(c) >= 0) {
- // all escaped characters are ASCII, so a single byte is enough
- sb.append('%').append(HEX_FORMAT.toHexDigits((byte)c));
+ sb.append('%').append(HEX_DIGITS.charAt(c >>
4)).append(HEX_DIGITS.charAt(c & 0xF));
} else {
sb.append(c);
}
@@ -605,14 +603,12 @@ public final class ModelEncryptionSupport {
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c == '%') {
- if (i + 2 >= str.length()) {
+ int hi = i + 2 < str.length() ?
HEX_DIGITS.indexOf(str.charAt(i + 1)) : -1;
+ int lo = hi >= 0 ? HEX_DIGITS.indexOf(str.charAt(i + 2)) : -1;
+ if (lo < 0) {
throw new SecurityException("Invalid escape sequence");
}
- try {
- c = (char)HexFormat.fromHexDigits(str, i + 1, i + 3);
- } catch (NumberFormatException ex) {
- throw new SecurityException("Invalid escape sequence", ex);
- }
+ c = (char)((hi << 4) | lo);
i += 2;
}
sb.append(c);