From 03d8e55d1eb6b25068a6ed821c19d30818ff7333 Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Tue, 24 Oct 2023 12:46:37 +0100 Subject: [PATCH] Use java.text.Normalizer directly into Jasypt substitutions instead of using reflection (#181) --- .../jasypt/runtime/JasyptSubstitutions.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/jasypt/runtime/src/main/java/io/quarkus/config/jasypt/runtime/JasyptSubstitutions.java b/jasypt/runtime/src/main/java/io/quarkus/config/jasypt/runtime/JasyptSubstitutions.java index 8032753..3d85f58 100644 --- a/jasypt/runtime/src/main/java/io/quarkus/config/jasypt/runtime/JasyptSubstitutions.java +++ b/jasypt/runtime/src/main/java/io/quarkus/config/jasypt/runtime/JasyptSubstitutions.java @@ -19,18 +19,16 @@ public class JasyptSubstitutions { @TargetClass(Normalizer.class) static final class Target_Normalizer { - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias) - private static Boolean useIcuNormalizer; - - @Substitute - static void initializeIcu4j() throws ClassNotFoundException { - useIcuNormalizer = Boolean.FALSE; - } - @Substitute - static char[] normalizeWithIcu4j(final char[] message) { - throw new UnsupportedOperationException(); + public static char[] normalizeToNfc(final char[] message) { + final String messageStr = new String(message); + final String result; + try { + result = java.text.Normalizer.normalize(messageStr, java.text.Normalizer.Form.NFC); + } catch (final Exception e) { + throw new EncryptionInitializationException("Could not perform a valid UNICODE normalization", e); + } + return result.toCharArray(); } }