com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource Maven / Gradle / Ivy
package com.ulisesbocchio.jasyptspringboot;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.properties.PropertyValueEncryptionUtils;
import org.springframework.core.env.PropertySource;
/**
* @author Ulises Bocchio
*/
public interface EncryptablePropertySource {
public default Object getProperty(StringEncryptor encryptor, PropertySource source, String name) {
Object value = source.getProperty(name);
if(value instanceof String) {
String stringValue = String.valueOf(value);
if(PropertyValueEncryptionUtils.isEncryptedValue(stringValue)) {
value = PropertyValueEncryptionUtils.decrypt(stringValue, encryptor);
}
}
return value;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy