@@ -142,16 +142,16 @@ String responsePayload = FieldLevelEncryption.decryptPayload(encryptedResponsePa
142142Use the ` FieldLevelEncryptionConfigBuilder ` to create ` FieldLevelEncryptionConfig ` instances. Example:
143143``` java
144144FieldLevelEncryptionConfig config = FieldLevelEncryptionConfigBuilder . aFieldLevelEncryptionConfig()
145- .withEncryptionCertificate(encryptionCertificate)
146- .withDecryptionKey(decryptionKey)
147- .withEncryptionPath(" $.path.to.foo" , " $.path.to.encryptedFoo" )
148- .withDecryptionPath(" $.path.to.encryptedFoo" , " $.path.to.foo" )
149- .withOaepPaddingDigestAlgorithm(" SHA-256" )
150- .withEncryptedValueFieldName(" encryptedValue" )
151- .withEncryptedKeyFieldName(" encryptedKey" )
152- .withIvFieldName(" iv" )
153- .withFieldValueEncoding(FieldValueEncoding . HEX )
154- .build();
145+ .withEncryptionCertificate(encryptionCertificate)
146+ .withDecryptionKey(decryptionKey)
147+ .withEncryptionPath(" $.path.to.foo" , " $.path.to.encryptedFoo" )
148+ .withDecryptionPath(" $.path.to.encryptedFoo" , " $.path.to.foo" )
149+ .withOaepPaddingDigestAlgorithm(" SHA-256" )
150+ .withEncryptedValueFieldName(" encryptedValue" )
151+ .withEncryptedKeyFieldName(" encryptedKey" )
152+ .withIvFieldName(" iv" )
153+ .withFieldValueEncoding(FieldValueEncoding . HEX )
154+ .build();
155155```
156156
157157See also:
@@ -165,15 +165,15 @@ Call `FieldLevelEncryption.encryptPayload` with a JSON request payload and a `Fi
165165Example using the configuration [ above] ( #configuring-the-field-level-encryption ) :
166166``` java
167167String payload = " {" +
168- " \" path\" : {" +
169- " \" to\" : {" +
170- " \" foo\" : {" +
171- " \" sensitiveField1\" : \" sensitiveValue1\" ," +
172- " \" sensitiveField2\" : \" sensitiveValue2\" " +
173- " }" +
174- " }" +
175- " }" +
176- " }" ;
168+ " \" path\" : {" +
169+ " \" to\" : {" +
170+ " \" foo\" : {" +
171+ " \" sensitiveField1\" : \" sensitiveValue1\" ," +
172+ " \" sensitiveField2\" : \" sensitiveValue2\" " +
173+ " }" +
174+ " }" +
175+ " }" +
176+ " }" ;
177177String encryptedPayload = FieldLevelEncryption . encryptPayload(payload, config);
178178System . out. println(new GsonBuilder (). setPrettyPrinting(). create(). toJson(new JsonParser (). parse(encryptedPayload)));
179179```
@@ -200,16 +200,16 @@ Call `FieldLevelEncryption.decryptPayload` with a JSON response payload and a `F
200200Example using the configuration [ above] ( #configuring-the-field-level-encryption ) :
201201``` java
202202String encryptedPayload = " {" +
203- " \" path\" : {" +
204- " \" to\" : {" +
205- " \" encryptedFoo\" : {" +
206- " \" iv\" : \" e5d313c056c411170bf07ac82ede78c9\" ," +
207- " \" encryptedKey\" : \" e3a56746c0f9109d18b3a2652b76(...)f16d8afeff36b2479652f5c24ae7bd\" ," +
208- " \" encryptedValue\" : \" 809a09d78257af5379df0c454dcdf(...)353ed59fe72fd4a7735c69da4080e74f\" " +
209- " }" +
210- " }" +
211- " }" +
212- " }" ;
203+ " \" path\" : {" +
204+ " \" to\" : {" +
205+ " \" encryptedFoo\" : {" +
206+ " \" iv\" : \" e5d313c056c411170bf07ac82ede78c9\" ," +
207+ " \" encryptedKey\" : \" e3a56746c0f9109d18b3a2652b76(...)f16d8afeff36b2479652f5c24ae7bd\" ," +
208+ " \" encryptedValue\" : \" 809a09d78257af5379df0c454dcdf(...)353ed59fe72fd4a7735c69da4080e74f\" " +
209+ " }" +
210+ " }" +
211+ " }" +
212+ " }" ;
213213String payload = FieldLevelEncryption . decryptPayload(encryptedPayload, config);
214214System . out. println(new GsonBuilder (). setPrettyPrinting(). create(). toJson(new JsonParser (). parse(payload)));
215215```
@@ -234,18 +234,18 @@ Entire payloads can be encrypted using the "$" operator as encryption path:
234234
235235``` java
236236FieldLevelEncryptionConfig config = FieldLevelEncryptionConfigBuilder . aFieldLevelEncryptionConfig()
237- .withEncryptionCertificate(encryptionCertificate)
238- .withEncryptionPath(" $" , " $" )
239- // ...
240- .build();
237+ .withEncryptionCertificate(encryptionCertificate)
238+ .withEncryptionPath(" $" , " $" )
239+ // ...
240+ .build();
241241```
242242
243243Example:
244244``` java
245245String payload = " {" +
246- " \" sensitiveField1\" : \" sensitiveValue1\" ," +
247- " \" sensitiveField2\" : \" sensitiveValue2\" " +
248- " }" ;
246+ " \" sensitiveField1\" : \" sensitiveValue1\" ," +
247+ " \" sensitiveField2\" : \" sensitiveValue2\" " +
248+ " }" ;
249249String encryptedPayload = FieldLevelEncryption . encryptPayload(payload, config);
250250System . out. println(new GsonBuilder (). setPrettyPrinting(). create(). toJson(new JsonParser (). parse(encryptedPayload)));
251251```
@@ -265,19 +265,19 @@ Entire payloads can be decrypted using the "$" operator as decryption path:
265265
266266``` java
267267FieldLevelEncryptionConfig config = FieldLevelEncryptionConfigBuilder . aFieldLevelEncryptionConfig()
268- .withDecryptionKey(decryptionKey)
269- .withDecryptionPath(" $" , " $" )
270- // ...
271- .build();
268+ .withDecryptionKey(decryptionKey)
269+ .withDecryptionPath(" $" , " $" )
270+ // ...
271+ .build();
272272```
273273
274274Example:
275275``` java
276276String encryptedPayload = " {" +
277- " \" iv\" : \" 1b9396c98ab2bfd195de661d70905a45\" ," +
278- " \" encryptedKey\" : \" 7d5112fa08e554e3dbc455d0628(...)52e826dd10311cf0d63bbfb231a1a63ecc13\" ," +
279- " \" encryptedValue\" : \" e5e9340f4d2618d27f8955828c86(...)379b13901a3b1e2efed616b6750a90fd379515\" " +
280- " }" ;
277+ " \" iv\" : \" 1b9396c98ab2bfd195de661d70905a45\" ," +
278+ " \" encryptedKey\" : \" 7d5112fa08e554e3dbc455d0628(...)52e826dd10311cf0d63bbfb231a1a63ecc13\" ," +
279+ " \" encryptedValue\" : \" e5e9340f4d2618d27f8955828c86(...)379b13901a3b1e2efed616b6750a90fd379515\" " +
280+ " }" ;
281281String payload = FieldLevelEncryption . decryptPayload(encryptedPayload, config);
282282System . out. println(new GsonBuilder (). setPrettyPrinting(). create(). toJson(new JsonParser (). parse(payload)));
283283```
@@ -301,17 +301,17 @@ Here is how to configure the library for using HTTP headers instead.
301301Call ` with{Param}HeaderName ` instead of ` with{Param}FieldName ` when building a ` FieldLevelEncryptionConfig ` instance. Example:
302302``` java
303303FieldLevelEncryptionConfig config = FieldLevelEncryptionConfigBuilder . aFieldLevelEncryptionConfig()
304- .withEncryptionCertificate(encryptionCertificate)
305- .withDecryptionKey(decryptionKey)
306- .withEncryptionPath(" $" , " $" )
307- .withDecryptionPath(" $" , " $" )
308- .withOaepPaddingDigestAlgorithm(" SHA-256" )
309- .withEncryptedValueFieldName(" data" )
310- .withIvHeaderName(" x-iv" )
311- .withEncryptedKeyHeaderName(" x-encrypted-key" )
312- // ...
313- .withFieldValueEncoding(FieldValueEncoding . HEX )
314- .build();
304+ .withEncryptionCertificate(encryptionCertificate)
305+ .withDecryptionKey(decryptionKey)
306+ .withEncryptionPath(" $" , " $" )
307+ .withDecryptionPath(" $" , " $" )
308+ .withOaepPaddingDigestAlgorithm(" SHA-256" )
309+ .withEncryptedValueFieldName(" data" )
310+ .withIvHeaderName(" x-iv" )
311+ .withEncryptedKeyHeaderName(" x-encrypted-key" )
312+ // ...
313+ .withFieldValueEncoding(FieldValueEncoding . HEX )
314+ .build();
315315```
316316
317317See also:
@@ -345,9 +345,9 @@ Example using the configuration [above](#configuration-for-using-http-headers):
345345
346346``` java
347347String payload = " {" +
348- " \" sensitiveField1\" : \" sensitiveValue1\" ," +
349- " \" sensitiveField2\" : \" sensitiveValue2\" " +
350- " }" ;
348+ " \" sensitiveField1\" : \" sensitiveValue1\" ," +
349+ " \" sensitiveField2\" : \" sensitiveValue2\" " +
350+ " }" ;
351351String encryptedPayload = FieldLevelEncryption . encryptPayload(payload, config, params);
352352System . out. println(new GsonBuilder (). setPrettyPrinting(). create(). toJson(new JsonParser (). parse(encryptedPayload)));
353353```
@@ -386,8 +386,8 @@ Example using the configuration [above](#configuration-for-using-http-headers):
386386
387387``` java
388388String encryptedPayload = " {" +
389- " \" data\" : \" 53b5f07ee46403af2e92abab900853(...)d560a0a08a1ed142099e3f4c84fe5e5\" " +
390- " }" ;
389+ " \" data\" : \" 53b5f07ee46403af2e92abab900853(...)d560a0a08a1ed142099e3f4c84fe5e5\" " +
390+ " }" ;
391391String payload = FieldLevelEncryption . decryptPayload(encryptedPayload, config, params);
392392System . out. println(new GsonBuilder (). setPrettyPrinting(). create(). toJson(new JsonParser (). parse(payload)));
393393```
0 commit comments