in extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptConfig.java [96:134]
default PBEConfig pbeConfig() {
EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig();
String password = null;
if (password().isPresent()) {
password = password().get();
if (ObjectHelper.isNotEmpty(password)) {
// Preserve backwards compat with the Camel way of configuring the master password
if (password.startsWith(SYS_ENV_CONFIG_PREFIX)) {
password = System.getenv(StringHelper.after(password, SYS_ENV_CONFIG_PREFIX));
} else if (password.startsWith(SYS_CONFIG_PREFIX)) {
password = System.getProperty(StringHelper.after(password, SYS_CONFIG_PREFIX));
}
}
}
config.setPassword(password);
config.setAlgorithm(algorithm());
config.setIvGenerator(ALGORITHMS_THAT_REQUIRE_IV.contains(algorithm().toUpperCase())
? new RandomIvGenerator(randomIvGeneratorAlgorithm()) : new NoIvGenerator());
config.setSaltGenerator(new RandomSaltGenerator(randomSaltGeneratorAlgorithm()));
if (configurationCustomizerClassName().isPresent()) {
try {
Class<?> encryptorClass = Thread.currentThread().getContextClassLoader()
.loadClass(configurationCustomizerClassName().get());
JasyptConfigurationCustomizer customizer = (JasyptConfigurationCustomizer) encryptorClass
.getDeclaredConstructor().newInstance();
customizer.customize(config);
} catch (ClassNotFoundException | InvocationTargetException | InstantiationException | IllegalAccessException
| NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
// Avoid potentially confusing runtime NPEs and fail fast if no password has been configured
try {
config.getPassword();
} catch (NullPointerException e) {
throw new IllegalStateException("The jasypt password has not been configured.");
}
return config;
}