use of org.jasypt.encryption.pbe.StandardPBEStringEncryptor in project uPortal by Jasig.
the class PortalPropertySourcesPlaceholderConfigurer method mergeProperties.
/**
* Override PropertiesLoaderSupport.mergeProprties in order to slip in a properly-configured
* EncryptableProperties instance, allowing us to encrypt property values at rest.
*/
@Override
protected Properties mergeProperties() throws IOException {
Properties rslt = null;
/*
* If properties file encryption is used in this deployment, the
* encryption key will be made available to the application as an
* environment variable called UP_JASYPT_KEY.
*/
final String encryptionKey = System.getenv(JAYSYPT_ENCRYPTION_KEY_VARIABLE);
if (encryptionKey != null) {
logger.info("Jasypt support for encrypted property values ENABLED");
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
encryptor.setPassword(encryptionKey);
rslt = new EncryptableProperties(encryptor);
if (this.localOverride) {
// Load properties from file upfront, to let local properties override.
loadProperties(rslt);
}
if (this.localProperties != null) {
for (int i = 0; i < this.localProperties.length; i++) {
CollectionUtils.mergePropertiesIntoMap(this.localProperties[i], rslt);
}
}
if (!this.localOverride) {
// Load properties from file afterwards, to let those properties override.
loadProperties(rslt);
}
/*
* END copied from PropertiesLoaderSupport.mergeProperties()
*/
} else {
logger.info("Jasypt support for encrypted property values DISABLED; " + "specify environment variable {} to use this feature", JAYSYPT_ENCRYPTION_KEY_VARIABLE);
/*
* The feature is not in use; defer to the Spring-provided
* implementation of this method.
*/
return super.mergeProperties();
}
return rslt;
}
Aggregations