From df2a759cc3c46329f29a0d6dc32b1ace09cf5c8d Mon Sep 17 00:00:00 2001
From: Ross Lawley `):
+ - `@ref type_name` → `{@link type_name}` (for types) or `{@link #function_name}`
+ (for functions in the same class)
+ - `@p param_name` → `{@code param_name}`
+ - `@param[in] name` / `@param[out] name` → `@param name`
+ - `@returns` → `@return`
+ - `@pre condition` → a ` Requires that condition.` paragraph (keeping the condition text verbatim)
+ - `@code{.c}` example blocks may be omitted
+- Preserve the header's own quirks (e.g. a `@ref` pointing at an unexpected status function) —
+ fidelity to the header beats local consistency
+
+Declarations with no `mongocrypt.h` counterpart (e.g. the `cstring` helper, the legacy
+`mongocrypt_opts_t` class) get Java-authored Javadoc; keep it accurate and note when a type is
+retained only for backwards compatibility.
+
+Verify the result still generates cleanly with `./gradlew :mongodb-crypt:javadoc`.
+
## Build & Test
```bash
diff --git a/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/CAPI.java b/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/CAPI.java
index 41cc8ced31b..521037057ea 100644
--- a/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/CAPI.java
+++ b/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/CAPI.java
@@ -52,16 +52,18 @@ public String toString() {
/**
* Indicates success or contains error information.
*
- * Functions like @ref mongocrypt_ctx_encrypt_init follow a pattern to expose a
+ * Functions like {@link #mongocrypt_ctx_encrypt_init} follow a pattern to expose a
* status. A boolean is returned. True indicates success, and false indicates
* failure. On failure a status on the handle is set, and is accessible with a
- * corresponding status function. E.g. @ref mongocrypt_ctx_status.
+ * corresponding (handle)_status function. E.g. {@link #mongocrypt_ctx_status}.
*/
public static class mongocrypt_status_t extends PointerType {
}
/**
- * Contains all options passed on initialization of a @ref mongocrypt_ctx_t.
+ * Contains all options passed on initialization of a {@link mongocrypt_t}.
+ *
+ * Not present in mongocrypt.h: retained for backwards compatibility of this binding class.
*/
public static class mongocrypt_opts_t extends PointerType {
}
@@ -69,8 +71,19 @@ public static class mongocrypt_opts_t extends PointerType {
/**
* A non-owning view of a byte buffer.
*
- * Functions returning a mongocrypt_binary_t* expect it to be destroyed with
- * mongocrypt_binary_destroy.
+ * When constructing a {@link mongocrypt_binary_t} it is the responsibility of the
+ * caller to maintain the lifetime of the viewed data. However, all public
+ * functions that take a {@link mongocrypt_binary_t} as an argument will make a copy of
+ * the viewed data.
+ *
+ * Functions with a {@link mongocrypt_binary_t}* out guarantee the lifetime of the
+ * viewed data to live as long as the parent object. For example,
+ * {@link #mongocrypt_ctx_mongo_op} guarantees that the viewed data of
+ * {@link mongocrypt_binary_t} is valid until the parent ctx is destroyed with
+ * {@link #mongocrypt_ctx_destroy}.
+ *
+ * The {@code mongocrypt_binary_t} struct definition is public.
+ * Consumers may rely on the struct layout.
*/
public static class mongocrypt_binary_t extends PointerType {
// The `mongocrypt_binary_t` struct layout is part of libmongocrypt's ABI:
@@ -83,9 +96,11 @@ public static class mongocrypt_binary_t extends PointerType {
public mongocrypt_binary_t() {
super();
}
+
public Pointer data() {
return this.getPointer().getPointer(0);
}
+
public int len() {
int len = this.getPointer().getInt(Native.POINTER_SIZE);
// mongocrypt_binary_t represents length as an unsigned `uint32_t`.
@@ -107,7 +122,7 @@ public int len() {
* encryption, decryption, registering log callbacks, etc.
*
* Functions on a mongocrypt_t are thread safe, though functions on derived
- * handle (e.g. mongocrypt_encryptor_t) are not and must be owned by a single
+ * handles (e.g. mongocrypt_ctx_t) are not and must be owned by a single
* thread. See each handle's documentation for thread-safety considerations.
*
* Multiple mongocrypt_t handles may be created.
@@ -152,7 +167,7 @@ public static class mongocrypt_kms_ctx_t extends PointerType {
* Create a new non-owning view of a buffer (data + length).
*
* @param data A pointer to an array of bytes. This is not copied. data must outlive the binary object.
- * @param len The length of the @p data byte array.
+ * @param len The length of the {@code data} byte array.
* @return A new mongocrypt_binary_t.
*/
public static native mongocrypt_binary_t
@@ -160,31 +175,29 @@ public static class mongocrypt_kms_ctx_t extends PointerType {
/**
- * Get a pointer to the referenced data.
+ * Get a pointer to the viewed data.
*
- * @param binary The @ref mongocrypt_binary_t.
- * @return A pointer to the referenced data.
+ * @param binary The {@link mongocrypt_binary_t}.
+ * @return A pointer to the viewed data.
*/
public static native Pointer
mongocrypt_binary_data(mongocrypt_binary_t binary);
/**
- * Get the length of the referenced data.
+ * Get the length of the viewed data.
*
- * @param binary The @ref mongocrypt_binary_t.
- * @return The length of the referenced data.
+ * @param binary The {@link mongocrypt_binary_t}.
+ * @return The length of the viewed data.
*/
public static native int
mongocrypt_binary_len(mongocrypt_binary_t binary);
/**
- * Free the @ref mongocrypt_binary_t.
+ * Free the {@link mongocrypt_binary_t}.
*
- * This does not free the referenced data. Refer to individual function
- * documentation to determine the lifetime guarantees of the underlying
- * data.
+ * This does not free the viewed data.
*
* @param binary The mongocrypt_binary_t destroy.
*/
@@ -200,8 +213,8 @@ public static class mongocrypt_kms_ctx_t extends PointerType {
* Create a new status object.
*
* Use a new status object to retrieve the status from a handle by passing
- * this as an out-parameter to functions like @ref mongocrypt_ctx_status.
- * When done, destroy it with @ref mongocrypt_status_destroy.
+ * this as an out-parameter to functions like {@link #mongocrypt_ctx_status}.
+ * When done, destroy it with {@link #mongocrypt_status_destroy}.
*
* @return A new status object.
*/
@@ -217,20 +230,23 @@ public static class mongocrypt_kms_ctx_t extends PointerType {
* @param type The status type.
* @param code The status code.
* @param message The message.
- * @param message_len The length of @p message. Pass -1 to determine the * string length with strlen (must * be NULL terminated).
+ * @param message_len Due to historical behavior, pass 1 + the string length
+ * of {@code message} (which differs from other functions accepting string
+ * arguments). Alternatively, if message is NULL terminated this may be -1 to
+ * tell mongocrypt to determine the string's length with strlen.
*/
public static native void
mongocrypt_status_set(mongocrypt_status_t status,
- int type,
- int code,
- cstring message,
- int message_len);
+ int type,
+ int code,
+ cstring message,
+ int message_len);
/**
* Indicates success or the type of error.
*
* @param status The status object.
- * @return A @ref mongocrypt_status_type_t.
+ * @return A mongocrypt_status_type_t.
*/
public static native int
@@ -248,11 +264,12 @@ public static class mongocrypt_kms_ctx_t extends PointerType {
/**
- * Get the error message associated with a status, or an empty string.
+ * Get the error message associated with a status or NULL.
*
* @param status The status object.
- * @param len an optional length of the returned string. May be NULL.
- * @return An error message or an empty string.
+ * @param len An optional length of the returned string (excluding the
+ * trailing NULL byte). May be NULL.
+ * @return A NULL terminated error message or NULL.
*/
public static native cstring
mongocrypt_status_message(mongocrypt_status_t status, Pointer len);
@@ -310,24 +327,26 @@ public interface mongocrypt_random_fn extends Callback {
}
/**
- * Allocate a new @ref mongocrypt_t object.
+ * Allocate a new {@link mongocrypt_t} object.
*
- * Initialize with @ref mongocrypt_init. When done, free with @ref
- * mongocrypt_destroy.
+ * Set options using mongocrypt_setopt_* functions, then initialize with {@link #mongocrypt_init}.
+ * When done with the {@link mongocrypt_t}, free with {@link #mongocrypt_destroy}.
*
- * @return A new @ref mongocrypt_t object.
+ * @return A new {@link mongocrypt_t} object.
*/
public static native mongocrypt_t
mongocrypt_new();
/**
- * Set a handler to get called on every log message.
+ * Set a handler on the {@link mongocrypt_t} object to get called on every log message.
+ *
+ * Requires that {@link #mongocrypt_init} has not been called on {@code crypt}.
*
- * @param crypt The @ref mongocrypt_t object.
+ * @param crypt The {@link mongocrypt_t} object.
* @param log_fn The log callback.
* @param log_ctx A context passed as an argument to the log callback every
- * invokation.
- * @return A boolean indicating success.
+ * invocation.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status}
*/
public static native boolean
mongocrypt_setopt_log_handler(mongocrypt_t crypt,
@@ -348,19 +367,18 @@ public interface mongocrypt_random_fn extends Callback {
/**
* Set a crypto hook for the AES256-CTR operations.
*
- * @param crypt The @ref mongocrypt_t object.
+ * @param crypt The {@link mongocrypt_t} object.
* @param aes_256_ctr_encrypt The crypto callback function for encrypt
- * operation.
+ * operation.
* @param aes_256_ctr_decrypt The crypto callback function for decrypt
- * operation.
- * @param ctx A context passed as an argument to the crypto callback
- * every invocation.
- * @return A boolean indicating success. If false, an error status is set.
- * Retrieve it with @ref mongocrypt_status
+ * operation.
+ * @param ctx A context passed as an argument to the crypto callback
+ * every invocation.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_status}
*
*/
public static native boolean
- mongocrypt_setopt_aes_256_ctr (mongocrypt_t crypt,
+ mongocrypt_setopt_aes_256_ctr(mongocrypt_t crypt,
mongocrypt_crypto_fn aes_256_ctr_encrypt,
mongocrypt_crypto_fn aes_256_ctr_decrypt,
Pointer ctx);
@@ -373,12 +391,11 @@ public interface mongocrypt_random_fn extends Callback {
* Note: this function has the wrong name. It should be:
* mongocrypt_setopt_crypto_hook_sign_rsassa_pkcs1_v1_5 This has been superseded by the more flexible:
+ * {@link #mongocrypt_setopt_kms_providers}.
+ *
+ * Requires that {@link #mongocrypt_init} has not been called on {@code crypt}.
+ *
+ * @param crypt The {@link mongocrypt_t} object.
+ * @param aws_access_key_id The AWS access key ID used to generate KMS
+ * messages.
+ * @param aws_access_key_id_len The string length (in bytes) of {@code aws_access_key_id}.
+ * Pass -1 to determine the string length with strlen (must be NULL terminated).
+ * @param aws_secret_access_key The AWS secret access key used to generate
+ * KMS messages.
+ * @param aws_secret_access_key_len The string length (in bytes) of {@code aws_secret_access_key}.
+ * Pass -1 to determine the string length
+ * with strlen (must be NULL terminated).
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status}
*/
public static native boolean
mongocrypt_setopt_kms_provider_aws(mongocrypt_t crypt,
@@ -410,11 +431,18 @@ public interface mongocrypt_random_fn extends Callback {
int aws_secret_access_key_len);
/**
- * Configure a local KMS provider on the @ref mongocrypt_t object.
+ * Configure a local KMS provider on the {@link mongocrypt_t} object.
*
- * @param crypt The @ref mongocrypt_t object.
- * @param key A 64 byte master key used to encrypt and decrypt key vault keys.
- * @return A boolean indicating success.
+ * This has been superseded by the more flexible:
+ * {@link #mongocrypt_setopt_kms_providers}.
+ *
+ * Requires that {@link #mongocrypt_init} has not been called on {@code crypt}.
+ *
+ * @param crypt The {@link mongocrypt_t} object.
+ * @param key A 96 byte master key used to encrypt and decrypt key vault
+ * keys. The viewed data is copied. It is valid to destroy {@code key} with
+ * {@link #mongocrypt_binary_destroy} immediately after.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status}
*/
public static native boolean
mongocrypt_setopt_kms_provider_local(mongocrypt_t crypt,
@@ -423,10 +451,13 @@ public interface mongocrypt_random_fn extends Callback {
/**
* Configure KMS providers with a BSON document.
*
- * @param crypt The @ref mongocrypt_t object.
- * @param kms_providers A BSON document mapping the KMS provider names to credentials.
- * @return A boolean indicating success. If false, an error status is set.
- * @since 1.1
+ * Requires that {@link #mongocrypt_init} has not been called on {@code crypt}.
+ *
+ * @param crypt The {@link mongocrypt_t} object.
+ * @param kms_providers A BSON document mapping the KMS provider names to credentials. Set a KMS
+ * provider value to an empty document to supply credentials on-demand with
+ * {@link #mongocrypt_ctx_provide_kms_providers}.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status}
*/
public static native boolean
mongocrypt_setopt_kms_providers(mongocrypt_t crypt,
@@ -435,41 +466,50 @@ public interface mongocrypt_random_fn extends Callback {
/**
* Set a local schema map for encryption.
*
- * @param crypt The @ref mongocrypt_t object.
+ * Requires that {@code crypt} has not been initialized.
+ *
+ * @param crypt The {@link mongocrypt_t} object.
* @param schema_map A BSON document representing the schema map supplied by
- * the user. The keys are collection namespaces and values are JSON schemas.
- * @return A boolean indicating success. If false, an error status is set.
- * Retrieve it with @ref mongocrypt_status
+ * the user. The keys are collection namespaces and values are JSON schemas.
+ * The viewed data copied. It is valid to destroy {@code schema_map} with
+ * {@link #mongocrypt_binary_destroy} immediately after.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_status}
*/
public static native boolean
- mongocrypt_setopt_schema_map (mongocrypt_t crypt, mongocrypt_binary_t schema_map);
+ mongocrypt_setopt_schema_map(mongocrypt_t crypt, mongocrypt_binary_t schema_map);
/**
- * Opt-into setting KMS providers before each KMS request.
+ * Opt-into handling the {@link #MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS} state.
*
- * If set, before entering the MONGOCRYPT_CTX_NEED_KMS state,
- * contexts will enter the MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS state
- * and then wait for credentials to be supplied through @ref mongocrypt_ctx_provide_kms_providers.
+ * If set, before entering the {@link #MONGOCRYPT_CTX_NEED_KMS} state,
+ * contexts may enter the {@link #MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS} state
+ * and then wait for credentials to be supplied through
+ * {@link #mongocrypt_ctx_provide_kms_providers}.
*
- * @param crypt The @ref mongocrypt_t object to update
+ * A context will only enter {@link #MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS}
+ * if an empty document was set for a KMS provider in
+ * {@link #mongocrypt_setopt_kms_providers}.
+ *
+ * @param crypt The {@link mongocrypt_t} object to update
*/
public static native void
- mongocrypt_setopt_use_need_kms_credentials_state (mongocrypt_t crypt);
+ mongocrypt_setopt_use_need_kms_credentials_state(mongocrypt_t crypt);
/**
* Set a local EncryptedFieldConfigMap for encryption.
*
- * @param crypt The @ref mongocrypt_t object.
+ * Requires that {@code crypt} has not been initialized.
+ *
+ * @param crypt The {@link mongocrypt_t} object.
* @param encryptedFieldConfigMap A BSON document representing the EncryptedFieldConfigMap
- * supplied by the user. The keys are collection namespaces and values are
- * EncryptedFieldConfigMap documents. The viewed data copied. It is valid to
- * destroy @p efc_map with @ref mongocrypt_binary_destroy immediately after.
- * @return A boolean indicating success. If false, an error status is set.
- * Retrieve it with @ref mongocrypt_status
+ * supplied by the user. The keys are collection namespaces and values are
+ * EncryptedFieldConfigMap documents. The viewed data copied. It is valid to
+ * destroy {@code efc_map} with {@link #mongocrypt_binary_destroy} immediately after.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_status}
*/
public static native boolean
- mongocrypt_setopt_encrypted_field_config_map (mongocrypt_t crypt, mongocrypt_binary_t encryptedFieldConfigMap);
+ mongocrypt_setopt_encrypted_field_config_map(mongocrypt_t crypt, mongocrypt_binary_t encryptedFieldConfigMap);
/**
* Opt-into skipping query analysis.
@@ -477,113 +517,106 @@ public interface mongocrypt_random_fn extends Callback {
* If opted in:
*
+ * If the index key id not set, the key id from {@link #mongocrypt_ctx_setopt_key_id} is used.
*
- * If the index key id not set, the key id from @ref mongocrypt_ctx_setopt_key_id is used.
- *
- * @param ctx The @ref mongocrypt_ctx_t object.
+ * @param ctx The {@link mongocrypt_ctx_t} object.
* @param key_id The binary corresponding to the _id (a UUID) of the data key to use from
* the key vault collection. Note, the UUID must be encoded with RFC-4122 byte order.
- * The viewed data is copied. It is valid to destroy key_id with @ref mongocrypt_binary_destroy immediately after.
- * @return A boolean indicating success. If false, an error status is set.
- * Retrieve it with @ref mongocrypt_ctx_status
- * @since 1.5
+ * The viewed data is copied. It is valid to destroy key_id with {@link #mongocrypt_binary_destroy} immediately after.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status}
*/
public static native boolean
- mongocrypt_ctx_setopt_index_key_id (mongocrypt_ctx_t ctx, mongocrypt_binary_t key_id);
+ mongocrypt_ctx_setopt_index_key_id(mongocrypt_ctx_t ctx, mongocrypt_binary_t key_id);
/**
* Append an additional search directory to the search path for loading
* the crypt_shared dynamic library.
*
- * @param crypt The @ref mongocrypt_t object to update
- * @param path A null-terminated sequence of bytes for the search path. On
- * some filesystems, this may be arbitrary bytes. On other filesystems, this may
- * be required to be a valid UTF-8 code unit sequence. If the leading element of
- * the path is the literal string "$ORIGIN", that substring will be replaced
- * with the directory path containing the executable libmongocrypt module. If
- * the path string is literal "$SYSTEM", then libmongocrypt will defer to the
- * system's library resolution mechanism to find the crypt_shared library.
- *
- * If no crypt_shared dynamic library is found in any of the directories
- * specified by the search paths loaded here, @ref mongocrypt_init() will still
- * succeed and continue to operate without crypt_shared. The search paths are searched in the order that they are appended. This
- * allows one to provide a precedence in how the library will be discovered. For
- * example, appending known directories before appending "$SYSTEM" will allow
- * one to supersede the system's installed library, but still fall-back to it if
- * the library wasn't found otherwise. If one does not ever append "$SYSTEM",
- * then the system's library-search mechanism will never be consulted. If an absolute path to the library is specified using @ref mongocrypt_setopt_set_crypt_shared_lib_path_override,
- * then paths appended here will have no effect. If no crypt_shared dynamic library is found in any of the directories
+ * specified by the search paths loaded here, {@link #mongocrypt_init}() will still
+ * succeed and continue to operate without crypt_shared. The search paths are searched in the order that they are appended. This
+ * allows one to provide a precedence in how the library will be discovered. For
+ * example, appending known directories before appending "$SYSTEM" will allow
+ * one to supersede the system's installed library, but still fall-back to it if
+ * the library wasn't found otherwise. If one does not ever append "$SYSTEM",
+ * then the system's library-search mechanism will never be consulted. If an absolute path to the library is specified using {@link #mongocrypt_setopt_set_crypt_shared_lib_path_override},
+ * then paths appended here will have no effect. This function will do no IO nor path validation. All validation will
- * occur during the call to @ref mongocrypt_init. If a crypt_shared library path override is specified here, then no paths given
- * to @ref mongocrypt_setopt_append_crypt_shared_lib_search_path will be consulted when
- * opening the crypt_shared library. If a path is provided via this API and @ref mongocrypt_init fails to
- * initialize a valid crypt_shared library instance for the path specified, then
- * the initialization of mongocrypt_t will fail with an error. This function will do no IO nor path validation. All validation will
+ * occur during the call to {@link #mongocrypt_init}. If a crypt_shared library path override is specified here, then no paths given
+ * to {@link #mongocrypt_setopt_append_crypt_shared_lib_search_path} will be consulted when
+ * opening the crypt_shared library. If a path is provided via this API and {@link #mongocrypt_init} fails to
+ * initialize a valid crypt_shared library instance for the path specified, then
+ * the initialization of mongocrypt_t will fail with an error.
* opts is a BSON document of the form:
* {
- * "min": Optional<BSON value>,
- * "max": Optional<BSON value>,
- * "sparsity": Int64,
- * "precision": Optional<Int32>
- * "trimFactor": Optional<Int32>
+ * "min": Optional<BSON value>,
+ * "max": Optional<BSON value>,
+ * "sparsity": Optional<Int64>,
+ * "precision": Optional<Int32>
+ * "trimFactor": Optional<Int32>
* }
*
- * @param ctx The @ref mongocrypt_ctx_t object.
+ * @param ctx The {@link mongocrypt_ctx_t} object.
* @param opts BSON.
* @return A boolean indicating success. If false, an error status is set.
- * @since 1.7
*/
public static native boolean
- mongocrypt_ctx_setopt_algorithm_range (mongocrypt_ctx_t ctx, mongocrypt_binary_t opts);
+ mongocrypt_ctx_setopt_algorithm_range(mongocrypt_ctx_t ctx, mongocrypt_binary_t opts);
/**
* Set options for explicit encryption with the "textPreview" algorithm. "prefix" and "suffix" can both be set.
* NOTE: "textPreview" is experimental only and may be removed in a future non-major release.
* opts is a BSON document of the form:
- *
+ *
* {
- * "caseSensitive": bool,
- * "diacriticSensitive": bool,
- * "prefix": Optional{
- * "strMaxQueryLength": Int32,
- * "strMinQueryLength": Int32,
- * },
- * "suffix": Optional{
- * "strMaxQueryLength": Int32,
- * "strMinQueryLength": Int32,
- * },
- * "substring": Optional{
- * "strMaxLength": Int32,
- * "strMaxQueryLength": Int32,
- * "strMinQueryLength": Int32,
- * },
+ * "caseSensitive": bool,
+ * "diacriticSensitive": bool,
+ * "prefix": Optional{
+ * "strMaxQueryLength": Int32,
+ * "strMinQueryLength": Int32,
+ * },
+ * "suffix": Optional{
+ * "strMaxQueryLength": Int32,
+ * "strMinQueryLength": Int32,
+ * },
+ * "substring": Optional{
+ * "strMaxLength": Int32,
+ * "strMaxQueryLength": Int32,
+ * "strMinQueryLength": Int32,
+ * },
* }
*
- * @param ctx The @ref mongocrypt_ctx_t object.
+ * @param ctx The {@link mongocrypt_ctx_t} object.
* @param opts BSON.
* @return A boolean indicating success. If false, an error status is set.
- * @since 5.6
*/
public static native boolean mongocrypt_ctx_setopt_algorithm_text(mongocrypt_ctx_t ctx, mongocrypt_binary_t opts);
/**
- * Initialize new @ref mongocrypt_t object.
+ * Initialize new {@link mongocrypt_t} object.
*
- * @param crypt The @ref mongocrypt_t object.
- * @return A boolean indicating success. Failure may occur if previously set options are invalid.
+ * Set options before using {@link #mongocrypt_setopt_kms_provider_local},
+ * {@link #mongocrypt_setopt_kms_provider_aws}, or {@link #mongocrypt_setopt_log_handler}.
+ *
+ * @param crypt The {@link mongocrypt_t} object.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with
+ * {@link #mongocrypt_ctx_status} Failure may occur if previously set options are invalid.
*/
public static native boolean
mongocrypt_init(mongocrypt_t crypt);
/**
- * Get the status associated with a @ref mongocrypt_t object.
+ * Get the status associated with a {@link mongocrypt_t} object.
*
- * @param crypt The @ref mongocrypt_t object.
+ * @param crypt The {@link mongocrypt_t} object.
* @param status Receives the status.
* @return A boolean indicating success.
*/
@@ -685,9 +718,9 @@ public interface mongocrypt_random_fn extends Callback {
mongocrypt_is_crypto_available();
/**
- * Destroy the @ref mongocrypt_t object.
+ * Destroy the {@link mongocrypt_t} object.
*
- * @param crypt The @ref mongocrypt_t object to destroy.
+ * @param crypt The {@link mongocrypt_t} object to destroy.
*/
public static native void
mongocrypt_destroy(mongocrypt_t crypt);
@@ -695,45 +728,49 @@ public interface mongocrypt_random_fn extends Callback {
/**
* Obtain a nul-terminated version string of the loaded crypt_shared dynamic library,
* if available.
- *
+ *
* If no crypt_shared was successfully loaded, this function returns NULL.
*
- * @param crypt The mongocrypt_t object after a successful call to mongocrypt_init.
- * @param len an optional length of the returned string. May be NULL.
- *
+ * @param crypt The {@link mongocrypt_t} object after a successful call to {@link #mongocrypt_init}.
+ * @param len an optional length of the returned string. May be NULL.
* @return A nul-terminated string of the dynamically loaded crypt_shared library.
- * @since 1.5
*/
public static native cstring
- mongocrypt_crypt_shared_lib_version_string (mongocrypt_t crypt, Pointer len);
+ mongocrypt_crypt_shared_lib_version_string(mongocrypt_t crypt, Pointer len);
/**
- * Call in response to the MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS state
+ * Call in response to the {@link #MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS} state
* to set per-context KMS provider settings. These follow the same format
- * as @ref mongocrypt_setopt_kms_providers. If no keys are present in the
- * BSON input, the KMS provider settings configured for the @ref mongocrypt_t
+ * as {@link #mongocrypt_setopt_kms_providers}. If no keys are present in the
+ * BSON input, the KMS provider settings configured for the {@link mongocrypt_t}
* at initialization are used.
*
- * @param ctx The @ref mongocrypt_ctx_t object.
+ * @param ctx The {@link mongocrypt_ctx_t} object.
* @param kms_providers A BSON document mapping the KMS provider names
- * to credentials.
- * @return A boolean indicating success. If false, an error status is set.
- * Retrieve it with @ref mongocrypt_ctx_status.
+ * to credentials.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status}.
*/
public static native boolean
- mongocrypt_ctx_provide_kms_providers (mongocrypt_ctx_t ctx,
- mongocrypt_binary_t kms_providers);
+ mongocrypt_ctx_provide_kms_providers(mongocrypt_ctx_t ctx,
+ mongocrypt_binary_t kms_providers);
/**
* Set the key id to use for explicit encryption.
*
- * @param ctx The @ref mongocrypt_ctx_t object.
- * @param key_id The key_id to use.
- * @return A boolean indicating success.
+ * It is an error to set both this and the key alt name.
+ *
+ * Requires that {@code ctx} has not been initialized.
+ *
+ * @param ctx The {@link mongocrypt_ctx_t} object.
+ * @param key_id The binary corresponding to the _id (a UUID) of the data
+ * key to use from the key vault collection. Note, the UUID must be encoded with
+ * RFC-4122 byte order. The viewed data is copied. It is valid to destroy
+ * {@code key_id} with {@link #mongocrypt_binary_destroy} immediately after.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status}
*/
public static native boolean
- mongocrypt_ctx_setopt_key_id (mongocrypt_ctx_t ctx,
- mongocrypt_binary_t key_id);
+ mongocrypt_ctx_setopt_key_id(mongocrypt_ctx_t ctx,
+ mongocrypt_binary_t key_id);
/**
* Set the keyAltName to use for explicit encryption.
@@ -742,14 +779,13 @@ public interface mongocrypt_random_fn extends Callback {
*
* It is an error to set both this and the key id.
*
*
- * @param crypt The @ref mongocrypt_t object to update
- * @since 1.5
+ * @param crypt The {@link mongocrypt_t} object to update
*/
public static native void
- mongocrypt_setopt_bypass_query_analysis (mongocrypt_t crypt);
+ mongocrypt_setopt_bypass_query_analysis(mongocrypt_t crypt);
/**
* Set the expiration time for the data encryption key cache. Defaults to 60 seconds if not set.
*
- * @param crypt The @ref mongocrypt_t object to update
+ * @param crypt The {@link mongocrypt_t} object to update
* @param cache_expiration_ms if 0 the cache never expires
* @return A boolean indicating success. If false, an error status is set.
- * @since 5.4
*/
public static native boolean
- mongocrypt_setopt_key_expiration (mongocrypt_t crypt, long cache_expiration_ms);
+ mongocrypt_setopt_key_expiration(mongocrypt_t crypt, long cache_expiration_ms);
/**
* Opt-into enabling sending multiple collection info documents.
*
- * @param crypt The @ref mongocrypt_t object to update
+ * @param crypt The {@link mongocrypt_t} object to update
*/
public static native void
- mongocrypt_setopt_enable_multiple_collinfo (mongocrypt_t crypt);
+ mongocrypt_setopt_enable_multiple_collinfo(mongocrypt_t crypt);
/**
* Set the contention factor used for explicit encryption.
* The contention factor is only used for indexed Queryable Encryption.
*
- * @param ctx The @ref mongocrypt_ctx_t object.
+ * @param ctx The {@link mongocrypt_ctx_t} object.
* @param contention_factor the contention factor
- * @return A boolean indicating success. If false, an error status is set.
- * Retrieve it with @ref mongocrypt_ctx_status.
- * @since 1.5
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status}.
*/
public static native boolean
- mongocrypt_ctx_setopt_contention_factor (mongocrypt_ctx_t ctx, long contention_factor);
+ mongocrypt_ctx_setopt_contention_factor(mongocrypt_ctx_t ctx, long contention_factor);
/**
* Set the index key id to use for Queryable Encryption explicit encryption.
+ * { "keyMaterial" : (BSON BINARY value) }
*
Requires that {@code ctx} has not been initialized. + * + * @param ctx The {@link mongocrypt_ctx_t} object. * @param key_material The data encryption key to use. The viewed data is - * copied. It is valid to destroy @p key_material with @ref - * mongocrypt_binary_destroy immediately after. - * @return A boolean indicating success. If false, an error status is set. - * Retrieve it with @ref mongocrypt_ctx_status + * copied. It is valid to destroy {@code key_material} with {@link #mongocrypt_binary_destroy} immediately after. + * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status} */ public static native boolean - mongocrypt_ctx_setopt_key_material (mongocrypt_ctx_t ctx, mongocrypt_binary_t key_material); + mongocrypt_ctx_setopt_key_material(mongocrypt_ctx_t ctx, mongocrypt_binary_t key_material); /** * Set the algorithm used for encryption to either * deterministic or random encryption. This value * should only be set when using explicit encryption. - * + *
* If -1 is passed in for "len", then "algorithm" is * assumed to be a null-terminated string. - * + *
* Valid values for algorithm are: - * "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" - * "AEAD_AES_256_CBC_HMAC_SHA_512-Randomized" + * "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" + * "AEAD_AES_256_CBC_HMAC_SHA_512-Random" * - * @param ctx The @ref mongocrypt_ctx_t object. + * @param ctx The {@link mongocrypt_ctx_t} object. * @param algorithm A string specifying the algorithm to - * use for encryption. - * @param len The length of the algorithm string. + * use for encryption. + * @param len The length of the algorithm string. * @return A boolean indicating success. */ public static native boolean @@ -794,12 +830,12 @@ public interface mongocrypt_random_fn extends Callback { /** - * Create a new uninitialized @ref mongocrypt_ctx_t. + * Create a new uninitialized {@link mongocrypt_ctx_t}. *
- * Initialize the context with functions like @ref mongocrypt_ctx_encrypt_init. - * When done, destroy it with @ref mongocrypt_ctx_destroy. + * Initialize the context with functions like {@link #mongocrypt_ctx_encrypt_init}. + * When done, destroy it with {@link #mongocrypt_ctx_destroy}. * - * @param crypt The @ref mongocrypt_t object. + * @param crypt The {@link mongocrypt_t} object. * @return A new context. */ public static native mongocrypt_ctx_t @@ -807,9 +843,9 @@ public interface mongocrypt_random_fn extends Callback { /** - * Get the status associated with a @ref mongocrypt_ctx_t object. + * Get the status associated with a {@link mongocrypt_ctx_t} object. * - * @param ctx The @ref mongocrypt_ctx_t object. + * @param ctx The {@link mongocrypt_ctx_t} object. * @param status Receives the status. * @return A boolean indicating success. */ @@ -821,14 +857,14 @@ public interface mongocrypt_random_fn extends Callback { /** * Identify the AWS KMS master key to use for creating a data key. * - * @param ctx The @ref mongocrypt_ctx_t object. - * @param region The AWS region. - * @param region_len The string length of @p region. Pass -1 to determine - * the string length with strlen (must be NULL terminated). - * @param cmk The Amazon Resource Name (ARN) of the customer master key - * (CMK). - * @param cmk_len The string length of @p cmk_len. Pass -1 to determine the - * string length with strlen (must be NULL terminated). + * @param ctx The {@link mongocrypt_ctx_t} object. + * @param region The AWS region. + * @param region_len The string length of {@code region}. Pass -1 to determine + * the string length with strlen (must be NULL terminated). + * @param cmk The Amazon Resource Name (ARN) of the customer master key + * (CMK). + * @param cmk_len The string length of {@code cmk_len}. Pass -1 to determine the + * string length with strlen (must be NULL terminated). * @return A boolean indicating success. */ public static native boolean @@ -845,12 +881,11 @@ public interface mongocrypt_random_fn extends Callback { * is persisted in the new data key, and will be returned via * mongocrypt_kms_ctx_endpoint. * - * @param ctx The @ref mongocrypt_ctx_t object. - * @param endpoint The endpoint. - * @param endpoint_len The string length of @p endpoint. Pass -1 to - * determine the string length with strlen (must be NULL terminated). - * @return A boolean indicating success. If false, an error status is set. - * Retrieve it with @ref mongocrypt_ctx_status + * @param ctx The {@link mongocrypt_ctx_t} object. + * @param endpoint The endpoint. + * @param endpoint_len The string length of {@code endpoint}. Pass -1 to + * determine the string length with strlen (must be NULL terminated). + * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status} */ public static native boolean mongocrypt_ctx_setopt_masterkey_aws_endpoint (mongocrypt_ctx_t ctx, @@ -860,53 +895,52 @@ public interface mongocrypt_random_fn extends Callback { /** * Set the master key to "local" for creating a data key. + * This has been superseded by the more flexible: + * {@link #mongocrypt_ctx_setopt_key_encryption_key} * - * @param ctx The @ref mongocrypt_ctx_t object. - * @return A boolean indicating success. + *
Requires that {@code ctx} has not been initialized. + * + * @param ctx The {@link mongocrypt_ctx_t} object. + * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status} */ public static native boolean - mongocrypt_ctx_setopt_masterkey_local (mongocrypt_ctx_t ctx); + mongocrypt_ctx_setopt_masterkey_local(mongocrypt_ctx_t ctx); /** * Set key encryption key document for creating a data key. * - * @param ctx The @ref mongocrypt_ctx_t object. + * @param ctx The {@link mongocrypt_ctx_t} object. * @param keyDocument BSON representing the key encryption key document. * @return A boolean indicating success. If false, and error status is set. - * @since 1.1 */ public static native boolean mongocrypt_ctx_setopt_key_encryption_key(mongocrypt_ctx_t ctx, - mongocrypt_binary_t keyDocument); + mongocrypt_binary_t keyDocument); /** * Initialize a context to create a data key. - * - * Set options before using @ref mongocrypt_ctx_setopt_masterkey_aws and + *
+ * Set options before using {@link #mongocrypt_ctx_setopt_masterkey_aws} and * mongocrypt_ctx_setopt_masterkey_local. * - * @param ctx The @ref mongocrypt_ctx_t object. + * @param ctx The {@link mongocrypt_ctx_t} object. * @return A boolean indicating success. - * + *
* Assumes a master key option has been set, and an associated KMS provider - * has been set on the parent @ref mongocrypt_t. + * has been set on the parent {@link mongocrypt_t}. */ public static native boolean - mongocrypt_ctx_datakey_init (mongocrypt_ctx_t ctx); + mongocrypt_ctx_datakey_init(mongocrypt_ctx_t ctx); /** * Initialize a context for encryption. * - * Associated options: - * - @ref mongocrypt_ctx_setopt_cache_noblock - * - @ref mongocrypt_ctx_setopt_schema - * - * @param ctx The @ref mongocrypt_ctx_t object. - * @param db The database name. - * @param db_len The byte length of @p db. Pass -1 to determine the string length with strlen (must be NULL terminated). - * @param cmd The BSON command to be encrypted. - * @return A boolean indicating success. If false, an error status is set. - * Retrieve it with @ref mongocrypt_ctx_status + * @param ctx The {@link mongocrypt_ctx_t} object. + * @param db The database name. + * @param db_len The byte length of {@code db}. Pass -1 to determine the string length with strlen (must be NULL terminated). + * @param cmd The BSON command to be encrypted. The viewed data is copied. + * It is valid to destroy {@code cmd} with {@link #mongocrypt_binary_destroy} immediately after. + * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status} */ public static native boolean mongocrypt_ctx_encrypt_init(mongocrypt_ctx_t ctx, @@ -917,65 +951,67 @@ public interface mongocrypt_random_fn extends Callback { /** * Explicit helper method to encrypt a single BSON object. Contexts * created for explicit encryption will not go through mongocryptd. - * + *
* To specify a key_id, algorithm, or iv to use, please use the * corresponding mongocrypt_setopt methods before calling this. - * + *
* This method expects the passed-in BSON to be of the form: * { "v" : BSON value to encrypt } * - * @param ctx A @ref mongocrypt_ctx_t. - * @param msg A @ref mongocrypt_binary_t the plaintext BSON value. + * @param ctx A {@link mongocrypt_ctx_t}. + * @param msg A {@link mongocrypt_binary_t} the plaintext BSON value. * @return A boolean indicating success. */ public static native boolean - mongocrypt_ctx_explicit_encrypt_init (mongocrypt_ctx_t ctx, - mongocrypt_binary_t msg); + mongocrypt_ctx_explicit_encrypt_init(mongocrypt_ctx_t ctx, + mongocrypt_binary_t msg); /** * Explicit helper method to encrypt a Match Expression or Aggregate Expression. * Contexts created for explicit encryption will not go through mongocryptd. * Requires query_type to be "range". - * NOTE: "range" is currently unstable API and subject to backwards breaking changes. - * + *
* This method expects the passed-in BSON to be of the form: - * { "v" : FLE2RangeFindDriverSpec } + * {@code { "v" : FLE2RangeFindDriverSpec } } * * FLE2RangeFindDriverSpec is a BSON document with one of these forms: * + *
+ *
* 1. A Match Expression of this form:
- * {$and: [{<field>: {<op>: <value1>, {<field>: {<op>: <value2> }}]}
+ * {$and: [{: {: , {: {: }}]}
* 2. An Aggregate Expression of this form:
- * {$and: [{<op>: [<fieldpath>, <value1>]}, {<op>: [<fieldpath>, <value2>]}]
+ * {$and: [{: [, ]}, {: [, ]}]
*
* may be $lt, $lte, $gt, or $gte.
+ *
+ *
*
* The value of "v" is expected to be the BSON value passed to a driver
* ClientEncryption.encryptExpression helper.
*
+ * * Associated options for FLE 1: - * - @ref mongocrypt_ctx_setopt_key_id - * - @ref mongocrypt_ctx_setopt_key_alt_name - * - @ref mongocrypt_ctx_setopt_algorithm - * + * - {@link #mongocrypt_ctx_setopt_key_id} + * - {@link #mongocrypt_ctx_setopt_key_alt_name} + * - {@link #mongocrypt_ctx_setopt_algorithm} + *
* Associated options for Queryable Encryption: - * - @ref mongocrypt_ctx_setopt_key_id - * - @ref mongocrypt_ctx_setopt_index_key_id - * - @ref mongocrypt_ctx_setopt_contention_factor - * - @ref mongocrypt_ctx_setopt_query_type - * - @ref mongocrypt_ctx_setopt_algorithm_range - * + * - {@link #mongocrypt_ctx_setopt_key_id} + * - {@link #mongocrypt_ctx_setopt_index_key_id} + * - {@link #mongocrypt_ctx_setopt_contention_factor} + * - {@link #mongocrypt_ctx_setopt_query_type} + * - {@link #mongocrypt_ctx_setopt_algorithm_range} + *
* An error is returned if FLE 1 and Queryable Encryption incompatible options * are set. * - * @param ctx A @ref mongocrypt_ctx_t. - * @param msg A @ref mongocrypt_binary_t the plaintext BSON value. + * @param ctx A {@link mongocrypt_ctx_t}. + * @param msg A {@link mongocrypt_binary_t} the plaintext BSON value. * @return A boolean indicating success. - * @since 1.7 */ public static native boolean - mongocrypt_ctx_explicit_encrypt_expression_init (mongocrypt_ctx_t ctx, - mongocrypt_binary_t msg); + mongocrypt_ctx_explicit_encrypt_expression_init(mongocrypt_ctx_t ctx, mongocrypt_binary_t msg); /** * Initialize a context for decryption. @@ -991,26 +1027,24 @@ public interface mongocrypt_random_fn extends Callback { /** * Explicit helper method to decrypt a single BSON object. * - * @param ctx A @ref mongocrypt_ctx_t. - * @param msg A @ref mongocrypt_binary_t the encrypted BSON. + * @param ctx A {@link mongocrypt_ctx_t}. + * @param msg A {@link mongocrypt_binary_t} the encrypted BSON. * @return A boolean indicating success. */ public static native boolean - mongocrypt_ctx_explicit_decrypt_init (mongocrypt_ctx_t ctx, - mongocrypt_binary_t msg); + mongocrypt_ctx_explicit_decrypt_init(mongocrypt_ctx_t ctx, mongocrypt_binary_t msg); /** * Initialize a context to rewrap datakeys. - * + *
* Associated options {@link #mongocrypt_ctx_setopt_key_encryption_key(mongocrypt_ctx_t, mongocrypt_binary_t)} * - * @param ctx The @ref mongocrypt_ctx_t object. + * @param ctx The {@link mongocrypt_ctx_t} object. * @param filter The filter to use for the find command on the key vault collection to retrieve datakeys to rewrap. * @return A boolean indicating success. If false, and error status is set. - * @since 1.5 */ public static native boolean - mongocrypt_ctx_rewrap_many_datakey_init (mongocrypt_ctx_t ctx, mongocrypt_binary_t filter); + mongocrypt_ctx_rewrap_many_datakey_init(mongocrypt_ctx_t ctx, mongocrypt_binary_t filter); public static final int MONGOCRYPT_CTX_ERROR = 0; @@ -1029,8 +1063,8 @@ public interface mongocrypt_random_fn extends Callback { /** * Get the current state of a context. * - * @param ctx The @ref mongocrypt_ctx_t object. - * @return A @ref mongocrypt_ctx_state_t. + * @param ctx The {@link mongocrypt_ctx_t} object. + * @return A mongocrypt_ctx_state_t. */ public static native int mongocrypt_ctx_state(mongocrypt_ctx_t ctx); @@ -1041,15 +1075,20 @@ public interface mongocrypt_random_fn extends Callback { * is in MONGOCRYPT_CTX_NEED_MONGO_* states. * *
- * op_bson is a BSON document to be used for the operation. - * - For MONGOCRYPT_CTX_NEED_MONGO_COLLINFO it is a listCollections filter. - * - For MONGOCRYPT_CTX_NEED_MONGO_KEYS it is a find filter. - * - For MONGOCRYPT_CTX_NEED_MONGO_MARKINGS it is a JSON schema to append. + * {@code op_bson} is a BSON document to be used for the operation. + * - For {@link #MONGOCRYPT_CTX_NEED_MONGO_COLLINFO}(_WITH_DB) it is a listCollections filter. + * - For {@link #MONGOCRYPT_CTX_NEED_MONGO_KEYS} it is a find filter. + * - For {@link #MONGOCRYPT_CTX_NEED_MONGO_MARKINGS} it is a command to send to mongocryptd. *
* - * @param ctx The @ref mongocrypt_ctx_t object. - * @param op_bson A BSON document for the MongoDB operation. - * @return A boolean indicating success. + *The lifetime of {@code op_bson} is tied to the lifetime of {@code ctx}. It is valid + * until {@link #mongocrypt_ctx_destroy} is called. + * + * @param ctx The {@link mongocrypt_ctx_t} object. + * @param op_bson A BSON document for the MongoDB operation. The data + * viewed by {@code op_bson} is guaranteed to be valid until {@code ctx} is destroyed with + * {@link #mongocrypt_ctx_destroy}. + * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status} */ public static native boolean mongocrypt_ctx_mongo_op(mongocrypt_ctx_t ctx, mongocrypt_binary_t op_bson); @@ -1061,12 +1100,12 @@ public interface mongocrypt_random_fn extends Callback { * depending on the operation. *
* op_bson is a BSON document to be used for the operation. - * - For MONGOCRYPT_CTX_NEED_MONGO_COLLINFO it is a doc from a listCollections + * - For {@link #MONGOCRYPT_CTX_NEED_MONGO_COLLINFO} it is a doc from a listCollections * cursor. - * - For MONGOCRYPT_CTX_NEED_MONGO_KEYS it is a doc from a find cursor. - * - For MONGOCRYPT_CTX_NEED_MONGO_MARKINGS it is a reply from mongocryptd. + * - For {@link #MONGOCRYPT_CTX_NEED_MONGO_KEYS} it is a doc from a find cursor. + * - For {@link #MONGOCRYPT_CTX_NEED_MONGO_MARKINGS} it is a reply from mongocryptd. * - * @param ctx The @ref mongocrypt_ctx_t object. + * @param ctx The {@link mongocrypt_ctx_t} object. * @param reply A BSON document for the MongoDB operation. * @return A boolean indicating success. */ @@ -1077,7 +1116,7 @@ public interface mongocrypt_random_fn extends Callback { /** * Call when done feeding the reply (or replies) back to the context. * - * @param ctx The @ref mongocrypt_ctx_t object. + * @param ctx The {@link mongocrypt_ctx_t} object. * @return A boolean indicating success. */ @@ -1091,35 +1130,36 @@ public interface mongocrypt_random_fn extends Callback { * out multiple concurrent KMS HTTP requests. Feeding multiple KMS requests * is thread-safe. *
- * Is KMS handles are being handled synchronously, the driver can reuse the same + * If KMS handles are being handled synchronously, the driver can reuse the same * TLS socket to send HTTP requests and receive responses. + *
+ * The returned KMS handle does not outlive {@code ctx}. * - * @param ctx A @ref mongocrypt_ctx_t. - * @return a new @ref mongocrypt_kms_ctx_t or NULL. + * @param ctx A {@link mongocrypt_ctx_t}. + * @return a new {@link mongocrypt_kms_ctx_t} or NULL. */ public static native mongocrypt_kms_ctx_t mongocrypt_ctx_next_kms_ctx(mongocrypt_ctx_t ctx); /** * Get the KMS provider identifier associated with this KMS request. - * + *
* This is used to conditionally configure TLS connections based on the KMS * request. It is useful for KMIP, which authenticates with a client * certificate. * * @param kms The mongocrypt_kms_ctx_t object. * @param len Receives the length of the returned string. - * * @return The name of the KMS provider */ public static native cstring mongocrypt_kms_ctx_get_kms_provider(mongocrypt_kms_ctx_t kms, - Pointer len); + Pointer len); /** * Get the HTTP request message for a KMS handle. * - * @param kms A @ref mongocrypt_kms_ctx_t. + * @param kms A {@link mongocrypt_kms_ctx_t}. * @param msg The HTTP request to send to KMS. * @return A boolean indicating success. */ @@ -1130,11 +1170,11 @@ public interface mongocrypt_random_fn extends Callback { /** * Get the hostname from which to connect over TLS. *
- * The storage for @p endpoint is not owned by the caller, but - * is valid until calling @ref mongocrypt_ctx_kms_done on the - * parent @ref mongocrypt_ctx_t. + * The storage for {@code endpoint} is not owned by the caller, but + * is valid until calling {@link #mongocrypt_ctx_kms_done} on the + * parent {@link mongocrypt_ctx_t}. * - * @param kms A @ref mongocrypt_kms_ctx_t. + * @param kms A {@link mongocrypt_kms_ctx_t}. * @param endpoint The output hostname. * @return A boolean indicating success. */ @@ -1142,9 +1182,9 @@ public interface mongocrypt_random_fn extends Callback { mongocrypt_kms_ctx_endpoint(mongocrypt_kms_ctx_t kms, PointerByReference endpoint); /** - * Indicates how many bytes to feed into @ref mongocrypt_kms_ctx_feed. + * Indicates how many bytes to feed into {@link #mongocrypt_kms_ctx_feed}. * - * @param kms The @ref mongocrypt_kms_ctx_t. + * @param kms The {@link mongocrypt_kms_ctx_t}. * @return The number of requested bytes. */ public static native int @@ -1154,34 +1194,35 @@ public interface mongocrypt_random_fn extends Callback { /** * Feed bytes from the HTTP response. *
- * Feeding more bytes than what has been returned in @ref
- * mongocrypt_kms_ctx_bytes_needed is an error.
+ * Feeding more bytes than what has been returned in
+ * {@link #mongocrypt_kms_ctx_bytes_needed} is an error.
*
- * @param kms The @ref mongocrypt_kms_ctx_t.
- * @param bytes The bytes to feed.
- * @return A boolean indicating success.
+ * @param kms The {@link mongocrypt_kms_ctx_t}.
+ * @param bytes The bytes to feed. The viewed data is copied. It is valid to
+ * destroy bytes with {@link #mongocrypt_binary_destroy} immediately after.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_kms_ctx_status}
*/
public static native boolean
mongocrypt_kms_ctx_feed(mongocrypt_kms_ctx_t kms, mongocrypt_binary_t bytes);
/**
- * Get the status associated with a @ref mongocrypt_kms_ctx_t object.
+ * Get the status associated with a {@link mongocrypt_kms_ctx_t} object.
*
- * @param kms The @ref mongocrypt_kms_ctx_t object.
+ * @param kms The {@link mongocrypt_kms_ctx_t} object.
* @param status Receives the status.
* @return A boolean indicating success.
*/
public static native boolean
mongocrypt_kms_ctx_status(mongocrypt_kms_ctx_t kms,
- mongocrypt_status_t status);
+ mongocrypt_status_t status);
/**
* Call when done handling all KMS contexts.
*
- * @param ctx The @ref mongocrypt_ctx_t object.
- * @return A boolean indicating success.
+ * @param ctx The {@link mongocrypt_ctx_t} object.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status}
*/
public static native boolean
mongocrypt_ctx_kms_done(mongocrypt_ctx_t ctx);
@@ -1190,7 +1231,7 @@ public interface mongocrypt_random_fn extends Callback {
/**
* Perform the final encryption or decryption.
*
- * @param ctx A @ref mongocrypt_ctx_t.
+ * @param ctx A {@link mongocrypt_ctx_t}.
* @param out The final BSON to send to the server.
* @return a boolean indicating success.
*/
@@ -1199,9 +1240,9 @@ public interface mongocrypt_random_fn extends Callback {
/**
- * Destroy and free all memory associated with a @ref mongocrypt_ctx_t.
+ * Destroy and free all memory associated with a {@link mongocrypt_ctx_t}.
*
- * @param ctx A @ref mongocrypt_ctx_t.
+ * @param ctx A {@link mongocrypt_ctx_t}.
*/
public static native void
mongocrypt_ctx_destroy(mongocrypt_ctx_t ctx);
From 5bff2aea9500357c532571b73b7d44c9581fbfca Mon Sep 17 00:00:00 2001
From: Ross Lawley Requires that {@link #mongocrypt_init} has not been called on {@code crypt}.
+ *
+ * @param crypt The {@link mongocrypt_t} object.
+ * @param enable A boolean indicating whether to retry operations.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_ctx_status}
+ */
+ public static native boolean
+ mongocrypt_setopt_retry_kms(mongocrypt_t crypt, boolean enable);
+
/**
* Set the expiration time for the data encryption key cache. Defaults to 60 seconds if not set.
*
@@ -1205,6 +1218,43 @@ public interface mongocrypt_random_fn extends Callback {
public static native boolean
mongocrypt_kms_ctx_feed(mongocrypt_kms_ctx_t kms, mongocrypt_binary_t bytes);
+ /**
+ * Indicates how long to sleep before sending this request.
+ *
+ * @param kms The {@link mongocrypt_kms_ctx_t}.
+ * @return How long to sleep in microseconds.
+ */
+ public static native long
+ mongocrypt_kms_ctx_usleep(mongocrypt_kms_ctx_t kms);
+
+ /**
+ * Feed bytes from the KMS response.
+ *
+ * Feeding more bytes than what has been returned in
+ * {@link #mongocrypt_kms_ctx_bytes_needed} is an error.
+ *
+ * @param kms The {@link mongocrypt_kms_ctx_t}.
+ * @param bytes The bytes to feed. The viewed data is copied. It is valid to
+ * destroy {@code bytes} with {@link #mongocrypt_binary_destroy} immediately after.
+ * @param should_retry Whether the KMS request should be retried. Retry in-place
+ * without calling {@link #mongocrypt_kms_ctx_fail}.
+ * @return A boolean indicating success. If false, an error status is set. Retrieve it with {@link #mongocrypt_kms_ctx_status}
+ */
+ public static native boolean
+ mongocrypt_kms_ctx_feed_with_retry(mongocrypt_kms_ctx_t kms,
+ mongocrypt_binary_t bytes,
+ ByteByReference should_retry);
+
+ /**
+ * Indicate a network error. Discards all data fed to this KMS context with
+ * {@link #mongocrypt_kms_ctx_feed}. The {@link mongocrypt_kms_ctx_t} may be reused.
+ *
+ * @param kms The {@link mongocrypt_kms_ctx_t}.
+ * @return A boolean indicating whether the failed request may be retried.
+ */
+ public static native boolean
+ mongocrypt_kms_ctx_fail(mongocrypt_kms_ctx_t kms);
+
/**
* Get the status associated with a {@link mongocrypt_kms_ctx_t} object.
diff --git a/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoCryptImpl.java b/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoCryptImpl.java
index 774b9e718cb..e4d0a74e1d6 100644
--- a/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoCryptImpl.java
+++ b/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoCryptImpl.java
@@ -73,6 +73,7 @@
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_setopt_kms_provider_local;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_setopt_kms_providers;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_setopt_log_handler;
+import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_setopt_retry_kms;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_setopt_schema_map;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_setopt_set_crypt_shared_lib_path_override;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_setopt_use_need_kms_credentials_state;
@@ -198,6 +199,9 @@ class MongoCryptImpl implements MongoCrypt {
mongocrypt_setopt_use_need_kms_credentials_state(wrapped);
}
+ // always enabled; backoff and budget management are the driver's responsibility
+ configure(() -> mongocrypt_setopt_retry_kms(wrapped, true));
+
if (options.getKmsProviderOptions() != null) {
withBinaryHolder(options.getKmsProviderOptions(),
binary -> configure(() -> mongocrypt_setopt_kms_providers(wrapped, binary)));
diff --git a/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoKeyDecryptor.java b/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoKeyDecryptor.java
index 9b0eae6776f..6bb6a348067 100644
--- a/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoKeyDecryptor.java
+++ b/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoKeyDecryptor.java
@@ -70,7 +70,32 @@ public interface MongoKeyDecryptor {
* returns 0.
* The driver uses {@link #feedWithRetry(ByteBuffer)}; this method is retained to mirror the libmongocrypt API.
+ *
* @param bytes the received bytes
+ * @see #feedWithRetry(ByteBuffer)
*/
void feed(ByteBuffer bytes);
+
+ /**
+ * Gets the number of microseconds to sleep before sending the next KMS request.
+ *
+ * @return the number of microseconds to sleep, or 0 if no delay is needed
+ */
+ long sleepMicroseconds();
+
+ /**
+ * Feed the received bytes to the decryptor, with retry support.
+ *
+ * @param bytes the received bytes
+ * @return true if the KMS request should be retried
+ */
+ boolean feedWithRetry(ByteBuffer bytes);
+
+ /**
+ * Signal to libmongocrypt that a network error occurred on this KMS request.
+ *
+ * @return true if the request should be retried, false if retries are exhausted
+ */
+ boolean fail();
}
diff --git a/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoKeyDecryptorImpl.java b/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoKeyDecryptorImpl.java
index 1411adffc21..24b5e3cc67b 100644
--- a/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoKeyDecryptorImpl.java
+++ b/mongodb-crypt/src/main/com/mongodb/internal/crypt/capi/MongoKeyDecryptorImpl.java
@@ -22,6 +22,7 @@
import com.mongodb.internal.crypt.capi.CAPI.mongocrypt_kms_ctx_t;
import com.mongodb.internal.crypt.capi.CAPI.mongocrypt_status_t;
import com.sun.jna.Pointer;
+import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.ptr.PointerByReference;
import java.nio.ByteBuffer;
@@ -30,10 +31,13 @@
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_binary_new;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_kms_ctx_bytes_needed;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_kms_ctx_endpoint;
+import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_kms_ctx_fail;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_kms_ctx_feed;
+import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_kms_ctx_feed_with_retry;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_kms_ctx_get_kms_provider;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_kms_ctx_message;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_kms_ctx_status;
+import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_kms_ctx_usleep;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_status_code;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_status_destroy;
import static com.mongodb.internal.crypt.capi.CAPI.mongocrypt_status_message;
@@ -96,6 +100,28 @@ public void feed(final ByteBuffer bytes) {
}
}
+ @Override
+ public long sleepMicroseconds() {
+ return mongocrypt_kms_ctx_usleep(wrapped);
+ }
+
+ @Override
+ public boolean feedWithRetry(final ByteBuffer bytes) {
+ try (BinaryHolder binaryHolder = toBinary(bytes)) {
+ ByteByReference shouldRetry = new ByteByReference();
+ boolean success = mongocrypt_kms_ctx_feed_with_retry(wrapped, binaryHolder.getBinary(), shouldRetry);
+ if (!success) {
+ throwExceptionFromStatus();
+ }
+ return shouldRetry.getValue() != 0;
+ }
+ }
+
+ @Override
+ public boolean fail() {
+ return mongocrypt_kms_ctx_fail(wrapped);
+ }
+
private void throwExceptionFromStatus() {
mongocrypt_status_t status = mongocrypt_status_new();
mongocrypt_kms_ctx_status(wrapped, status);
diff --git a/mongodb-crypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java b/mongodb-crypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java
index 14bb2a5ccdc..e6b7d36865f 100644
--- a/mongodb-crypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java
+++ b/mongodb-crypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java
@@ -49,10 +49,12 @@
import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
@SuppressWarnings("SameParameterValue")
@@ -313,6 +315,87 @@ public void testExplicitEncryptionDecryptionKeyAltName() throws IOException, URI
mongoCrypt.close();
}
+ @Test
+ public void testKmsRetryOnHttpErrorAndNetworkError() {
+ MongoCrypt mongoCrypt = createMongoCrypt();
+ assertNotNull(mongoCrypt);
+
+ MongoCryptContext decryptor = mongoCrypt.createDecryptionContext(getResourceAsDocument("encrypted-command-reply.json"));
+ MongoKeyDecryptor keyDecryptor = feedKeysAndGetKeyDecryptor(decryptor);
+
+ // No backoff is requested before the first attempt
+ assertEquals(0, keyDecryptor.sleepMicroseconds());
+
+ // A complete HTTP 429 response marks the request as retryable. The backoff is jittered,
+ // so it may legitimately be zero; only that the call succeeds can be asserted.
+ assertTrue(keyDecryptor.feedWithRetry(getHttpResourceAsByteBuffer("kms-reply-429.txt")));
+ keyDecryptor.sleepMicroseconds();
+
+ // The context stays in NEED_KMS and the key decryptor is re-presented for the retry
+ keyDecryptor = reenterNeedKms(decryptor);
+ assertTrue(keyDecryptor.bytesNeeded() > 0);
+ assertTrue(keyDecryptor.getMessage().remaining() > 0);
+
+ // A network error is retryable while budget remains
+ assertTrue(keyDecryptor.fail());
+ keyDecryptor = reenterNeedKms(decryptor);
+
+ // A successful response completes the key decryption
+ assertFalse(keyDecryptor.feedWithRetry(getHttpResourceAsByteBuffer("kms-reply.txt")));
+ assertEquals(0, keyDecryptor.bytesNeeded());
+
+ assertNull(decryptor.nextKeyDecryptor());
+ decryptor.completeKeyDecryptors();
+ assertEquals(State.READY, decryptor.getState());
+
+ RawBsonDocument decryptedDocument = decryptor.finish();
+ assertEquals(State.DONE, decryptor.getState());
+ assertEquals(getResourceAsDocument("command-reply.json"), decryptedDocument);
+
+ decryptor.close();
+ mongoCrypt.close();
+ }
+
+ @Test
+ public void testKmsRetryExhaustsBudget() {
+ MongoCrypt mongoCrypt = createMongoCrypt();
+ assertNotNull(mongoCrypt);
+
+ MongoCryptContext decryptor = mongoCrypt.createDecryptionContext(getResourceAsDocument("encrypted-command-reply.json"));
+ MongoKeyDecryptor keyDecryptor = feedKeysAndGetKeyDecryptor(decryptor);
+
+ int retriesAllowed = 0;
+ while (retriesAllowed < 100 && keyDecryptor.fail()) {
+ retriesAllowed++;
+ }
+ assertTrue(retriesAllowed > 0, "expected at least one retry to be allowed");
+ assertTrue(retriesAllowed < 100, "expected the retry budget to be exhausted");
+
+ decryptor.close();
+ mongoCrypt.close();
+ }
+
+ private MongoKeyDecryptor reenterNeedKms(final MongoCryptContext context) {
+ assertEquals(State.NEED_KMS, context.getState());
+ MongoKeyDecryptor keyDecryptor = context.nextKeyDecryptor();
+ assertNotNull(keyDecryptor);
+ return keyDecryptor;
+ }
+
+ private MongoKeyDecryptor feedKeysAndGetKeyDecryptor(final MongoCryptContext context) {
+ assertEquals(State.NEED_MONGO_KEYS, context.getState());
+ BsonDocument keyFilter = context.getMongoOperation();
+ assertEquals(getResourceAsDocument("key-filter.json"), keyFilter);
+ context.addMongoOperationResult(getResourceAsDocument("key-document.json"));
+ context.completeMongoOperation();
+ assertEquals(State.NEED_KMS, context.getState());
+
+ MongoKeyDecryptor keyDecryptor = context.nextKeyDecryptor();
+ assertNotNull(keyDecryptor);
+ assertEquals("aws", keyDecryptor.getKmsProvider());
+ return keyDecryptor;
+ }
+
private void testKeyDecryptor(final MongoCryptContext context) {
testKeyDecryptor(context, "key-filter.json", "key-document.json");
}
diff --git a/mongodb-crypt/src/test/resources/kms-reply-429.txt b/mongodb-crypt/src/test/resources/kms-reply-429.txt
new file mode 100644
index 00000000000..e9fcc56d51b
--- /dev/null
+++ b/mongodb-crypt/src/test/resources/kms-reply-429.txt
@@ -0,0 +1,6 @@
+HTTP/1.1 429 Too Many Requests
+x-amzn-RequestId: 00000000-0000-0000-0000-000000000000
+Content-Type: application/x-amz-json-1.1
+Content-Length: 32
+
+{"__type":"ThrottlingException"}
From 68115e87e2b74346c352f03730ec592708292f3a Mon Sep 17 00:00:00 2001
From: Ross Lawley Requires the {@code org.mongodb.test.kms.retry.ca.path} system property pointing to the CA cert for the
+ * failpoint server.
+ */
+public abstract class AbstractClientSideEncryptionKmsRetryProseTest {
+
+ private static final String FAILPOINT_SERVER_ADDRESS = "127.0.0.1:9003";
+ private static final String FAILPOINT_URL_BASE = "https://" + FAILPOINT_SERVER_ADDRESS;
+
+ @Nullable
+ private static volatile SSLContext failpointSslContext;
+
+ @NonNull
+ protected abstract ClientEncryption getClientEncryption(ClientEncryptionSettings settings);
+
+ @BeforeEach
+ public void setUp() {
+ assumeTrue(System.getProperty("org.mongodb.test.kms.retry.ca.path") != null,
+ "org.mongodb.test.kms.retry.ca.path system property is not set");
+ assumeTrue(hasEncryptionTestsEnabled());
+ assumeTrue(serverVersionAtLeast(4, 2));
+ resetFailpoints();
+ getMongoClient().getDatabase("keyvault").getCollection("datakeys").drop();
+ }
+
+ @AfterEach
+ public void tearDown() {
+ // runs even when setUp's assumptions aborted the test, so re-check the environment
+ if (System.getProperty("org.mongodb.test.kms.retry.ca.path") == null || !hasEncryptionTestsEnabled()) {
+ return;
+ }
+ // leave the shared failpoint server clean for whoever runs next; a test that aborts
+ // mid-retry (e.g. on operation timeout) leaves unconsumed failure counts armed
+ resetFailpoints();
+ }
+
+ /**
+ * Case 1: createDataKey and encrypt with TCP retry.
+ */
+ @ParameterizedTest(name = "Case 1: TCP retry with {0}")
+ @ValueSource(strings = {"aws", "azure", "gcp"})
+ public void testCreateDataKeyAndEncryptWithTcpRetry(final String provider) {
+ try (ClientEncryption clientEncryption = createClientEncryptionForRetryTest()) {
+ setFailpoint("network", 1);
+ BsonBinary keyId = assertDoesNotThrow(
+ () -> clientEncryption.createDataKey(provider, getDataKeyOptions(provider)));
+
+ setFailpoint("network", 1);
+ assertDoesNotThrow(
+ () -> clientEncryption.encrypt(new BsonInt32(123),
+ new EncryptOptions("AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic").keyId(keyId)));
+ }
+ }
+
+ /**
+ * Case 2: createDataKey and encrypt with HTTP retry.
+ */
+ @ParameterizedTest(name = "Case 2: HTTP retry with {0}")
+ @ValueSource(strings = {"aws", "azure", "gcp"})
+ public void testCreateDataKeyAndEncryptWithHttpRetry(final String provider) {
+ try (ClientEncryption clientEncryption = createClientEncryptionForRetryTest()) {
+ setFailpoint("http", 1);
+ BsonBinary keyId = assertDoesNotThrow(
+ () -> clientEncryption.createDataKey(provider, getDataKeyOptions(provider)));
+
+ setFailpoint("http", 1);
+ assertDoesNotThrow(
+ () -> clientEncryption.encrypt(new BsonInt32(123),
+ new EncryptOptions("AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic").keyId(keyId)));
+ }
+ }
+
+ /**
+ * Case 3: createDataKey fails after too many retries.
+ */
+ @ParameterizedTest(name = "Case 3: Exhausted retries with {0}")
+ @ValueSource(strings = {"aws", "azure", "gcp"})
+ public void testCreateDataKeyFailsAfterTooManyRetries(final String provider) {
+ try (ClientEncryption clientEncryption = createClientEncryptionForRetryTest()) {
+ setFailpoint("network", 4);
+ assertThrows(MongoClientException.class,
+ () -> clientEncryption.createDataKey(provider, getDataKeyOptions(provider)));
+ }
+ }
+
+ /**
+ * Prose test: createDataKey fails when the operation timeout expires mid-retry. Configures a 100ms
+ * operation timeout and a failpoint that triggers repeated network errors, so the cumulative retry
+ * backoff normally pushes the operation past its deadline.
+ */
+ @Test
+ public void testCreateDataKeyTimesOutDuringRetry() {
+ try (ClientEncryption clientEncryption = createClientEncryptionForRetryTest(100L)) {
+ setFailpoint("network", 4);
+ // The 100ms deadline races libmongocrypt's jittered retry backoff: usually the deadline
+ // expires mid-retry and MongoOperationTimeoutException (a MongoClientException subclass) is
+ // thrown, but if the random backoffs are small enough the retry budget is exhausted first and
+ // the network error surfaces as a plain MongoClientException. Both are correct CSOT outcomes,
+ // so only the common supertype is asserted to keep the test deterministic.
+ assertThrows(MongoClientException.class,
+ () -> clientEncryption.createDataKey("aws", getDataKeyOptions("aws")));
+ }
+ }
+
+ private ClientEncryption createClientEncryptionForRetryTest() {
+ return createClientEncryptionForRetryTest(null);
+ }
+
+ private ClientEncryption createClientEncryptionForRetryTest(@Nullable final Long timeoutMS) {
+ Map