Class ClientEncryptionSettings
- java.lang.Object
-
- com.mongodb.ClientEncryptionSettings
-
public final class ClientEncryptionSettings extends Object
The client-side settings for data key creation and explicit encryption.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
Nested Classes Modifier and Type Class Description static class
ClientEncryptionSettings.Builder
A builder forClientEncryptionSettings
so thatClientEncryptionSettings
can be immutable, and to support easier construction through chaining.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ClientEncryptionSettings.Builder
builder()
Convenience method to create a Builder.MongoClientSettings
getKeyVaultMongoClientSettings()
Gets the key vault settings.String
getKeyVaultNamespace()
Gets the key vault namespace.Map<String,Map<String,Object>>
getKmsProviders()
Gets the map of KMS provider properties.
-
-
-
Method Detail
-
builder
public static ClientEncryptionSettings.Builder builder()
Convenience method to create a Builder.- Returns:
- a builder
-
getKeyVaultMongoClientSettings
public MongoClientSettings getKeyVaultMongoClientSettings()
Gets the key vault settings.The key vault collection is assumed to reside on the same MongoDB cluster as indicated by the connecting URI. But the optional keyVaultMongoClientSettings can be used to route data key queries to a separate MongoDB cluster, or the same cluster but with a different credential.
- Returns:
- the key vault settings, which may be null to indicate that the same
MongoClient
should be used to access the key vault collection as is used for the rest of the application.
-
getKeyVaultNamespace
public String 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
public Map<String,Map<String,Object>> getKmsProviders()
Gets the map of KMS provider properties.Multiple KMS providers may be specified. The following KMS providers are supported: "aws", "azure", "gcp" and "local". The kmsProviders map values differ by provider:
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 "local", the properties are:
- key: byte[] of length 96, the local key
- Returns:
- map of KMS provider properties
-
-