Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Changes for api review #27095

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Helper class to build a encryption supported {@link ChangeFeedProcessor} instance.
*
*/
public class ChangeFeedEncryptionProcessorBuilder {
public final class ChangeFeedEncryptionProcessorBuilder {
FabianMeiswinkel marked this conversation as resolved.
Show resolved Hide resolved

private String hostName ;
private ChangeFeedProcessorOptions changeFeedProcessorOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* CosmosClient with encryption support.
*/
public class CosmosEncryptionAsyncClient {
public final class CosmosEncryptionAsyncClient {
private final static Logger LOGGER = LoggerFactory.getLogger(CosmosEncryptionAsyncClient.class);
private final CosmosAsyncClient cosmosAsyncClient;
private final AsyncCache<String, CosmosContainerProperties> containerPropertiesCacheByContainerId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
/**
* CosmosAsyncContainer with encryption capabilities.
*/
public class CosmosEncryptionAsyncContainer {
public final class CosmosEncryptionAsyncContainer {
private final Scheduler encryptionScheduler;
private final CosmosResponseFactory responseFactory = new CosmosResponseFactory();
private final CosmosAsyncContainer container;
Expand Down Expand Up @@ -955,8 +955,6 @@ public Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> transform(Functio
* Use {@link CosmosBatchResponse#isSuccessStatusCode} on the response returned to ensure that the
* transactional batch succeeded.
*/
@Beta(value = Beta.SinceVersion.V1, warningText =
xinlian12 marked this conversation as resolved.
Show resolved Hide resolved
Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
public Mono<CosmosBatchResponse> executeCosmosBatch(CosmosBatch cosmosBatch) {
return this.executeCosmosBatch(cosmosBatch, new CosmosBatchRequestOptions());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/**
* CosmosEncryptionAsyncDatabase with encryption capabilities.
*/
public class CosmosEncryptionAsyncDatabase {
public final class CosmosEncryptionAsyncDatabase {
private final CosmosAsyncDatabase cosmosAsyncDatabase;
private final CosmosEncryptionAsyncClient cosmosEncryptionAsyncClient;
private final static EncryptionImplementationBridgeHelpers.EncryptionKeyWrapProviderHelper.EncryptionKeyWrapProviderAccessor encryptionKeyWrapProviderAccessor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* CosmosClient with encryption support.
*/
public class CosmosEncryptionClient {
public final class CosmosEncryptionClient {
private final static Logger LOGGER = LoggerFactory.getLogger(CosmosEncryptionAsyncClient.class);
private final CosmosEncryptionAsyncClient cosmosEncryptionAsyncClient;
private EncryptionKeyWrapProvider encryptionKeyWrapProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/**
* CosmosContainer with encryption capabilities.
*/
public class CosmosEncryptionContainer {
public final class CosmosEncryptionContainer {
private final CosmosContainer cosmosContainer;
private final CosmosEncryptionAsyncContainer cosmosEncryptionAsyncContainer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* CosmosEncryptionDatabase with encryption capabilities.
*/
public class CosmosEncryptionDatabase {
public final class CosmosEncryptionDatabase {
private final CosmosDatabase cosmosDatabase;
private final CosmosEncryptionAsyncDatabase cosmosEncryptionAsyncDatabase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.azure.cosmos.encryption.implementation.mdesrc.azurekeyvaultprovider.AzureKeyVaultKeyStoreProvider;
import com.azure.cosmos.encryption.implementation.mdesrc.cryptography.KeyEncryptionKeyAlgorithm;
import com.azure.cosmos.encryption.implementation.mdesrc.cryptography.MicrosoftDataEncryptionException;
import com.azure.cosmos.encryption.models.KeyEncryptionAlgorithm;
import com.azure.cosmos.implementation.HttpConstants;
import com.azure.cosmos.implementation.ImplementationBridgeHelpers;

Expand All @@ -30,7 +31,7 @@
* <p>
* signature: Signature of the entire byte array. Signature is validated before decrypting the data encryption key.
*/
public class AzureKeyVaultKeyWrapProvider extends EncryptionKeyWrapProvider {
public final class AzureKeyVaultKeyWrapProvider extends EncryptionKeyWrapProvider {
private AzureKeyVaultKeyStoreProvider azureKeyVaultKeyStoreProvider;
private final static ImplementationBridgeHelpers.CosmosExceptionHelper.CosmosExceptionAccessor cosmosExceptionAccessor =
ImplementationBridgeHelpers.CosmosExceptionHelper.getCosmosExceptionAccessor();
Expand Down Expand Up @@ -71,7 +72,7 @@ public String getProviderName() {
@Override
public byte[] unwrapKey(String encryptionKeyId, String cosmosKeyEncryptionKeyAlgorithm, byte[] encryptedKey) {
try {
if (!com.azure.cosmos.encryption.models.KeyEncryptionKeyAlgorithm.RSA_OAEP.getName().equals(cosmosKeyEncryptionKeyAlgorithm)) {
if (!KeyEncryptionAlgorithm.RSA_OAEP.getName().equals(cosmosKeyEncryptionKeyAlgorithm)) {
throw new IllegalArgumentException("The specified KeyEncryptionAlgorithm is not supported. Please " +
"refer to https://aka.ms/CosmosClientEncryption for more details. ");
}
Expand All @@ -93,7 +94,7 @@ public byte[] unwrapKey(String encryptionKeyId, String cosmosKeyEncryptionKeyAlg
@Override
public byte[] wrapKey(String encryptionKeyId, String cosmosKeyEncryptionKeyAlgorithm, byte[] key) {
try {
if (!com.azure.cosmos.encryption.models.KeyEncryptionKeyAlgorithm.RSA_OAEP.getName().equals(cosmosKeyEncryptionKeyAlgorithm)) {
if (!KeyEncryptionAlgorithm.RSA_OAEP.getName().equals(cosmosKeyEncryptionKeyAlgorithm)) {
throw new IllegalArgumentException("The specified KeyEncryptionAlgorithm is not supported. Please " +
"refer to https://aka.ms/CosmosClientEncryption for more details. ");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
* Represents the encryption algorithms supported for key encryption.
*
*/
public enum KeyEncryptionKeyAlgorithm {
public enum KeyEncryptionAlgorithm {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we decided to update the implementation class's name and not the public one. But I think that is fine, once the cryptography jars release to maven, then we can just use them without having to update our code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I am avoiding any code change in shaded code

/**
* RSA public key cryptography algorithm with Optimal Asymmetric Encryption Padding (OAEP) padding.
*/
RSA_OAEP("RSA_OAEP");

private final String keyEncryptionKeyAlgorithmName;
private static final Map<String, KeyEncryptionKeyAlgorithm> ENUM_MAP;
private static final Map<String, KeyEncryptionAlgorithm> ENUM_MAP;

KeyEncryptionKeyAlgorithm(String keyEncryptionKeyAlgorithmName) {
KeyEncryptionAlgorithm(String keyEncryptionKeyAlgorithmName) {
this.keyEncryptionKeyAlgorithmName = keyEncryptionKeyAlgorithmName;
}

Expand All @@ -45,19 +45,19 @@ public String getName() {
// Any Map impl can be used.

static {
Map<String, KeyEncryptionKeyAlgorithm> map = new ConcurrentHashMap<>();
for (KeyEncryptionKeyAlgorithm instance : KeyEncryptionKeyAlgorithm.values()) {
Map<String, KeyEncryptionAlgorithm> map = new ConcurrentHashMap<>();
for (KeyEncryptionAlgorithm instance : KeyEncryptionAlgorithm.values()) {
map.put(instance.getName(), instance);
}
ENUM_MAP = Collections.unmodifiableMap(map);
}

/**
* Gets the KeyEncryptionKeyAlgorithm enum back from the string value
* Gets the KeyEncryptionAlgorithm enum back from the string value
* @param name the string value
* @return KeyEncryptionKeyAlgorithm enum
* @return KeyEncryptionAlgorithm enum
*/
public static KeyEncryptionKeyAlgorithm get(String name) {
public static KeyEncryptionAlgorithm get(String name) {
return ENUM_MAP.get(name);
}
}