Package com.azure.cosmos.encryption
Class CosmosEncryptionClientBuilder
java.lang.Object
com.azure.cosmos.encryption.CosmosEncryptionClientBuilder
Helper class to build
CosmosEncryptionAsyncClient and CosmosEncryptionClient
instances as logical representation of the Azure Cosmos database service.
When building client, cosmosAsyncClient()/cosmosClient(), keyEncryptionKeyResolver() and keyEncryptionKeyResolverName() are mandatory APIs, without these the initialization will fail.
Building Cosmos Encryption Async Client APIs.
If Azure key vault is used in keyEncryptionKeyResolver(KeyEncryptionKeyResolver), we can input KEY_RESOLVER_NAME_AZURE_KEY_VAULT in keyEncryptionKeyResolverName(String)
CosmosEncryptionAsyncClient cosmosEncryptionAsyncClient = new CosmosEncryptionClientBuilder()
.cosmosAsyncClient(cosmosAsyncClient)
.keyEncryptionKeyResolver(keyEncryptionKeyResolver)
.keyEncryptionKeyResolverName(keyEncryptionKeyResolverName)
.buildAsyncClient();
Building Cosmos Encryption Sync Client minimal APIs
If Azure key vault is used in keyEncryptionKeyResolver(KeyEncryptionKeyResolver), we can input KEY_RESOLVER_NAME_AZURE_KEY_VAULT in keyEncryptionKeyResolverName(String)
*
CosmosEncryptionClient client = new CosmosEncryptionClientBuilder()
.cosmosClient(cosmosClient)
.keyEncryptionKeyResolver(keyEncryptionKeyResolver)
.keyEncryptionKeyResolverName(keyEncryptionKeyResolverName)
.buildClient();
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringKeyEncryptionKeyResolver name forkeyEncryptionKeyResolverName(String)if Azure key vault resolver is being used inkeyEncryptionKeyResolver(KeyEncryptionKeyResolver). -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new Cosmos encryption client builder. -
Method Summary
Modifier and TypeMethodDescriptionBuilds a cosmos encryption async client.Builds a cosmos encryption async client.cosmosAsyncClient(CosmosAsyncClient cosmosAsyncClient) Sets the cosmos core async client to be used.cosmosClient(CosmosClient cosmosClient) Sets the cosmos core sync client to be used.keyEncryptionKeyResolver(com.azure.core.cryptography.KeyEncryptionKeyResolver keyEncryptionKeyResolver) Sets the key wrap providerkeyEncryptionKeyResolverName(String keyEncryptionKeyResolverName) Sets the key encryption key resolver name
-
Field Details
-
KEY_RESOLVER_NAME_AZURE_KEY_VAULT
KeyEncryptionKeyResolver name forkeyEncryptionKeyResolverName(String)if Azure key vault resolver is being used inkeyEncryptionKeyResolver(KeyEncryptionKeyResolver).- See Also:
-
-
Constructor Details
-
CosmosEncryptionClientBuilder
public CosmosEncryptionClientBuilder()Instantiates a new Cosmos encryption client builder.
-
-
Method Details
-
cosmosAsyncClient
Sets the cosmos core async client to be used.- Parameters:
cosmosAsyncClient- cosmos async client- Returns:
- current CosmosEncryptionClientBuilder
-
cosmosClient
Sets the cosmos core sync client to be used.- Parameters:
cosmosClient- cosmos sync client- Returns:
- current CosmosEncryptionClientBuilder
-
keyEncryptionKeyResolver
public CosmosEncryptionClientBuilder keyEncryptionKeyResolver(com.azure.core.cryptography.KeyEncryptionKeyResolver keyEncryptionKeyResolver) Sets the key wrap provider- Parameters:
keyEncryptionKeyResolver- custom keyEncryptionKeyResolver implementation ofKeyEncryptionKeyResolver- Returns:
- current CosmosEncryptionClientBuilder
-
keyEncryptionKeyResolverName
public CosmosEncryptionClientBuilder keyEncryptionKeyResolverName(String keyEncryptionKeyResolverName) Sets the key encryption key resolver name- Parameters:
keyEncryptionKeyResolverName- customKeyEncryptionKeyResolvername- Returns:
- current CosmosEncryptionClientBuilder
-
buildAsyncClient
Builds a cosmos encryption async client.- Returns:
- CosmosEncryptionAsyncClient Cosmos encryption async client
-
buildClient
Builds a cosmos encryption async client.- Returns:
- CosmosEncryptionAsyncClient Cosmos encryption async client
-