Skip to content

Commit ab1ab0c

Browse files
Restore missing encryption config and switch 'pin' to string.
Re-added previously lost code block for Queryable Encryption setup, and changed int32(pin) to string(pin) to preserve leading zeros as suggested. Signed-off-by: Ricardo Mello <[email protected]>
1 parent 60107a8 commit ab1ab0c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ BsonBinary ageDK = clientEncryption.createDataKey("local", new com.mongodb.clien
147147
BsonBinary signDK = clientEncryption.createDataKey("local", new com.mongodb.client.model.vault.DataKeyOptions());
148148
149149
CollectionOptions collectionOptions = CollectionOptions.encryptedCollection(options -> options
150-
.encrypted(int32("pin"), pinDK)
150+
.encrypted(string("pin"), pinDK)
151151
.queryable(encrypted(string("ssn")).algorithm("Indexed").keyId(ssnDK.asUuid()), equality().contention(0))
152152
.queryable(encrypted(int32("age")).algorithm("Range").keyId(ageDK.asUuid()), range().contention(8).min(0).max(150))
153153
.queryable(encrypted(int64("address.sign")).algorithm("Range").keyId(signDK.asUuid()), range().contention(2).min(-10L).max(10L))
@@ -167,13 +167,16 @@ class Patient {
167167
168168
@Id String id;
169169
170-
@Encrypted(algorithm = "Indexed") //
170+
@Encrypted(algorithm = "Indexed")
171171
@Queryable(queryType = "equality", contentionFactor = 0)
172172
String ssn;
173173
174174
@RangeEncrypted(contentionFactor = 8, rangeOptions = "{ 'min' : 0, 'max' : 150 }")
175175
Integer age;
176176
177+
@Encrypted(algorithm = "Unindexed")
178+
String pin;
179+
177180
Address address;
178181
}
179182
@@ -217,6 +220,11 @@ MongoDB Collection Info::
217220
bsonType: 'int',
218221
queries: [ { queryType: 'range', contention: Long('8'), min: 0, max: 150 } ]
219222
},
223+
{
224+
keyId: ...,
225+
path: 'pin',
226+
bsonType: 'string'
227+
},
220228
{
221229
keyId: ...,
222230
path: 'address.sign',

0 commit comments

Comments
 (0)