Skip to content

Commit 2f288a1

Browse files
author
Chris Cho
authored
DOCSP-13035: CSFLE Azure and Java (#687)
* DOCSP-12575: add Azure instructions for Java
1 parent 8e62682 commit 2f288a1

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

source/includes/steps-fle-convert-to-a-remote-master-key-aws.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ content: |
156156
String base64DataKeyId = Base64.getEncoder().encodeToString(dataKeyId.getData());
157157
158158
System.out.println("DataKeyId [base64]: " + base64DataKeyId);
159+
160+
.. note::
161+
162+
To use AWS KMS, you must use `mongodb-crypt <https://mvnrepository.com/artifact/org.mongodb/mongodb-crypt>`__
163+
version 1.0 or later in your application's environment.
164+
159165
.. tab::
160166
:tabid: nodejs
161167
@@ -174,6 +180,7 @@ content: |
174180
175181
const base64DataKeyId = key.toString('base64');
176182
console.log('DataKeyId [base64]: ', base64DataKeyId);
183+
177184
.. tab::
178185
:tabid: python
179186

source/includes/steps-fle-convert-to-a-remote-master-key-azure.yaml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ content: |
8383
.. tab::
8484
:tabid: java-sync
8585
86+
In ``CSFLEHelpers.java``, update the ``kmsProviders`` map that you
87+
pass to ``ClientEncryptionSettings.builder().kmsProviders()`` method
88+
with your Azure authentication details:
89+
8690
8791
.. code-block:: java
8892
@@ -96,6 +100,11 @@ content: |
96100
Map<String, Map<String, Object>> kmsProviders = new HashMap<String, Map<String, Object>>();
97101
kmsProviders.put("azure", providerDetails);
98102
103+
ClientEncryptionSettings clientEncryptionSettings = ClientEncryptionSettings.builder()
104+
// ...
105+
.kmsProviders(kmsProviders)
106+
.build();
107+
99108
.. tab::
100109
:tabid: nodejs
101110
@@ -192,28 +201,24 @@ content: |
192201
.. tab::
193202
:tabid: java-sync
194203
195-
.. code-block:: Java
204+
In ``CSFLEHelpers.java``, add your KMS provider and master key
205+
details to your call to createDataKey() on your ``ClientEncryption``
206+
instance as follows:
196207
197-
// TODO: update for Azure
198-
ClientEncryption clientEncryption = ClientEncryptions.create(ClientEncryptionSettings.builder()
199-
.keyVaultMongoClientSettings(MongoClientSettings.builder()
200-
.applyConnectionString(new ConnectionString("mongodb://localhost:27017"))
201-
.build())
202-
.keyVaultNamespace(keyVaultNamespace)
203-
.kmsProviders(kmsProviders)
204-
.build());
208+
.. code-block:: Java
205209
206-
BsonString masterKeyRegion = new BsonString("<Master Key AWS Region>"); // e.g. "us-east-2"
207-
BsonString masterKeyArn = new BsonString("<Master Key ARN>"); // e.g. "arn:aws:kms:us-east-2:111122223333:alias/test-key"
208210
DataKeyOptions dataKeyOptions = new DataKeyOptions().masterKey(
209211
new BsonDocument()
210-
.append("region", masterKeyRegion)
211-
.append("key", masterKeyArn));
212+
.append("keyName", new BsonString("<Azure key name>"))
213+
.append("keyVersion", new BsonString("<Azure key version>"))
214+
.append("keyVersion", new BsonString("<Azure key vault endpoint>")));
215+
216+
BsonBinary dataKeyId = clientEncryption.createDataKey("azure", dataKeyOptions);
212217
213-
BsonBinary dataKeyId = clientEncryption.createDataKey("aws", dataKeyOptions);
214-
String base64DataKeyId = Base64.getEncoder().encodeToString(dataKeyId.getData());
218+
.. note::
215219
216-
System.out.println("DataKeyId [base64]: " + base64DataKeyId);
220+
To use the Azure Key Vault, you must use `mongodb-crypt <https://mvnrepository.com/artifact/org.mongodb/mongodb-crypt>`__
221+
version 1.1 or later in your application's environment.
217222
218223
.. tab::
219224
:tabid: nodejs

0 commit comments

Comments
 (0)