diff --git a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml index 85dcc3e002347..7bf100478e9d3 100755 --- a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml +++ b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml @@ -178,6 +178,7 @@ + diff --git a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchAsyncClient.java b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchAsyncClient.java index 089f5de97167f..58c20f41c43a9 100644 --- a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchAsyncClient.java +++ b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchAsyncClient.java @@ -21,7 +21,7 @@ import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobStorageException; import com.azure.storage.blob.models.DeleteSnapshotsOptionType; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Mono; import java.time.Duration; @@ -147,7 +147,7 @@ public PagedFlux> deleteBlobs(List blobUrls, DeleteSnapsh PagedFlux> deleteBlobsWithTimeout(List blobUrls, DeleteSnapshotsOptionType deleteOptions, Duration timeout, Context context) { return new PagedFlux<>(() -> - Utility.applyOptionalTimeout(submitDeleteBlobsBatch(blobUrls, deleteOptions, context), timeout)); + StorageImplUtils.applyOptionalTimeout(submitDeleteBlobsBatch(blobUrls, deleteOptions, context), timeout)); } private Mono>> submitDeleteBlobsBatch(List blobUrls, @@ -181,7 +181,7 @@ public PagedFlux> setBlobsAccessTier(List blobUrls, Acces PagedFlux> setBlobsAccessTierWithTimeout(List blobUrls, AccessTier accessTier, Duration timeout, Context context) { return new PagedFlux<>(() -> - Utility.applyOptionalTimeout(submitSetTierBatch(blobUrls, accessTier, context), timeout)); + StorageImplUtils.applyOptionalTimeout(submitSetTierBatch(blobUrls, accessTier, context), timeout)); } private Mono>> submitSetTierBatch(List blobUrls, AccessTier accessTier, diff --git a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClient.java b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClient.java index 27fc75877dae1..1d650ee037f73 100644 --- a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClient.java +++ b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClient.java @@ -12,8 +12,7 @@ import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobStorageException; import com.azure.storage.blob.models.DeleteSnapshotsOptionType; -import com.azure.storage.common.Utility; - +import com.azure.storage.common.implementation.StorageImplUtils; import java.time.Duration; import java.util.List; @@ -85,8 +84,8 @@ public void submitBatch(BlobBatch batch) { @ServiceMethod(returns = ReturnType.SINGLE) public Response submitBatchWithResponse(BlobBatch batch, boolean throwOnAnyFailure, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(client.submitBatchWithResponse(batch, throwOnAnyFailure, context), - timeout); + return StorageImplUtils.blockWithOptionalTimeout(client.submitBatchWithResponse(batch, + throwOnAnyFailure, context), timeout); } /** diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClient.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClient.java index 9f7d7b40e9dea..0d297ab773d07 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClient.java +++ b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClient.java @@ -11,7 +11,7 @@ import com.azure.storage.blob.models.BlobAccessConditions; import com.azure.storage.blob.models.BlobHttpHeaders; import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Mono; import java.io.UncheckedIOException; @@ -92,7 +92,7 @@ public void uploadFromFile(String filePath, ParallelTransferOptions parallelTran headers, metadata, tier, accessConditions); try { - Utility.blockWithOptionalTimeout(upload, timeout); + StorageImplUtils.blockWithOptionalTimeout(upload, timeout); } catch (UncheckedIOException e) { throw logger.logExceptionAsError(e); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java index d50887b48a36a..6fd26cf88bbad 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java @@ -14,7 +14,7 @@ import com.azure.storage.blob.specialized.BlockBlobClient; import com.azure.storage.blob.specialized.PageBlobClient; import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Mono; import java.io.UncheckedIOException; @@ -135,7 +135,7 @@ public void uploadFromFile(String filePath, ParallelTransferOptions parallelTran filePath, parallelTransferOptions, headers, metadata, tier, accessConditions); try { - Utility.blockWithOptionalTimeout(upload, timeout); + StorageImplUtils.blockWithOptionalTimeout(upload, timeout); } catch (UncheckedIOException e) { throw logger.logExceptionAsError(e); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java index 8ca108b7e7a1b..d21d83b66e327 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java @@ -29,7 +29,7 @@ import com.azure.storage.blob.models.ModifiedAccessConditions; import com.azure.storage.blob.models.PublicAccessType; import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Mono; import java.time.Duration; @@ -139,8 +139,8 @@ public BlobAsyncClient getBlobAsyncClient(String blobName) { */ public BlobAsyncClient getBlobAsyncClient(String blobName, String snapshot) { return new BlobAsyncClient(getHttpPipeline(), - Utility.appendToUrlPath(getBlobContainerUrl(), blobName).toString(), getServiceVersion(), getAccountName(), - getBlobContainerName(), blobName, snapshot, getCustomerProvidedKey()); + StorageImplUtils.appendToUrlPath(getBlobContainerUrl(), blobName).toString(), getServiceVersion(), + getAccountName(), getBlobContainerName(), blobName, snapshot, getCustomerProvidedKey()); } /** @@ -718,7 +718,7 @@ private Mono listBlobsFlatSegment(String Duration timeout) { options = options == null ? new ListBlobsOptions() : options; - return Utility.applyOptionalTimeout( + return StorageImplUtils.applyOptionalTimeout( this.azureBlobStorage.containers().listBlobFlatSegmentWithRestResponseAsync(null, options.getPrefix(), marker, options.getMaxResultsPerPage(), options.getDetails().toList(), null, null, Context.NONE), timeout); @@ -846,7 +846,7 @@ private Mono listBlobsHierarchySegme new UnsupportedOperationException("Including snapshots in a hierarchical listing is not supported.")); } - return Utility.applyOptionalTimeout( + return StorageImplUtils.applyOptionalTimeout( this.azureBlobStorage.containers().listBlobHierarchySegmentWithRestResponseAsync(null, delimiter, options.getPrefix(), marker, options.getMaxResultsPerPage(), options.getDetails().toList(), null, null, Context.NONE), diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java index 103d3fabe9dff..efaa9b2a34bb1 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java @@ -17,7 +17,7 @@ import com.azure.storage.blob.models.ListBlobsOptions; import com.azure.storage.blob.models.PublicAccessType; import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Mono; import java.time.Duration; @@ -178,7 +178,7 @@ public boolean exists() { public Response existsWithResponse(Duration timeout, Context context) { Mono> response = blobContainerAsyncClient.existsWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -213,7 +213,7 @@ public void create() { public Response createWithResponse(Map metadata, PublicAccessType accessType, Duration timeout, Context context) { Mono> response = blobContainerAsyncClient.createWithResponse(metadata, accessType, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -247,7 +247,7 @@ public Response deleteWithResponse(BlobContainerAccessConditions accessCon Context context) { Mono> response = blobContainerAsyncClient.deleteWithResponse(accessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -283,7 +283,7 @@ public Response getPropertiesWithResponse(LeaseAccessCo Mono> response = blobContainerAsyncClient .getPropertiesWithResponse(leaseAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -317,7 +317,7 @@ public Response setMetadataWithResponse(Map metadata, BlobContainerAccessConditions accessConditions, Duration timeout, Context context) { Mono> response = blobContainerAsyncClient.setMetadataWithResponse(metadata, accessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -356,7 +356,7 @@ public Response getAccessPolicyWithResponse( Mono> response = blobContainerAsyncClient .getAccessPolicyWithResponse(leaseAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -408,7 +408,7 @@ public Response setAccessPolicyWithResponse(PublicAccessType accessType, Mono> response = blobContainerAsyncClient .setAccessPolicyWithResponse(accessType, identifiers, accessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -558,6 +558,6 @@ public StorageAccountInfo getAccountInfo(Duration timeout) { public Response getAccountInfoWithResponse(Duration timeout, Context context) { Mono> response = blobContainerAsyncClient.getAccountInfoWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java index 8c5fad2f961dc..effa314ed4349 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java @@ -27,7 +27,8 @@ import com.azure.storage.blob.models.PublicAccessType; import com.azure.storage.blob.models.StorageAccountInfo; import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Mono; import java.time.Duration; @@ -111,8 +112,8 @@ public BlobContainerAsyncClient getBlobContainerAsyncClient(String containerName } return new BlobContainerAsyncClient(getHttpPipeline(), - Utility.appendToUrlPath(getAccountUrl(), containerName).toString(), getServiceVersion(), getAccountName(), - containerName, customerProvidedKey); + StorageImplUtils.appendToUrlPath(getAccountUrl(), containerName).toString(), getServiceVersion(), + getAccountName(), containerName, customerProvidedKey); } /** @@ -295,7 +296,7 @@ private Mono listBlobContainersSegmen ListBlobContainersOptions options, Duration timeout) { options = options == null ? new ListBlobContainersOptions() : options; - return Utility.applyOptionalTimeout( + return StorageImplUtils.applyOptionalTimeout( this.azureBlobStorage.services().listBlobContainersSegmentWithRestResponseAsync( options.getPrefix(), marker, options.getMaxResultsPerPage(), options.getDetails().toIncludeType(), null, null, Context.NONE), timeout); @@ -438,7 +439,7 @@ public Mono> getUserDelegationKeyWithResponse(Offset Mono> getUserDelegationKeyWithResponse(OffsetDateTime start, OffsetDateTime expiry, Context context) { - Utility.assertNotNull("expiry", expiry); + StorageImplUtils.assertNotNull("expiry", expiry); if (start != null && !start.isBefore(expiry)) { throw logger.logExceptionAsError( new IllegalArgumentException("`start` must be null or a datetime before `expiry`.")); @@ -446,8 +447,8 @@ Mono> getUserDelegationKeyWithResponse(OffsetDateTim return this.azureBlobStorage.services().getUserDelegationKeyWithRestResponseAsync( new KeyInfo() - .setStart(start == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(start)) - .setExpiry(Utility.ISO_8601_UTC_DATE_FORMATTER.format(expiry)), + .setStart(start == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(start)) + .setExpiry(Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiry)), null, null, context).map(rb -> new SimpleResponse<>(rb, rb.getValue())); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java index a403aa3782548..a418caae27693 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java @@ -17,7 +17,7 @@ import com.azure.storage.blob.models.PublicAccessType; import com.azure.storage.blob.models.StorageAccountInfo; import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Mono; import java.time.Duration; @@ -221,7 +221,7 @@ public Response getPropertiesWithResponse(Duration timeou Mono> response = blobServiceAsyncClient.getPropertiesWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -259,7 +259,7 @@ public Response setPropertiesWithResponse(BlobServiceProperties properties Context context) { Mono> response = blobServiceAsyncClient.setPropertiesWithResponse(properties, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -297,7 +297,7 @@ public Response getUserDelegationKeyWithResponse(OffsetDateTi Mono> response = blobServiceAsyncClient.getUserDelegationKeyWithResponse(start, expiry, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -333,7 +333,7 @@ public BlobServiceStatistics getStatistics() { public Response getStatisticsWithResponse(Duration timeout, Context context) { Mono> response = blobServiceAsyncClient.getStatisticsWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -361,7 +361,7 @@ public StorageAccountInfo getAccountInfo() { public Response getAccountInfoWithResponse(Duration timeout, Context context) { Mono> response = blobServiceAsyncClient.getAccountInfoWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/HttpGetterInfo.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/HttpGetterInfo.java index efba9e6f43ef1..29ce7bc00cf4d 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/HttpGetterInfo.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/HttpGetterInfo.java @@ -5,8 +5,8 @@ import com.azure.core.util.Context; import com.azure.storage.blob.models.BlobAccessConditions; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import java.time.Duration; /** @@ -55,7 +55,7 @@ public Long getCount() { */ public HttpGetterInfo setCount(Long count) { if (count != null) { - Utility.assertInBounds("count", count, 0, Long.MAX_VALUE); + StorageImplUtils.assertInBounds("count", count, 0, Long.MAX_VALUE); } this.count = count; return this; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/UploadBufferPool.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/UploadBufferPool.java index 6f35d2e7006b7..f9ad4a2166186 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/UploadBufferPool.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/UploadBufferPool.java @@ -5,7 +5,7 @@ import com.azure.core.util.logging.ClientLogger; import com.azure.storage.blob.specialized.BlockBlobClient; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Flux; import java.nio.ByteBuffer; @@ -59,13 +59,13 @@ final class UploadBufferPool { We only need one overflow buffer because the max size of a ByteBuffer is assumed to be the size as a buffer in the pool. */ - Utility.assertInBounds("numBuffs", numBuffs, 2, Integer.MAX_VALUE); + StorageImplUtils.assertInBounds("numBuffs", numBuffs, 2, Integer.MAX_VALUE); this.maxBuffs = numBuffs; buffers = new LinkedBlockingQueue<>(numBuffs); // These buffers will be used in calls to stageBlock, so they must be no greater than block size. - Utility.assertInBounds("buffSize", buffSize, 1, BlockBlobClient.MAX_STAGE_BLOCK_BYTES); + StorageImplUtils.assertInBounds("buffSize", buffSize, 1, BlockBlobClient.MAX_STAGE_BLOCK_BYTES); this.buffSize = buffSize; // We prep the queue with two buffers in case there is overflow. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParallelTransferOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParallelTransferOptions.java index 75176df184b9e..20da1dccd5135 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParallelTransferOptions.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ParallelTransferOptions.java @@ -5,7 +5,7 @@ import com.azure.storage.blob.ProgressReceiver; import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; public class ParallelTransferOptions { @@ -64,7 +64,7 @@ public ProgressReceiver getProgressReceiver() { * @throws IllegalArgumentException when block size is less than 0 or greater than max blob block size (10MB). */ public ParallelTransferOptions setBlockSize(int blockSize) { - Utility.assertInBounds("blockSize", blockSize, 0, BLOB_MAX_BLOCK_SIZE); + StorageImplUtils.assertInBounds("blockSize", blockSize, 0, BLOB_MAX_BLOCK_SIZE); this.blockSize = blockSize; return this; } @@ -80,7 +80,7 @@ public ParallelTransferOptions setBlockSize(int blockSize) { * @throws IllegalArgumentException when numBuffers is less than 2. */ public ParallelTransferOptions setNumBuffers(int numBuffers) { - Utility.assertInBounds("numBuffers", numBuffers, 2, Integer.MAX_VALUE); + StorageImplUtils.assertInBounds("numBuffers", numBuffers, 2, Integer.MAX_VALUE); this.numBuffers = numBuffers; return this; } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java index 5d33ee53779b7..41024d158c4f3 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java @@ -19,6 +19,7 @@ import com.azure.storage.blob.models.BlobStorageException; import com.azure.storage.blob.models.SourceModifiedAccessConditions; import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; @@ -119,7 +120,7 @@ public AppendBlobItem create() { */ public Response createWithResponse(BlobHttpHeaders headers, Map metadata, BlobAccessConditions accessConditions, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(appendBlobAsyncClient. + return StorageImplUtils.blockWithOptionalTimeout(appendBlobAsyncClient. createWithResponse(headers, metadata, accessConditions, context), timeout); } @@ -169,7 +170,7 @@ public Response appendBlockWithResponse(InputStream data, long l Flux fbb = Utility.convertStreamToByteBuffer(data, length, MAX_APPEND_BLOCK_BYTES); Mono> response = appendBlobAsyncClient.appendBlockWithResponse( fbb.subscribeOn(Schedulers.elastic()), length, appendBlobAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -215,6 +216,6 @@ public Response appendBlockFromUrlWithResponse(String sourceUrl, SourceModifiedAccessConditions sourceAccessConditions, Duration timeout, Context context) { Mono> response = appendBlobAsyncClient.appendBlockFromUrlWithResponse(sourceUrl, sourceRange, sourceContentMD5, destAccessConditions, sourceAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java index b940c83b38f34..85ddb887bf389 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java @@ -31,8 +31,8 @@ import com.azure.storage.blob.models.ReliableDownloadOptions; import com.azure.storage.blob.models.SourceModifiedAccessConditions; import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; @@ -1047,7 +1047,7 @@ public Mono> setAccessTierWithResponse(AccessTier tier, Rehydrate Mono> setTierWithResponse(AccessTier tier, RehydratePriority priority, LeaseAccessConditions leaseAccessConditions, Context context) { - Utility.assertNotNull("tier", tier); + StorageImplUtils.assertNotNull("tier", tier); return this.azureBlobStorage.blobs().setTierWithRestResponseAsync( null, null, tier, null, priority, null, leaseAccessConditions, context) diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java index 83bbedbdda63a..85e6c3a5e5c15 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java @@ -25,7 +25,7 @@ import com.azure.storage.blob.models.RehydratePriority; import com.azure.storage.blob.models.ReliableDownloadOptions; import com.azure.storage.blob.models.StorageAccountInfo; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.Exceptions; import reactor.core.publisher.Mono; @@ -209,7 +209,7 @@ public Boolean exists() { public Response existsWithResponse(Duration timeout, Context context) { Mono> response = client.existsWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -261,7 +261,7 @@ public Response startCopyFromURLWithResponse(String sourceUrl, Map abortCopyFromURLWithResponse(String copyId, LeaseAccessCon Mono> response = client.abortCopyFromURLWithResponse(copyId, leaseAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -353,7 +353,7 @@ public Response copyFromURLWithResponse(String copySource, Map downloadWithResponse(OutputStream stream, BlobRange range, ReliableDownloadOptions options, BlobAccessConditions accessConditions, boolean rangeGetContentMD5, Duration timeout, Context context) { - Utility.assertNotNull("stream", stream); + StorageImplUtils.assertNotNull("stream", stream); Mono> download = client .downloadWithResponse(range, options, accessConditions, rangeGetContentMD5, context) .flatMap(response -> response.getValue().reduce(stream, (outputStream, buffer) -> { @@ -411,7 +411,7 @@ public Response downloadWithResponse(OutputStream stream, BlobRange range, } }).thenReturn(new SimpleResponse<>(response, null))); - return Utility.blockWithOptionalTimeout(download, timeout); + return StorageImplUtils.blockWithOptionalTimeout(download, timeout); } /** @@ -475,7 +475,7 @@ public Response downloadToFileWithResponse(String filePath, Blob BlobAccessConditions accessConditions, boolean rangeGetContentMD5, Duration timeout, Context context) { Mono> download = client.downloadToFileWithResponse(filePath, range, parallelTransferOptions, options, accessConditions, rangeGetContentMD5, context); - return Utility.blockWithOptionalTimeout(download, timeout); + return StorageImplUtils.blockWithOptionalTimeout(download, timeout); } /** @@ -515,7 +515,7 @@ public Response deleteWithResponse(DeleteSnapshotsOptionType deleteBlobSna Mono> response = client .deleteWithResponse(deleteBlobSnapshotOptions, accessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -553,7 +553,7 @@ public Response getPropertiesWithResponse(BlobAccessConditions a Context context) { Mono> response = client.getPropertiesWithResponse(accessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -595,7 +595,7 @@ public Response setHttpHeadersWithResponse(BlobHttpHeaders headers, BlobAc Mono> response = client .setHttpHeadersWithResponse(headers, accessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -636,7 +636,7 @@ public Response setMetadataWithResponse(Map metadata, Blob Duration timeout, Context context) { Mono> response = client.setMetadataWithResponse(metadata, accessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -680,7 +680,7 @@ public Response createSnapshotWithResponse(Map m .createSnapshotWithResponse(metadata, accessConditions, context) .map(rb -> new SimpleResponse<>(rb, new BlobClientBase(rb.getValue()))); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -728,7 +728,7 @@ public Response setAccessTierWithResponse(AccessTier tier, RehydratePriori Mono> response = client.setTierWithResponse(tier, priority, leaseAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -762,7 +762,7 @@ public void undelete() { public Response undeleteWithResponse(Duration timeout, Context context) { Mono> response = client.undeleteWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -798,6 +798,6 @@ public StorageAccountInfo getAccountInfo() { public Response getAccountInfoWithResponse(Duration timeout, Context context) { Mono> response = client.getAccountInfoWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobServiceSasSignatureValues.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobServiceSasSignatureValues.java index 41164b76854ef..8d2bb20fc0c1f 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobServiceSasSignatureValues.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobServiceSasSignatureValues.java @@ -9,13 +9,13 @@ import com.azure.storage.blob.BlobSasPermission; import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.blob.models.UserDelegationKey; +import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.Utility; import com.azure.storage.common.sas.SasIpRange; import com.azure.storage.common.sas.SasProtocol; import java.time.OffsetDateTime; - /** * Used to generate a Shared Access Signature (SAS) for an Azure Blob Storage service. Once all the values here are set, * call {@link @@ -223,7 +223,7 @@ public String getPermissions() { * @throws NullPointerException if {@code permissions} is null. */ public BlobServiceSasSignatureValues setPermissions(BlobSasPermission permissions) { - Utility.assertNotNull("permissions", permissions); + StorageImplUtils.assertNotNull("permissions", permissions); this.permissions = permissions.toString(); return this; } @@ -236,7 +236,7 @@ public BlobServiceSasSignatureValues setPermissions(BlobSasPermission permission * @throws NullPointerException if {@code permissions} is null. */ public BlobServiceSasSignatureValues setPermissions(BlobContainerSasPermission permissions) { - Utility.assertNotNull("permissions", permissions); + StorageImplUtils.assertNotNull("permissions", permissions); this.permissions = permissions.toString(); return this; } @@ -472,7 +472,7 @@ public BlobServiceSasSignatureValues setContentType(String contentType) { */ public BlobServiceSasQueryParameters generateSasQueryParameters( StorageSharedKeyCredential storageSharedKeyCredentials) { - Utility.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); + StorageImplUtils.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); ensureState(); @@ -522,18 +522,21 @@ public BlobServiceSasQueryParameters generateSasQueryParameters( */ public BlobServiceSasQueryParameters generateSasQueryParameters(UserDelegationKey delegationKey, String accountName) { - Utility.assertNotNull("delegationKey", delegationKey); - Utility.assertNotNull("accountName", accountName); + StorageImplUtils.assertNotNull("delegationKey", delegationKey); + StorageImplUtils.assertNotNull("accountName", accountName); ensureState(); // Signature is generated on the un-url-encoded values. final String canonicalName = getCanonicalName(accountName); - String signature = Utility.computeHMac256(delegationKey.getValue(), stringToSign(delegationKey, canonicalName)); + String signature = StorageImplUtils.computeHMac256( + delegationKey.getValue(), stringToSign(delegationKey, canonicalName)); + return new BlobServiceSasQueryParameters(this.version, this.protocol, this.startTime, this.expiryTime, - this.sasIpRange, null /* identifier */, this.resource, this.permissions, signature, this.cacheControl, - this.contentDisposition, this.contentEncoding, this.contentLanguage, this.contentType, delegationKey); + this.sasIpRange, null /* identifier */, this.resource, this.permissions, signature, + this.cacheControl, this.contentDisposition, this.contentEncoding, this.contentLanguage, this.contentType, + delegationKey); } /** @@ -594,8 +597,8 @@ private String getCanonicalName(String account) { private String stringToSign(String canonicalName) { return String.join("\n", this.permissions == null ? "" : permissions, - this.startTime == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - this.expiryTime == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), + this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), + this.expiryTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), canonicalName, this.identifier == null ? "" : this.identifier, this.sasIpRange == null ? "" : this.sasIpRange.toString(), @@ -614,13 +617,13 @@ private String stringToSign(String canonicalName) { private String stringToSign(final UserDelegationKey key, String canonicalName) { return String.join("\n", this.permissions == null ? "" : this.permissions, - this.startTime == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - this.expiryTime == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), + this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), + this.expiryTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), canonicalName, key.getSignedOid() == null ? "" : key.getSignedOid(), key.getSignedTid() == null ? "" : key.getSignedTid(), - key.getSignedStart() == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedStart()), - key.getSignedExpiry() == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedExpiry()), + key.getSignedStart() == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedStart()), + key.getSignedExpiry() == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(key.getSignedExpiry()), key.getSignedService() == null ? "" : key.getSignedService(), key.getSignedVersion() == null ? "" : key.getSignedVersion(), this.sasIpRange == null ? "" : this.sasIpRange.toString(), diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobClient.java index 006520439b9cc..dec7fc3bfd9bf 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobClient.java @@ -21,6 +21,7 @@ import com.azure.storage.blob.models.LeaseAccessConditions; import com.azure.storage.blob.models.SourceModifiedAccessConditions; import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; @@ -156,7 +157,7 @@ public Response uploadWithResponse(InputStream data, long length, accessConditions, context); try { - return Utility.blockWithOptionalTimeout(upload, timeout); + return StorageImplUtils.blockWithOptionalTimeout(upload, timeout); } catch (UncheckedIOException e) { throw logger.logExceptionAsError(e); } @@ -211,7 +212,7 @@ public Response stageBlockWithResponse(String base64BlockID, InputStream d Mono> response = blockBlobAsyncClient.stageBlockWithResponse(base64BlockID, fbb.subscribeOn(Schedulers.elastic()), length, leaseAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -267,7 +268,7 @@ public Response stageBlockFromURLWithResponse(String base64BlockID, String SourceModifiedAccessConditions sourceModifiedAccessConditions, Duration timeout, Context context) { Mono> response = blockBlobAsyncClient.stageBlockFromURLWithResponse(base64BlockID, sourceUrl, sourceRange, sourceContentMD5, leaseAccessConditions, sourceModifiedAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -307,7 +308,7 @@ public Response listBlocksWithResponse(BlockListType listType, Mono> response = blockBlobAsyncClient.listBlocksWithResponse(listType, leaseAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -356,6 +357,6 @@ public Response commitBlockListWithResponse(List base64Bl Mono> response = blockBlobAsyncClient.commitBlockListWithResponse( base64BlockIDs, headers, metadata, tier, accessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/DownloadAsyncResponse.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/DownloadAsyncResponse.java index e598783508659..c6bbe08a67a33 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/DownloadAsyncResponse.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/DownloadAsyncResponse.java @@ -7,7 +7,7 @@ import com.azure.storage.blob.HttpGetterInfo; import com.azure.storage.blob.models.BlobDownloadHeaders; import com.azure.storage.blob.models.ReliableDownloadOptions; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -41,9 +41,9 @@ public final class DownloadAsyncResponse { // The constructor is package-private because customers should not be creating their own responses. DownloadAsyncResponse(ResponseBase> response, HttpGetterInfo info, Function> getter) { - Utility.assertNotNull("getter", getter); - Utility.assertNotNull("info", info); - Utility.assertNotNull("info.eTag", info.getETag()); + StorageImplUtils.assertNotNull("getter", getter); + StorageImplUtils.assertNotNull("info", info); + StorageImplUtils.assertNotNull("info.eTag", info.getETag()); this.rawResponse = response; this.info = info; this.getter = getter; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/LeaseClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/LeaseClient.java index bc01530be04cc..ef349950fd5df 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/LeaseClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/LeaseClient.java @@ -11,8 +11,8 @@ import com.azure.storage.blob.BlobClient; import com.azure.storage.blob.BlobContainerClient; import com.azure.storage.blob.models.ModifiedAccessConditions; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import java.net.URL; import java.time.Duration; @@ -97,7 +97,7 @@ public String acquireLease(int duration) { @ServiceMethod(returns = ReturnType.SINGLE) public Response acquireLeaseWithResponse(int duration, ModifiedAccessConditions modifiedAccessConditions, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(this.client + return StorageImplUtils.blockWithOptionalTimeout(this.client .acquireLeaseWithResponse(duration, modifiedAccessConditions, context), timeout); } @@ -132,7 +132,7 @@ public String renewLease() { @ServiceMethod(returns = ReturnType.SINGLE) public Response renewLeaseWithResponse(ModifiedAccessConditions modifiedAccessConditions, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(this.client + return StorageImplUtils.blockWithOptionalTimeout(this.client .renewLeaseWithResponse(modifiedAccessConditions, context), timeout); } @@ -165,7 +165,7 @@ public void releaseLease() { @ServiceMethod(returns = ReturnType.SINGLE) public Response releaseLeaseWithResponse(ModifiedAccessConditions modifiedAccessConditions, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(this.client + return StorageImplUtils.blockWithOptionalTimeout(this.client .releaseLeaseWithResponse(modifiedAccessConditions, context), timeout); } @@ -207,7 +207,7 @@ public Integer breakLease() { @ServiceMethod(returns = ReturnType.SINGLE) public Response breakLeaseWithResponse(Integer breakPeriodInSeconds, ModifiedAccessConditions modifiedAccessConditions, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(this.client + return StorageImplUtils.blockWithOptionalTimeout(this.client .breakLeaseWithResponse(breakPeriodInSeconds, modifiedAccessConditions, context), timeout); } @@ -244,7 +244,7 @@ public String changeLease(String proposedId) { @ServiceMethod(returns = ReturnType.SINGLE) public Response changeLeaseWithResponse(String proposedId, ModifiedAccessConditions modifiedAccessConditions, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(this.client + return StorageImplUtils.blockWithOptionalTimeout(this.client .changeLeaseWithResponse(proposedId, modifiedAccessConditions, context), timeout); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobClient.java index 8d5d1c099ba6e..e85ff562275a8 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobClient.java @@ -21,6 +21,7 @@ import com.azure.storage.blob.models.SequenceNumberActionType; import com.azure.storage.blob.models.SourceModifiedAccessConditions; import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; @@ -137,7 +138,7 @@ public Response createWithResponse(long size, Long sequenceNumber, Map metadata, BlobAccessConditions accessConditions, Duration timeout, Context context) { Mono> response = pageBlobAsyncClient.createWithResponse(size, sequenceNumber, headers, metadata, accessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -194,7 +195,7 @@ public Response uploadPagesWithResponse(PageRange pageRange, Input Mono> response = pageBlobAsyncClient.uploadPagesWithResponse(pageRange, fbb.subscribeOn(Schedulers.elastic()), pageBlobAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -255,7 +256,7 @@ public Response uploadPagesFromURLWithResponse(PageRange range, St Mono> response = pageBlobAsyncClient.uploadPagesFromURLWithResponse(range, sourceUrl, sourceOffset, sourceContentMD5, destAccessConditions, sourceAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -296,7 +297,7 @@ public Response clearPagesWithResponse(PageRange pageRange, Mono> response = pageBlobAsyncClient.clearPagesWithResponse(pageRange, pageBlobAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -330,7 +331,7 @@ public PageList getPageRanges(BlobRange blobRange) { */ public Response getPageRangesWithResponse(BlobRange blobRange, BlobAccessConditions accessConditions, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(pageBlobAsyncClient + return StorageImplUtils.blockWithOptionalTimeout(pageBlobAsyncClient .getPageRangesWithResponse(blobRange, accessConditions, context), timeout); } @@ -373,7 +374,7 @@ public PageList getPageRangesDiff(BlobRange blobRange, String prevSnapshot) { */ public Response getPageRangesDiffWithResponse(BlobRange blobRange, String prevSnapshot, BlobAccessConditions accessConditions, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(pageBlobAsyncClient + return StorageImplUtils.blockWithOptionalTimeout(pageBlobAsyncClient .getPageRangesDiffWithResponse(blobRange, prevSnapshot, accessConditions, context), timeout); } @@ -411,7 +412,7 @@ public PageBlobItem resize(long size) { public Response resizeWithResponse(long size, BlobAccessConditions accessConditions, Duration timeout, Context context) { Mono> response = pageBlobAsyncClient.resizeWithResponse(size, accessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -452,7 +453,7 @@ public Response updateSequenceNumberWithResponse(SequenceNumberAct Long sequenceNumber, BlobAccessConditions accessConditions, Duration timeout, Context context) { Mono> response = pageBlobAsyncClient .updateSequenceNumberWithResponse(action, sequenceNumber, accessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -502,6 +503,6 @@ public Response copyIncrementalWithResponse(String source, Strin ModifiedAccessConditions modifiedAccessConditions, Duration timeout, Context context) { Mono> response = pageBlobAsyncClient .copyIncrementalWithResponse(source, snapshot, modifiedAccessConditions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } } diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SASTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SASTest.groovy index f8830d44776b7..857ffe3ee926b 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SASTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SASTest.groovy @@ -10,6 +10,8 @@ import com.azure.storage.blob.models.BlobStorageException import com.azure.storage.blob.models.UserDelegationKey import com.azure.storage.blob.specialized.BlobServiceSasSignatureValues import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder +import com.azure.storage.common.Utility +import com.azure.storage.common.implementation.StorageImplUtils import com.azure.storage.common.sas.AccountSasResourceType import com.azure.storage.common.sas.AccountSasService import com.azure.storage.common.sas.AccountSasPermission @@ -18,7 +20,6 @@ import com.azure.storage.common.sas.SasProtocol import com.azure.storage.common.StorageSharedKeyCredential import com.azure.storage.common.implementation.Constants -import com.azure.storage.common.Utility import com.azure.storage.common.sas.SasIpRange import spock.lang.Unroll @@ -670,16 +671,16 @@ class SASTest extends APISpec { */ where: startTime | identifier | ipRange | protocol | snapId | cacheControl | disposition | encoding | language | type || expectedStringToSign - OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) | null | null | null | null | null | null | null | null | null || "r\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | "id" | null | null | null | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\nid\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | null | new SasIpRange() | null | null | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\nip\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | null | null | SasProtocol.HTTPS_ONLY | null | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n" + SasProtocol.HTTPS_ONLY + "\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | null | null | null | "snapId" | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nbs\nsnapId\n\n\n\n\n" - null | null | null | null | null | "control" | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\ncontrol\n\n\n\n" - null | null | null | null | null | null | "disposition" | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\ndisposition\n\n\n" - null | null | null | null | null | null | null | "encoding" | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\nencoding\n\n" - null | null | null | null | null | null | null | null | "language" | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\nlanguage\n" - null | null | null | null | null | null | null | null | null | "type" || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\ntype" + OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) | null | null | null | null | null | null | null | null | null || "r\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | "id" | null | null | null | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\nid\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | null | new SasIpRange() | null | null | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\nip\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | null | null | SasProtocol.HTTPS_ONLY | null | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n" + SasProtocol.HTTPS_ONLY + "\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | null | null | null | "snapId" | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nbs\nsnapId\n\n\n\n\n" + null | null | null | null | null | "control" | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\ncontrol\n\n\n\n" + null | null | null | null | null | null | "disposition" | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\ndisposition\n\n\n" + null | null | null | null | null | null | null | "encoding" | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\nencoding\n\n" + null | null | null | null | null | null | null | null | "language" | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\nlanguage\n" + null | null | null | null | null | null | null | null | null | "type" || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\ntype" } @Unroll @@ -721,28 +722,28 @@ class SASTest extends APISpec { def token = v.generateSasQueryParameters(key, primaryCredential.getAccountName()) then: - token.getSignature() == Utility.computeHMac256(key.getValue(), expected) + token.getSignature() == StorageImplUtils.computeHMac256(key.getValue(), expected) /* We test string to sign functionality directly related to user delegation sas specific parameters */ where: startTime | keyOid | keyTid | keyStart | keyExpiry | keyService | keyVersion | keyValue | ipRange | protocol | snapId | cacheControl | disposition | encoding | language | type || expectedStringToSign - OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | "11111111-1111-1111-1111-111111111111" | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n11111111-1111-1111-1111-111111111111\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | null | "22222222-2222-2222-2222-222222222222" | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n22222222-2222-2222-2222-222222222222\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | null | null | OffsetDateTime.of(LocalDateTime.of(2018, 1, 1, 0, 0), ZoneOffset.UTC) | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n2018-01-01T00:00:00Z\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | null | null | null | OffsetDateTime.of(LocalDateTime.of(2018, 1, 1, 0, 0), ZoneOffset.UTC) | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n2018-01-01T00:00:00Z\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | null | null | null | null | "b" | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\nb\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | null | null | null | null | null | "2018-06-17" | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n2018-06-17\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | new SasIpRange() | null | null | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\nip\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | SasProtocol.HTTPS_ONLY | null | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n" + SasProtocol.HTTPS_ONLY + "\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | "snapId" | null | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nbs\nsnapId\n\n\n\n\n" - null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | "control" | null | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\ncontrol\n\n\n\n" - null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | "disposition" | null | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\ndisposition\n\n\n" - null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | "encoding" | null | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\nencoding\n\n" - null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | "language" | null || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\nlanguage\n" - null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | "type" || "r\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\ntype" + OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | "11111111-1111-1111-1111-111111111111" | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n11111111-1111-1111-1111-111111111111\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | null | "22222222-2222-2222-2222-222222222222" | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n22222222-2222-2222-2222-222222222222\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | null | null | OffsetDateTime.of(LocalDateTime.of(2018, 1, 1, 0, 0), ZoneOffset.UTC) | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n2018-01-01T00:00:00Z\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | null | null | null | OffsetDateTime.of(LocalDateTime.of(2018, 1, 1, 0, 0), ZoneOffset.UTC) | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n2018-01-01T00:00:00Z\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | null | null | null | null | "b" | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\nb\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | null | null | null | null | null | "2018-06-17" | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n2018-06-17\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | new SasIpRange() | null | null | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\nip\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | SasProtocol.HTTPS_ONLY | null | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n" + SasProtocol.HTTPS_ONLY + "\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | "snapId" | null | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nbs\nsnapId\n\n\n\n\n" + null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | "control" | null | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\ncontrol\n\n\n\n" + null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | "disposition" | null | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\ndisposition\n\n\n" + null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | "encoding" | null | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\nencoding\n\n" + null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | "language" | null || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\nlanguage\n" + null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | "type" || "r\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\ntype" } def "serviceSasSignatureValues IA"() { @@ -967,9 +968,9 @@ class SASTest extends APISpec { where: startTime | ipRange | protocol || expectedStringToSign - OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) | null | null || "%s" + "\nr\nb\no\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" - null | new SasIpRange() | null || "%s" + "\nr\nb\no\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\nip\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" - null | null | SasProtocol.HTTPS_ONLY || "%s" + "\nr\nb\no\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n\n" + SasProtocol.HTTPS_ONLY + "\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" + OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) | null | null || "%s" + "\nr\nb\no\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" + null | new SasIpRange() | null || "%s" + "\nr\nb\no\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\nip\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" + null | null | SasProtocol.HTTPS_ONLY || "%s" + "\nr\nb\no\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n\n" + SasProtocol.HTTPS_ONLY + "\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" } @Unroll diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTest.groovy index dabe50a2b3f5c..53e15aedfcaf6 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/HelperTest.groovy @@ -11,6 +11,7 @@ import com.azure.storage.blob.BlobServiceVersion import com.azure.storage.blob.BlobUrlParts import com.azure.storage.blob.models.BlobRange import com.azure.storage.blob.models.UserDelegationKey +import com.azure.storage.common.implementation.StorageImplUtils import com.azure.storage.common.StorageSharedKeyCredential import com.azure.storage.common.Utility import com.azure.storage.common.implementation.Constants @@ -122,12 +123,12 @@ class HelperTest extends APISpec { if (startTime != null) { expectedStringToSign = String.format(expectedStringToSign, - Utility.ISO_8601_UTC_DATE_FORMATTER.format(startTime), - Utility.ISO_8601_UTC_DATE_FORMATTER.format(expiryTime), + Constants.ISO_8601_UTC_DATE_FORMATTER.format(startTime), + Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiryTime), primaryCredential.getAccountName()) } else { expectedStringToSign = String.format(expectedStringToSign, - Utility.ISO_8601_UTC_DATE_FORMATTER.format(expiryTime), + Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiryTime), primaryCredential.getAccountName()) } @@ -199,10 +200,10 @@ class HelperTest extends APISpec { BlobServiceSasQueryParameters token = v.generateSasQueryParameters(key, primaryCredential.getAccountName()) - expectedStringToSign = String.format(expectedStringToSign, Utility.ISO_8601_UTC_DATE_FORMATTER.format(v.getExpiryTime()), primaryCredential.getAccountName()) + expectedStringToSign = String.format(expectedStringToSign, Constants.ISO_8601_UTC_DATE_FORMATTER.format(v.getExpiryTime()), primaryCredential.getAccountName()) then: - token.getSignature() == Utility.computeHMac256(key.getValue(), expectedStringToSign) + token.getSignature() == StorageImplUtils.computeHMac256(key.getValue(), expectedStringToSign) /* We test string to sign functionality directly related to user delegation sas specific parameters @@ -210,7 +211,7 @@ class HelperTest extends APISpec { where: permissions | startTime | expiryTime | keyOid | keyTid | keyStart | keyExpiry | keyService | keyVersion | keyValue | ipRange | protocol | snapId | cacheControl | disposition | encoding | language | type || expectedStringToSign new BlobSasPermission() | null | null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "r\n\n%s\n" + "/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" - null | OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) | null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n%s\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" + null | OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) | null | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n%s\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" null | null | OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) | null | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "\n\n%s\n/blob/%s/containerName/blobName\n\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" null | null | null | "11111111-1111-1111-1111-111111111111" | null | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "\n\n%s\n/blob/%s/containerName/blobName\n11111111-1111-1111-1111-111111111111\n\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" null | null | null | null | "22222222-2222-2222-2222-222222222222" | null | null | null | null | "3hd4LRwrARVGbeMRQRfTLIsGMkCPuZJnvxZDU7Gak8c=" | null | null | null | null | null | null | null | null || "\n\n%s\n/blob/%s/containerName/blobName\n\n22222222-2222-2222-2222-222222222222\n\n\n\n\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\nb\n\n\n\n\n\n" @@ -242,7 +243,7 @@ class HelperTest extends APISpec { } expectedStringToSign = String.format(expectedStringToSign, - Utility.ISO_8601_UTC_DATE_FORMATTER.format(expiryTime), + Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiryTime), primaryCredential.getAccountName()) when: @@ -461,9 +462,9 @@ class HelperTest extends APISpec { where: startTime | ipRange | protocol || expectedStringToSign - OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) | null | null || "%s\nr\nb\no\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" - null | new SasIpRange() | null || "%s\nr\nb\no\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\nip\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" - null | null | SasProtocol.HTTPS_ONLY || "%s\nr\nb\no\n\n" + Utility.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n\n" + SasProtocol.HTTPS_ONLY + "\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" + OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) | null | null || "%s\nr\nb\no\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" + null | new SasIpRange() | null || "%s\nr\nb\no\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\nip\n\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" + null | null | SasProtocol.HTTPS_ONLY || "%s\nr\nb\no\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n\n" + SasProtocol.HTTPS_ONLY + "\n" + Constants.HeaderConstants.TARGET_STORAGE_VERSION + "\n" } @Unroll diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/StorageSharedKeyCredential.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/StorageSharedKeyCredential.java index 948551f4744a4..dbebb2545e22e 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/StorageSharedKeyCredential.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/StorageSharedKeyCredential.java @@ -3,8 +3,12 @@ package com.azure.storage.common; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.policy.HttpPipelinePolicy; import com.azure.core.implementation.util.ImplUtils; +import com.azure.storage.common.implementation.StorageImplUtils; +import com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -88,7 +92,8 @@ public String getAccountName() { * @return the SharedKey authorization value */ public String generateAuthorizationHeader(URL requestURL, String httpMethod, Map headers) { - String signature = Utility.computeHMac256(accountKey, buildStringToSign(requestURL, httpMethod, headers)); + String signature = StorageImplUtils.computeHMac256(accountKey, + buildStringToSign(requestURL, httpMethod, headers)); return String.format(AUTHORIZATION_HEADER_FORMAT, accountName, signature); } @@ -102,7 +107,7 @@ public String generateAuthorizationHeader(URL requestURL, String httpMethod, Map * string, or the UTF-8 charset isn't supported. */ public String computeHmac256(final String stringToSign) { - return Utility.computeHMac256(accountKey, stringToSign); + return StorageImplUtils.computeHMac256(accountKey, stringToSign); } private String buildStringToSign(URL requestURL, String httpMethod, Map headers) { @@ -110,7 +115,8 @@ private String buildStringToSign(URL requestURL, String httpMethod, Map queryParams = Utility.parseQueryStringSplitValues(requestURL.getQuery()); + Map queryParams = StorageImplUtils.parseQueryStringSplitValues(requestURL.getQuery()); ArrayList queryParamNames = new ArrayList<>(queryParams.keySet()); Collections.sort(queryParamNames); @@ -203,4 +209,23 @@ private String getCanonicalizedResource(URL requestURL) { // append to main string builder the join of completed params with new line return canonicalizedResource.toString(); } + + /** + * Searches for a {@link StorageSharedKeyCredential} in the passed {@link HttpPipeline}. + * + * @param httpPipeline Pipeline being searched + * @return a StorageSharedKeyCredential if the pipeline contains one, otherwise null. + */ + public static StorageSharedKeyCredential getSharedKeyCredentialFromPipeline(HttpPipeline httpPipeline) { + for (int i = 0; i < httpPipeline.getPolicyCount(); i++) { + HttpPipelinePolicy httpPipelinePolicy = httpPipeline.getPolicy(i); + if (httpPipelinePolicy instanceof StorageSharedKeyCredentialPolicy) { + StorageSharedKeyCredentialPolicy storageSharedKeyCredentialPolicy = + (StorageSharedKeyCredentialPolicy) httpPipelinePolicy; + return storageSharedKeyCredentialPolicy.sharedKeyCredential(); + } + } + return null; + } + } diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/Utility.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/Utility.java index 8f381a22cec0e..1fc33ce660d3f 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/Utility.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/Utility.java @@ -4,57 +4,28 @@ package com.azure.storage.common; import com.azure.core.exception.UnexpectedLengthException; -import com.azure.core.http.HttpHeader; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.implementation.http.UrlBuilder; import com.azure.core.implementation.util.ImplUtils; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; import java.net.URLDecoder; import java.net.URLEncoder; import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.time.Duration; import java.time.LocalDateTime; import java.time.OffsetDateTime; -import java.time.ZoneId; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; -import java.util.Base64; import java.util.Locale; -import java.util.Map; -import java.util.TreeMap; -import java.util.function.Function; public final class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); - private static final String DESERIALIZED_HEADERS = "deserializedHeaders"; - private static final String ETAG = "eTag"; private static final String UTF8_CHARSET = "UTF-8"; - private static final String ARGUMENT_NULL_OR_EMPTY = - "The argument must not be null or an empty string. Argument name: %s."; - private static final String PARAMETER_NOT_IN_RANGE = "The value of the parameter '%s' should be between %s and %s."; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; - private static final String NO_PATH_SEGMENTS = "URL %s does not contain path segments."; - public static final DateTimeFormatter ISO_8601_UTC_DATE_FORMATTER = - DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ROOT).withZone(ZoneId.of("UTC")); /** * Stores a reference to the date/time pattern with the greatest precision Java.util.Date is capable of expressing. */ @@ -73,46 +44,6 @@ public final class Utility { private static final int MAX_PRECISION_DATESTRING_LENGTH = MAX_PRECISION_PATTERN.replaceAll("'", "") .length(); - /** - * Parses the query string into a key-value pair map that maintains key, query parameter key, order. The value is - * stored as a string (ex. key=val1,val2,val3 instead of key=[val1, val2, val3]). - * - * @param queryString Query string to parse - * @return a mapping of query string pieces as key-value pairs. - */ - public static Map parseQueryString(final String queryString) { - return parseQueryStringHelper(queryString, Utility::urlDecode); - } - - /** - * Parses the query string into a key-value pair map that maintains key, query parameter key, order. The value is - * stored as a parsed array (ex. key=[val1, val2, val3] instead of key=val1,val2,val3). - * - * @param queryString Query string to parse - * @return a mapping of query string pieces as key-value pairs. - */ - public static Map parseQueryStringSplitValues(final String queryString) { - return parseQueryStringHelper(queryString, (value) -> urlDecode(value).split(",")); - } - - private static Map parseQueryStringHelper(final String queryString, - Function valueParser) { - TreeMap pieces = new TreeMap<>(); - - if (ImplUtils.isNullOrEmpty(queryString)) { - return pieces; - } - - for (String kvp : queryString.split("&")) { - int equalIndex = kvp.indexOf("="); - String key = urlDecode(kvp.substring(0, equalIndex).toLowerCase(Locale.ROOT)); - T value = valueParser.apply(kvp.substring(equalIndex + 1)); - - pieces.putIfAbsent(key, value); - } - - return pieces; - } /** * Performs a safe decoding of the passed string, taking care to preserve each {@code +} character rather than @@ -216,81 +147,6 @@ private static String encode(final String stringToEncode) { } } - /** - * Blocks an asynchronous response with an optional timeout. - * - * @param response Asynchronous response to block - * @param timeout Optional timeout - * @param Return type of the asynchronous response - * @return the value of the asynchronous response - * @throws RuntimeException If the asynchronous response doesn't complete before the timeout expires. - */ - public static T blockWithOptionalTimeout(Mono response, Duration timeout) { - if (timeout == null) { - return response.block(); - } else { - return response.block(timeout); - } - } - - /** - * Applies a timeout to a publisher if the given timeout is not null. - * - * @param publisher Mono to apply optional timeout to. - * @param timeout Optional timeout. - * @param Return type of the Mono. - * @return Mono with an applied timeout, if any. - */ - public static Mono applyOptionalTimeout(Mono publisher, Duration timeout) { - return timeout == null - ? publisher - : publisher.timeout(timeout); - } - - /** - * Applies a timeout to a publisher if the given timeout is not null. - * - * @param publisher Flux to apply optional timeout to. - * @param timeout Optional timeout. - * @param Return type of the Flux. - * @return Flux with an applied timeout, if any. - */ - public static Flux applyOptionalTimeout(Flux publisher, Duration timeout) { - return timeout == null - ? publisher - : publisher.timeout(timeout); - } - - /** - * Asserts that a value is not {@code null}. - * - * @param param Name of the parameter - * @param value Value of the parameter - * @throws NullPointerException If {@code value} is {@code null} - */ - public static void assertNotNull(final String param, final Object value) { - if (value == null) { - throw new NullPointerException(String.format(Locale.ROOT, ARGUMENT_NULL_OR_EMPTY, param)); - } - } - - /** - * Asserts that the specified number is in the valid range. The range is inclusive. - * - * @param param Name of the parameter - * @param value Value of the parameter - * @param min The minimum allowed value - * @param max The maximum allowed value - * @throws IllegalArgumentException If {@code value} is less than {@code min} or {@code value} is greater than - * {@code max}. - */ - public static void assertInBounds(final String param, final long value, final long min, final long max) { - if (value < min || value > max) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format(Locale.ROOT, - PARAMETER_NOT_IN_RANGE, param, min, max))); - } - } - /** * Given a String representing a date in a form of the ISO8601 pattern, generates a Date representing it with up to * millisecond precision. @@ -329,157 +185,7 @@ public static OffsetDateTime parseDate(String dateString) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern, Locale.ROOT); return LocalDateTime.parse(dateString, formatter).atZone(ZoneOffset.UTC).toOffsetDateTime(); - } - - /** - * Wraps any potential error responses from the service and applies post processing of the response's eTag header to - * standardize the value. - * - * @param response Response from a service call - * @param errorWrapper Error wrapping function that is applied to the response - * @param Value type of the response - * @return an updated response with post processing steps applied. - */ - public static Mono postProcessResponse(Mono response, Function, Mono> errorWrapper) { - return scrubETagHeader(errorWrapper.apply(response)); - } - - /* - The service is inconsistent in whether or not the etag header value has quotes. This method will check if the - response returns an etag value, and if it does, remove any quotes that may be present to give the user a more - predictable format to work with. - */ - private static Mono scrubETagHeader(Mono unprocessedResponse) { - return unprocessedResponse.map(response -> { - String eTag = null; - - try { - Object headers = response.getClass().getMethod(DESERIALIZED_HEADERS).invoke(response); - Method eTagGetterMethod = headers.getClass().getMethod(ETAG); - eTag = (String) eTagGetterMethod.invoke(headers); - - if (eTag == null) { - return response; - } - - eTag = eTag.replace("\"", ""); - headers.getClass().getMethod(ETAG, String.class).invoke(headers, eTag); - } catch (NoSuchMethodException ex) { - // Response did not return an eTag value. - } catch (IllegalAccessException | InvocationTargetException ex) { - // Unable to access the method or the invoked method threw an exception. - } - - try { - HttpHeaders rawHeaders = (HttpHeaders) response.getClass().getMethod("getHeaders") - .invoke(response); - // - if (eTag != null) { - rawHeaders.put(ETAG, eTag); - } else { - HttpHeader eTagHeader = rawHeaders.get(ETAG); - if (eTagHeader != null && eTagHeader.getValue() != null) { - eTag = eTagHeader.getValue().replace("\"", ""); - rawHeaders.put(ETAG, eTag); - } - } - } catch (NoSuchMethodException e) { - // Response did not return an eTag value. No change necessary. - } catch (IllegalAccessException | InvocationTargetException e) { - // Unable to access the method or the invoked method threw an exception. - } - - return response; - }); - } - - /** - * Computes a signature for the specified string using the HMAC-SHA256 algorithm. - * - * @param base64Key Base64 encoded key used to sign the string - * @param stringToSign UTF-8 encoded string to sign - * @return the HMAC-SHA256 encoded signature - * @throws RuntimeException If the HMAC-SHA256 algorithm isn't support, if the key isn't a valid Base64 encoded - * string, or the UTF-8 charset isn't supported. - */ - public static String computeHMac256(final String base64Key, final String stringToSign) { - try { - byte[] key = Base64.getDecoder().decode(base64Key); - Mac hmacSHA256 = Mac.getInstance("HmacSHA256"); - hmacSHA256.init(new SecretKeySpec(key, "HmacSHA256")); - byte[] utf8Bytes = stringToSign.getBytes(StandardCharsets.UTF_8); - return Base64.getEncoder().encodeToString(hmacSHA256.doFinal(utf8Bytes)); - } catch (NoSuchAlgorithmException | InvalidKeyException ex) { - throw new RuntimeException(ex); - } - } - - /** - * Appends a string to the end of the passed URL's path. - * - * @param baseURL URL having a path appended - * @param name Name of the path - * @return a URL with the path appended. - * @throws IllegalArgumentException If {@code name} causes the URL to become malformed. - */ - public static URL appendToUrlPath(String baseURL, String name) { - UrlBuilder builder = UrlBuilder.parse(baseURL); - - if (builder.getPath() == null) { - builder.setPath("/"); - } else if (!builder.getPath().endsWith("/")) { - builder.setPath(builder.getPath() + "/"); - } - - builder.setPath(builder.getPath() + name); - - try { - return builder.toURL(); - } catch (MalformedURLException ex) { - throw new IllegalArgumentException(ex); - } - } - - /** - * Strips the last path segment from the passed URL. - * - * @param baseUrl URL having its last path segment stripped - * @return a URL with the path segment stripped. - * @throws IllegalArgumentException If stripping the last path segment causes the URL to become malformed or it - * doesn't contain any path segments. - */ - public static URL stripLastPathSegment(URL baseUrl) { - UrlBuilder builder = UrlBuilder.parse(baseUrl); - - if (builder.getPath() == null || !builder.getPath().contains("/")) { - throw new IllegalArgumentException(String.format(Locale.ROOT, NO_PATH_SEGMENTS, baseUrl)); - } - - builder.setPath(builder.getPath().substring(0, builder.getPath().lastIndexOf("/"))); - try { - return builder.toURL(); - } catch (MalformedURLException ex) { - throw new IllegalArgumentException(ex); - } - } - - /** - * Searches for a {@link StorageSharedKeyCredential} in the passed {@link HttpPipeline}. - * - * @param httpPipeline Pipeline being searched - * @return a StorageSharedKeyCredential if the pipeline contains one, otherwise null. - */ - public static StorageSharedKeyCredential getSharedKeyCredential(HttpPipeline httpPipeline) { - for (int i = 0; i < httpPipeline.getPolicyCount(); i++) { - HttpPipelinePolicy httpPipelinePolicy = httpPipeline.getPolicy(i); - if (httpPipelinePolicy instanceof StorageSharedKeyCredentialPolicy) { - StorageSharedKeyCredentialPolicy storageSharedKeyCredentialPolicy = - (StorageSharedKeyCredentialPolicy) httpPipelinePolicy; - return storageSharedKeyCredentialPolicy.sharedKeyCredential(); - } - } - return null; - } + } /** * A utility method for converting the input stream to Flux of ByteBuffer. Will check the equality of entity length diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/Constants.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/Constants.java index 505f1bf87bf9d..df5b6a0e3d2bc 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/Constants.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/Constants.java @@ -4,6 +4,9 @@ package com.azure.storage.common.implementation; import com.azure.storage.common.sas.SasProtocol; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.Locale; /** * Defines general constants. @@ -42,6 +45,10 @@ public final class Constants { public static final String ENUM_COULD_NOT_BE_PARSED_INVALID_VALUE = "%s could not be parsed from '%s' due to invalid value %s."; + + public static final DateTimeFormatter ISO_8601_UTC_DATE_FORMATTER = + DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ROOT).withZone(ZoneId.of("UTC")); + private Constants() { } diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/StorageImplUtils.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/StorageImplUtils.java new file mode 100644 index 0000000000000..95e039a3dda8b --- /dev/null +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/StorageImplUtils.java @@ -0,0 +1,253 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.common.implementation; + +import com.azure.core.implementation.http.UrlBuilder; +import com.azure.core.implementation.util.ImplUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.storage.common.Utility; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.time.Duration; +import java.util.Base64; +import java.util.Locale; +import java.util.Map; +import java.util.TreeMap; +import java.util.function.Function; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + +import static com.azure.storage.common.Utility.urlDecode; + +/** + * Utility class which is used internally. + */ +public class StorageImplUtils { + private static final ClientLogger LOGGER = new ClientLogger(StorageImplUtils.class); + + private static final String ARGUMENT_NULL_OR_EMPTY = + "The argument must not be null or an empty string. Argument name: %s."; + + private static final String PARAMETER_NOT_IN_RANGE = "The value of the parameter '%s' should be between %s and %s."; + + private static final String NO_PATH_SEGMENTS = "URL %s does not contain path segments."; + + /** + * Parses the query string into a key-value pair map that maintains key, query parameter key, order. The value is + * stored as a string (ex. key=val1,val2,val3 instead of key=[val1, val2, val3]). + * + * @param queryString Query string to parse + * @return a mapping of query string pieces as key-value pairs. + */ + public static Map parseQueryString(final String queryString) { + return parseQueryStringHelper(queryString, Utility::urlDecode); + } + + /** + * Parses the query string into a key-value pair map that maintains key, query parameter key, order. The value is + * stored as a parsed array (ex. key=[val1, val2, val3] instead of key=val1,val2,val3). + * + * @param queryString Query string to parse + * @return a mapping of query string pieces as key-value pairs. + */ + public static Map parseQueryStringSplitValues(final String queryString) { + return parseQueryStringHelper(queryString, (value) -> urlDecode(value).split(",")); + } + + private static Map parseQueryStringHelper(final String queryString, + Function valueParser) { + TreeMap pieces = new TreeMap<>(); + + if (com.azure.core.implementation.util.ImplUtils.isNullOrEmpty(queryString)) { + return pieces; + } + + for (String kvp : queryString.split("&")) { + int equalIndex = kvp.indexOf("="); + String key = urlDecode(kvp.substring(0, equalIndex).toLowerCase(Locale.ROOT)); + T value = valueParser.apply(kvp.substring(equalIndex + 1)); + + pieces.putIfAbsent(key, value); + } + + return pieces; + } + + /** + * Blocks an asynchronous response with an optional timeout. + * + * @param response Asynchronous response to block + * @param timeout Optional timeout + * @param Return type of the asynchronous response + * @return the value of the asynchronous response + * @throws RuntimeException If the asynchronous response doesn't complete before the timeout expires. + */ + public static T blockWithOptionalTimeout(Mono response, Duration timeout) { + if (timeout == null) { + return response.block(); + } else { + return response.block(timeout); + } + } + + /** + * Applies a timeout to a publisher if the given timeout is not null. + * + * @param publisher Mono to apply optional timeout to. + * @param timeout Optional timeout. + * @param Return type of the Mono. + * @return Mono with an applied timeout, if any. + */ + public static Mono applyOptionalTimeout(Mono publisher, Duration timeout) { + return timeout == null + ? publisher + : publisher.timeout(timeout); + } + + /** + * Applies a timeout to a publisher if the given timeout is not null. + * + * @param publisher Flux to apply optional timeout to. + * @param timeout Optional timeout. + * @param Return type of the Flux. + * @return Flux with an applied timeout, if any. + */ + public static Flux applyOptionalTimeout(Flux publisher, Duration timeout) { + return timeout == null + ? publisher + : publisher.timeout(timeout); + } + + /** + * Asserts that a value is not {@code null}. + * + * @param param Name of the parameter + * @param value Value of the parameter + * @throws NullPointerException If {@code value} is {@code null} + */ + public static void assertNotNull(final String param, final Object value) { + if (value == null) { + throw new NullPointerException(String.format(Locale.ROOT, ARGUMENT_NULL_OR_EMPTY, param)); + } + } + + /** + * Asserts that the specified number is in the valid range. The range is inclusive. + * + * @param param Name of the parameter + * @param value Value of the parameter + * @param min The minimum allowed value + * @param max The maximum allowed value + * @throws IllegalArgumentException If {@code value} is less than {@code min} or {@code value} is greater than + * {@code max}. + */ + public static void assertInBounds(final String param, final long value, final long min, final long max) { + if (value < min || value > max) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format(Locale.ROOT, + PARAMETER_NOT_IN_RANGE, param, min, max))); + } + } + + /** + * Computes a signature for the specified string using the HMAC-SHA256 algorithm. + * + * @param base64Key Base64 encoded key used to sign the string + * @param stringToSign UTF-8 encoded string to sign + * @return the HMAC-SHA256 encoded signature + * @throws RuntimeException If the HMAC-SHA256 algorithm isn't support, if the key isn't a valid Base64 encoded + * string, or the UTF-8 charset isn't supported. + */ + public static String computeHMac256(final String base64Key, final String stringToSign) { + try { + byte[] key = Base64.getDecoder().decode(base64Key); + Mac hmacSHA256 = Mac.getInstance("HmacSHA256"); + hmacSHA256.init(new SecretKeySpec(key, "HmacSHA256")); + byte[] utf8Bytes = stringToSign.getBytes(StandardCharsets.UTF_8); + return Base64.getEncoder().encodeToString(hmacSHA256.doFinal(utf8Bytes)); + } catch (NoSuchAlgorithmException | InvalidKeyException ex) { + throw new RuntimeException(ex); + } + } + + /** + * Appends a string to the end of the passed URL's path. + * + * @param baseURL URL having a path appended + * @param name Name of the path + * @return a URL with the path appended. + * @throws IllegalArgumentException If {@code name} causes the URL to become malformed. + */ + public static URL appendToUrlPath(String baseURL, String name) { + UrlBuilder builder = UrlBuilder.parse(baseURL); + + if (builder.getPath() == null) { + builder.setPath("/"); + } else if (!builder.getPath().endsWith("/")) { + builder.setPath(builder.getPath() + "/"); + } + + builder.setPath(builder.getPath() + name); + + try { + return builder.toURL(); + } catch (MalformedURLException ex) { + throw new IllegalArgumentException(ex); + } + } + + + /** + * Strips the last path segment from the passed URL. + * + * @param baseUrl URL having its last path segment stripped + * @return a URL with the path segment stripped. + * @throws IllegalArgumentException If stripping the last path segment causes the URL to become malformed or it + * doesn't contain any path segments. + */ + public static URL stripLastPathSegment(URL baseUrl) { + UrlBuilder builder = UrlBuilder.parse(baseUrl); + + if (builder.getPath() == null || !builder.getPath().contains("/")) { + throw new IllegalArgumentException(String.format(Locale.ROOT, NO_PATH_SEGMENTS, baseUrl)); + } + + builder.setPath(builder.getPath().substring(0, builder.getPath().lastIndexOf("/"))); + try { + return builder.toURL(); + } catch (MalformedURLException ex) { + throw new IllegalArgumentException(ex); + } + } + + /** + * Strips the account name from host part of the URL object. + * + * @param url URL having its hostanme + * @return account name. + */ + public static String getAccountName(URL url) { + UrlBuilder builder = UrlBuilder.parse(url); + String accountName = null; + String host = builder.getHost(); + //Parse host to get account name + // host will look like this : .blob.core.windows.net + if (!ImplUtils.isNullOrEmpty(host)) { + int accountNameIndex = host.indexOf('.'); + if (accountNameIndex == -1) { + // host only contains account name + accountName = host; + } else { + // if host is separated by . + accountName = host.substring(0, accountNameIndex); + } + } + return accountName; + } +} diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/policy/RequestRetryOptions.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/policy/RequestRetryOptions.java index ecb6bb9004605..db6569aee3333 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/policy/RequestRetryOptions.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/policy/RequestRetryOptions.java @@ -5,8 +5,8 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import java.util.concurrent.TimeUnit; /** @@ -59,14 +59,14 @@ public RequestRetryOptions(RetryPolicyType retryPolicyType, Integer maxTries, In Long retryDelayInMs, Long maxRetryDelayInMs, String secondaryHost) { this.retryPolicyType = retryPolicyType == null ? RetryPolicyType.EXPONENTIAL : retryPolicyType; if (maxTries != null) { - Utility.assertInBounds("maxRetries", maxTries, 1, Integer.MAX_VALUE); + StorageImplUtils.assertInBounds("maxRetries", maxTries, 1, Integer.MAX_VALUE); this.maxTries = maxTries; } else { this.maxTries = 4; } if (tryTimeout != null) { - Utility.assertInBounds("tryTimeout", tryTimeout, 1, Integer.MAX_VALUE); + StorageImplUtils.assertInBounds("tryTimeout", tryTimeout, 1, Integer.MAX_VALUE); this.tryTimeout = tryTimeout; } else { this.tryTimeout = Integer.MAX_VALUE; @@ -79,8 +79,8 @@ public RequestRetryOptions(RetryPolicyType retryPolicyType, Integer maxTries, In } if (retryDelayInMs != null) { - Utility.assertInBounds("maxRetryDelayInMs", maxRetryDelayInMs, 1, Long.MAX_VALUE); - Utility.assertInBounds("retryDelayInMs", retryDelayInMs, 1, maxRetryDelayInMs); + StorageImplUtils.assertInBounds("maxRetryDelayInMs", maxRetryDelayInMs, 1, Long.MAX_VALUE); + StorageImplUtils.assertInBounds("retryDelayInMs", retryDelayInMs, 1, maxRetryDelayInMs); this.maxRetryDelayInMs = maxRetryDelayInMs; this.retryDelayInMs = retryDelayInMs; } else { diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasQueryParameters.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasQueryParameters.java index 085cb3449acbf..37093937b409d 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasQueryParameters.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasQueryParameters.java @@ -3,7 +3,6 @@ package com.azure.storage.common.sas; - import com.azure.storage.common.implementation.Constants; import java.time.OffsetDateTime; import java.util.Map; diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasSignatureValues.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasSignatureValues.java index 1b5c31636c806..58efbbe213ac8 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasSignatureValues.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasSignatureValues.java @@ -4,9 +4,9 @@ package com.azure.storage.common.sas; import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.StorageImplUtils; import java.time.OffsetDateTime; /** @@ -260,12 +260,12 @@ public AccountSasSignatureValues setResourceTypes(String resourceTypes) { */ public AccountSasQueryParameters generateSasQueryParameters( StorageSharedKeyCredential storageSharedKeyCredentials) { - Utility.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); - Utility.assertNotNull("services", this.services); - Utility.assertNotNull("resourceTypes", this.resourceTypes); - Utility.assertNotNull("expiryTime", this.expiryTime); - Utility.assertNotNull("permissions", this.permissions); - Utility.assertNotNull("version", this.version); + StorageImplUtils.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); + StorageImplUtils.assertNotNull("services", this.services); + StorageImplUtils.assertNotNull("resourceTypes", this.resourceTypes); + StorageImplUtils.assertNotNull("expiryTime", this.expiryTime); + StorageImplUtils.assertNotNull("permissions", this.permissions); + StorageImplUtils.assertNotNull("version", this.version); // Signature is generated on the un-url-encoded values. String signature = storageSharedKeyCredentials.computeHmac256(stringToSign(storageSharedKeyCredentials)); @@ -280,8 +280,8 @@ private String stringToSign(final StorageSharedKeyCredential storageSharedKeyCre AccountSasPermission.parse(this.permissions).toString(), // guarantees ordering this.services, resourceTypes, - this.startTime == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - Utility.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), + this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), + Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), this.sasIpRange == null ? "" : this.sasIpRange.toString(), this.protocol == null ? "" : this.protocol.toString(), this.version, diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/BaseSasQueryParameters.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/BaseSasQueryParameters.java index 5055f37fe532d..648faf1565548 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/BaseSasQueryParameters.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/BaseSasQueryParameters.java @@ -192,7 +192,7 @@ protected String formatQueryParameterDate(OffsetDateTime dateTime) { if (dateTime == null) { return null; } else { - return Utility.ISO_8601_UTC_DATE_FORMATTER.format(dateTime); + return Constants.ISO_8601_UTC_DATE_FORMATTER.format(dateTime); } } diff --git a/sdk/storage/azure-storage-common/src/main/java/module-info.java b/sdk/storage/azure-storage-common/src/main/java/module-info.java index 24e9cd2d34ec6..538800045c3fe 100644 --- a/sdk/storage/azure-storage-common/src/main/java/module-info.java +++ b/sdk/storage/azure-storage-common/src/main/java/module-info.java @@ -11,6 +11,7 @@ exports com.azure.storage.common.implementation to // FIXME this should not be a long-term solution com.azure.storage.blob, com.azure.storage.blob.cryptography, + com.azure.storage.blob.batch, com.azure.storage.file, com.azure.storage.queue; diff --git a/sdk/storage/azure-storage-common/src/samples/java/com/azure/storage/common/credentials/SASTokenCredentialJavaDocCodeSnippets.java b/sdk/storage/azure-storage-common/src/samples/java/com/azure/storage/common/credentials/SASTokenCredentialJavaDocCodeSnippets.java index 2988a14cbd4b8..d0f94b0f4ac41 100644 --- a/sdk/storage/azure-storage-common/src/samples/java/com/azure/storage/common/credentials/SASTokenCredentialJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-common/src/samples/java/com/azure/storage/common/credentials/SASTokenCredentialJavaDocCodeSnippets.java @@ -3,11 +3,10 @@ package com.azure.storage.common.credentials; -import com.azure.storage.common.Utility; - import com.azure.storage.common.implementation.credentials.SasTokenCredential; import java.net.MalformedURLException; import java.net.URL; +import java.util.HashMap; import java.util.Map; /** @@ -37,8 +36,12 @@ public void fromSASTokenString() { */ public void fromQueryParameters() { // BEGIN: com.azure.storage.common.credentials.SasTokenCredential.fromQueryParameters#Map + Map queryMap = new HashMap() {{ + put("queryPara1", "queryValue1"); + put("queryPara2", "queryValue2"); + }}; SasTokenCredential credential = SasTokenCredential - .fromQueryParameters(Utility.parseQueryString(url.getQuery())); + .fromQueryParameters(queryMap); // END: com.azure.storage.common.credentials.SasTokenCredential.fromQueryParameters#Map } } diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/DirectoryAsyncClient.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/DirectoryAsyncClient.java index 02f6cf89d9f1c..2eb0b5b63cda5 100644 --- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/DirectoryAsyncClient.java +++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/DirectoryAsyncClient.java @@ -14,8 +14,8 @@ import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.implementation.AzureFileStorageImpl; import com.azure.storage.file.implementation.models.DirectorysCreateResponse; import com.azure.storage.file.implementation.models.DirectorysGetPropertiesResponse; @@ -517,7 +517,7 @@ public PagedFlux listFilesAndDirectories(String prefix, Integer PagedFlux listFilesAndDirectoriesWithOptionalTimeout(String prefix, Integer maxResultsPerPage, Duration timeout, Context context) { Function>> retriever = - marker -> Utility.applyOptionalTimeout(this.azureFileStorageClient.directorys() + marker -> StorageImplUtils.applyOptionalTimeout(this.azureFileStorageClient.directorys() .listFilesAndDirectoriesSegmentWithRestResponseAsync(shareName, directoryPath, prefix, snapshot, marker, maxResultsPerPage, null, context), timeout) .map(response -> new PagedResponseBase<>(response.getRequest(), @@ -558,7 +558,7 @@ public PagedFlux listHandles(Integer maxResultPerPage, boolean recur PagedFlux listHandlesWithOptionalTimeout(Integer maxResultPerPage, boolean recursive, Duration timeout, Context context) { Function>> retriever = - marker -> Utility.applyOptionalTimeout(this.azureFileStorageClient.directorys() + marker -> StorageImplUtils.applyOptionalTimeout(this.azureFileStorageClient.directorys() .listHandlesWithRestResponseAsync(shareName, directoryPath, marker, maxResultPerPage, null, snapshot, recursive, context), timeout) .map(response -> new PagedResponseBase<>(response.getRequest(), @@ -650,7 +650,7 @@ public Mono forceCloseAllHandles(boolean recursive) { PagedFlux forceCloseAllHandlesWithTimeout(boolean recursive, Duration timeout, Context context) { Function>> retriever = - marker -> Utility.applyOptionalTimeout(this.azureFileStorageClient.directorys() + marker -> StorageImplUtils.applyOptionalTimeout(this.azureFileStorageClient.directorys() .forceCloseHandlesWithRestResponseAsync(shareName, directoryPath, "*", null, marker, snapshot, recursive, context), timeout) .map(response -> new PagedResponseBase<>(response.getRequest(), @@ -1024,7 +1024,7 @@ private void validateFilePermissionAndKey(String filePermission, String filePer } if (filePermission != null) { - Utility.assertInBounds("filePermission", + StorageImplUtils.assertInBounds("filePermission", filePermission.getBytes(StandardCharsets.UTF_8).length, 0, 8 * Constants.KB); } } diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/DirectoryClient.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/DirectoryClient.java index 66b5b265ab26c..54a4b8425013c 100644 --- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/DirectoryClient.java +++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/DirectoryClient.java @@ -8,8 +8,8 @@ import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.models.DirectoryInfo; import com.azure.storage.file.models.DirectoryProperties; import com.azure.storage.file.models.DirectorySetMetadataInfo; @@ -143,7 +143,7 @@ public Response createWithResponse(FileSmbProperties smbPropertie Map metadata, Duration timeout, Context context) { Mono> response = directoryAsyncClient .createWithResponse(smbProperties, filePermission, metadata, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -185,7 +185,7 @@ public void delete() { */ public Response deleteWithResponse(Duration timeout, Context context) { Mono> response = directoryAsyncClient.deleteWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -228,7 +228,7 @@ public DirectoryProperties getProperties() { */ public Response getPropertiesWithResponse(Duration timeout, Context context) { Mono> response = directoryAsyncClient.getPropertiesWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -274,7 +274,7 @@ public Response setPropertiesWithResponse(FileSmbProperties smbPr Duration timeout, Context context) { Mono> response = directoryAsyncClient .setPropertiesWithResponse(smbProperties, filePermission, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -334,7 +334,7 @@ public Response setMetadataWithResponse(Map> response = directoryAsyncClient .setMetadataWithResponse(metadata, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -453,7 +453,7 @@ public void forceCloseHandle(String handleId) { * @return A response that only contains headers and response status code. */ public Response forceCloseHandleWithResponse(String handleId, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(directoryAsyncClient + return StorageImplUtils.blockWithOptionalTimeout(directoryAsyncClient .forceCloseHandleWithResponse(handleId, context), timeout); } @@ -581,7 +581,7 @@ public void deleteSubDirectory(String subDirectoryName) { */ public Response deleteSubDirectoryWithResponse(String subDirectoryName, Duration timeout, Context context) { Mono> response = directoryAsyncClient.deleteSubDirectoryWithResponse(subDirectoryName, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -685,7 +685,7 @@ public void deleteFile(String fileName) { */ public Response deleteFileWithResponse(String fileName, Duration timeout, Context context) { Mono> response = directoryAsyncClient.deleteFileWithResponse(fileName, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileAsyncClient.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileAsyncClient.java index a0259fd6f24d8..74831e5b3935a 100644 --- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileAsyncClient.java +++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileAsyncClient.java @@ -13,9 +13,9 @@ import com.azure.core.implementation.util.FluxUtil; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.implementation.AzureFileStorageImpl; import com.azure.storage.file.implementation.models.FileGetPropertiesHeaders; import com.azure.storage.file.implementation.models.FileRangeWriteType; @@ -1046,7 +1046,7 @@ public PagedFlux listRanges(FileRange range) { PagedFlux listRangesWithOptionalTimeout(FileRange range, Duration timeout, Context context) { String rangeString = range == null ? null : range.toString(); Function>> retriever = - marker -> Utility.applyOptionalTimeout(this.azureFileStorageClient.files() + marker -> StorageImplUtils.applyOptionalTimeout(this.azureFileStorageClient.files() .getRangeListWithRestResponseAsync(shareName, filePath, snapshot, null, rangeString, context), timeout) .map(response -> new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), @@ -1105,7 +1105,7 @@ public PagedFlux listHandles(Integer maxResultsPerPage) { PagedFlux listHandlesWithOptionalTimeout(Integer maxResultsPerPage, Duration timeout, Context context) { Function>> retriever = - marker -> Utility.applyOptionalTimeout(this.azureFileStorageClient.files() + marker -> StorageImplUtils.applyOptionalTimeout(this.azureFileStorageClient.files() .listHandlesWithRestResponseAsync(shareName, filePath, marker, maxResultsPerPage, null, snapshot, context), timeout) .map(response -> new PagedResponseBase<>(response.getRequest(), @@ -1195,7 +1195,7 @@ public Mono forceCloseAllHandles() { PagedFlux forceCloseAllHandlesWithOptionalTimeout(Duration timeout, Context context) { Function>> retriever = - marker -> Utility.applyOptionalTimeout(this.azureFileStorageClient.files() + marker -> StorageImplUtils.applyOptionalTimeout(this.azureFileStorageClient.files() .forceCloseHandlesWithRestResponseAsync(shareName, filePath, "*", null, marker, snapshot, context), timeout) .map(response -> new PagedResponseBase<>(response.getRequest(), @@ -1365,7 +1365,7 @@ private void validateFilePermissionAndKey(String filePermission, String filePer } if (filePermission != null) { - Utility.assertInBounds("filePermission", + StorageImplUtils.assertInBounds("filePermission", filePermission.getBytes(StandardCharsets.UTF_8).length, 0, 8 * Constants.KB); } } diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileClient.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileClient.java index 96109220dc4ce..76d32fc770bcd 100644 --- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileClient.java +++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileClient.java @@ -10,8 +10,9 @@ import com.azure.core.implementation.util.FluxUtil; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.models.FileCopyInfo; import com.azure.storage.file.models.FileHttpHeaders; import com.azure.storage.file.models.FileInfo; @@ -179,7 +180,7 @@ public Response createWithResponse(long maxSize, FileHttpHeaders httpH Context context) { Mono> response = fileAsyncClient .createWithResponse(maxSize, httpHeaders, smbProperties, filePermission, metadata, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -229,7 +230,7 @@ public FileCopyInfo startCopy(String sourceUrl, Map metadata) { public Response startCopyWithResponse(String sourceUrl, Map metadata, Duration timeout, Context context) { Mono> response = fileAsyncClient.startCopyWithResponse(sourceUrl, metadata, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -271,7 +272,7 @@ public void abortCopy(String copyId) { */ public Response abortCopyWithResponse(String copyId, Duration timeout, Context context) { Mono> response = fileAsyncClient.abortCopyWithResponse(copyId, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -322,7 +323,7 @@ public Response downloadToFileWithResponse(String downloadFilePa Duration timeout, Context context) { Mono> response = fileAsyncClient.downloadToFileWithResponse(downloadFilePath, range, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -381,7 +382,7 @@ public Response downloadWithResponse(OutputStream stream, FileRange range, } }).thenReturn(new SimpleResponse<>(response, null))); - return Utility.blockWithOptionalTimeout(download, timeout); + return StorageImplUtils.blockWithOptionalTimeout(download, timeout); } /** @@ -424,7 +425,7 @@ public void delete() { */ public Response deleteWithResponse(Duration timeout, Context context) { Mono> response = fileAsyncClient.deleteWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -467,7 +468,7 @@ public FileProperties getProperties() { */ public Response getPropertiesWithResponse(Duration timeout, Context context) { Mono> response = fileAsyncClient.getPropertiesWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -534,7 +535,7 @@ public Response setPropertiesWithResponse(long newFileSize, FileHttpHe FileSmbProperties smbProperties, String filePermission, Duration timeout, Context context) { Mono> response = fileAsyncClient .setPropertiesWithResponse(newFileSize, httpHeaders, smbProperties, filePermission, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -592,7 +593,7 @@ public FileMetadataInfo setMetadata(Map metadata) { public Response setMetadataWithResponse(Map metadata, Duration timeout, Context context) { Mono> response = fileAsyncClient.setMetadataWithResponse(metadata, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -645,7 +646,7 @@ public FileUploadInfo upload(InputStream data, long length) { */ public Response uploadWithResponse(InputStream data, long length, Long offset, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(fileAsyncClient.uploadWithResponse(Utility + return StorageImplUtils.blockWithOptionalTimeout(fileAsyncClient.uploadWithResponse(Utility .convertStreamToByteBuffer(data, length, (int) FileAsyncClient.FILE_DEFAULT_BLOCK_SIZE), length, offset, context), timeout); } @@ -703,7 +704,7 @@ public Response uploadRangeFromUrlWithResponse(long long sourceOffset, String sourceUrl, Duration timeout, Context context) { Mono> response = fileAsyncClient.uploadRangeFromUrlWithResponse(length, destinationOffset, sourceOffset, sourceUrl, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -750,7 +751,7 @@ public FileUploadInfo clearRange(long length) { public Response clearRangeWithResponse(long length, long offset, Duration timeout, Context context) { Mono> response = fileAsyncClient.clearRangeWithResponse(length, offset, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -892,7 +893,7 @@ public void forceCloseHandle(String handleId) { * @return A response that only contains headers and response status code. */ public Response forceCloseHandleWithResponse(String handleId, Duration timeout, Context context) { - return Utility.blockWithOptionalTimeout(fileAsyncClient + return StorageImplUtils.blockWithOptionalTimeout(fileAsyncClient .forceCloseHandleWithResponse(handleId, context), timeout); } diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileClientBuilder.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileClientBuilder.java index 943b5d0621fa9..78f3bff267978 100644 --- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileClientBuilder.java +++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileClientBuilder.java @@ -11,8 +11,8 @@ import com.azure.core.implementation.util.ImplUtils; import com.azure.core.util.Configuration; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.common.implementation.connectionstring.StorageAuthenticationSettings; import com.azure.storage.common.implementation.connectionstring.StorageConnectionString; import com.azure.storage.common.implementation.connectionstring.StorageEndpoint; @@ -231,7 +231,6 @@ public FileClientBuilder endpoint(String endpoint) { try { URL fullUrl = new URL(endpoint); this.endpoint = fullUrl.getProtocol() + "://" + fullUrl.getHost(); - this.accountName = BuilderHelper.getAccountName(fullUrl); // Attempt to get the share name and file path from the URL passed @@ -243,7 +242,7 @@ public FileClientBuilder endpoint(String endpoint) { // Attempt to get the SAS token from the URL passed String sasToken = new FileServiceSasQueryParameters( - Utility.parseQueryStringSplitValues(fullUrl.getQuery()), false).encode(); + StorageImplUtils.parseQueryStringSplitValues(fullUrl.getQuery()), false).encode(); if (!ImplUtils.isNullOrEmpty(sasToken)) { sasToken(sasToken); } diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceAsyncClient.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceAsyncClient.java index 83d2d6dfc4d39..40756dd2a6e64 100644 --- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceAsyncClient.java +++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceAsyncClient.java @@ -13,8 +13,8 @@ import com.azure.core.implementation.util.ImplUtils; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.implementation.AzureFileStorageImpl; import com.azure.storage.file.implementation.models.DeleteSnapshotsOptionType; import com.azure.storage.file.implementation.models.ListSharesIncludeType; @@ -202,7 +202,7 @@ PagedFlux listSharesWithOptionalTimeout(String marker, ListSharesOpti } Function>> retriever = - nextMarker -> Utility.applyOptionalTimeout(this.azureFileStorageClient.services() + nextMarker -> StorageImplUtils.applyOptionalTimeout(this.azureFileStorageClient.services() .listSharesSegmentWithRestResponseAsync( prefix, nextMarker, maxResultsPerPage, include, null, context), timeout) .map(response -> new PagedResponseBase<>(response.getRequest(), diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceClient.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceClient.java index 08683cbffb668..197135b9aa8d2 100644 --- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceClient.java +++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceClient.java @@ -8,8 +8,8 @@ import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.models.FileCorsRule; import com.azure.storage.file.models.FileServiceProperties; import com.azure.storage.file.models.ListSharesOptions; @@ -180,7 +180,7 @@ public FileServiceProperties getProperties() { */ public Response getPropertiesWithResponse(Duration timeout, Context context) { Mono> response = fileServiceAsyncClient.getPropertiesWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -267,7 +267,7 @@ public void setProperties(FileServiceProperties properties) { public Response setPropertiesWithResponse(FileServiceProperties properties, Duration timeout, Context context) { Mono> response = fileServiceAsyncClient.setPropertiesWithResponse(properties, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -365,7 +365,7 @@ public void deleteShare(String shareName) { public Response deleteShareWithResponse(String shareName, String snapshot, Duration timeout, Context context) { Mono> response = fileServiceAsyncClient.deleteShareWithResponse(shareName, snapshot, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceClientBuilder.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceClientBuilder.java index 31f792ee316ca..cd36635a97d7b 100644 --- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceClientBuilder.java +++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceClientBuilder.java @@ -11,8 +11,8 @@ import com.azure.core.implementation.util.ImplUtils; import com.azure.core.util.Configuration; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.common.implementation.connectionstring.StorageAuthenticationSettings; import com.azure.storage.common.implementation.connectionstring.StorageConnectionString; import com.azure.storage.common.implementation.connectionstring.StorageEndpoint; @@ -163,12 +163,11 @@ public FileServiceClientBuilder endpoint(String endpoint) { try { URL fullUrl = new URL(endpoint); this.endpoint = fullUrl.getProtocol() + "://" + fullUrl.getHost(); - this.accountName = BuilderHelper.getAccountName(fullUrl); // Attempt to get the SAS token from the URL passed String sasToken = new FileServiceSasQueryParameters( - Utility.parseQueryStringSplitValues(fullUrl.getQuery()), false).encode(); + StorageImplUtils.parseQueryStringSplitValues(fullUrl.getQuery()), false).encode(); if (!ImplUtils.isNullOrEmpty(sasToken)) { this.sasToken(sasToken); } diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceSasSignatureValues.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceSasSignatureValues.java index cbc80f24c8967..d1f48da91d8c2 100644 --- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceSasSignatureValues.java +++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/FileServiceSasSignatureValues.java @@ -4,10 +4,11 @@ package com.azure.storage.file; import com.azure.core.implementation.util.ImplUtils; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.Utility; -import com.azure.storage.common.sas.SasIpRange; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.common.sas.SasProtocol; +import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.sas.SasIpRange; +import com.azure.storage.common.StorageSharedKeyCredential; import java.time.OffsetDateTime; @@ -169,7 +170,7 @@ public String getPermissions() { * @return the updated FileServiceSasSignatureValues object. */ public FileServiceSasSignatureValues setPermissions(ShareSasPermission permissions) { - Utility.assertNotNull("permissions", permissions); + StorageImplUtils.assertNotNull("permissions", permissions); this.permissions = permissions.toString(); return this; } @@ -182,7 +183,7 @@ public FileServiceSasSignatureValues setPermissions(ShareSasPermission permissio * @return the updated FileServiceSasSignatureValues object */ public FileServiceSasSignatureValues setPermissions(FileSasPermission permissions) { - Utility.assertNotNull("permissions", permissions); + StorageImplUtils.assertNotNull("permissions", permissions); this.permissions = permissions.toString(); return this; } @@ -392,7 +393,7 @@ public FileServiceSasSignatureValues setContentType(String contentType) { */ public FileServiceSasQueryParameters generateSasQueryParameters( StorageSharedKeyCredential storageSharedKeyCredentials) { - Utility.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); + StorageImplUtils.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); final String resource; if (ImplUtils.isNullOrEmpty(filePath)) { @@ -445,8 +446,8 @@ private static String getCanonicalName(String account, String shareName, String private String stringToSign(String canonicalName) { return String.join("\n", this.permissions == null ? "" : this.permissions, - this.startTime == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - this.expiryTime == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), + this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), + this.expiryTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), canonicalName, this.identifier == null ? "" : this.identifier, this.sasIpRange == null ? "" : this.sasIpRange.toString(), diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/ShareClient.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/ShareClient.java index 47f1c4a0f8bc5..5b225329002c2 100644 --- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/ShareClient.java +++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/ShareClient.java @@ -8,8 +8,8 @@ import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.models.FileHttpHeaders; import com.azure.storage.file.models.FileSignedIdentifier; import com.azure.storage.file.models.FileStorageException; @@ -151,7 +151,7 @@ public ShareInfo create() { public Response createWithResponse(Map metadata, Integer quotaInGB, Duration timeout, Context context) { Mono> response = client.createWithResponse(metadata, quotaInGB, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -200,7 +200,7 @@ public ShareSnapshotInfo createSnapshot() { public Response createSnapshotWithResponse(Map metadata, Duration timeout, Context context) { Mono> response = client.createSnapshotWithResponse(metadata, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -242,7 +242,7 @@ public void delete() { */ public Response deleteWithResponse(Duration timeout, Context context) { Mono> response = client.deleteWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -287,7 +287,7 @@ public ShareProperties getProperties() { */ public Response getPropertiesWithResponse(Duration timeout, Context context) { Mono> response = client.getPropertiesWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -332,7 +332,7 @@ public ShareInfo setQuota(int quotaInGB) { */ public Response setQuotaWithResponse(int quotaInGB, Duration timeout, Context context) { Mono> response = client.setQuotaWithResponse(quotaInGB, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -386,7 +386,7 @@ public ShareInfo setMetadata(Map metadata) { public Response setMetadataWithResponse(Map metadata, Duration timeout, Context context) { Mono> response = client.setMetadataWithResponse(metadata, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -454,7 +454,7 @@ public ShareInfo setAccessPolicy(List permissions) { public Response setAccessPolicyWithResponse(List permissions, Duration timeout, Context context) { Mono> response = client.setAccessPolicyWithResponse(permissions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -495,7 +495,7 @@ public ShareStatistics getStatistics() { */ public Response getStatisticsWithResponse(Duration timeout, Context context) { Mono> response = client.getStatisticsWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -667,7 +667,7 @@ public void deleteDirectory(String directoryName) { */ public Response deleteDirectoryWithResponse(String directoryName, Duration timeout, Context context) { Mono> response = client.deleteDirectoryWithResponse(directoryName, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -711,7 +711,7 @@ public void deleteFile(String fileName) { */ public Response deleteFileWithResponse(String fileName, Duration timeout, Context context) { Mono> response = client.deleteFileWithResponse(fileName, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/ShareClientBuilder.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/ShareClientBuilder.java index 9f52fa6c59989..69f0e5b157cbc 100644 --- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/ShareClientBuilder.java +++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/file/ShareClientBuilder.java @@ -11,8 +11,8 @@ import com.azure.core.implementation.util.ImplUtils; import com.azure.core.util.Configuration; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.common.implementation.connectionstring.StorageAuthenticationSettings; import com.azure.storage.common.implementation.connectionstring.StorageConnectionString; import com.azure.storage.common.implementation.connectionstring.StorageEndpoint; @@ -176,6 +176,7 @@ public ShareClientBuilder endpoint(String endpoint) { this.accountName = BuilderHelper.getAccountName(fullUrl); + // Attempt to get the share name from the URL passed String[] pathSegments = fullUrl.getPath().split("/"); int length = pathSegments.length; @@ -187,7 +188,7 @@ public ShareClientBuilder endpoint(String endpoint) { // Attempt to get the SAS token from the URL passed String sasToken = new FileServiceSasQueryParameters( - Utility.parseQueryStringSplitValues(fullUrl.getQuery()), false).encode(); + StorageImplUtils.parseQueryStringSplitValues(fullUrl.getQuery()), false).encode(); if (!ImplUtils.isNullOrEmpty(sasToken)) { this.sasToken(sasToken); } diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/BuilderHelper.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/BuilderHelper.java index d9156d4e0ac13..3a0b1147db75a 100644 --- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/BuilderHelper.java +++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/BuilderHelper.java @@ -16,8 +16,8 @@ import com.azure.core.implementation.util.ImplUtils; import com.azure.core.util.Configuration; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.common.policy.RequestRetryOptions; import com.azure.storage.common.policy.RequestRetryPolicy; import com.azure.storage.common.policy.ResponseValidationPolicyBuilder; @@ -94,7 +94,7 @@ static QueueUrlParts parseEndpoint(String endpoint, ClientLogger logger) { // Attempt to get the SAS token from the URL passed String sasToken = new QueueServiceSasQueryParameters( - Utility.parseQueryStringSplitValues(url.getQuery()), false).encode(); + StorageImplUtils.parseQueryStringSplitValues(url.getQuery()), false).encode(); if (!ImplUtils.isNullOrEmpty(sasToken)) { parts.setQueueName(sasToken); } diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java index 95db814d1cf9e..9110cd9b93c5e 100644 --- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java +++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java @@ -12,8 +12,8 @@ import com.azure.core.implementation.util.FluxUtil; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.queue.implementation.AzureQueueStorageImpl; import com.azure.storage.queue.implementation.models.MessageIdUpdateHeaders; import com.azure.storage.queue.implementation.models.MessageIdsUpdateResponse; @@ -653,7 +653,7 @@ PagedFlux receiveMessagesWithOptionalTimeout(Integer maxMessag Duration timeout, Context context) { Integer visibilityTimeoutInSeconds = (visibilityTimeout == null) ? null : (int) visibilityTimeout.getSeconds(); Function>> retriever = - marker -> Utility.applyOptionalTimeout(this.client.messages() + marker -> StorageImplUtils.applyOptionalTimeout(this.client.messages() .dequeueWithRestResponseAsync(queueName, maxMessages, visibilityTimeoutInSeconds, null, null, context), timeout) .map(response -> new PagedResponseBase<>(response.getRequest(), @@ -724,7 +724,7 @@ public PagedFlux peekMessages(Integer maxMessages) { PagedFlux peekMessagesWithOptionalTimeout(Integer maxMessages, Duration timeout, Context context) { Function>> retriever = - marker -> Utility.applyOptionalTimeout(this.client.messages() + marker -> StorageImplUtils.applyOptionalTimeout(this.client.messages() .peekWithRestResponseAsync(queueName, maxMessages, null, null, context), timeout) .map(response -> new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClient.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClient.java index 8e8a44097ab73..d513e812f548d 100644 --- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClient.java +++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClient.java @@ -6,8 +6,8 @@ import com.azure.core.http.rest.PagedIterable; import com.azure.core.http.rest.Response; import com.azure.core.util.Context; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.queue.models.PeekedMessageItem; import com.azure.storage.queue.models.QueueMessageItem; import com.azure.storage.queue.models.QueueProperties; @@ -106,7 +106,7 @@ public void create() { */ public Response createWithResponse(Map metadata, Duration timeout, Context context) { Mono> response = client.createWithResponse(metadata, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -148,7 +148,7 @@ public void delete() { */ public Response deleteWithResponse(Duration timeout, Context context) { Mono> response = client.deleteWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -193,7 +193,7 @@ public QueueProperties getProperties() { */ public Response getPropertiesWithResponse(Duration timeout, Context context) { Mono> response = client.getPropertiesWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -249,7 +249,7 @@ public void setMetadata(Map metadata) { */ public Response setMetadataWithResponse(Map metadata, Duration timeout, Context context) { Mono> response = client.setMetadataWithResponse(metadata, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -315,7 +315,7 @@ public void setAccessPolicy(List permissions) { public Response setAccessPolicyWithResponse(List permissions, Duration timeout, Context context) { Mono> response = client.setAccessPolicyWithResponse(permissions, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -357,7 +357,7 @@ public void clearMessages() { */ public Response clearMessagesWithResponse(Duration timeout, Context context) { Mono> response = client.clearMessagesWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -419,7 +419,7 @@ public Response sendMessageWithResponse(String messageText, D Duration timeToLive, Duration timeout, Context context) { Mono> response = client.sendMessageWithResponse(messageText, visibilityTimeout, timeToLive, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -616,7 +616,7 @@ public Response updateMessageWithResponse(String messageId, String messageText, Duration visibilityTimeout, Duration timeout, Context context) { Mono> response = client.updateMessageWithResponse(messageId, popReceipt, messageText, visibilityTimeout, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -665,7 +665,7 @@ public void deleteMessage(String messageId, String popReceipt) { public Response deleteMessageWithResponse(String messageId, String popReceipt, Duration timeout, Context context) { Mono> response = client.deleteMessageWithResponse(messageId, popReceipt, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClientBuilder.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClientBuilder.java index ebd69f24b87c3..08cb21908ead6 100644 --- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClientBuilder.java +++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClientBuilder.java @@ -13,7 +13,7 @@ import com.azure.core.util.Configuration; import com.azure.core.util.logging.ClientLogger; import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.common.implementation.connectionstring.StorageAuthenticationSettings; import com.azure.storage.common.implementation.connectionstring.StorageConnectionString; import com.azure.storage.common.implementation.connectionstring.StorageEndpoint; @@ -134,7 +134,7 @@ public QueueClient buildClient() { * or {@link #sasToken(String) SAS token} has been set. */ public QueueAsyncClient buildAsyncClient() { - Utility.assertNotNull("queueName", queueName); + StorageImplUtils.assertNotNull("queueName", queueName); QueueServiceVersion serviceVersion = version != null ? version : QueueServiceVersion.getLatest(); HttpPipeline pipeline = (httpPipeline != null) ? httpPipeline : BuilderHelper.buildPipeline(() -> { diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java index 6caa404b578a5..064620f010d62 100644 --- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java +++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java @@ -11,8 +11,8 @@ import com.azure.core.implementation.util.FluxUtil; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.queue.implementation.AzureQueueStorageImpl; import com.azure.storage.queue.implementation.models.ListQueuesIncludeType; import com.azure.storage.queue.models.QueueCorsRule; @@ -270,7 +270,7 @@ PagedFlux listQueuesWithOptionalTimeout(String marker, QueuesSegmentO } Function>> retriever = - nextMarker -> Utility.applyOptionalTimeout(this.client.services() + nextMarker -> StorageImplUtils.applyOptionalTimeout(this.client.services() .listQueuesSegmentWithRestResponseAsync(prefix, nextMarker, maxResultsPerPage, include, null, null, context), timeout) .map(response -> new PagedResponseBase<>(response.getRequest(), diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClient.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClient.java index f305a781321dd..79c2e09d28262 100644 --- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClient.java +++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClient.java @@ -7,8 +7,8 @@ import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; -import com.azure.storage.common.Utility; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.queue.models.QueueCorsRule; import com.azure.storage.queue.models.QueueItem; import com.azure.storage.queue.models.QueueServiceProperties; @@ -116,7 +116,7 @@ public Response createQueueWithResponse(String queueName, Map> asyncResponse = client.createQueueWithResponse(queueName, metadata, context); - Response response = Utility.blockWithOptionalTimeout(asyncResponse, timeout); + Response response = StorageImplUtils.blockWithOptionalTimeout(asyncResponse, timeout); return new SimpleResponse<>(response, new QueueClient(response.getValue())); } @@ -155,7 +155,7 @@ public void deleteQueue(String queueName) { */ public Response deleteQueueWithResponse(String queueName, Duration timeout, Context context) { Mono> response = client.deleteQueueWithResponse(queueName, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -263,7 +263,7 @@ public QueueServiceProperties getProperties() { */ public Response getPropertiesWithResponse(Duration timeout, Context context) { Mono> response = client.getPropertiesWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -351,7 +351,7 @@ public void setProperties(QueueServiceProperties properties) { public Response setPropertiesWithResponse(QueueServiceProperties properties, Duration timeout, Context context) { Mono> response = client.setPropertiesWithResponse(properties, context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } /** @@ -392,7 +392,7 @@ public QueueServiceStatistics getStatistics() { */ public Response getStatisticsWithResponse(Duration timeout, Context context) { Mono> response = client.getStatisticsWithResponse(context); - return Utility.blockWithOptionalTimeout(response, timeout); + return StorageImplUtils.blockWithOptionalTimeout(response, timeout); } diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java index 49479b7639327..51b9b8271e9a4 100644 --- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java +++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java @@ -169,7 +169,6 @@ public QueueServiceClientBuilder endpoint(String endpoint) { BuilderHelper.QueueUrlParts parts = BuilderHelper.parseEndpoint(endpoint, logger); this.endpoint = parts.getEndpoint(); this.accountName = parts.getAccountName(); - if (!ImplUtils.isNullOrEmpty(parts.getSasToken())) { sasToken(parts.getSasToken()); } diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceSasSignatureValues.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceSasSignatureValues.java index 70713c71b0f74..67256676400d0 100644 --- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceSasSignatureValues.java +++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceSasSignatureValues.java @@ -3,11 +3,12 @@ package com.azure.storage.queue; +import com.azure.storage.common.implementation.StorageImplUtils; +import com.azure.storage.common.sas.SasProtocol; +import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.sas.SasIpRange; import com.azure.core.implementation.util.ImplUtils; import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.Utility; -import com.azure.storage.common.sas.SasIpRange; -import com.azure.storage.common.sas.SasProtocol; import java.time.OffsetDateTime; @@ -148,7 +149,7 @@ public String getPermissions() { * @throws NullPointerException if {@code permissions} is null. */ public QueueServiceSasSignatureValues setPermissions(QueueSasPermission permissions) { - Utility.assertNotNull("permissions", permissions); + StorageImplUtils.assertNotNull("permissions", permissions); this.permissions = permissions.toString(); return this; } @@ -238,7 +239,7 @@ public QueueServiceSasSignatureValues setIdentifier(String identifier) { */ public QueueServiceSasQueryParameters generateSasQueryParameters( StorageSharedKeyCredential storageSharedKeyCredentials) { - Utility.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); + StorageImplUtils.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); if (ImplUtils.isNullOrEmpty(version)) { version = QueueServiceVersion.getLatest().getVersion(); @@ -267,8 +268,8 @@ private static String getCanonicalName(String account, String queueName) { private String stringToSign(String canonicalName) { return String.join("\n", this.permissions == null ? "" : this.permissions, - this.startTime == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), - this.expiryTime == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), + this.startTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.startTime), + this.expiryTime == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(this.expiryTime), canonicalName, this.identifier == null ? "" : this.identifier, this.sasIpRange == null ? "" : this.sasIpRange.toString(),