Browse Source

Update Documentation.

Updated code sample so that it includes the required `keyId(...)` configuration for Queryable Encryption using the Range algorithm.

Closes: #4991

Signed-off-by: Ricardo Mello <ricardohsmello@gmail.com>
pull/5002/head
Ricardo Mello 7 months ago committed by Christoph Strobl
parent
commit
f5570aa6bb
No known key found for this signature in database
GPG Key ID: E6054036D0C37A4B
  1. 14
      src/main/antora/modules/ROOT/pages/mongodb/mongo-encryption.adoc

14
src/main/antora/modules/ROOT/pages/mongodb/mongo-encryption.adoc

@ -140,11 +140,17 @@ Manual Collection Setup:: @@ -140,11 +140,17 @@ Manual Collection Setup::
====
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
----
BsonBinary pinDK = clientEncryption.createDataKey("local", new com.mongodb.client.model.vault.DataKeyOptions());
BsonBinary ssnDK = clientEncryption.createDataKey("local", new com.mongodb.client.model.vault.DataKeyOptions());
BsonBinary ageDK = clientEncryption.createDataKey("local", new com.mongodb.client.model.vault.DataKeyOptions());
BsonBinary signDK = clientEncryption.createDataKey("local", new com.mongodb.client.model.vault.DataKeyOptions());
CollectionOptions collectionOptions = CollectionOptions.encryptedCollection(options -> options
.queryable(encrypted(string("ssn")).algorithm("Indexed"), equality().contention(0))
.queryable(encrypted(int32("age")).algorithm("Range"), range().contention(8).min(0).max(150))
.encrypted(string("pin"))
.queryable(encrypted(int64("address.sign")).algorithm("Range"), range().contention(2).min(-10L).max(10L))
.encrypted(string("pin"), pinDK)
.queryable(encrypted(string("ssn")).algorithm("Indexed").keyId(ssnDK.asUuid()), equality().contention(0))
.queryable(encrypted(int32("age")).algorithm("Range").keyId(ageDK.asUuid()), range().contention(8).min(0).max(150))
.queryable(encrypted(int64("address.sign")).algorithm("Range").keyId(signDK.asUuid()), range().contention(2).min(-10L).max(10L))
);
mongoTemplate.createCollection(Patient.class, collectionOptions); <1>

Loading…
Cancel
Save