This app showcases a bunch of different features.
DemoApplication.java
declares a @EnableEncryptableProperties
annotation that bootstraps jasypt-spring-boot
declaratively
and enables property encryption across the entire Spring Environment.
@EnableEncryptableProperties
public class DemoApplication {
}
DemoApplication.java
declares a few @EncryptablePropertySource
annotations that load encryption-capable property sources.
@EncryptablePropertySource(name = "EncryptedProperties2", value = "classpath:encrypted2.properties")
@EncryptablePropertySource(name = "EncryptedProperties3", value = "classpath:encrypted3.yml")
public class DemoApplication {
}
In this scenario is not strictly necessary since @EnableEncryptableProperties
already decorates all property sources, so
when using @EnableEncryptableProperties
(Or the starter jar) you can load encryption-capable properties with Spring's
@PropertySource
annotation.
DemoApplication.java
declares a @PropertySource
annotations that loads an encryption-capable property source.
@PropertySource(name = "EncryptedProperties", value = "classpath:encrypted.properties")
public class DemoApplication {
}
As mentioned above, the fact that we're using @EnableEncryptableProperties
, it already decorates all property sources, so
when using @EnableEncryptableProperties
(Or the starter jar) you can load encryption-capable properties with Spring's
@PropertySource
annotation.
DemoApplication.java
declares a @EnableConfigurationProperties
that allows ItemConfig
to be populated from the environment.
jasypt-spring-boot
works seamlessly with this annotation also so you can define your @ConfigurationProperties
annotated classes
that contain references to encrypted properties.
@EnableConfigurationProperties(ItemConfig.class)
public class DemoApplication {
}
DemoApplication.java
declares a @ImportResource
that allows testConfig.xml
to be loaded.
jasypt-spring-boot
works seamlessly with this annotation also so you can import your XML
that contains references to encrypted
properties.
@ImportResource("classpath:/testConfig.xml")
public class DemoApplication {
}
SimpleBean.java
and MyService.java
both use the @Value
annotation to inject decrypted versions of the encrypted
properties present on the configuration files.