Skip to content

Commit d0ee281

Browse files
ricardohsmellochristophstrobl
authored andcommitted
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 <[email protected]>
1 parent 772a359 commit d0ee281

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,17 @@ Manual Collection Setup::
140140
====
141141
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
142142
----
143+
144+
BsonBinary pinDK = clientEncryption.createDataKey("local", new com.mongodb.client.model.vault.DataKeyOptions());
145+
BsonBinary ssnDK = clientEncryption.createDataKey("local", new com.mongodb.client.model.vault.DataKeyOptions());
146+
BsonBinary ageDK = clientEncryption.createDataKey("local", new com.mongodb.client.model.vault.DataKeyOptions());
147+
BsonBinary signDK = clientEncryption.createDataKey("local", new com.mongodb.client.model.vault.DataKeyOptions());
148+
143149
CollectionOptions collectionOptions = CollectionOptions.encryptedCollection(options -> options
144-
.queryable(encrypted(string("ssn")).algorithm("Indexed"), equality().contention(0))
145-
.queryable(encrypted(int32("age")).algorithm("Range"), range().contention(8).min(0).max(150))
146-
.encrypted(string("pin"))
147-
.queryable(encrypted(int64("address.sign")).algorithm("Range"), range().contention(2).min(-10L).max(10L))
150+
.encrypted(string("pin"), pinDK)
151+
.queryable(encrypted(string("ssn")).algorithm("Indexed").keyId(ssnDK.asUuid()), equality().contention(0))
152+
.queryable(encrypted(int32("age")).algorithm("Range").keyId(ageDK.asUuid()), range().contention(8).min(0).max(150))
153+
.queryable(encrypted(int64("address.sign")).algorithm("Range").keyId(signDK.asUuid()), range().contention(2).min(-10L).max(10L))
148154
);
149155
150156
mongoTemplate.createCollection(Patient.class, collectionOptions); <1>

0 commit comments

Comments
 (0)