I have a spring TextEncryptor defined like this
You can also do the following. Though this seems to have stopped working on the latest builds of Java 8.
Field field = Class.forName("javax.crypto.JceSecurity").getDeclaredField("isRestricted");
if (Boolean.TRUE.equals(field.get(null))) {
if (Modifier.isFinal(field.getModifiers())) {
Field modifiers = Field.class.getDeclaredField("modifiers");
modifiers.setAccessible(true);
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
}
field.setAccessible(true);
field.setBoolean(null, false); // isRestricted = false;
field.setAccessible(false);
}
textEncryptor = Encryptors.text(key, salt);