MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
data_key.hpp
Go to the documentation of this file.
1// Copyright 2009-present 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 <mongocxx/options/data_key-fwd.hpp> // IWYU pragma: export
18
19//
20
22
23#include <mongocxx/v1/data_key_options.hpp> // IWYU pragma: export
24
25#include <cstdint>
26#include <string>
27#include <utility>
28#include <vector>
29
30#include <mongocxx/client_encryption-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
31
35
37
38namespace mongocxx {
39namespace v_noabi {
40namespace options {
41
45class data_key {
46 public:
50 data_key() = default;
51
56
60 explicit operator v1::data_key_options() const {
62
63 if (_master_key) {
65 }
66
67 ret.key_alt_names(_key_alt_names);
68
69 if (_key_material) {
70 ret.key_material(*_key_material);
71 }
72
73 return ret;
74 }
75
142 _master_key = std::move(master_key);
143 return *this;
144 }
145
155
170 data_key& key_alt_names(std::vector<std::string> key_alt_names) {
171 _key_alt_names = std::move(key_alt_names);
172 return *this;
173 }
174
181 std::vector<std::string> const& key_alt_names() const {
182 return _key_alt_names;
183 }
184
188 using key_material_type = std::vector<std::uint8_t>;
189
210 _key_material = std::move(key_material);
211 return *this;
212 }
213
224 return _key_material;
225 }
226
227 class internal;
228
229 private:
231 std::vector<std::string> _key_alt_names;
233};
234
235} // namespace options
236} // namespace v_noabi
237} // namespace mongocxx
238
239namespace mongocxx {
240namespace v_noabi {
241
246 return {std::move(v)};
247}
248
254
255} // namespace v_noabi
256} // namespace mongocxx
257
259
A BSON document.
Definition value.hpp:46
A polyfill for std::optional<T>.
Definition optional.hpp:799
data_key()=default
Default initialization.
A Data Encryption Key (DEK) for In-Use Encryption.
Definition data_key_options.hpp:50
data_key_options & master_key(bsoncxx::v1::document::value master_key)
Set the "masterKey" field.
data_key_options & key_material(key_material_type key_material)
Set the "keyMaterial" field.
data_key_options & key_alt_names(std::vector< std::string > key_alt_names)
Set the "keyAltNames" field.
Used by mongocxx::v_noabi::client_encryption::create_data_key.
Definition data_key.hpp:45
operator v1::data_key_options() const
Convert to the mongocxx::v1 equivalent.
Definition data_key.hpp:60
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & master_key() const
Gets the master key.
Definition data_key.hpp:152
std::vector< std::string > const & key_alt_names() const
Gets the alternate names for the data key.
Definition data_key.hpp:181
data_key()=default
Default initialization.
bsoncxx::v_noabi::stdx::optional< key_material_type > const & key_material()
Gets the keyMaterial as binary data.
Definition data_key.hpp:223
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. If a key is created with a...
Definition data_key.hpp:170
std::vector< std::uint8_t > key_material_type
Represents binary data used to represent key material.
Definition data_key.hpp:188
data_key & master_key(bsoncxx::v_noabi::document::view_or_value master_key)
Sets a KMS-specific key used to encrypt the new data key.
Definition data_key.hpp:141
data_key & key_material(key_material_type key_material)
Sets the binary data for the key material.
Definition data_key.hpp:209
Declares mongocxx::v_noabi::options::data_key.
Provides mongocxx::v1::data_key_options.
Provides bsoncxx::v_noabi::document::view_or_value.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
v_noabi::view_or_value< v_noabi::document::view, v_noabi::document::value > view_or_value
Equivalent to v_noabi::view_or_value<v_noabi::document::view, v_noabi::document::value>.
Definition view_or_value.hpp:30
v1::element::view to_v1(v_noabi::array::element const &v)
Convert to the bsoncxx::v1 equivalent of v.
Definition element.hpp:132
Declares entities whose ABI stability is guaranteed for documented symbols.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
The top-level namespace within which all mongocxx library entities are declared.
Provides bsoncxx::v1::document::value.
Provides bsoncxx::v_noabi::document::view.
Provides std::optional-related polyfills for library API usage.
Declares mongocxx::v_noabi::client_encryption.