MongoDB C++ Driver  mongocxx-3.9.0
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
data_key.hpp
1 // Copyright 2020 MongoDB Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <string>
18 #include <vector>
19 
20 #include <bsoncxx/document/view_or_value.hpp>
21 #include <bsoncxx/stdx/optional.hpp>
22 #include <mongocxx/stdx.hpp>
23 
24 #include <mongocxx/config/prelude.hpp>
25 
26 namespace mongocxx {
27 inline namespace v_noabi {
28 class client_encryption;
29 
30 namespace options {
31 
35 class MONGOCXX_API data_key {
36  public:
74  // keyId: Optional<String>, // keyId is the KMIP Unique Identifier to a 96 byte KMIP Secret
75  // // Data managed object.If keyId is omitted, the driver creates a
76  // // random 96 byte KMIP Secret Data managed object.
77  // endpoint: Optional<String> // Host with optional port.
91  data_key& master_key(bsoncxx::document::view_or_value master_key);
92 
99  const stdx::optional<bsoncxx::document::view_or_value>& master_key() const;
100 
114  data_key& key_alt_names(std::vector<std::string> key_alt_names);
115 
122  const std::vector<std::string>& key_alt_names() const;
123 
142  using key_material_type = std::vector<uint8_t>;
143  data_key& key_material(key_material_type key_material);
144 
153  const stdx::optional<key_material_type>& key_material();
154 
155  private:
156  friend class mongocxx::client_encryption;
157  MONGOCXX_PRIVATE void* convert() const;
158 
159  stdx::optional<bsoncxx::document::view_or_value> _master_key;
160  std::vector<std::string> _key_alt_names;
161  stdx::optional<key_material_type> _key_material;
162 };
163 
164 } // namespace options
165 
166 } // namespace v_noabi
167 } // namespace mongocxx
168 
169 // CXX-2770: missing include of postlude header.
170 #if defined(MONGOCXX_TEST_MACRO_GUARDS_FIX_MISSING_POSTLUDE)
171 #include <mongocxx/config/postlude.hpp>
172 #endif
Class supporting operations for MongoDB Client-Side Field Level Encryption.
Definition: client_encryption.hpp:38
Class representing options for data key generation for encryption.
Definition: data_key.hpp:35
std::vector< uint8_t > key_material_type
Sets the binary data for the key material.
Definition: data_key.hpp:142
const stdx::optional< key_material_type > & key_material()
Gets the keyMaterial as binary data.
const stdx::optional< bsoncxx::document::view_or_value > & master_key() const
Gets the master key.
data_key & master_key(bsoncxx::document::view_or_value master_key)
Sets a KMS-specific key used to encrypt the new data key.
const std::vector< std::string > & key_alt_names() const
Gets the alternate names for the data key.
data_key & key_alt_names(std::vector< std::string > key_alt_names)
Sets an optional list of string alternate names used to reference the key.
The top-level namespace for mongocxx library entities.
Definition: bulk_write.hpp:24