Class ClientEncryptionSettings
Explicit encryption/decryption is a community feature, enabled with the new com.mongodb.client.vault.ClientEncryption
type,
for which this is the settings.
- Since:
- 3.11
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A builder forClientEncryptionSettings
so thatClientEncryptionSettings
can be immutable, and to support easier construction through chaining. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Convenience method to create a Builder.Gets theMongoClientSettings
that will be used to access the key vault.Gets the key vault namespace.This method is similar togetKmsProviders()
, but instead of getting properties for KMS providers, it getsSupplier
s of properties.Gets the map of KMS provider properties.Gets the KMS provider to SSLContext map.getTimeout
(TimeUnit timeUnit) The time limit for the full execution of an operation.
-
Method Details
-
builder
Convenience method to create a Builder.- Returns:
- a builder
-
getKeyVaultMongoClientSettings
Gets theMongoClientSettings
that will be used to access the key vault.- Returns:
- the key vault settings, which may be not be null
-
getKeyVaultNamespace
Gets the key vault namespace.The key vault namespace refers to a collection that contains all data keys used for encryption and decryption (aka the key vault collection). Data keys are stored as documents in a special MongoDB collection. Data keys are protected with encryption by a KMS provider (AWS, Azure, GCP KMS or a local master key).
- Returns:
- the key vault namespace, which may not be null
-
getKmsProviders
Gets the map of KMS provider properties.Multiple KMS providers can be specified within this map. Each KMS provider is identified by a unique key. Keys are formatted as either
"KMS provider type"
or"KMS provider type:KMS provider name"
(e.g., "aws" or "aws:myname"). The KMS provider name must only contain alphanumeric characters (a-z, A-Z, 0-9), underscores (_), and must not be empty.Supported KMS provider types include "aws", "azure", "gcp", and "local". The provider name is optional and allows for the configuration of multiple providers of the same type under different names (e.g., "aws:name1" and "aws:name2" could represent different AWS accounts).
The kmsProviders map values differ by provider type. The following properties are supported for each provider type:
For "aws", the properties are:
- accessKeyId: a String, the AWS access key identifier
- secretAccessKey: a String, the AWS secret access key
- sessionToken: an optional String, the AWS session token
For "azure", the properties are:
- tenantId: a String, the tenantId that identifies the organization for the account.
- clientId: a String, the clientId to authenticate a registered application.
- clientSecret: a String, the client secret to authenticate a registered application.
- identityPlatformEndpoint: optional String, a host with optional port. e.g. "example.com" or "example.com:443". Generally used for private Azure instances.
For "gcp", the properties are:
- email: a String, the service account email to authenticate.
- privateKey: a String or byte[], the encoded PKCS#8 encrypted key
- endpoint: optional String, a host with optional port. e.g. "example.com" or "example.com:443".
For "kmip", the properties are:
- endpoint: a String, the endpoint as a host with required port. e.g. "example.com:443".
For "local", the properties are:
- key: byte[] of length 96, the local key
It is also permitted for the value of a kms provider to be an empty map, in which case the driver will first
- use the
Supplier
configured ingetKmsProviderPropertySuppliers()
to obtain a non-empty map - attempt to obtain the properties from the environment
Supplier
or environment.- Returns:
- map of KMS provider properties
- See Also:
-
getKmsProviderPropertySuppliers
This method is similar togetKmsProviders()
, but instead of getting properties for KMS providers, it getsSupplier
s of properties.If
getKmsProviders()
returns empty properties for a KMS provider, the driver will use aSupplier
of properties configured for the KMS provider to obtain non-empty properties. -
getKmsProviderSslContextMap
Gets the KMS provider to SSLContext map.If a KMS provider is mapped to a non-null
SSLContext
, the context will be used to establish a TLS connection to the KMS. Otherwise, the default context will be used.- Returns:
- the KMS provider to SSLContext map
- Since:
- 4.4
-
getTimeout
The time limit for the full execution of an operation.If set the following deprecated options will be ignored:
waitQueueTimeoutMS
,socketTimeoutMS
,wTimeoutMS
,maxTimeMS
andmaxCommitTimeMS
null
means that the timeout mechanism for operations will defer to using:waitQueueTimeoutMS
: The maximum wait time in milliseconds that a thread may wait for a connection to become availablesocketTimeoutMS
: How long a send or receive on a socket can take before timing out.wTimeoutMS
: How long the server will wait for the write concern to be fulfilled before timing out.maxTimeMS
: The cumulative time limit for processing operations on a cursor. See: cursor.maxTimeMS.maxCommitTimeMS
: The maximum amount of time to allow a singlecommitTransaction
command to execute. See:TransactionOptions.getMaxCommitTime(java.util.concurrent.TimeUnit)
.
0
means infinite timeout.> 0
The time limit to use for the full execution of an operation.
- Parameters:
timeUnit
- the time unit- Returns:
- the timeout in the given time unit
- Since:
- 5.2
-