MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
encrypt.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/encrypt-fwd.hpp> // IWYU pragma: export
18
19//
20
22
23#include <mongocxx/v1/encrypt_options.hpp> // IWYU pragma: export
24
25#include <cstdint>
26#include <string>
27#include <utility>
28
29#include <mongocxx/client_encryption-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
30
32#include <bsoncxx/types.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
35
38
40
41namespace mongocxx {
42namespace v_noabi {
43namespace options {
44
48class encrypt {
49 public:
53 encrypt() = default;
54
58 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() encrypt(v1::encrypt_options opts);
59
63 explicit operator v1::encrypt_options() const {
66
68
69 if (_key_id) {
71 }
72
73 if (_key_alt_name) {
74 ret.key_alt_name(*_key_alt_name);
75 }
76
77 if (_algorithm) {
78 ret.algorithm(*_algorithm);
79 }
80
81 if (_contention_factor) {
82 ret.contention_factor(*_contention_factor);
83 }
84
85 if (_query_type) {
86 ret.query_type(*_query_type);
87 }
88
89 if (_range_opts) {
90 ret.range_opts(to_v1(*_range_opts));
91 }
92
93 if (_text_opts) {
94 ret.text_opts(*_text_opts);
95 }
96
97 return ret;
98 }
99
118 _key_id = std::move(key_id);
119 return *this;
120 }
121
131
145 encrypt& key_alt_name(std::string name) {
146 _key_alt_name = std::move(name);
147 return *this;
148 }
149
157 return _key_alt_name;
158 }
159
165
171
189 _algorithm = algorithm;
190 return *this;
191 }
192
202 return _algorithm;
203 }
204
214 _contention_factor = contention_factor;
215 return *this;
216 }
217
225 return _contention_factor;
226 }
227
237 _query_type = query_type;
238 return *this;
239 }
240
248 return _query_type;
249 }
250
255 _range_opts = std::move(opts);
256 return *this;
257 }
258
266 return _range_opts;
267 }
268
272 encrypt& text_opts(options::text opts) {
273 _text_opts = std::move(opts);
274 return *this;
275 }
276
281 return _text_opts;
282 }
283
284 class internal;
285
286 private:
294};
295
296} // namespace options
297} // namespace v_noabi
298} // namespace mongocxx
299
300namespace mongocxx {
301namespace v_noabi {
302
307 return {std::move(v)};
308}
309
316
317} // namespace v_noabi
318} // namespace mongocxx
319
321
A polyfill for std::optional<T>.
Definition optional.hpp:799
A union of BSON type values.
Definition value.hpp:54
encrypt()=default
Default initialization.
Options related to explicit encryption for In-Use Encryption.
Definition encrypt_options.hpp:59
encrypt_options & algorithm(encryption_algorithm v)
Set the "algorithm" field.
encrypt_options & query_type(encryption_query_type v)
Set the "queryType" field.
encrypt_options & key_alt_name(std::string v)
Set the "keyAltName" field.
encrypt_options & text_opts(v1::text_options v)
Set the "textOpts" field.
encrypt_options & key_id(bsoncxx::v1::types::value v)
Set the "keyId" field.
encrypt_options & contention_factor(std::int64_t v)
Set the "contentionFactor" field.
encrypt_options & range_opts(v1::range_options v)
Set the "rangeOpts" field.
encryption_algorithm
An encryption algorithm.
Definition encrypt_options.hpp:74
encryption_query_type
A query type.
Definition encrypt_options.hpp:95
Used by mongocxx::v_noabi::client_encryption.
Definition encrypt.hpp:48
bsoncxx::v_noabi::stdx::optional< options::text > const & text_opts() const
Gets the current text options.
Definition encrypt.hpp:280
bsoncxx::v_noabi::stdx::optional< std::string > const & key_alt_name() const
Gets the current key alt name.
Definition encrypt.hpp:156
operator v1::encrypt_options() const
Convert to the mongocxx::v1 equivalent.
Definition encrypt.hpp:63
encrypt & key_id(bsoncxx::v_noabi::types::bson_value::view_or_value key_id)
Sets the key to use for this encryption operation. A key id can be used instead of a key alt name.
Definition encrypt.hpp:117
encrypt & text_opts(options::text opts)
Sets the text options to use for encryption.
Definition encrypt.hpp:272
encrypt & algorithm(encryption_algorithm algorithm)
Sets the algorithm to use for encryption.
Definition encrypt.hpp:188
encrypt & key_alt_name(std::string name)
Sets a name by which to lookup a key from the key vault collection to use for this encryption operati...
Definition encrypt.hpp:145
v1::encrypt_options::encryption_query_type encryption_query_type
queryType only applies when algorithm is "indexed" or "range". It is an error to set queryType when a...
Definition encrypt.hpp:170
encrypt & query_type(encryption_query_type query_type)
Sets the query type to use for encryption.
Definition encrypt.hpp:236
v1::encrypt_options::encryption_algorithm encryption_algorithm
Determines which AEAD_AES_256_CBC algorithm to use with HMAC_SHA_512 when encrypting data.
Definition encrypt.hpp:164
bsoncxx::v_noabi::stdx::optional< options::range > const & range_opts() const
Gets the current range options.
Definition encrypt.hpp:265
bsoncxx::v_noabi::stdx::optional< encryption_query_type > const & query_type() const
Gets the current query type.
Definition encrypt.hpp:247
bsoncxx::v_noabi::stdx::optional< std::int64_t > const & contention_factor() const
Gets the current contention factor.
Definition encrypt.hpp:224
encrypt & contention_factor(std::int64_t contention_factor)
Sets the contention factor to use for encryption. contentionFactor only applies when algorithm is "In...
Definition encrypt.hpp:213
encrypt & range_opts(options::range opts)
Sets the range options to use for encryption.
Definition encrypt.hpp:254
encrypt()=default
Default initialization.
bsoncxx::v_noabi::stdx::optional< encryption_algorithm > const & algorithm() const
Gets the current algorithm.
Definition encrypt.hpp:201
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::types::bson_value::view_or_value > const & key_id() const
Gets the key_id.
Definition encrypt.hpp:128
Used by mongocxx::v_noabi::options::encrypt::range_opts.
Definition range.hpp:51
Declares mongocxx::v_noabi::options::encrypt.
Provides mongocxx::v1::encrypt_options.
#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< view, value > view_or_value
Equivalent to v_noabi::view_or_value<view, value>.
Definition view_or_value.hpp:31
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 mongocxx::v_noabi::options::range.
Declares mongocxx::v_noabi::options::range.
Provides bsoncxx::v_noabi::types::bson_value::view_or_value.
Provides entities used to represent BSON types.
Provides bsoncxx::v1::types::value.
Provides std::optional-related polyfills for library API usage.
Provides bsoncxx::v_noabi::types::bson_value::view.
Declares mongocxx::v_noabi::client_encryption.