@Target(value=TYPE) @Retention(value=RUNTIME) @Import(value=EnableEncryptablePropertiesConfiguration.class) public @interface EnableEncryptableProperties
Annotation that enables Jasypt for properties decryption by annotating Configuration classes.
Only one occurrence of this annotation is needed.
This works well in conjunction with the PropertySource annotation.
For instance:
@SpringBootApplication
@EnableEncryptableProperties
@PropertySource(name="EncryptedProperties", "classpath:app.properties")
public class MySpringBootApp {
public static void main(String[] args) {
SpringApplication.run(MySpringBootApp.class, args);
}
}
The above code will then enable encryptable properties within all PropertySources defined in the environment,
not only the ones defined with the PropertySource annotation, but also
all system properties, command line properties, and those auto-magically picked up from application.properties and application.yml
if they exist.
This Configuration class basically registers a BeanFactoryPostProcessor that wraps all PropertySource defined in the Environment
with EncryptablePropertySourceWrapper and defines a default StringEncryptor for decrypting properties
that can be configured through the same properties it wraps.
For more information on how to declare encrypted properties, encrypt them, and encryption configuration go to http://jasypt.org
EnableEncryptablePropertiesConfiguration,
EnableEncryptablePropertiesBeanFactoryPostProcessor,
EncryptablePropertySourceWrapper,
PropertySourceCopyright © 2017. All rights reserved.