Skip to content

Commit 9b1670a

Browse files
committed
Create internal MongoClient for auto-encryption
JAVA-3932
1 parent c329baa commit 9b1670a

36 files changed

+398
-527
lines changed

driver-core/src/main/com/mongodb/MongoClientSettings.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,23 @@ public Builder uuidRepresentation(final UuidRepresentation uuidRepresentation) {
477477
/**
478478
* Sets the auto-encryption settings
479479
*
480+
* A separate, internal {@code MongoClient} is created if any of the following are true:
481+
*
482+
* <ul>
483+
* <li>{@code AutoEncryptionSettings.keyVaultClient} is not passed</li>
484+
* <li>{@code AutoEncryptionSettings.bypassAutomaticEncryption} is {@code false}</li>
485+
* </ul>
486+
*
487+
* If an internal {@code MongoClient} is created, it is configured with the same
488+
* options as the parent {@code MongoClient} except {@code minPoolSize} is set to {@code 0}
489+
* and {@code AutoEncryptionSettings} is omitted.
490+
*
480491
* @param autoEncryptionSettings the auto-encryption settings
481492
* @return this
482493
* @since 3.11
483494
* @see #getAutoEncryptionSettings()
484495
*/
485-
public Builder autoEncryptionSettings(final AutoEncryptionSettings autoEncryptionSettings) {
496+
public Builder autoEncryptionSettings(@Nullable final AutoEncryptionSettings autoEncryptionSettings) {
486497
this.autoEncryptionSettings = autoEncryptionSettings;
487498
return this;
488499
}

driver-core/src/test/resources/client-side-encryption/aggregate.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,6 @@
150150
"command_name": "listCollections"
151151
}
152152
},
153-
{
154-
"command_started_event": {
155-
"command": {
156-
"listCollections": 1,
157-
"filter": {
158-
"name": "datakeys"
159-
},
160-
"$db": "keyvault"
161-
},
162-
"command_name": "listCollections"
163-
}
164-
},
165153
{
166154
"command_started_event": {
167155
"command": {
@@ -273,18 +261,6 @@
273261
"command_name": "aggregate"
274262
}
275263
},
276-
{
277-
"command_started_event": {
278-
"command": {
279-
"listCollections": 1,
280-
"filter": {
281-
"name": "datakeys"
282-
},
283-
"$db": "keyvault"
284-
},
285-
"command_name": "listCollections"
286-
}
287-
},
288264
{
289265
"command_started_event": {
290266
"command": {

driver-core/src/test/resources/client-side-encryption/azureKMS.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,6 @@
139139
"command_name": "listCollections"
140140
}
141141
},
142-
{
143-
"command_started_event": {
144-
"command": {
145-
"listCollections": 1,
146-
"filter": {
147-
"name": "datakeys"
148-
},
149-
"$db": "keyvault"
150-
},
151-
"command_name": "listCollections"
152-
}
153-
},
154142
{
155143
"command_started_event": {
156144
"command": {

driver-core/src/test/resources/client-side-encryption/basic.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,6 @@
144144
"command_name": "listCollections"
145145
}
146146
},
147-
{
148-
"command_started_event": {
149-
"command": {
150-
"listCollections": 1,
151-
"filter": {
152-
"name": "datakeys"
153-
},
154-
"$db": "keyvault"
155-
},
156-
"command_name": "listCollections"
157-
}
158-
},
159147
{
160148
"command_started_event": {
161149
"command": {
@@ -283,18 +271,6 @@
283271
"command_name": "listCollections"
284272
}
285273
},
286-
{
287-
"command_started_event": {
288-
"command": {
289-
"listCollections": 1,
290-
"filter": {
291-
"name": "datakeys"
292-
},
293-
"$db": "keyvault"
294-
},
295-
"command_name": "listCollections"
296-
}
297-
},
298274
{
299275
"command_started_event": {
300276
"command": {

driver-core/src/test/resources/client-side-encryption/bulk.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,6 @@
178178
"command_name": "listCollections"
179179
}
180180
},
181-
{
182-
"command_started_event": {
183-
"command": {
184-
"listCollections": 1,
185-
"filter": {
186-
"name": "datakeys"
187-
},
188-
"$db": "keyvault"
189-
},
190-
"command_name": "listCollections"
191-
}
192-
},
193181
{
194182
"command_started_event": {
195183
"command": {

driver-core/src/test/resources/client-side-encryption/count.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,6 @@
149149
"command_name": "listCollections"
150150
}
151151
},
152-
{
153-
"command_started_event": {
154-
"command": {
155-
"listCollections": 1,
156-
"filter": {
157-
"name": "datakeys"
158-
},
159-
"$db": "keyvault"
160-
},
161-
"command_name": "listCollections"
162-
}
163-
},
164152
{
165153
"command_started_event": {
166154
"command": {

driver-core/src/test/resources/client-side-encryption/countDocuments.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,6 @@
150150
"command_name": "listCollections"
151151
}
152152
},
153-
{
154-
"command_started_event": {
155-
"command": {
156-
"listCollections": 1,
157-
"filter": {
158-
"name": "datakeys"
159-
},
160-
"$db": "keyvault"
161-
},
162-
"command_name": "listCollections"
163-
}
164-
},
165153
{
166154
"command_started_event": {
167155
"command": {

driver-core/src/test/resources/client-side-encryption/delete.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,6 @@
151151
"command_name": "listCollections"
152152
}
153153
},
154-
{
155-
"command_started_event": {
156-
"command": {
157-
"listCollections": 1,
158-
"filter": {
159-
"name": "datakeys"
160-
},
161-
"$db": "keyvault"
162-
},
163-
"command_name": "listCollections"
164-
}
165-
},
166154
{
167155
"command_started_event": {
168156
"command": {
@@ -276,18 +264,6 @@
276264
"command_name": "listCollections"
277265
}
278266
},
279-
{
280-
"command_started_event": {
281-
"command": {
282-
"listCollections": 1,
283-
"filter": {
284-
"name": "datakeys"
285-
},
286-
"$db": "keyvault"
287-
},
288-
"command_name": "listCollections"
289-
}
290-
},
291267
{
292268
"command_started_event": {
293269
"command": {

driver-core/src/test/resources/client-side-encryption/distinct.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,6 @@
161161
"command_name": "listCollections"
162162
}
163163
},
164-
{
165-
"command_started_event": {
166-
"command": {
167-
"listCollections": 1,
168-
"filter": {
169-
"name": "datakeys"
170-
},
171-
"$db": "keyvault"
172-
},
173-
"command_name": "listCollections"
174-
}
175-
},
176164
{
177165
"command_started_event": {
178166
"command": {

driver-core/src/test/resources/client-side-encryption/explain.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,6 @@
155155
"command_name": "listCollections"
156156
}
157157
},
158-
{
159-
"command_started_event": {
160-
"command": {
161-
"listCollections": 1,
162-
"filter": {
163-
"name": "datakeys"
164-
},
165-
"$db": "keyvault"
166-
},
167-
"command_name": "listCollections"
168-
}
169-
},
170158
{
171159
"command_started_event": {
172160
"command": {

driver-core/src/test/resources/client-side-encryption/find.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,6 @@
160160
"command_name": "listCollections"
161161
}
162162
},
163-
{
164-
"command_started_event": {
165-
"command": {
166-
"listCollections": 1,
167-
"filter": {
168-
"name": "datakeys"
169-
},
170-
"$db": "keyvault"
171-
},
172-
"command_name": "listCollections"
173-
}
174-
},
175163
{
176164
"command_started_event": {
177165
"command": {
@@ -302,18 +290,6 @@
302290
"command_name": "listCollections"
303291
}
304292
},
305-
{
306-
"command_started_event": {
307-
"command": {
308-
"listCollections": 1,
309-
"filter": {
310-
"name": "datakeys"
311-
},
312-
"$db": "keyvault"
313-
},
314-
"command_name": "listCollections"
315-
}
316-
},
317293
{
318294
"command_started_event": {
319295
"command": {

driver-core/src/test/resources/client-side-encryption/findOneAndDelete.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,6 @@
148148
"command_name": "listCollections"
149149
}
150150
},
151-
{
152-
"command_started_event": {
153-
"command": {
154-
"listCollections": 1,
155-
"filter": {
156-
"name": "datakeys"
157-
},
158-
"$db": "keyvault"
159-
},
160-
"command_name": "listCollections"
161-
}
162-
},
163151
{
164152
"command_started_event": {
165153
"command": {

driver-core/src/test/resources/client-side-encryption/findOneAndReplace.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,6 @@
147147
"command_name": "listCollections"
148148
}
149149
},
150-
{
151-
"command_started_event": {
152-
"command": {
153-
"listCollections": 1,
154-
"filter": {
155-
"name": "datakeys"
156-
},
157-
"$db": "keyvault"
158-
},
159-
"command_name": "listCollections"
160-
}
161-
},
162150
{
163151
"command_started_event": {
164152
"command": {

driver-core/src/test/resources/client-side-encryption/findOneAndUpdate.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,6 @@
149149
"command_name": "listCollections"
150150
}
151151
},
152-
{
153-
"command_started_event": {
154-
"command": {
155-
"listCollections": 1,
156-
"filter": {
157-
"name": "datakeys"
158-
},
159-
"$db": "keyvault"
160-
},
161-
"command_name": "listCollections"
162-
}
163-
},
164152
{
165153
"command_started_event": {
166154
"command": {

driver-core/src/test/resources/client-side-encryption/gcpKMS.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,6 @@
141141
"command_name": "listCollections"
142142
}
143143
},
144-
{
145-
"command_started_event": {
146-
"command": {
147-
"listCollections": 1,
148-
"filter": {
149-
"name": "datakeys"
150-
},
151-
"$db": "keyvault"
152-
},
153-
"command_name": "listCollections"
154-
}
155-
},
156144
{
157145
"command_started_event": {
158146
"command": {

driver-core/src/test/resources/client-side-encryption/getMore.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,6 @@
179179
"command_name": "find"
180180
}
181181
},
182-
{
183-
"command_started_event": {
184-
"command": {
185-
"listCollections": 1,
186-
"filter": {
187-
"name": "datakeys"
188-
},
189-
"$db": "keyvault"
190-
},
191-
"command_name": "listCollections"
192-
}
193-
},
194182
{
195183
"command_started_event": {
196184
"command": {

0 commit comments

Comments
 (0)