Skip to content

Commit

Permalink
Reset changes to the patch version.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimrabab committed May 12, 2022
1 parent 4e9f735 commit 057bb4b
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 120 deletions.
17 changes: 2 additions & 15 deletions sdk/storage/azure-storage-blob-cryptography/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
# Release History

## 12.16.0-beta.2 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes

## 12.16.0-beta.1 (2022-05-06)

### Features Added
- Added support for 2021-06-08 service version.

## 12.15.1 (2022-04-07)

### Other Changes

#### Dependency Updates

- Upgraded `azure-core` from `1.26.0` to version `1.27.0`.
- Upgraded `azure-core-http-netty` from `1.11.8` to version `1.11.9`.
- Upgraded `azure-storage-blob` from `12.15.0` to version `12.16.0`.
Expand Down
4 changes: 1 addition & 3 deletions sdk/storage/azure-storage-blob-cryptography/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ add the direct dependency to your project as follows.
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob-cryptography</artifactId>
<version>12.15.1</version>
<version>12.15.0</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand Down Expand Up @@ -262,5 +262,3 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
[rest_docs]: https://docs.microsoft.com/rest/api/storageservices/blob-service-rest-api
[product_docs]: https://docs.microsoft.com/azure/storage/blobs/storage-blobs-overview
[samples]: https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/storage/azure-storage-blob-cryptography/src/samples
[error_codes]: https://docs.microsoft.com/rest/api/storageservices/blob-service-error-codes
[performance_tuning]: https://github.com/Azure/azure-sdk-for-java/wiki/Performance-Tuning
24 changes: 12 additions & 12 deletions sdk/storage/azure-storage-blob-cryptography/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>com.azure</groupId>
<artifactId>azure-storage-blob-cryptography</artifactId>
<version>12.16.0-beta.2</version> <!-- {x-version-update;com.azure:azure-storage-blob-cryptography;current} -->
<version>12.15.1</version> <!-- {x-version-update;com.azure:azure-storage-blob-cryptography;current} -->

<name>Microsoft Azure client library for Blob Storage cryptography</name>
<description>This module contains client library for Microsoft Azure Blob Storage cryptography.</description>
Expand Down Expand Up @@ -52,30 +52,30 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.28.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
<version>1.27.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-netty</artifactId>
<version>1.12.0</version> <!-- {x-version-update;com.azure:azure-core-http-netty;dependency} -->
<version>1.11.9</version> <!-- {x-version-update;com.azure:azure-core-http-netty;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.16.1</version> <!-- {x-version-update;com.azure:azure-storage-blob;current} -->
<version>12.16.0</version> <!-- {x-version-update;com.azure:azure-storage-blob;current} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-common</artifactId>
<version>12.15.2</version> <!-- {x-version-update;com.azure:azure-storage-common;current} -->
<version>12.15.1</version> <!-- {x-version-update;com.azure:azure-storage-common;current} -->
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-test</artifactId>
<version>1.8.0</version> <!-- {x-version-update;com.azure:azure-core-test;dependency} -->
<version>1.7.10</version> <!-- {x-version-update;com.azure:azure-core-test;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -115,37 +115,37 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.5.1</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
<version>1.5.0</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-security-keyvault-keys</artifactId>
<version>4.4.1</version> <!-- {x-version-update;com.azure:azure-security-keyvault-keys;dependency} -->
<version>4.4.0</version> <!-- {x-version-update;com.azure:azure-security-keyvault-keys;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.17.2</version> <!-- {x-version-update;org.apache.logging.log4j:log4j-slf4j-impl;external_dependency} -->
<version>2.17.1</version> <!-- {x-version-update;org.apache.logging.log4j:log4j-slf4j-impl;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.2</version> <!-- {x-version-update;org.apache.logging.log4j:log4j-api;external_dependency} -->
<version>2.17.1</version> <!-- {x-version-update;org.apache.logging.log4j:log4j-api;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.2</version> <!-- {x-version-update;org.apache.logging.log4j:log4j-core;external_dependency} -->
<version>2.17.1</version> <!-- {x-version-update;org.apache.logging.log4j:log4j-core;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-okhttp</artifactId>
<version>1.9.0</version> <!-- {x-version-update;com.azure:azure-core-http-okhttp;dependency} -->
<version>1.8.0</version> <!-- {x-version-update;com.azure:azure-core-http-okhttp;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
public class BlobDecryptionPolicy implements HttpPipelinePolicy {

private static final ClientLogger LOGGER = new ClientLogger(BlobDecryptionPolicy.class);
private final ClientLogger logger = new ClientLogger(BlobDecryptionPolicy.class);

/**
* The {@link AsyncKeyEncryptionKeyResolver} used to select the correct key for decrypting existing blobs.
Expand All @@ -56,7 +56,7 @@ public class BlobDecryptionPolicy implements HttpPipelinePolicy {
private final AsyncKeyEncryptionKey keyWrapper;

/**
* Whether encryption is enforced by this client. Throws an exception if data is downloaded and it is not
* Whether or not encryption is enforced by this client. Throws an exception if data is downloaded and it is not
* encrypted.
*/
private final boolean requiresEncryption;
Expand All @@ -73,7 +73,7 @@ public class BlobDecryptionPolicy implements HttpPipelinePolicy {
* @param key An object of type {@link AsyncKeyEncryptionKey} that is used to wrap/unwrap the content encryption
* key
* @param keyResolver The key resolver used to select the correct key for decrypting existing blobs.
* @param requiresEncryption Whether encryption is enforced by this client.
* @param requiresEncryption Whether or not encryption is enforced by this client.
*/
BlobDecryptionPolicy(AsyncKeyEncryptionKey key, AsyncKeyEncryptionKeyResolver keyResolver,
boolean requiresEncryption) {
Expand All @@ -92,7 +92,7 @@ public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineN
// Assumption: Download is the only API on an encrypted client that sets x-ms-range
// Only set the x-ms-range header if it already exists
if (requestHeaders.getValue(CryptographyConstants.RANGE_HEADER) != null) {
requestHeaders.set(CryptographyConstants.RANGE_HEADER, encryptedRange.toBlobRange().toString());
requestHeaders.put(CryptographyConstants.RANGE_HEADER, encryptedRange.toBlobRange().toString());
}

// 2. Replace the body of the response with a decrypted version of the body
Expand All @@ -114,7 +114,8 @@ public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineN
boolean padding = encryptedRange.toBlobRange().getOffset()
+ encryptedRange.toBlobRange().getCount() > (blobSize(responseHeaders) - ENCRYPTION_BLOCK_SIZE);
String encryptedDataString = responseHeaders
.getValue(Constants.HeaderConstants.X_MS_META + "-" + CryptographyConstants.ENCRYPTION_DATA_KEY);
.getValue(Constants.HeaderConstants.X_MS_META + "-"
+ CryptographyConstants.ENCRYPTION_DATA_KEY);

Flux<ByteBuffer> plainTextData = this.decryptBlob(encryptedDataString,
httpResponse.getBody(), encryptedRange, padding);
Expand Down Expand Up @@ -156,7 +157,7 @@ Flux<ByteBuffer> decryptBlob(String encryptedDataString, Flux<ByteBuffer> encryp
*
* If we are starting at the beginning, we can grab the IV from the encryptionData. Otherwise,
* Reactor makes it difficult to grab the first 16 bytes of data to pass as an IV to the cipher.
* As a workaround, we initialize the cipher with a garbage IV (empty byte array) and attempt to
* As a work around, we initialize the cipher with a garbage IV (empty byte array) and attempt to
* decrypt the first 16 bytes (the actual IV for the relevant data). We throw away this "decrypted"
* data. Now, though, because each block of 16 is used as the IV for the next, the original 16 bytes
* of downloaded data are in position to be used as the IV for the data actually requested and we
Expand All @@ -179,7 +180,7 @@ Flux<ByteBuffer> decryptBlob(String encryptedDataString, Flux<ByteBuffer> encryp
try {
cipher = getCipher(contentEncryptionKey, encryptionData, iv, padding);
} catch (InvalidKeyException e) {
throw LOGGER.logExceptionAsError(Exceptions.propagate(e));
throw logger.logExceptionAsError(Exceptions.propagate(e));
}

return encryptedFlux.map(encryptedByteBuffer -> {
Expand All @@ -204,7 +205,7 @@ Flux<ByteBuffer> decryptBlob(String encryptedDataString, Flux<ByteBuffer> encryp
cipher.update(encryptedByteBuffer, plaintextByteBuffer);
}
} catch (GeneralSecurityException e) {
throw LOGGER.logExceptionAsError(Exceptions.propagate(e));
throw logger.logExceptionAsError(Exceptions.propagate(e));
}
totalInputBytes.addAndGet(bytesToInput);

Expand Down Expand Up @@ -313,7 +314,7 @@ Flux<ByteBuffer> decryptBlob(String encryptedDataString, Flux<ByteBuffer> encryp
private EncryptionData getAndValidateEncryptionData(String encryptedDataString) {
if (encryptedDataString == null) {
if (requiresEncryption) {
throw LOGGER.logExceptionAsError(new IllegalStateException("'requiresEncryption' set to true but "
throw logger.logExceptionAsError(new IllegalStateException("'requiresEncryption' set to true but "
+ "downloaded data is not encrypted."));
}
return null;
Expand All @@ -325,7 +326,7 @@ private EncryptionData getAndValidateEncryptionData(String encryptedDataString)
// Blob being downloaded is not null.
if (encryptionData == null) {
if (requiresEncryption) {
throw LOGGER.logExceptionAsError(new IllegalStateException("'requiresEncryption' set to true but "
throw logger.logExceptionAsError(new IllegalStateException("'requiresEncryption' set to true but "
+ "downloaded data is not encrypted."));
}
return null;
Expand All @@ -340,14 +341,14 @@ private EncryptionData getAndValidateEncryptionData(String encryptedDataString)
// understands and is able to decrypt.
if (!CryptographyConstants.ENCRYPTION_PROTOCOL_V1
.equals(encryptionData.getEncryptionAgent().getProtocol())) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format(Locale.ROOT,
throw logger.logExceptionAsError(new IllegalArgumentException(String.format(Locale.ROOT,
"Invalid Encryption Agent. This version of the client library does not understand the "
+ "Encryption Agent set on the blob message: %s",
encryptionData.getEncryptionAgent())));
}
return encryptionData;
} catch (IOException e) {
throw LOGGER.logExceptionAsError(new RuntimeException(e));
throw logger.logExceptionAsError(new RuntimeException(e));
}
}

Expand All @@ -362,7 +363,7 @@ private Mono<byte[]> getKeyEncryptionKey(EncryptionData encryptionData) {
/*
* 1. Invoke the key resolver if specified to get the key. If the resolver is specified but does not have a
* mapping for the key id, an error should be thrown. This is important for key rotation scenario.
* 2. If resolver is not specified but a key is specified, match the key id on the key and use it.
* 2. If resolver is not specified but a key is specified, match the key id on the key and and use it.
*/
Mono<? extends AsyncKeyEncryptionKey> keyMono;

Expand All @@ -373,14 +374,14 @@ private Mono<byte[]> getKeyEncryptionKey(EncryptionData encryptionData) {
* keyResolver returns null if it cannot find the key, but Reactor throws on null values
* passing through workflows, so we propagate this case with an IllegalArgumentException
*/
throw LOGGER.logExceptionAsError(Exceptions.propagate(e));
throw logger.logExceptionAsError(Exceptions.propagate(e));
});
} else {
keyMono = this.keyWrapper.getKeyId().flatMap(keyId -> {
if (encryptionData.getWrappedContentKey().getKeyId().equals(keyId)) {
return Mono.just(this.keyWrapper);
} else {
throw LOGGER.logExceptionAsError(Exceptions.propagate(new IllegalArgumentException("Key mismatch. "
throw logger.logExceptionAsError(Exceptions.propagate(new IllegalArgumentException("Key mismatch. "
+ "The key id stored on the service does not match the specified key.")));
}
});
Expand Down Expand Up @@ -420,12 +421,12 @@ private Cipher getCipher(byte[] contentEncryptionKey, EncryptionData encryptionD
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivParameterSpec);
return cipher;
default:
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
throw logger.logExceptionAsError(new IllegalArgumentException(
"Invalid Encryption Algorithm found on the resource. This version of the client library "
+ "does not support the specified encryption algorithm."));
}
} catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidAlgorithmParameterException e) {
throw LOGGER.logExceptionAsError(Exceptions.propagate(e));
throw logger.logExceptionAsError(Exceptions.propagate(e));
}
}

Expand Down
Loading

0 comments on commit 057bb4b

Please sign in to comment.