@@ -5,106 +5,90 @@ content: |
55 First, retrieve the contents of the local master key file that you generated
66 in the :ref:`Create a Master Key <fle-create-a-master-key>` section:
77
8- .. tabs::
9-
10- tabs:
11-
12- - id: use-cases-fle-guide-java
13- name: "Java"
14- content: |
15-
16- .. code-block:: java
17- :emphasize-lines: 11
18-
19- String path = "master-key.txt";
20-
21- byte[] fileBytes = new byte[96];
22-
23- try (FileInputStream fis = new FileInputStream(path)) {
24- fileBytes = fis.readAllBytes();
25- } catch (IOException e) {
26- e.printStackTrace();
27- }
28-
29- final byte[] localMasterKey = Arrays.copyOf(fileBytes, 96);
30-
31-
8+ .. tabs-drivers::
9+
10+ .. tab::
11+ :tabid: java-sync
12+
13+ .. code-block:: java
14+ :emphasize-lines: 11
15+
16+ String path = "master-key.txt";
17+
18+ byte[] fileBytes = new byte[96];
19+
20+ try (FileInputStream fis = new FileInputStream(path)) {
21+ fileBytes = fis.readAllBytes();
22+ } catch (IOException e) {
23+ e.printStackTrace();
24+ }
25+
26+ final byte[] localMasterKey = Arrays.copyOf(fileBytes, 96);
3227 ---
3328title : Specify KMS Provider Settings
3429ref : specify-kms-provider-settings
3530level : 4
3631content : |
37- Next, specify the KMS provider settings. The client uses these settings to
38- discover the master key. Set the provider name to ``local`` when using a local
32+ Next, specify the KMS provider settings. The client uses these settings to
33+ discover the master key. Set the provider name to ``local`` when using a local
3934 master key:
4035
41- .. tabs::
42-
43- tabs:
44-
45- - id: use-cases-fle-guide-java
46- name: "Java"
47- content: |
48-
49- .. code-block:: java
50- :emphasize-lines: 4,5
51-
52- String kmsProvider = "local";
53-
54- Map<String, Map<String, Object>> kmsProviders = new HashMap<String, Map<String, Object>>() {{
55- put(kmsProvider, new HashMap<String, Object>() {{
56- put("key", localMasterKey);
57- }});
58- }};
59-
60-
36+ .. tabs-drivers::
37+
38+ .. tab::
39+ :tabid: java-sync
40+
41+ .. code-block:: java
42+ :emphasize-lines: 4,5
43+
44+ String kmsProvider = "local";
45+
46+ Map<String, Map<String, Object>> kmsProviders = new HashMap<String, Map<String, Object>>() {{
47+ put(kmsProvider, new HashMap<String, Object>() {{
48+ put("key", localMasterKey);
49+ }});
50+ }};
6151 ---
6252title : Create a Data Encryption Key
6353ref : create-a-data-encryption-key
6454level : 4
6555content : |
66- Construct a client with the MongoDB connection string and key vault
67- namespace configuration, and create a data encryption key. The key vault in
56+ Construct a client with the MongoDB connection string and key vault
57+ namespace configuration, and create a data encryption key. The key vault in
6858 this example uses the ``encryption`` database and ``__keyVault`` collection.
6959
70- .. tabs::
71-
72- tabs:
73-
74- - id: use-cases-fle-guide-java
75- name: "Java"
76- content: |
77-
78- .. code-block:: java
79- :emphasize-lines: 8,9,12
80-
81- String connectionString = "mongodb://localhost:27017";
82- String keyVaultNamespace = "encryption.__keyVault";
83-
84- ClientEncryptionSettings clientEncryptionSettings = ClientEncryptionSettings.builder()
85- .keyVaultMongoClientSettings(MongoClientSettings.builder()
86- .applyConnectionString(new ConnectionString(connectionString))
87- .build())
88- .keyVaultNamespace(keyVaultNamespace)
89- .kmsProviders(kmsProviders)
90- .build();
91-
92- ClientEncryption clientEncryption = ClientEncryptions.create(clientEncryptionSettings);
93-
60+ .. tabs-drivers::
61+
62+ .. tab::
63+ :tabid: java-sync
64+
65+ .. code-block:: java
66+ :emphasize-lines: 8,9,12
67+
68+ String connectionString = "mongodb://localhost:27017";
69+ String keyVaultNamespace = "encryption.__keyVault";
70+
71+ ClientEncryptionSettings clientEncryptionSettings = ClientEncryptionSettings.builder()
72+ .keyVaultMongoClientSettings(MongoClientSettings.builder()
73+ .applyConnectionString(new ConnectionString(connectionString))
74+ .build())
75+ .keyVaultNamespace(keyVaultNamespace)
76+ .kmsProviders(kmsProviders)
77+ .build();
78+
79+ ClientEncryption clientEncryption = ClientEncryptions.create(clientEncryptionSettings);
9480
9581 .. note::
9682
9783 Ensure that the client has `ReadWrite
9884 <https://docs.mongodb.com/manual/reference/built-in-roles/#readWrite>`_
9985 permissions on the specified key vault namespace.
100-
101-
10286 ---
10387title : Verify the data encryption key was created
10488ref : verify-data-key-created
10589level : 4
10690content : |
107- Verify that the key document was created in your MongoDB replica set in the
91+ Verify that the key document was created in your MongoDB replica set in the
10892 key vault collection. This document contains the following data:
10993
11094 * Data encryption key, in encrypted form.
0 commit comments