File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,27 @@ DOTENV_PRIVATE_KEY_TEST=0c8eac932150e0d51cfc59ccbd2c0613298464b2922d900b96511cf7
9393- Read private key from ` $HOME/.dotenvx/.env.keys.json ` file by the public key
9494- Read private key from ` .env.keys ` or ` $HOME/.env.keys ` file
9595
96+ # Jackson Integration
97+
98+ If you want to use Dotenvx to protect some fields with JSON output, you can use the following code:
99+
100+ ``` java
101+
102+ @Configuration
103+ public class DotenvxJacksonConfig {
104+ @Bean
105+ public SimpleModule dotenvxJacksonModule (@Value (" ${dotenv.public.key}" ) String publicKey , @Value (" ${dotenvx.private.key}" ) String privateKey ) {
106+ SimpleModule simpleModule = new SimpleModule ();
107+ simpleModule. addSerializer(new DotenvxGlobalJsonSerializer (publicKey));
108+ simpleModule. addDeserializer(String . class, new DotenvxGlobalJsonDeserializer (privateKey));
109+ return simpleModule;
110+ }
111+ }
112+ ```
113+
114+ For encryption, make sure the field value with ` private: ` prefix.
115+ For decryption, make sure the field value with ` encrypted: ` prefix.
116+
96117# Credits
97118
98119* jasypt-spring-boot: https://github.com/ulisesbocchio/jasypt-spring-boot
You can’t perform that action at this time.
0 commit comments