Skip to content

Commit

Permalink
Use java.text.Normalizer directly into Jasypt substitutions instead o…
Browse files Browse the repository at this point in the history
…f using reflection (#181)
  • Loading branch information
radcortez authored Oct 24, 2023
1 parent 7e1c0ef commit 03d8e55
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit 03d8e55

Please sign in to comment.