From db7ebe0fd7c737522666399214afe40c2df9a574 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Fri, 11 Jun 2021 15:06:46 -0700 Subject: [PATCH 01/13] deprecate BlobSasServiceVersion. Make version not settable. --- .../implementation/util/BlobSasImplUtil.java | 8 +-- .../blob/sas/BlobSasServiceVersion.java | 2 + .../sas/BlobServiceSasSignatureValues.java | 6 +- .../blob/BlobServiceSasModelsTest.groovy | 1 - .../azure/storage/blob/SasClientTests.groovy | 13 ++--- .../blob/specialized/HelperTest.groovy | 6 +- .../common/sas/AccountSasSignatureValues.java | 11 ++-- .../DataLakeServiceSasSignatureValues.java | 4 +- .../storage/file/datalake/SASTest.groovy | 57 +++++++++---------- .../sas/ShareServiceSasSignatureValues.java | 11 ++-- .../sas/QueueServiceSasSignatureValues.java | 11 ++-- 11 files changed, 57 insertions(+), 73 deletions(-) diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobSasImplUtil.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobSasImplUtil.java index 50d9797dcfc0d..3c4618912acf1 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobSasImplUtil.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobSasImplUtil.java @@ -10,7 +10,6 @@ import com.azure.storage.blob.sas.BlobContainerSasPermission; import com.azure.storage.blob.sas.BlobSasPermission; import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.blob.sas.BlobSasServiceVersion; import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.Constants; import com.azure.storage.common.implementation.StorageImplUtils; @@ -51,7 +50,7 @@ public class BlobSasImplUtil { private final ClientLogger logger = new ClientLogger(BlobSasImplUtil.class); - private String version; + private final String version = Constants.HeaderConstants.TARGET_STORAGE_VERSION; private SasProtocol protocol; @@ -115,7 +114,6 @@ public BlobSasImplUtil(BlobServiceSasSignatureValues sasValues, String container throw logger.logExceptionAsError( new IllegalArgumentException("'snapshot' and 'versionId' cannot be used at the same time.")); } - this.version = null; /* Setting this to null forces the latest service version - see ensureState. */ this.protocol = sasValues.getProtocol(); this.startTime = sasValues.getStartTime(); this.expiryTime = sasValues.getExpiryTime(); @@ -246,10 +244,6 @@ private String encode(UserDelegationKey userDelegationKey, String signature) { * https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/storage/Azure.Storage.Blobs/src/Sas/BlobSasBuilder.cs */ private void ensureState() { - if (version == null) { - version = BlobSasServiceVersion.getLatest().getVersion(); - } - if (identifier == null) { if (expiryTime == null || permissions == null) { throw logger.logExceptionAsError(new IllegalStateException("If identifier is not set, expiry time " diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasServiceVersion.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasServiceVersion.java index de955f985fed3..6dc5f59fc06d7 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasServiceVersion.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasServiceVersion.java @@ -7,7 +7,9 @@ /** * The versions of Azure Storage Blob Sas supported by this client library. + * @deprecated The version is set to the latest version of sas. */ +@Deprecated public enum BlobSasServiceVersion implements ServiceVersion { V2019_02_02("2019-02-02"), V2019_07_07("2019-07-07"), diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasSignatureValues.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasSignatureValues.java index 7619e7aa27227..f2bb8df04a0bf 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasSignatureValues.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasSignatureValues.java @@ -45,7 +45,7 @@ public final class BlobServiceSasSignatureValues { private final ClientLogger logger = new ClientLogger(BlobServiceSasSignatureValues.class); - private final String version = BlobSasServiceVersion.getLatest().getVersion(); + private final String version = Constants.HeaderConstants.TARGET_STORAGE_VERSION; private SasProtocol protocol; @@ -543,8 +543,6 @@ public BlobServiceSasSignatureValues setCorrelationId(String correlationId) { * *

Notes on SAS generation

*