Skip to content

Latest commit

 

History

History
87 lines (68 loc) · 4.36 KB

README.md

File metadata and controls

87 lines (68 loc) · 4.36 KB

Spring Properties

  • jasypt encrypt/decrypt
  • runtime.properties

Dependencies

Jasypt Properties

Key Required Default Value
jasypt.encryptor.password True -
jasypt.encryptor.algorithm False PBEWITHHMACSHA512ANDAES_256
jasypt.encryptor.key-obtention-iterations False 1000
jasypt.encryptor.pool-size False 1
jasypt.encryptor.provider-name False SunJCE
jasypt.encryptor.provider-class-name False null
jasypt.encryptor.salt-generator-classname False org.jasypt.salt.RandomSaltGenerator
jasypt.encryptor.iv-generator-classname False org.jasypt.iv.RandomIvGenerator
jasypt.encryptor.string-output-type False base64
jasypt.encryptor.proxy-property-sources False false
jasypt.encryptor.skip-property-sources False empty list

Jasypt Auto Configuration

  • EncryptablePropertyResolverConfiguration
    • injection jasypt bean
  • DefaultPropertyResolver#resolvePropertyValue
    • convert encrypted property -> decrypt
  • DefaultPropertyDetector#isEncrypted
    • prefix, suffix

Custom Environment PropertySource

  • ApplicationContextInitializer
  • EnvironmentPostProcessor
## META-INF/spring.factories

# ApplicationContextInitializer
org.springframework.context.ApplicationContextInitializer=\
com.gmoon.core.config.DecryptEnvironmentInitializer

# Environment Post Processors
org.springframework.boot.env.EnvironmentPostProcessor=\
com.gmoon.core.config.CustomEnvironmentPostProcessor

EnvironmentPostProcessor

  1. Default properties (specified by setting SpringApplication.setDefaultProperties).
  2. @PropertySource annotations on your @Configuration classes. Please note that such property sources are not added to the Environment until the application context is being refreshed. This is too late to configure certain properties such as logging.* and spring.main.* which are read before refresh begins.
  3. Config data (such as application.properties files).
  4. A RandomValuePropertySource that has properties only in random.*.
  5. OS environment variables.
  6. Java System properties (System.getProperties()).
  7. JNDI attributes from java:comp/env.
  8. ServletContext init parameters.
  9. ServletConfig init parameters.
  10. Properties from SPRING_APPLICATION_JSON (inline JSON embedded in an environment variable or system property).
  11. Command line arguments.
  12. properties attribute on your tests. Available on @SpringBootTest and the test annotations for testing a particular slice of your application.
  13. @TestPropertySource annotations on your tests.
  14. Devtools global settings properties in the $HOME/.config/spring-boot directory when devtools is active.

Config data files are considered in the following order:

  1. Application properties packaged inside your jar (application.properties and YAML variants).
  2. Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants).
  3. Application properties outside of your packaged jar (application.properties and YAML variants).
  4. Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants).

Reference