Skip to content

Commit

Permalink
Api review clean up (Azure#27063)
Browse files Browse the repository at this point in the history
* Api review clean up

* adding java docs to missing public api

* Adding doc on emum static methods

* Resolving comments
  • Loading branch information
simplynaveen20 authored Feb 14, 2022
1 parent 8a612e9 commit d2dc100
Show file tree
Hide file tree
Showing 28 changed files with 530 additions and 340 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ private void createEncryptionDatabaseAndContainer() {
CosmosClientEncryptionKeyProperties keyProperties =
cosmosEncryptionAsyncDatabase.createClientEncryptionKey(
dataEncryptionKeyId,
CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256, metadata).block().getProperties();
CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256.getName(), metadata).block().getProperties();

logger.info("Database {} is created for this test with client encryption key {}",
this.configuration.getDatabaseId(), dataEncryptionKeyId);
Expand All @@ -526,23 +526,23 @@ private void createEncryptionDatabaseAndContainer() {
includedPath.setClientEncryptionKeyId(dataEncryptionKeyId);
includedPath.setPath("/" + ENCRYPTED_STRING_FIELD + i);
includedPath.setEncryptionType(CosmosEncryptionType.DETERMINISTIC.toString());
includedPath.setEncryptionAlgorithm(CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256);
includedPath.setEncryptionAlgorithm(CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256.getName());
encryptionPaths.add(includedPath);
}
for (int i = 1; i <= configuration.getEncryptedDoubleFieldCount(); i++) {
ClientEncryptionIncludedPath includedPath = new ClientEncryptionIncludedPath();
includedPath.setClientEncryptionKeyId(dataEncryptionKeyId);
includedPath.setPath("/" + ENCRYPTED_LONG_FIELD + i);
includedPath.setEncryptionType(CosmosEncryptionType.DETERMINISTIC.toString());
includedPath.setEncryptionAlgorithm(CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256);
includedPath.setEncryptionAlgorithm(CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256.getName());
encryptionPaths.add(includedPath);
}
for (int i = 1; i <= configuration.getEncryptedLongFieldCount(); i++) {
ClientEncryptionIncludedPath includedPath = new ClientEncryptionIncludedPath();
includedPath.setClientEncryptionKeyId(dataEncryptionKeyId);
includedPath.setPath("/" + ENCRYPTED_DOUBLE_FIELD + i);
includedPath.setEncryptionType(CosmosEncryptionType.DETERMINISTIC.toString());
includedPath.setEncryptionAlgorithm(CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256);
includedPath.setEncryptionAlgorithm(CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256.getName());
encryptionPaths.add(includedPath);
}
ClientEncryptionPolicy clientEncryptionPolicy = new ClientEncryptionPolicy(encryptionPaths);
Expand Down
4 changes: 2 additions & 2 deletions sdk/cosmos/azure-cosmos-encryption/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ You need to first create Container with ClientEncryptionPolicy and using cosmos
//Create Client Encryption Key
EncryptionKeyWrapMetadata metadata = new EncryptionKeyWrapMetadata(encryptionKeyWrapProvider.getProviderName(), "key", "tempmetadata");
CosmosEncryptionAsyncContainer cosmosEncryptionAsyncContainer = cosmosEncryptionAsyncDatabase
.createClientEncryptionKey("key", CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256, metadata)
.createClientEncryptionKey("key", CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256.getName(), metadata)
// TIP: Our APIs are Reactor Core based, so try to chain your calls
.then(Mono.defer(() -> {
//Create Encryption Container
ClientEncryptionIncludedPath includedPath = new ClientEncryptionIncludedPath();
includedPath.setClientEncryptionKeyId("key");
includedPath.setPath("/sensitiveString");
includedPath.setEncryptionType(CosmosEncryptionType.DETERMINISTIC.toString());
includedPath.setEncryptionAlgorithm(CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256);
includedPath.setEncryptionAlgorithm(CosmosEncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA256.getName());

List<ClientEncryptionIncludedPath> paths = new ArrayList<>();
paths.add(includedPath);
Expand Down
7 changes: 0 additions & 7 deletions sdk/cosmos/azure-cosmos-encryption/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ Licensed under the MIT License.
<version>4.0.0</version> <!-- {x-version-update;org.mockito:mockito-core;external_dependency} -->
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.68</version> <!-- {x-version-update;org.bouncycastle:bcprov-jdk15on;external_dependency} -->
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -220,7 +214,6 @@ Licensed under the MIT License.
<bannedDependencies>
<includes>
<include>com.azure:*</include>
<include>org.bouncycastle:bcprov-jdk15on:[1.68]</include> <!-- {x-include-update;org.bouncycastle:bcprov-jdk15on;external_dependency} -->
</includes>
</bannedDependencies>
</rules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.azure.cosmos.CosmosAsyncContainer;
import com.azure.cosmos.CosmosAsyncDatabase;
import com.azure.cosmos.CosmosException;
import com.azure.cosmos.encryption.implementation.EncryptionImplementationBridgeHelpers;
import com.azure.cosmos.encryption.keyprovider.EncryptionKeyWrapProvider;
import com.azure.cosmos.implementation.HttpConstants;
import com.azure.cosmos.implementation.Utils;
Expand Down Expand Up @@ -190,4 +191,20 @@ private CosmosContainerProperties getContainerPropertiesWithVersionValidation(Co

return cosmosContainerResponse.getProperties();
}

static {
EncryptionImplementationBridgeHelpers.CosmosEncryptionAsyncClientHelper.seCosmosEncryptionAsyncClientAccessor(new EncryptionImplementationBridgeHelpers.CosmosEncryptionAsyncClientHelper.CosmosEncryptionAsyncClientAccessor() {
@Override
public Mono<CosmosClientEncryptionKeyProperties> getClientEncryptionPropertiesAsync(CosmosEncryptionAsyncClient cosmosEncryptionAsyncClient, String clientEncryptionKeyId, String databaseRid, CosmosAsyncContainer cosmosAsyncContainer, boolean shouldForceRefresh) {
return cosmosEncryptionAsyncClient.getClientEncryptionPropertiesAsync(clientEncryptionKeyId,
databaseRid, cosmosAsyncContainer, shouldForceRefresh);
}

@Override
public Mono<CosmosContainerProperties> getContainerPropertiesAsync(CosmosEncryptionAsyncClient cosmosEncryptionAsyncClient, CosmosAsyncContainer cosmosAsyncContainer, boolean shouldForceRefresh) {
return cosmosEncryptionAsyncClient.getContainerPropertiesAsync(cosmosAsyncContainer,
shouldForceRefresh);
}
});
}
}
Loading

0 comments on commit d2dc100

Please sign in to comment.