Search in sources :

Example 1 with CryptographyClientBuilder

use of com.azure.security.keyvault.keys.cryptography.CryptographyClientBuilder in project mssql-jdbc by Microsoft.

the class SQLServerColumnEncryptionAzureKeyVaultProvider method getCryptographyClient.

private CryptographyClient getCryptographyClient(String masterKeyPath) throws SQLServerException {
    if (this.cachedCryptographyClients.containsKey(masterKeyPath)) {
        return cachedCryptographyClients.get(masterKeyPath);
    }
    KeyVaultKey retrievedKey = getKeyVaultKey(masterKeyPath);
    CryptographyClient cryptoClient;
    if (null != credential) {
        cryptoClient = new CryptographyClientBuilder().credential(credential).keyIdentifier(retrievedKey.getId()).buildClient();
    } else {
        cryptoClient = new CryptographyClientBuilder().pipeline(keyVaultPipeline).keyIdentifier(retrievedKey.getId()).buildClient();
    }
    cachedCryptographyClients.putIfAbsent(masterKeyPath, cryptoClient);
    return cachedCryptographyClients.get(masterKeyPath);
}
Also used : CryptographyClientBuilder(com.azure.security.keyvault.keys.cryptography.CryptographyClientBuilder) CryptographyClient(com.azure.security.keyvault.keys.cryptography.CryptographyClient) KeyVaultKey(com.azure.security.keyvault.keys.models.KeyVaultKey)

Example 2 with CryptographyClientBuilder

use of com.azure.security.keyvault.keys.cryptography.CryptographyClientBuilder in project mssql-jdbc by microsoft.

the class SQLServerColumnEncryptionAzureKeyVaultProvider method getCryptographyClient.

private CryptographyClient getCryptographyClient(String masterKeyPath) throws SQLServerException {
    if (this.cachedCryptographyClients.containsKey(masterKeyPath)) {
        return cachedCryptographyClients.get(masterKeyPath);
    }
    KeyVaultKey retrievedKey = getKeyVaultKey(masterKeyPath);
    CryptographyClient cryptoClient;
    if (null != credential) {
        cryptoClient = new CryptographyClientBuilder().credential(credential).keyIdentifier(retrievedKey.getId()).buildClient();
    } else {
        cryptoClient = new CryptographyClientBuilder().pipeline(keyVaultPipeline).keyIdentifier(retrievedKey.getId()).buildClient();
    }
    cachedCryptographyClients.putIfAbsent(masterKeyPath, cryptoClient);
    return cachedCryptographyClients.get(masterKeyPath);
}
Also used : CryptographyClientBuilder(com.azure.security.keyvault.keys.cryptography.CryptographyClientBuilder) CryptographyClient(com.azure.security.keyvault.keys.cryptography.CryptographyClient) KeyVaultKey(com.azure.security.keyvault.keys.models.KeyVaultKey)

Example 3 with CryptographyClientBuilder

use of com.azure.security.keyvault.keys.cryptography.CryptographyClientBuilder in project signers by ConsenSys.

the class AzureKeyVault method fetchKey.

public CryptographyClient fetchKey(final String keyName, final String keyVersion) {
    final KeyVaultKey key = keyClient.getKey(keyName, keyVersion);
    final String keyId = key.getId();
    return new CryptographyClientBuilder().credential(tokenCredential).keyIdentifier(keyId).buildClient();
}
Also used : CryptographyClientBuilder(com.azure.security.keyvault.keys.cryptography.CryptographyClientBuilder) KeyVaultKey(com.azure.security.keyvault.keys.models.KeyVaultKey)

Aggregations

CryptographyClientBuilder (com.azure.security.keyvault.keys.cryptography.CryptographyClientBuilder)3 KeyVaultKey (com.azure.security.keyvault.keys.models.KeyVaultKey)3 CryptographyClient (com.azure.security.keyvault.keys.cryptography.CryptographyClient)2