in meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java [1688:1731]
public String apply(final String value) {
if (value.startsWith("decode:")) {
if (transformers.isEmpty()) { // lazy loading
transformers.put("Static3DES", new ValueTransformer() { // compatibility with tomee
private final SecretKeySpec key = new SecretKeySpec(new byte[]{
(byte) 0x76, (byte) 0x6F, (byte) 0xBA, (byte) 0x39, (byte) 0x31,
(byte) 0x2F, (byte) 0x0D, (byte) 0x4A, (byte) 0xA3, (byte) 0x90,
(byte) 0x55, (byte) 0xFE, (byte) 0x55, (byte) 0x65, (byte) 0x61,
(byte) 0x13, (byte) 0x34, (byte) 0x82, (byte) 0x12, (byte) 0x17,
(byte) 0xAC, (byte) 0x77, (byte) 0x39, (byte) 0x19}, "DESede");
@Override
public String name() {
return "Static3DES";
}
@Override
public String apply(final String encodedPassword) {
Objects.requireNonNull(encodedPassword, "value can't be null");
try {
final byte[] cipherText = Base64.getDecoder().decode(encodedPassword);
final Cipher cipher = Cipher.getInstance("DESede");
cipher.init(Cipher.DECRYPT_MODE, key);
return new String(cipher.doFinal(cipherText), StandardCharsets.UTF_8);
} catch (final Exception e) {
throw new IllegalArgumentException(e);
}
}
});
for (final ValueTransformer t : ServiceLoader.load(ValueTransformer.class)) {
transformers.put(t.name(), t);
}
}
final String substring = value.substring("decode:".length());
final int sep = substring.indexOf(':');
if (sep < 0) {
throw new IllegalArgumentException("No transformer algorithm for " + value);
}
final String algo = substring.substring(0, sep);
return Objects.requireNonNull(transformers.get(algo), "No ValueTransformer for value '" + value + "'").apply(substring.substring(sep + 1));
}
return value;
}