From e89a3242d95e977db861e0897212bf1039dcdbc9 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Mon, 18 Nov 2019 15:39:48 -0800 Subject: [PATCH 01/17] blob Sas --- .../azure/storage/blob/BlobAsyncClient.java | 33 ++ .../com/azure/storage/blob/BlobClient.java | 31 ++ .../blob/BlobContainerAsyncClient.java | 14 + .../storage/blob/BlobContainerClient.java | 11 + .../storage/blob/BlobServiceAsyncClient.java | 8 + .../azure/storage/blob/BlobServiceClient.java | 7 + .../implementation/util/BlobSasImplUtil.java | 300 ++++++++++++++ .../sas/BlobServiceSasQueryParameters.java | 1 + .../sas/BlobServiceSasSignatureValues.java | 57 ++- .../blob/specialized/BlobAsyncClientBase.java | 35 ++ .../blob/specialized/BlobClientBase.java | 15 + .../com/azure/storage/blob/SASTest.groovy | 2 + .../azure/storage/blob/SasClientTests.groovy | 372 ++++++++++++++++++ .../implementation/AccountSasImplUtil.java | 106 +++++ .../common/implementation/SasImplUtils.java | 55 +++ .../implementation/StorageImplUtils.java | 4 + .../common/sas/AccountSasQueryParameters.java | 1 + .../common/sas/AccountSasSignatureValues.java | 27 ++ .../common/sas/BaseSasQueryParameters.java | 15 +- 19 files changed, 1062 insertions(+), 32 deletions(-) create mode 100644 sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobSasImplUtil.java create mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy create mode 100644 sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/AccountSasImplUtil.java create mode 100644 sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/SasImplUtils.java diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java index 5ac82adbdd23..ff4e32bee6a4 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java @@ -7,6 +7,7 @@ import com.azure.core.http.rest.Response; import com.azure.core.util.FluxUtil; import com.azure.core.util.logging.ClientLogger; +import com.azure.storage.blob.implementation.util.BlobSasImplUtil; import com.azure.storage.blob.implementation.util.ModelHelper; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobHttpHeaders; @@ -16,12 +17,15 @@ import com.azure.storage.blob.models.CpkInfo; import com.azure.storage.blob.models.CustomerProvidedKey; import com.azure.storage.blob.models.ParallelTransferOptions; +import com.azure.storage.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.blob.specialized.AppendBlobAsyncClient; import com.azure.storage.blob.specialized.BlobAsyncClientBase; import com.azure.storage.blob.specialized.BlockBlobAsyncClient; import com.azure.storage.blob.specialized.PageBlobAsyncClient; import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.SasImplUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -551,6 +555,35 @@ public Mono uploadFromFile(String filePath, ParallelTransferOptions parall } } + /** + * Generates a user delegation sas for the blob using the specified + * {@link BlobServiceSasSignatureValues}. + * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * @param userDelegationKey {@link UserDelegationKey} + * + * @return A {@code String} representing all SAS query parameters. + */ + public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, + UserDelegationKey userDelegationKey) { + return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(), getSnapshotId()) + .generateUserDelegationSas(userDelegationKey, getAccountName()); + } + + /** + * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} + * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * + * @return A {@code String} representing all SAS query parameters. + */ + public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { + return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(), getSnapshotId()) + .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline())); + } + boolean uploadInBlocks(String filePath) { AsynchronousFileChannel channel = uploadFileResourceSupplier(filePath); boolean retVal; 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 164746c3827c..96a60a895b5a 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 @@ -5,16 +5,20 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.util.logging.ClientLogger; +import com.azure.storage.blob.implementation.util.BlobSasImplUtil; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobRequestConditions; import com.azure.storage.blob.models.BlobHttpHeaders; import com.azure.storage.blob.models.ParallelTransferOptions; +import com.azure.storage.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.blob.specialized.AppendBlobClient; import com.azure.storage.blob.specialized.BlobClientBase; 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.implementation.Constants; +import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Mono; @@ -175,4 +179,31 @@ public void uploadFromFile(String filePath, ParallelTransferOptions parallelTran throw logger.logExceptionAsError(e); } } + + /** + * Generates a user delegation sas for the blob using the specified + * {@link BlobServiceSasSignatureValues}. + * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * @param userDelegationKey {@link UserDelegationKey} + * + * @return A {@code String} representing all SAS query parameters. + */ + public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, + UserDelegationKey userDelegationKey) { + return this.client.generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); + } + + /** + * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} + * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * + * @return A {@code String} representing all SAS query parameters. + */ + public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { + return this.client.generateSas(blobServiceSasSignatureValues); + } } 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 907d5a4e3d73..c66dbbd9fd85 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 @@ -20,6 +20,7 @@ import com.azure.storage.blob.implementation.models.ContainerGetPropertiesHeaders; import com.azure.storage.blob.implementation.models.ContainersListBlobFlatSegmentResponse; import com.azure.storage.blob.implementation.models.ContainersListBlobHierarchySegmentResponse; +import com.azure.storage.blob.implementation.util.BlobSasImplUtil; import com.azure.storage.blob.models.BlobContainerAccessPolicies; import com.azure.storage.blob.models.BlobContainerProperties; import com.azure.storage.blob.models.BlobItem; @@ -30,7 +31,10 @@ 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.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.common.Utility; +import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Mono; @@ -900,6 +904,16 @@ Mono> getAccountInfoWithResponse(Context context) { }); } + public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, + UserDelegationKey userDelegationKey) { + return new BlobSasImplUtil(blobServiceSasSignatureValues, getBlobContainerName()) + .generateUserDelegationSas(userDelegationKey, getAccountName()); + } + + public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { + return new BlobSasImplUtil(blobServiceSasSignatureValues, getBlobContainerName()) + .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline())); + } private boolean validateNoETag(BlobRequestConditions modifiedRequestConditions) { if (modifiedRequestConditions == null) { 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 6750a52b9605..e231c6e81553 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,6 +17,8 @@ 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.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import reactor.core.publisher.Mono; import java.time.Duration; @@ -552,4 +554,13 @@ public Response getAccountInfoWithResponse(Duration timeout, return blockWithOptionalTimeout(response, timeout); } + + public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, + UserDelegationKey userDelegationKey) { + return this.client.generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); + } + + public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { + return this.client.generateSas(blobServiceSasSignatureValues); + } } 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 d010d3cd24d5..050734edc258 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 @@ -28,8 +28,11 @@ 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.implementation.AccountSasImplUtil; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; +import com.azure.storage.common.sas.AccountSasSignatureValues; import reactor.core.publisher.Mono; import java.time.Duration; @@ -551,4 +554,9 @@ Mono> getAccountInfoWithResponse(Context context) { public String getAccountName() { return this.accountName; } + + public String generateSas(AccountSasSignatureValues accountSasSignatureValues) { + return new AccountSasImplUtil(accountSasSignatureValues) + .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline())); + } } 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 a418caae2769..3e380dda771e 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,10 @@ 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.implementation.AccountSasImplUtil; +import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; +import com.azure.storage.common.sas.AccountSasSignatureValues; import reactor.core.publisher.Mono; import java.time.Duration; @@ -372,4 +375,8 @@ public Response getAccountInfoWithResponse(Duration timeout, public String getAccountName() { return this.blobServiceAsyncClient.getAccountName(); } + + public String generateSas(AccountSasSignatureValues accountSasSignatureValues) { + return this.blobServiceAsyncClient.generateSas(accountSasSignatureValues); + } } 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 new file mode 100644 index 000000000000..b351c6db02d5 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BlobSasImplUtil.java @@ -0,0 +1,300 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.blob.implementation.util; + +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.storage.blob.BlobServiceVersion; +import com.azure.storage.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobContainerSasPermission; +import com.azure.storage.blob.sas.BlobSasPermission; +import com.azure.storage.blob.sas.BlobServiceSasQueryParameters; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; +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 com.azure.storage.common.sas.SasIpRange; +import com.azure.storage.common.sas.SasProtocol; + +import java.time.OffsetDateTime; +import java.util.Map; +import java.util.Objects; + +import static com.azure.storage.common.implementation.SasImplUtils.formatQueryParameterDate; +import static com.azure.storage.common.implementation.SasImplUtils.tryAppendQueryParameter; + +public class BlobSasImplUtil { + /** + * The SAS blob constant. + */ + private static final String SAS_BLOB_CONSTANT = "b"; + + /** + * The SAS blob snapshot constant. + */ + private static final String SAS_BLOB_SNAPSHOT_CONSTANT = "bs"; + + /** + * The SAS blob container constant. + */ + private static final String SAS_CONTAINER_CONSTANT = "c"; + + private final ClientLogger logger = new ClientLogger(BlobServiceSasSignatureValues.class); + + private String version; + + private SasProtocol protocol; + + private OffsetDateTime startTime; + + private OffsetDateTime expiryTime; + + private String permissions; + + private SasIpRange sasIpRange; + + private String containerName; + + private String blobName; + + private String resource; + + private String snapshotId; + + private String identifier; + + private String cacheControl; + + private String contentDisposition; + + private String contentEncoding; + + private String contentLanguage; + + private String contentType; + + /** + * Creates a new {@link BlobSasImplUtil} with the specified parameters + * + * @param sasValues {@link BlobServiceSasSignatureValues} + * @param containerName The container name + */ + public BlobSasImplUtil(BlobServiceSasSignatureValues sasValues, String containerName) { + this(sasValues, containerName, null, null); + } + + /** + * Creates a new {@link BlobSasImplUtil} with the specified parameters + * + * @param sasValues {@link BlobServiceSasSignatureValues} + * @param containerName The container name + * @param blobName The blob name + * @param snapshotId The snapshot id + */ + public BlobSasImplUtil(BlobServiceSasSignatureValues sasValues, String containerName, String blobName, + String snapshotId) { + Objects.requireNonNull(sasValues); + this.version = sasValues.getVersion(); + this.protocol = sasValues.getProtocol(); + this.startTime = sasValues.getStartTime(); + this.expiryTime = sasValues.getExpiryTime(); + this.permissions = sasValues.getPermissions(); + this.sasIpRange = sasValues.getSasIpRange(); + this.containerName = containerName; + this.blobName = blobName; + this.snapshotId = snapshotId; + this.identifier = sasValues.getIdentifier(); + this.cacheControl = sasValues.getCacheControl(); + this.contentDisposition = sasValues.getContentDisposition(); + this.contentEncoding = sasValues.getContentEncoding(); + this.contentLanguage = sasValues.getContentLanguage(); + this.contentType = sasValues.getContentType(); + } + + /** + * Generates a Sas signed with a {@link StorageSharedKeyCredential} + * + * @param storageSharedKeyCredentials {@link StorageSharedKeyCredential} + * @return A String representing the Sas + */ + public String generateSas(StorageSharedKeyCredential storageSharedKeyCredentials) { + StorageImplUtils.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); + + ensureState(); + + // Signature is generated on the un-url-encoded values. + final String canonicalName = getCanonicalName(storageSharedKeyCredentials.getAccountName()); + final String signature = storageSharedKeyCredentials.computeHmac256(stringToSign(canonicalName)); + + return encode(null /* userDelegationKey */, signature); + } + + /** + * Generates a Sas signed with a {@link UserDelegationKey} + * + * @param delegationKey {@link UserDelegationKey} + * @param accountName The account name + * @return A String representing the Sas + */ + public String generateUserDelegationSas(UserDelegationKey delegationKey, String 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 = StorageImplUtils.computeHMac256( + delegationKey.getValue(), stringToSign(delegationKey, canonicalName)); + + return encode(delegationKey, signature); + } + + /** + * Encodes a Sas from the values in this type. + * @param userDelegationKey {@link UserDelegationKey} + * @param signature The signature of the Sas. + * @return A String representing the Sas. + */ + public String encode(UserDelegationKey userDelegationKey, String signature) { + /* + We should be url-encoding each key and each value, but because we know all the keys and values will encode to + themselves, we cheat except for the signature value. + */ + StringBuilder sb = new StringBuilder(); + + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SERVICE_VERSION, this.version); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_PROTOCOL, this.protocol); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_START_TIME, formatQueryParameterDate(this.startTime)); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_EXPIRY_TIME, formatQueryParameterDate(this.expiryTime)); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_IP_RANGE, this.sasIpRange); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_IDENTIFIER, this.identifier); + if (userDelegationKey != null) { + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_OBJECT_ID, + userDelegationKey.getSignedObjectId()); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_TENANT_ID, + userDelegationKey.getSignedTenantId()); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_START, + formatQueryParameterDate(userDelegationKey.getSignedStart())); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_EXPIRY, + formatQueryParameterDate(userDelegationKey.getSignedExpiry())); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_SERVICE, + userDelegationKey.getSignedService()); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_VERSION, + userDelegationKey.getSignedVersion()); + } + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_RESOURCE, this.resource); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_PERMISSIONS, this.permissions); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNATURE, signature); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CACHE_CONTROL, this.cacheControl); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_DISPOSITION, this.contentDisposition); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_ENCODING, this.contentEncoding); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_LANGUAGE, this.contentLanguage); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_TYPE, this.contentType); + + return sb.toString(); + + } + + /** + * Ensures that the builder's properties are in a consistent state. + + * 1. If there is no version, use latest. + * 2. Resource name is chosen by: + * a. If "BlobName" is _not_ set, it is a container resource. + * b. Otherwise, if "SnapshotId" is set, it is a blob snapshot resource. + * c. Otherwise, it is a blob resource. + * 3. Reparse permissions depending on what the resource is. If it is an unrecognised resource, do nothing. + * + * Taken from: + * https://github.com/Azure/azure-storage-blob-go/blob/master/azblob/sas_service.go#L33 + * 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 = BlobServiceVersion.getLatest().getVersion(); + } + + if (CoreUtils.isNullOrEmpty(blobName)) { + resource = SAS_CONTAINER_CONSTANT; + } else if (snapshotId != null) { + resource = SAS_BLOB_SNAPSHOT_CONSTANT; + } else { + resource = SAS_BLOB_CONSTANT; + } + + if (permissions != null) { + switch (resource) { + case SAS_BLOB_CONSTANT: + case SAS_BLOB_SNAPSHOT_CONSTANT: + permissions = BlobSasPermission.parse(permissions).toString(); + break; + case SAS_CONTAINER_CONSTANT: + permissions = BlobContainerSasPermission.parse(permissions).toString(); + break; + default: + // We won't reparse the permissions if we don't know the type. + logger.info("Not re-parsing permissions. Resource type '{}' is unknown.", resource); + break; + } + } + } + + /** + * Computes the canonical name for a container or blob resource for SAS signing. + */ + private String getCanonicalName(String account) { + // Container: "/blob/account/containername" + // Blob: "/blob/account/containername/blobname" + return CoreUtils.isNullOrEmpty(blobName) + ? String.format("/blob/%s/%s", account, containerName) + : String.format("/blob/%s/%s/%s", account, containerName, blobName.replace("\\", "/")); + } + + private String stringToSign(String canonicalName) { + return String.join("\n", + this.permissions == null ? "" : permissions, + 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(), + this.protocol == null ? "" : this.protocol.toString(), + version, + resource, + this.snapshotId == null ? "" : this.snapshotId, + this.cacheControl == null ? "" : this.cacheControl, + this.contentDisposition == null ? "" : this.contentDisposition, + this.contentEncoding == null ? "" : this.contentEncoding, + this.contentLanguage == null ? "" : this.contentLanguage, + this.contentType == null ? "" : this.contentType + ); + } + + private String stringToSign(final UserDelegationKey key, String canonicalName) { + return String.join("\n", + this.permissions == null ? "" : this.permissions, + 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.getSignedObjectId() == null ? "" : key.getSignedObjectId(), + key.getSignedTenantId() == null ? "" : key.getSignedTenantId(), + 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(), + this.protocol == null ? "" : this.protocol.toString(), + version, + resource, + this.snapshotId == null ? "" : this.snapshotId, + this.cacheControl == null ? "" : this.cacheControl, + this.contentDisposition == null ? "" : this.contentDisposition, + this.contentEncoding == null ? "" : this.contentEncoding, + this.contentLanguage == null ? "" : this.contentLanguage, + this.contentType == null ? "" : this.contentType + ); + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java index 69f5e2515213..914e749402fa 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java @@ -241,6 +241,7 @@ UserDelegationKey userDelegationKey() { * * @return A {@code String} representing all SAS query parameters. */ + @Deprecated public String encode() { /* We should be url-encoding each key and each value, but because we know all the keys and values will encode to 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 5f878a5468fa..00ec1c716515 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 @@ -6,6 +6,7 @@ import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; import com.azure.storage.blob.BlobServiceVersion; +import com.azure.storage.blob.implementation.util.BlobSasImplUtil; import com.azure.storage.blob.models.UserDelegationKey; import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.Constants; @@ -15,28 +16,17 @@ 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 - * #generateSasQueryParameters(StorageSharedKeyCredential) generateSasQueryParameters(StorageSharedKeyCredential)} or - * {@link #generateSasQueryParameters(UserDelegationKey, String) generateSasQueryParameters(UserDelegationKey, String)} - * to obtain a representation of the SAS which can be applied to blob urls. - * - *

Generating SAS query parameters with {@link StorageSharedKeyCredential}

- * The following code generates SAS query parameters for an Azure storage blob. - *

- * {@codesnippet com.azure.storage.blob.specialized.BlobServiceSasSignatureValues.generateSasQueryParameters#StorageSharedKeyCredential} + * Used to initialize parameters for a Shared Access Signature (SAS) for an Azure Blob Storage service. Once all the + * values here are set, use the appropriate generate*Sas method on the desired client to obtain a representation of the + * SAS which can then be applied to a new client using the .sasToken method on a client builder. * - *

Generating SAS query parameters with {@link UserDelegationKey}

- * The following sample generates SAS query parameters for an Azure storage container. - *

- * {@codesnippet com.azure.storage.blob.specialized.BlobServiceSasSignatureValues.generateSasQueryParameters#UserDelegationKey-String} - * - * @see BlobServiceSasQueryParameters * @see Storage SAS overview * @see Constructing a Service * SAS */ +// TODO (gapra) : Add code snippets for new workflow public final class BlobServiceSasSignatureValues { /** * The SAS blob constant. @@ -90,6 +80,7 @@ public final class BlobServiceSasSignatureValues { /** * Creates an object with empty values for all fields. */ + @Deprecated public BlobServiceSasSignatureValues() { } @@ -99,17 +90,34 @@ public BlobServiceSasSignatureValues() { * @param expiryTime Time the SAS becomes valid * @param permissions Permissions granted by the SAS */ - BlobServiceSasSignatureValues(OffsetDateTime expiryTime, String permissions) { + public BlobServiceSasSignatureValues(OffsetDateTime expiryTime, BlobContainerSasPermission permissions) { + StorageImplUtils.assertNotNull("expiryTime", expiryTime); + StorageImplUtils.assertNotNull("permissions", permissions); + this.expiryTime = expiryTime; + this.permissions = permissions.toString(); + } + + /** + * Creates an object with the specified expiry time and permissions + * + * @param expiryTime Time the SAS becomes valid + * @param permissions Permissions granted by the SAS + */ + public BlobServiceSasSignatureValues(OffsetDateTime expiryTime, BlobSasPermission permissions) { + StorageImplUtils.assertNotNull("expiryTime", expiryTime); + StorageImplUtils.assertNotNull("permissions", permissions); this.expiryTime = expiryTime; - this.permissions = permissions; + this.permissions = permissions.toString(); } /** - * Creates an object with the specified identifier + * Creates an object with the specified identifier. + * NOTE: Identifier can not be used for a {@link UserDelegationKey} SAS. * * @param identifier Identifier for the SAS */ - BlobServiceSasSignatureValues(String identifier) { + public BlobServiceSasSignatureValues(String identifier) { + StorageImplUtils.assertNotNull("identifier", identifier); this.identifier = identifier; } @@ -130,6 +138,7 @@ public BlobServiceSasSignatureValues() { * @param contentLanguage The content-language header for the SAS. * @param contentType The content-type header for the SAS. */ + @Deprecated public BlobServiceSasSignatureValues(String version, SasProtocol sasProtocol, OffsetDateTime startTime, OffsetDateTime expiryTime, String permission, SasIpRange sasIpRange, String identifier, String cacheControl, String contentDisposition, String contentEncoding, String contentLanguage, String contentType) { @@ -290,6 +299,7 @@ public String getContainerName() { * @param containerName The name of the container. * @return The updated BlobServiceSASSignatureValues object. */ + @Deprecated public BlobServiceSasSignatureValues setContainerName(String containerName) { this.containerName = containerName; return this; @@ -312,6 +322,7 @@ public String getBlobName() { * @param blobName The name of the blob. Use {@code null} or an empty string to create a container SAS. * @return The updated BlobServiceSASSignatureValues object. */ + @Deprecated public BlobServiceSasSignatureValues setBlobName(String blobName) { this.blobName = (blobName == null) ? null : Utility.urlDecode(blobName); return this; @@ -333,6 +344,7 @@ public String getSnapshotId() { * @param snapshotId Identifier of the snapshot * @return the updated BlobServiceSASSignatureValues object */ + @Deprecated public BlobServiceSasSignatureValues setSnapshotId(String snapshotId) { this.snapshotId = snapshotId; if (snapshotId != null && SAS_BLOB_CONSTANT.equals(resource)) { @@ -358,6 +370,7 @@ public String getIdentifier() { * @param identifier Name of the access policy * @return the updated BlobServiceSASSignatureValues object */ + @Deprecated public BlobServiceSasSignatureValues setIdentifier(String identifier) { this.identifier = identifier; return this; @@ -486,6 +499,7 @@ public BlobServiceSasSignatureValues setContentType(String contentType) { * @throws IllegalArgumentException if {@link #getPermissions()} contains an invalid character for the SAS resource. * @throws NullPointerException if {@code storageSharedKeyCredentials} is null. */ + @Deprecated public BlobServiceSasQueryParameters generateSasQueryParameters( StorageSharedKeyCredential storageSharedKeyCredentials) { StorageImplUtils.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); @@ -536,8 +550,9 @@ public BlobServiceSasQueryParameters generateSasQueryParameters( * @see * Create a user delegation SAS */ + @Deprecated public BlobServiceSasQueryParameters generateSasQueryParameters(UserDelegationKey delegationKey, - String accountName) { + String accountName) { StorageImplUtils.assertNotNull("delegationKey", delegationKey); StorageImplUtils.assertNotNull("accountName", accountName); 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 e55fb46907f7..66eae423ab03 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 @@ -15,6 +15,8 @@ import com.azure.core.util.polling.LongRunningOperationStatus; import com.azure.core.util.polling.PollResponse; import com.azure.core.util.polling.PollerFlux; +import com.azure.storage.blob.BlobAsyncClient; +import com.azure.storage.blob.BlobClientBuilder; import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.blob.HttpGetterInfo; import com.azure.storage.blob.ProgressReporter; @@ -23,6 +25,7 @@ import com.azure.storage.blob.implementation.models.BlobGetAccountInfoHeaders; import com.azure.storage.blob.implementation.models.BlobGetPropertiesHeaders; import com.azure.storage.blob.implementation.models.BlobStartCopyFromURLHeaders; +import com.azure.storage.blob.implementation.util.BlobSasImplUtil; import com.azure.storage.blob.implementation.util.ModelHelper; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.ArchiveStatus; @@ -36,13 +39,17 @@ import com.azure.storage.blob.models.BlobStorageException; import com.azure.storage.blob.models.CopyStatusType; import com.azure.storage.blob.models.CpkInfo; +import com.azure.storage.blob.models.CustomerProvidedKey; import com.azure.storage.blob.models.DeleteSnapshotsOptionType; import com.azure.storage.blob.models.DownloadRetryOptions; import com.azure.storage.blob.models.ParallelTransferOptions; import com.azure.storage.blob.models.RehydratePriority; import com.azure.storage.blob.models.StorageAccountInfo; +import com.azure.storage.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -123,6 +130,34 @@ protected BlobAsyncClientBase(HttpPipeline pipeline, String url, BlobServiceVers this.customerProvidedKey = customerProvidedKey; } + public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, + UserDelegationKey userDelegationKey) { + return getBlobAsyncClient().generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); + } + + public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { + return getBlobAsyncClient().generateSas(blobServiceSasSignatureValues); + } + + private BlobAsyncClient getBlobAsyncClient() { + return prepareBuilder().buildAsyncClient(); + } + + BlobClientBuilder prepareBuilder() { + BlobClientBuilder builder = new BlobClientBuilder() + .pipeline(getHttpPipeline()) + .endpoint(getBlobUrl()) + .snapshot(getSnapshotId()) + .serviceVersion(getServiceVersion()); + + CpkInfo cpk = getCustomerProvidedKey(); + if (cpk != null) { + builder.customerProvidedKey(new CustomerProvidedKey(cpk.getEncryptionKey())); + } + + return builder; + } + /** * Creates a new {@link BlobAsyncClientBase} linked to the {@code snapshot} of this blob resource. * 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 f4490492b9ce..e49466f846ae 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 @@ -27,6 +27,8 @@ import com.azure.storage.blob.models.ParallelTransferOptions; import com.azure.storage.blob.models.RehydratePriority; import com.azure.storage.blob.models.StorageAccountInfo; +import com.azure.storage.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.Exceptions; import reactor.core.publisher.Mono; @@ -62,6 +64,19 @@ protected BlobClientBase(BlobAsyncClientBase client) { this.client = client; } + public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, + UserDelegationKey userDelegationKey) { + return getBlobClient().generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); + } + + public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { + return getBlobClient().generateSas(blobServiceSasSignatureValues); + } + + private BlobClient getBlobClient() { + return this.client.prepareBuilder().buildClient(); + } + /** * Creates a new {@link BlobClientBase} linked to the {@code snapshot} of this blob resource. * 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 d63e74b4ffdd..ae32de7b8e30 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 @@ -31,6 +31,8 @@ import java.time.ZoneOffset class SASTest extends APISpec { + // TODO (gapra) : Cleanup SAS Tests + @Unroll def "Blob range"() { expect: diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy new file mode 100644 index 000000000000..b32ab6700954 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy @@ -0,0 +1,372 @@ +package com.azure.storage.blob + +import com.azure.storage.blob.models.BlobAccessPolicy +import com.azure.storage.blob.models.BlobProperties +import com.azure.storage.blob.models.BlobSignedIdentifier +import com.azure.storage.blob.models.BlobStorageException +import com.azure.storage.blob.models.UserDelegationKey +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.specialized.BlockBlobClient +import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder +import com.azure.storage.common.sas.AccountSasPermission +import com.azure.storage.common.sas.AccountSasResourceType +import com.azure.storage.common.sas.AccountSasService +import com.azure.storage.common.sas.AccountSasSignatureValues +import com.azure.storage.common.sas.SasIpRange +import com.azure.storage.common.sas.SasProtocol + +class SasClientTests extends APISpec { + + BlockBlobClient sasClient + String blobName + + def setup() { + blobName = generateBlobName() + sasClient = getBlobClient(primaryCredential, cc.getBlobContainerUrl(), blobName).getBlockBlobClient() + sasClient.upload(new ByteArrayInputStream(defaultData.array()), defaultDataSize) + } + + def "network test blob sas"() { + setup: + def permissions = new BlobSasPermission() + .setReadPermission(true) + .setWritePermission(true) + .setCreatePermission(true) + .setDeletePermission(true) + .setAddPermission(true) + + def sasValues = generateValues(permissions) + + when: + def sas = sasClient.generateSas(sasValues) + + def client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient() + + def os = new ByteArrayOutputStream() + client.download(os) + def properties = client.getProperties() + + then: + os.toString() == new String(defaultData.array()) + validateSasProperties(properties) + notThrown(BlobStorageException) + } + + def "network test blob snapshot"() { + setup: + + def data = "test".getBytes() + def blobName = generateBlobName() + def bu = getBlobClient(primaryCredential, cc.getBlobContainerUrl(), blobName).getBlockBlobClient() + bu.upload(new ByteArrayInputStream(data), data.length) + def snapshotId = bu.createSnapshot().getSnapshotId() + def snapshotBlob = cc.getBlobClient(blobName, snapshotId).getBlockBlobClient() + + def permissions = new BlobSasPermission() + .setReadPermission(true) + .setWritePermission(true) + .setCreatePermission(true) + .setDeletePermission(true) + .setAddPermission(true) + + def sasValues = generateValues(permissions) + + when: + def sas = snapshotBlob.generateSas(sasValues) + + def client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName, snapshotId).getBlockBlobClient() + + def os = new ByteArrayOutputStream() + client.download(os) + def properties = client.getProperties() + + then: + os.toString() == new String(data) + validateSasProperties(properties) + } + + def "serviceSASSignatureValues network test container"() { + setup: + def identifier = new BlobSignedIdentifier() + .setId("0000") + .setAccessPolicy(new BlobAccessPolicy().setPermissions("racwdl") + .setExpiresOn(getUTCNow().plusDays(1))) + cc.setAccessPolicy(null, Arrays.asList(identifier)) + + // Check containerSASPermissions + def permissions = new BlobContainerSasPermission() + .setReadPermission(true) + .setWritePermission(true) + .setListPermission(true) + .setCreatePermission(true) + .setDeletePermission(true) + .setAddPermission(true) + .setListPermission(true) + def expiryTime = getUTCNow().plusDays(1) + + when: + def sasValues = new BlobServiceSasSignatureValues(identifier.getId()) + def sasWithId = cc.generateSas(sasValues) + def client1 = getContainerClient(sasWithId, cc.getBlobContainerUrl()) + client1.listBlobs().iterator().hasNext() + + and: + sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions) + def sasWithPermissions = cc.generateSas(sasValues) + def client2 = getContainerClient(sasWithPermissions, cc.getBlobContainerUrl()) + client2.listBlobs().iterator().hasNext() + + then: + notThrown(BlobStorageException) + } + + def "network test blob user delegation"() { + setup: + def permissions = new BlobSasPermission() + .setReadPermission(true) + .setWritePermission(true) + .setCreatePermission(true) + .setDeletePermission(true) + .setAddPermission(true) + + def sasValues = generateValues(permissions) + + when: + def sas = sasClient.generateUserDelegationSas(sasValues, getUserDelegationInfo()) + + def client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient() + + def os = new ByteArrayOutputStream() + client.download(os) + def properties = client.getProperties() + + then: + os.toString() == new String(defaultData.array()) + validateSasProperties(properties) + notThrown(BlobStorageException) + } + + def "BlobServiceSAS network test blob snapshot"() { + setup: + def snapshotBlob = new SpecializedBlobClientBuilder().blobClient(sasClient.createSnapshot()).buildBlockBlobClient() + def snapshotId = snapshotBlob.getSnapshotId() + def permissions = new BlobSasPermission() + .setReadPermission(true) + .setWritePermission(true) + .setCreatePermission(true) + .setDeletePermission(true) + .setAddPermission(true) + def sasValues = generateValues(permissions) + def sas = snapshotBlob.generateSas(sasValues) + + when: + // base blob with snapshot SAS + def client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getAppendBlobClient() + client.download(new ByteArrayOutputStream()) + + then: + // snapshot-level SAS shouldn't be able to access base blob + thrown(BlobStorageException) + + when: + // blob snapshot with snapshot SAS + def snapClient = getBlobClient(sas, cc.getBlobContainerUrl(), blobName, snapshotId).getAppendBlobClient() + + def os = new ByteArrayOutputStream() + snapClient.download(os) + + def properties = snapClient.getProperties() + + then: + notThrown(BlobStorageException) + os.toByteArray() == defaultData.array() + + then: + validateSasProperties(properties) + } + + def "network test blob snapshot user delegation"() { + setup: + def snapshotBlob = new SpecializedBlobClientBuilder().blobClient(sasClient.createSnapshot()).buildBlockBlobClient() + def snapshotId = snapshotBlob.getSnapshotId() + + def permissions = new BlobSasPermission() + .setReadPermission(true) + .setWritePermission(true) + .setCreatePermission(true) + .setDeletePermission(true) + .setAddPermission(true) + def sasValues = generateValues(permissions) + def sas = snapshotBlob.generateUserDelegationSas(sasValues, getUserDelegationInfo()) + + when: + // base blob with snapshot SAS + def client1 = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient() + client1.download(new ByteArrayOutputStream()) + + then: + // snapshot-level SAS shouldn't be able to access base blob + thrown(BlobStorageException) + + when: + // blob snapshot with snapshot SAS + def client2 = getBlobClient(sas, cc.getBlobContainerUrl(), blobName, snapshotId).getBlockBlobClient() + def os = new ByteArrayOutputStream() + client2.download(os) + + def properties = client2.getProperties() + + then: + notThrown(BlobStorageException) + os.toString() == new String(defaultData.array()) + validateSasProperties(properties) + } + + def "network test container user delegation"() { + setup: + def permissions = new BlobContainerSasPermission() + .setReadPermission(true) + .setWritePermission(true) + .setCreatePermission(true) + .setDeletePermission(true) + .setAddPermission(true) + .setListPermission(true) + def expiryTime = getUTCNow().plusDays(1) + + when: + def sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions) + def sasWithPermissions = cc.generateUserDelegationSas(sasValues, getUserDelegationInfo()) + + def client = getContainerClient(sasWithPermissions, cc.getBlobContainerUrl()) + client.listBlobs().iterator().hasNext() + + then: + notThrown(BlobStorageException) + } + + def "accountSAS network test blob read"() { + setup: + def service = new AccountSasService() + .setBlobAccess(true) + def resourceType = new AccountSasResourceType() + .setContainer(true) + .setService(true) + .setObject(true) + def permissions = new AccountSasPermission() + .setReadPermission(true) + def expiryTime = getUTCNow().plusDays(1) + + when: + def sasValues = new AccountSasSignatureValues(expiryTime, service, resourceType, permissions) + def sas = primaryBlobServiceClient.generateSas(sasValues) + def client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient() + def os = new ByteArrayOutputStream() + client.download(os) + + then: + os.toString() == new String(defaultData.array()) + } + + def "accountSAS network test blob delete fails new API"() { + setup: + def service = new AccountSasService() + .setBlobAccess(true) + def resourceType = new AccountSasResourceType() + .setContainer(true) + .setService(true) + .setObject(true) + def permissions = new AccountSasPermission() + .setReadPermission(true) + def expiryTime = getUTCNow().plusDays(1) + + when: + def sasValues = new AccountSasSignatureValues(expiryTime, service, resourceType, permissions) + def sas = primaryBlobServiceClient.generateSas(sasValues) + def client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient() + client.delete() + + then: + thrown(BlobStorageException) + } + + def "accountSAS network create container fails"() { + setup: + def service = new AccountSasService() + .setBlobAccess(true) + def resourceType = new AccountSasResourceType() + .setContainer(true) + .setService(true) + .setObject(true) + def permissions = new AccountSasPermission() + .setReadPermission(true) + .setCreatePermission(false) + def expiryTime = getUTCNow().plusDays(1) + + when: + def sasValues = new AccountSasSignatureValues(expiryTime, service, resourceType, permissions) + def sas = primaryBlobServiceClient.generateSas(sasValues) + def sc = getServiceClient(sas, primaryBlobServiceClient.getAccountUrl()) + sc.createBlobContainer(generateContainerName()) + + then: + thrown(BlobStorageException) + } + + def "accountSAS network create container succeeds"() { + setup: + def service = new AccountSasService() + .setBlobAccess(true) + def resourceType = new AccountSasResourceType() + .setContainer(true) + .setService(true) + .setObject(true) + def permissions = new AccountSasPermission() + .setReadPermission(true) + .setCreatePermission(true) + def expiryTime = getUTCNow().plusDays(1) + + when: + def sasValues = new AccountSasSignatureValues(expiryTime, service, resourceType, permissions) + def sas = primaryBlobServiceClient.generateSas(sasValues) + def sc = getServiceClient(sas, primaryBlobServiceClient.getAccountUrl()) + sc.createBlobContainer(generateContainerName()) + + then: + notThrown(BlobStorageException) + } + + BlobServiceSasSignatureValues generateValues(BlobSasPermission permission) { + return new BlobServiceSasSignatureValues(getUTCNow().plusDays(1), permission) + .setStartTime(getUTCNow().minusDays(1)) + .setProtocol(SasProtocol.HTTPS_HTTP) + .setSasIpRange(new SasIpRange() + .setIpMin("0.0.0.0") + .setIpMax("255.255.255.255")) + .setCacheControl("cache") + .setContentDisposition("disposition") + .setContentEncoding("encoding") + .setContentLanguage("language") + .setContentType("type") + } + + def validateSasProperties(BlobProperties properties) { + boolean ret = true + ret &= properties.getCacheControl() == "cache" + ret &= properties.getContentDisposition() == "disposition" + ret &= properties.getContentEncoding() == "encoding" + ret &= properties.getContentLanguage() == "language" + return ret + } + + UserDelegationKey getUserDelegationInfo() { + def key = getOAuthServiceClient().getUserDelegationKey(getUTCNow().minusDays(1), getUTCNow().plusDays(1)) + def keyOid = getConfigValue(key.getSignedObjectId()) + key.setSignedObjectId(keyOid) + def keyTid = getConfigValue(key.getSignedTenantId()) + key.setSignedTenantId(keyTid) + return key + } + +} diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/AccountSasImplUtil.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/AccountSasImplUtil.java new file mode 100644 index 000000000000..ed405430de95 --- /dev/null +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/AccountSasImplUtil.java @@ -0,0 +1,106 @@ +package com.azure.storage.common.implementation; + +import com.azure.core.util.CoreUtils; +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.sas.AccountSasPermission; +import com.azure.storage.common.sas.AccountSasSignatureValues; +import com.azure.storage.common.sas.SasIpRange; +import com.azure.storage.common.sas.SasProtocol; + +import java.time.OffsetDateTime; + +import static com.azure.storage.common.implementation.SasImplUtils.formatQueryParameterDate; +import static com.azure.storage.common.implementation.SasImplUtils.tryAppendQueryParameter; + +public class AccountSasImplUtil { + + private String version; + + private SasProtocol protocol; + + private OffsetDateTime startTime; + + private OffsetDateTime expiryTime; + + private String permissions; + + private SasIpRange sasIpRange; + + private String services; + + private String resourceTypes; + + /** + * Creates a new {@link AccountSasImplUtil} with the specified parameters + * + * @param sasValues {@link AccountSasSignatureValues} + */ + public AccountSasImplUtil(AccountSasSignatureValues sasValues) { + this.version = sasValues.getVersion(); + this.protocol = sasValues.getProtocol(); + this.startTime = sasValues.getStartTime(); + this.expiryTime = sasValues.getExpiryTime(); + this.permissions = sasValues.getPermissions(); + this.sasIpRange = sasValues.getSasIpRange(); + this.services = sasValues.getServices(); + this.resourceTypes = sasValues.getResourceTypes(); + } + + /** + * Generates a Sas signed with a {@link StorageSharedKeyCredential} + * + * @param storageSharedKeyCredentials {@link StorageSharedKeyCredential} + * @return A String representing the Sas + */ + public String generateSas(StorageSharedKeyCredential storageSharedKeyCredentials) { + StorageImplUtils.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); + StorageImplUtils.assertNotNull("services", this.services); + StorageImplUtils.assertNotNull("resourceTypes", this.resourceTypes); + StorageImplUtils.assertNotNull("expiryTime", this.expiryTime); + StorageImplUtils.assertNotNull("permissions", this.permissions); + + if (CoreUtils.isNullOrEmpty(version)) { + version = Constants.HeaderConstants.TARGET_STORAGE_VERSION; + } + + // Signature is generated on the un-url-encoded values. + String signature = storageSharedKeyCredentials.computeHmac256(stringToSign(storageSharedKeyCredentials)); + + return encode(signature); + } + + private String stringToSign(final StorageSharedKeyCredential storageSharedKeyCredentials) { + return String.join("\n", + storageSharedKeyCredentials.getAccountName(), + AccountSasPermission.parse(this.permissions).toString(), // guarantees ordering + this.services, + resourceTypes, + 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, + "" // Account SAS requires an additional newline character + ); + } + + private String encode(String signature) { + /* + We should be url-encoding each key and each value, but because we know all the keys and values will encode to + themselves, we cheat except for the signature value. + */ + StringBuilder sb = new StringBuilder(); + + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SERVICE_VERSION, this.version); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SERVICES, this.services); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_RESOURCES_TYPES, this.resourceTypes); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_PROTOCOL, this.protocol); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_START_TIME, formatQueryParameterDate(this.startTime)); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_EXPIRY_TIME, formatQueryParameterDate(this.expiryTime)); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_IP_RANGE, this.sasIpRange); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_PERMISSIONS, this.permissions); + tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNATURE, signature); + + return sb.toString(); + } +} diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/SasImplUtils.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/SasImplUtils.java new file mode 100644 index 000000000000..fc0241ae7527 --- /dev/null +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/SasImplUtils.java @@ -0,0 +1,55 @@ +package com.azure.storage.common.implementation; + +import com.azure.core.http.HttpPipeline; +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.Utility; +import com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy; + +import java.time.OffsetDateTime; + +public class SasImplUtils { + /** + * Extracts the {@link StorageSharedKeyCredential} from a {@link HttpPipeline} + * @param pipeline {@link HttpPipeline} + * @return a {@link StorageSharedKeyCredential} + */ + public static StorageSharedKeyCredential extractSharedKeyCredential(HttpPipeline pipeline) { + for (int i = 0; i < pipeline.getPolicyCount(); i++) { + if (pipeline.getPolicy(i) instanceof StorageSharedKeyCredentialPolicy) { + StorageSharedKeyCredentialPolicy policy = (StorageSharedKeyCredentialPolicy) pipeline.getPolicy(i); + return policy.sharedKeyCredential(); + } + } + return null; + } + + /** + * Shared helper method to append a SAS query parameter. + * + * @param sb The {@code StringBuilder} to append to. + * @param param The {@code String} parameter to append. + * @param value The value of the parameter to append. + */ + public static void tryAppendQueryParameter(StringBuilder sb, String param, Object value) { + if (value != null) { + if (sb.length() != 0) { + sb.append('&'); + } + sb.append(Utility.urlEncode(param)).append('=').append(Utility.urlEncode(value.toString())); + } + } + + /** + * Formats date time SAS query parameters. + * + * @param dateTime The SAS date time. + * @return A String representing the SAS date time. + */ + public static String formatQueryParameterDate(OffsetDateTime dateTime) { + if (dateTime == null) { + return null; + } else { + return Constants.ISO_8601_UTC_DATE_FORMATTER.format(dateTime); + } + } +} 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 index 14b9cb584589..7dbdd994cd6d 100644 --- 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 @@ -3,9 +3,11 @@ package com.azure.storage.common.implementation; +import com.azure.core.http.HttpPipeline; import com.azure.core.util.UrlBuilder; import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; +import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.Utility; import java.net.MalformedURLException; import java.net.URL; @@ -18,6 +20,8 @@ import java.util.Map; import java.util.TreeMap; import java.util.function.Function; + +import com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; 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 37093937b409..080d4cffca4c 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 @@ -81,6 +81,7 @@ public String getResourceTypes() { * * @return A {@code String} representing all SAS query parameters. */ + @Deprecated public String encode() { /* We should be url-encoding each key and each value, but because we know all the keys and values will encode to 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 240d253e3632..0ca6ca488fc6 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 @@ -45,9 +45,31 @@ public final class AccountSasSignatureValues { /** * Initializes a new {@link AccountSasSignatureValues} object. */ + @Deprecated public AccountSasSignatureValues() { } + /** + * Initializes a new {@link AccountSasSignatureValues} object. + * + * @param expiryTime The time after which the SAS will no longer work. + * @param services {@link AccountSasService} + * @param resourceTypes {@link AccountSasResourceType} + * @param permissions {@link AccountSasPermission} + */ + public AccountSasSignatureValues(OffsetDateTime expiryTime, AccountSasService services, + AccountSasResourceType resourceTypes, AccountSasPermission permissions) { + StorageImplUtils.assertNotNull("expiryTime", expiryTime); + StorageImplUtils.assertNotNull("services", services); + StorageImplUtils.assertNotNull("permissions", permissions); + StorageImplUtils.assertNotNull("resourceTypes", resourceTypes); + + this.expiryTime = expiryTime; + this.services = services.toString(); + this.resourceTypes = resourceTypes.toString(); + this.permissions = permissions.toString(); + } + /** * * @return the service version that is targeted, if {@code null} or empty the latest service version targeted by the @@ -118,6 +140,7 @@ public OffsetDateTime getExpiryTime() { * @param expiryTime Expiry time to set * @return the updated AccountSasSignatureValues object. */ + @Deprecated public AccountSasSignatureValues setExpiryTime(OffsetDateTime expiryTime) { this.expiryTime = expiryTime; return this; @@ -141,6 +164,7 @@ public String getPermissions() { * @return the updated AccountSasSignatureValues object. * @throws NullPointerException if {@code permissions} is null. */ + @Deprecated public AccountSasSignatureValues setPermissions(AccountSasPermission permissions) { StorageImplUtils.assertNotNull("permissions", permissions); this.permissions = permissions.toString(); @@ -179,6 +203,7 @@ public String getServices() { * @param services Allowed services string to set * @return the updated AccountSasSignatureValues object. */ + @Deprecated public AccountSasSignatureValues setServices(String services) { this.services = services; return this; @@ -199,6 +224,7 @@ public String getResourceTypes() { * @param resourceTypes Allowed resource types string to set * @return the updated AccountSasSignatureValues object. */ + @Deprecated public AccountSasSignatureValues setResourceTypes(String resourceTypes) { this.resourceTypes = resourceTypes; return this; @@ -233,6 +259,7 @@ public AccountSasSignatureValues setResourceTypes(String resourceTypes) { * @throws NullPointerException If any of {@code storageSharedKeyCredentials}, {@code services}, * {@code resourceTypes}, {@code expiryTime}, or {@code permissions} is null. */ + @Deprecated public AccountSasQueryParameters generateSasQueryParameters( StorageSharedKeyCredential storageSharedKeyCredentials) { StorageImplUtils.assertNotNull("storageSharedKeyCredentials", storageSharedKeyCredentials); 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 648faf156554..e03c24a0f15a 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 @@ -6,6 +6,8 @@ import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.SasImplUtils; + import java.time.OffsetDateTime; import java.util.Map; import java.util.function.Function; @@ -174,12 +176,7 @@ public String getSignature() { * @param value The value of the parameter to append. */ protected void tryAppendQueryParameter(StringBuilder sb, String param, Object value) { - if (value != null) { - if (sb.length() != 0) { - sb.append('&'); - } - sb.append(Utility.urlEncode(param)).append('=').append(Utility.urlEncode(value.toString())); - } + SasImplUtils.tryAppendQueryParameter(sb, param, value); } /** @@ -189,11 +186,7 @@ protected void tryAppendQueryParameter(StringBuilder sb, String param, Object va * @return A String representing the SAS date time. */ protected String formatQueryParameterDate(OffsetDateTime dateTime) { - if (dateTime == null) { - return null; - } else { - return Constants.ISO_8601_UTC_DATE_FORMATTER.format(dateTime); - } + return SasImplUtils.formatQueryParameterDate(dateTime); } /** From a5c133c3cdc311a5eacb29b008eafb9109ce3a83 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Fri, 22 Nov 2019 10:59:29 -0800 Subject: [PATCH 02/17] Added some java doc and deprecation notices --- .../blob/BlobContainerAsyncClient.java | 26 +++++++++++++ .../storage/blob/BlobContainerClient.java | 18 +++++++++ .../storage/blob/BlobServiceAsyncClient.java | 14 ++++++- .../azure/storage/blob/BlobServiceClient.java | 19 ++++++++-- .../sas/BlobServiceSasQueryParameters.java | 2 + .../sas/BlobServiceSasSignatureValues.java | 37 +++++++++++++----- .../blob/specialized/BlobAsyncClientBase.java | 2 - ...ServiceAsyncClientJavaDocCodeSnippets.java | 25 ++++++++++++ .../BlobServiceClientJavaDocCodeSnippets.java | 24 ++++++++++++ .../azure/storage/blob/SasClientTests.groovy | 16 ++++---- .../common/sas/AccountSasSignatureValues.java | 38 ++++++++++--------- ...SasSignatureValuesJavaDocCodeSnippets.java | 35 ----------------- 12 files changed, 180 insertions(+), 76 deletions(-) delete mode 100644 sdk/storage/azure-storage-common/src/samples/java/com/azure/storage/common/sas/AccountSasSignatureValuesJavaDocCodeSnippets.java 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 c66dbbd9fd85..74f34e5821ee 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 @@ -82,6 +82,14 @@ public final class BlobContainerAsyncClient { private final ClientLogger logger = new ClientLogger(BlobContainerAsyncClient.class); private final AzureBlobStorageImpl azureBlobStorage; + /** + * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} + * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * + * @return A {@code String} representing all SAS query parameters. + */ private final String accountName; private final String containerName; private final BlobServiceVersion serviceVersion; @@ -904,12 +912,30 @@ Mono> getAccountInfoWithResponse(Context context) { }); } + /** + * Generates a user delegation sas for the container using the specified + * {@link BlobServiceSasSignatureValues}. + * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * @param userDelegationKey {@link UserDelegationKey} + * + * @return A {@code String} representing all SAS query parameters. + */ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey) { return new BlobSasImplUtil(blobServiceSasSignatureValues, getBlobContainerName()) .generateUserDelegationSas(userDelegationKey, getAccountName()); } + /** + * Generates a service sas for the container using the specified {@link BlobServiceSasSignatureValues} + * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * + * @return A {@code String} representing all SAS query parameters. + */ public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { return new BlobSasImplUtil(blobServiceSasSignatureValues, getBlobContainerName()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline())); 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 e231c6e81553..112d1d084b70 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 @@ -555,11 +555,29 @@ public Response getAccountInfoWithResponse(Duration timeout, return blockWithOptionalTimeout(response, timeout); } + /** + * Generates a user delegation sas for the container using the specified + * {@link BlobServiceSasSignatureValues}. + * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * @param userDelegationKey {@link UserDelegationKey} + * + * @return A {@code String} representing all SAS query parameters. + */ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey) { return this.client.generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); } + /** + * Generates a service sas for the container using the specified {@link BlobServiceSasSignatureValues} + * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * + * @return A {@code String} representing all SAS query parameters. + */ public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { return this.client.generateSas(blobServiceSasSignatureValues); } 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 050734edc258..40fff379f1f4 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 @@ -555,7 +555,19 @@ public String getAccountName() { return this.accountName; } - public String generateSas(AccountSasSignatureValues accountSasSignatureValues) { + /** + * Generates an account sas for the Azure Storage account using the specified {@link AccountSasSignatureValues}. + * @see AccountSasSignatureValues for more information on how to construct an account SAS. + * + *

The snippet below generates a SAS that lasts for two days and gives the user read and list access to blob + * containers and file shares.

+ * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.generateAccountSas#AccountSasSignatureValues} + * + * @param accountSasSignatureValues {@link AccountSasSignatureValues} + * + * @return A {@code String} representing all SAS query parameters. + */ + public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues) { return new AccountSasImplUtil(accountSasSignatureValues) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline())); } 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 3e380dda771e..1668483bfc59 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,8 +17,6 @@ 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.implementation.AccountSasImplUtil; -import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.common.sas.AccountSasSignatureValues; import reactor.core.publisher.Mono; @@ -376,7 +374,20 @@ public String getAccountName() { return this.blobServiceAsyncClient.getAccountName(); } - public String generateSas(AccountSasSignatureValues accountSasSignatureValues) { - return this.blobServiceAsyncClient.generateSas(accountSasSignatureValues); + /** + * Generates an account sas for the Azure Storage account using the specified {@link AccountSasSignatureValues}. + * @see AccountSasSignatureValues for more information on how to construct an account SAS. + * + *

Generating an account SAS

+ *

The snippet below generates an AccountSasSignatureValues object that lasts for two days and gives the user + * read and list access to blob and file shares.

+ * {@codesnippet com.azure.storage.blob.BlobServiceClient.generateAccountSas#AccountSasSignatureValues} + * + * @param accountSasSignatureValues {@link AccountSasSignatureValues} + * + * @return A {@code String} representing all SAS query parameters. + */ + public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues) { + return this.blobServiceAsyncClient.generateAccountSas(accountSasSignatureValues); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java index 914e749402fa..d1fe21d78da4 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java @@ -240,6 +240,8 @@ UserDelegationKey userDelegationKey() { * Encodes all SAS query parameters into a string that can be appended to a URL. * * @return A {@code String} representing all SAS query parameters. + * @deprecated Please use the generate*Sas method on the desired container/blob client after initializing + * {@link BlobServiceSasSignatureValues}. */ @Deprecated public String encode() { 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 00ec1c716515..eb2a06ab47e5 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 @@ -6,7 +6,6 @@ import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; import com.azure.storage.blob.models.UserDelegationKey; import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.Constants; @@ -19,13 +18,17 @@ /** * Used to initialize parameters for a Shared Access Signature (SAS) for an Azure Blob Storage service. Once all the - * values here are set, use the appropriate generate*Sas method on the desired client to obtain a representation of the - * SAS which can then be applied to a new client using the .sasToken method on a client builder. + * values here are set, use the appropriate generate*Sas method on the desired container/blob client to obtain a + * representation of the SAS which can then be applied to a new client using the .sasToken(String) method on the + * desired client builder. * * @see Storage SAS overview * @see Constructing a Service * SAS + * @see Constructing a + * User Delegation SAS */ + // TODO (gapra) : Add code snippets for new workflow public final class BlobServiceSasSignatureValues { /** @@ -79,6 +82,9 @@ public final class BlobServiceSasSignatureValues { /** * Creates an object with empty values for all fields. + * @deprecated Please use {@link #BlobServiceSasSignatureValues(String)}, + * {@link #BlobServiceSasSignatureValues(OffsetDateTime, BlobSasPermission)}, or + * {@link #BlobServiceSasSignatureValues(OffsetDateTime, BlobContainerSasPermission)} */ @Deprecated public BlobServiceSasSignatureValues() { @@ -87,8 +93,8 @@ public BlobServiceSasSignatureValues() { /** * Creates an object with the specified expiry time and permissions * - * @param expiryTime Time the SAS becomes valid - * @param permissions Permissions granted by the SAS + * @param expiryTime The time after which the SAS will no longer work. + * @param permissions {@link BlobContainerSasPermission} allowed by the SAS. */ public BlobServiceSasSignatureValues(OffsetDateTime expiryTime, BlobContainerSasPermission permissions) { StorageImplUtils.assertNotNull("expiryTime", expiryTime); @@ -100,8 +106,8 @@ public BlobServiceSasSignatureValues(OffsetDateTime expiryTime, BlobContainerSas /** * Creates an object with the specified expiry time and permissions * - * @param expiryTime Time the SAS becomes valid - * @param permissions Permissions granted by the SAS + * @param expiryTime When the SAS will no longer work + * @param permissions {@link BlobSasPermission} allowed by the SAS */ public BlobServiceSasSignatureValues(OffsetDateTime expiryTime, BlobSasPermission permissions) { StorageImplUtils.assertNotNull("expiryTime", expiryTime); @@ -114,7 +120,7 @@ public BlobServiceSasSignatureValues(OffsetDateTime expiryTime, BlobSasPermissio * Creates an object with the specified identifier. * NOTE: Identifier can not be used for a {@link UserDelegationKey} SAS. * - * @param identifier Identifier for the SAS + * @param identifier Name of the access policy */ public BlobServiceSasSignatureValues(String identifier) { StorageImplUtils.assertNotNull("identifier", identifier); @@ -137,6 +143,10 @@ public BlobServiceSasSignatureValues(String identifier) { * @param contentEncoding The content-encoding header for the SAS. * @param contentLanguage The content-language header for the SAS. * @param contentType The content-type header for the SAS. + * @deprecated Please use {@link #BlobServiceSasSignatureValues(String)}, + * {@link #BlobServiceSasSignatureValues(OffsetDateTime, BlobSasPermission)}, or + * {@link #BlobServiceSasSignatureValues(OffsetDateTime, BlobContainerSasPermission)} + * followed by calls to the desired setters. */ @Deprecated public BlobServiceSasSignatureValues(String version, SasProtocol sasProtocol, OffsetDateTime startTime, @@ -298,6 +308,8 @@ public String getContainerName() { * * @param containerName The name of the container. * @return The updated BlobServiceSASSignatureValues object. + * @deprecated Please use the generate*Sas methods provided on the desired container/blob client that will + * auto-populate the container name. */ @Deprecated public BlobServiceSasSignatureValues setContainerName(String containerName) { @@ -321,6 +333,8 @@ public String getBlobName() { * * @param blobName The name of the blob. Use {@code null} or an empty string to create a container SAS. * @return The updated BlobServiceSASSignatureValues object. + * @deprecated Please use the generate*Sas methods provided on the desired blob client that will auto-populate the + * blob name. */ @Deprecated public BlobServiceSasSignatureValues setBlobName(String blobName) { @@ -343,6 +357,8 @@ public String getSnapshotId() { * * @param snapshotId Identifier of the snapshot * @return the updated BlobServiceSASSignatureValues object + * @deprecated Please use the generate*Sas methods provided on the desired (snapshot) blob client that will + * auto-populate the snapshot id. */ @Deprecated public BlobServiceSasSignatureValues setSnapshotId(String snapshotId) { @@ -370,7 +386,6 @@ public String getIdentifier() { * @param identifier Name of the access policy * @return the updated BlobServiceSASSignatureValues object */ - @Deprecated public BlobServiceSasSignatureValues setIdentifier(String identifier) { this.identifier = identifier; return this; @@ -498,6 +513,8 @@ public BlobServiceSasSignatureValues setContentType(String contentType) { * encoded string, or the UTF-8 charset isn't supported. * @throws IllegalArgumentException if {@link #getPermissions()} contains an invalid character for the SAS resource. * @throws NullPointerException if {@code storageSharedKeyCredentials} is null. + * @deprecated Please use the generateSas(BlobServiceSasSignatureValues) method on the desired container/blob client + * after initializing {@link BlobServiceSasSignatureValues}. */ @Deprecated public BlobServiceSasQueryParameters generateSasQueryParameters( @@ -549,6 +566,8 @@ public BlobServiceSasQueryParameters generateSasQueryParameters( * @throws NullPointerException if {@code delegationKey} or {@code account} is null. * @see * Create a user delegation SAS + * @deprecated Please use the generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey) method on + * the desired container/blob client after initializing {@link BlobServiceSasSignatureValues}. */ @Deprecated public BlobServiceSasQueryParameters generateSasQueryParameters(UserDelegationKey delegationKey, 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 66eae423ab03..81b5705756d6 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 @@ -25,7 +25,6 @@ import com.azure.storage.blob.implementation.models.BlobGetAccountInfoHeaders; import com.azure.storage.blob.implementation.models.BlobGetPropertiesHeaders; import com.azure.storage.blob.implementation.models.BlobStartCopyFromURLHeaders; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; import com.azure.storage.blob.implementation.util.ModelHelper; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.ArchiveStatus; @@ -49,7 +48,6 @@ import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceAsyncClientJavaDocCodeSnippets.java index c2c2b7167f3a..5ae2897a2e88 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceAsyncClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceAsyncClientJavaDocCodeSnippets.java @@ -11,7 +11,12 @@ import com.azure.storage.blob.models.BlobServiceProperties; import com.azure.storage.blob.models.ListBlobContainersOptions; import com.azure.storage.blob.models.PublicAccessType; +import com.azure.storage.common.sas.AccountSasPermission; +import com.azure.storage.common.sas.AccountSasResourceType; +import com.azure.storage.common.sas.AccountSasService; +import com.azure.storage.common.sas.AccountSasSignatureValues; +import java.time.Duration; import java.time.OffsetDateTime; import java.util.Collections; import java.util.Map; @@ -234,4 +239,24 @@ public void getAccountInfoWithResponse() { response.getValue().getSkuName())); // END: com.azure.storage.blob.BlobServiceAsyncClient.getAccountInfoWithResponse } + + /** + * Code snippet for {@link BlobServiceAsyncClient#generateAccountSas(AccountSasSignatureValues)} + */ + public void generateAccountSas() { + // BEGIN: com.azure.storage.blob.BlobServiceAsyncClient.generateAccountSas#AccountSasSignatureValues + AccountSasPermission permissions = new AccountSasPermission() + .setListPermission(true) + .setReadPermission(true); + AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); + AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); + OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); + + AccountSasSignatureValues sasValues = + new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); + + // Client must be authenticated via StorageSharedKeyCredential + String sas = client.generateAccountSas(sasValues); + // END: com.azure.storage.blob.BlobServiceAsyncClient.generateAccountSas#AccountSasSignatureValues + } } diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceClientJavaDocCodeSnippets.java index 5f2b7f135608..bfc83ae426f9 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobServiceClientJavaDocCodeSnippets.java @@ -12,6 +12,10 @@ import com.azure.storage.blob.models.ListBlobContainersOptions; import com.azure.storage.blob.models.PublicAccessType; import com.azure.storage.blob.models.StorageAccountInfo; +import com.azure.storage.common.sas.AccountSasPermission; +import com.azure.storage.common.sas.AccountSasResourceType; +import com.azure.storage.common.sas.AccountSasService; +import com.azure.storage.common.sas.AccountSasSignatureValues; import java.time.Duration; import java.time.OffsetDateTime; @@ -241,4 +245,24 @@ public void getAccountInfoWithResponse() { StorageAccountInfo accountInfo = client.getAccountInfoWithResponse(timeout, context).getValue(); // END: com.azure.storage.blob.BlobServiceClient.getAccountInfoWithResponse#Duration-Context } + + /** + * Code snippet for {@link BlobServiceClient#generateAccountSas(AccountSasSignatureValues)} + */ + public void generateAccountSas() { + // BEGIN: com.azure.storage.blob.BlobServiceClient.generateAccountSas#AccountSasSignatureValues + AccountSasPermission permissions = new AccountSasPermission() + .setListPermission(true) + .setReadPermission(true); + AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); + AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); + OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); + + AccountSasSignatureValues sasValues = + new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); + + // Client must be authenticated via StorageSharedKeyCredential + String sas = client.generateAccountSas(sasValues); + // END: com.azure.storage.blob.BlobServiceClient.generateAccountSas#AccountSasSignatureValues + } } diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy index b32ab6700954..d74cbed851f6 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy @@ -259,8 +259,8 @@ class SasClientTests extends APISpec { def expiryTime = getUTCNow().plusDays(1) when: - def sasValues = new AccountSasSignatureValues(expiryTime, service, resourceType, permissions) - def sas = primaryBlobServiceClient.generateSas(sasValues) + def sasValues = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType) + def sas = primaryBlobServiceClient.generateAccountSas(sasValues) def client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient() def os = new ByteArrayOutputStream() client.download(os) @@ -282,8 +282,8 @@ class SasClientTests extends APISpec { def expiryTime = getUTCNow().plusDays(1) when: - def sasValues = new AccountSasSignatureValues(expiryTime, service, resourceType, permissions) - def sas = primaryBlobServiceClient.generateSas(sasValues) + def sasValues = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType) + def sas = primaryBlobServiceClient.generateAccountSas(sasValues) def client = getBlobClient(sas, cc.getBlobContainerUrl(), blobName).getBlockBlobClient() client.delete() @@ -305,8 +305,8 @@ class SasClientTests extends APISpec { def expiryTime = getUTCNow().plusDays(1) when: - def sasValues = new AccountSasSignatureValues(expiryTime, service, resourceType, permissions) - def sas = primaryBlobServiceClient.generateSas(sasValues) + def sasValues = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType) + def sas = primaryBlobServiceClient.generateAccountSas(sasValues) def sc = getServiceClient(sas, primaryBlobServiceClient.getAccountUrl()) sc.createBlobContainer(generateContainerName()) @@ -328,8 +328,8 @@ class SasClientTests extends APISpec { def expiryTime = getUTCNow().plusDays(1) when: - def sasValues = new AccountSasSignatureValues(expiryTime, service, resourceType, permissions) - def sas = primaryBlobServiceClient.generateSas(sasValues) + def sasValues = new AccountSasSignatureValues(expiryTime, permissions, service, resourceType) + def sas = primaryBlobServiceClient.generateAccountSas(sasValues) def sc = getServiceClient(sas, primaryBlobServiceClient.getAccountUrl()) sc.createBlobContainer(generateContainerName()) 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 0ca6ca488fc6..45ee5fa9e817 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 @@ -11,19 +11,13 @@ import java.time.OffsetDateTime; /** - * Used to generate a Shared Access Signature (SAS) for an Azure Storage account. Once all the values are set, call - * {@link - * #generateSasQueryParameters(StorageSharedKeyCredential) generateSASQueryParameters(StorageSharedKeyCredential)} to - * obtain a representation of the SAS which can actually be applied to container, file, queue, and tables. - * - *

Generating an account SAS

- *

The snippet below generates an account SAS that lasts for two days and gives the user read and list access to - * blob containers and file shares.

- * - * {@codesnippet com.azure.storage.common.sas.accountSasSignatureValues.generateSasQueryParameters#StorageSharedKeyCredential} + * Used to initialize parameters for a Shared Access Signature (SAS) for an Azure Storage account. Once all the + * values here are set, use the appropriate generate*Sas method on the desired service client to obtain a + * representation of the SAS which can then be applied to a new client using the .sasToken(String) method on the + * desired client builder. * + * @see Storage SAS overview * @see Create an account SAS - * @see Storage SAS overview */ public final class AccountSasSignatureValues { private String version; @@ -44,6 +38,7 @@ public final class AccountSasSignatureValues { /** * Initializes a new {@link AccountSasSignatureValues} object. + * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, AccountSasResourceType)} */ @Deprecated public AccountSasSignatureValues() { @@ -51,14 +46,13 @@ public AccountSasSignatureValues() { /** * Initializes a new {@link AccountSasSignatureValues} object. - * * @param expiryTime The time after which the SAS will no longer work. - * @param services {@link AccountSasService} - * @param resourceTypes {@link AccountSasResourceType} - * @param permissions {@link AccountSasPermission} + * @param permissions {@link AccountSasPermission} allowed by the SAS. + * @param services {@link AccountSasService} targeted by the SAS. + * @param resourceTypes {@link AccountSasResourceType} targeted by the SAS. */ - public AccountSasSignatureValues(OffsetDateTime expiryTime, AccountSasService services, - AccountSasResourceType resourceTypes, AccountSasPermission permissions) { + public AccountSasSignatureValues(OffsetDateTime expiryTime, AccountSasPermission permissions, + AccountSasService services, AccountSasResourceType resourceTypes) { StorageImplUtils.assertNotNull("expiryTime", expiryTime); StorageImplUtils.assertNotNull("services", services); StorageImplUtils.assertNotNull("permissions", permissions); @@ -139,6 +133,8 @@ public OffsetDateTime getExpiryTime() { * * @param expiryTime Expiry time to set * @return the updated AccountSasSignatureValues object. + * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, AccountSasResourceType)} + * to specify the expiry time. */ @Deprecated public AccountSasSignatureValues setExpiryTime(OffsetDateTime expiryTime) { @@ -163,6 +159,8 @@ public String getPermissions() { * @param permissions Permissions to set. * @return the updated AccountSasSignatureValues object. * @throws NullPointerException if {@code permissions} is null. + * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, AccountSasResourceType)} + * to specify the allowed permissions. */ @Deprecated public AccountSasSignatureValues setPermissions(AccountSasPermission permissions) { @@ -202,6 +200,8 @@ public String getServices() { * * @param services Allowed services string to set * @return the updated AccountSasSignatureValues object. + * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, AccountSasResourceType)} + * to specify the services being targeted. */ @Deprecated public AccountSasSignatureValues setServices(String services) { @@ -223,6 +223,8 @@ public String getResourceTypes() { * * @param resourceTypes Allowed resource types string to set * @return the updated AccountSasSignatureValues object. + * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, AccountSasResourceType)} + * to specify the resource types being targeted. */ @Deprecated public AccountSasSignatureValues setResourceTypes(String resourceTypes) { @@ -258,6 +260,8 @@ public AccountSasSignatureValues setResourceTypes(String resourceTypes) { * @throws RuntimeException If the HMAC-SHA256 signature for {@code storageSharedKeyCredentials} fails to generate. * @throws NullPointerException If any of {@code storageSharedKeyCredentials}, {@code services}, * {@code resourceTypes}, {@code expiryTime}, or {@code permissions} is null. + * @deprecated Please use the generateAccountSas(AccountSasSignatureValues) method on the desired service client + * after initializing {@link AccountSasSignatureValues}. */ @Deprecated public AccountSasQueryParameters generateSasQueryParameters( diff --git a/sdk/storage/azure-storage-common/src/samples/java/com/azure/storage/common/sas/AccountSasSignatureValuesJavaDocCodeSnippets.java b/sdk/storage/azure-storage-common/src/samples/java/com/azure/storage/common/sas/AccountSasSignatureValuesJavaDocCodeSnippets.java deleted file mode 100644 index af33baca1953..000000000000 --- a/sdk/storage/azure-storage-common/src/samples/java/com/azure/storage/common/sas/AccountSasSignatureValuesJavaDocCodeSnippets.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.common.sas; - -import com.azure.storage.common.StorageSharedKeyCredential; - -import java.time.Duration; -import java.time.OffsetDateTime; - -/** - * Code snippets for {@link AccountSasSignatureValues}. - */ -public class AccountSasSignatureValuesJavaDocCodeSnippets { - public void generateSas() { - // BEGIN: com.azure.storage.common.sas.accountSasSignatureValues.generateSasQueryParameters#StorageSharedKeyCredential - StorageSharedKeyCredential credential = new StorageSharedKeyCredential("my-account", "my-key"); - - AccountSasPermission permissions = new AccountSasPermission() - .setListPermission(true) - .setReadPermission(true); - String resourceTypes = new AccountSasResourceType().setContainer(true).toString(); - String services = new AccountSasService().setBlobAccess(true).setFileAccess(true).toString(); - - // Creates an account SAS that can read and list from blob containers and file shares. - // The following are required: permissions, resourceTypes, services, and expiry date. - AccountSasQueryParameters sasQueryParameters = new AccountSasSignatureValues() - .setPermissions(permissions) - .setResourceTypes(resourceTypes) - .setServices(services) - .setExpiryTime(OffsetDateTime.now().plus(Duration.ofDays(2))) - .generateSasQueryParameters(credential); - // END: com.azure.storage.common.sas.accountSasSignatureValues.generateSasQueryParameters#StorageSharedKeyCredential - } -} From bad7d1acfa3b1de0d771ea3a5e2b9db12f241c26 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Mon, 25 Nov 2019 09:19:19 -0800 Subject: [PATCH 03/17] added test recordings + more tests --- .../implementation/util/BlobSasImplUtil.java | 14 +- .../azure/storage/blob/SasClientTests.groovy | 172 ++++++++++++++ ...accountsasnetworkcreatecontainerfails.json | 112 +++++++++ ...ountsasnetworkcreatecontainersucceeds.json | 130 +++++++++++ ...ntsasnetworktestblobdeletefailsnewapi.json | 112 +++++++++ ...entTestsaccountsasnetworktestblobread.json | 120 ++++++++++ ...ntTestsblobsasimplutilstringtosign[0].json | 90 +++++++ ...ntTestsblobsasimplutilstringtosign[1].json | 90 +++++++ ...ntTestsblobsasimplutilstringtosign[2].json | 90 +++++++ ...ntTestsblobsasimplutilstringtosign[3].json | 90 +++++++ ...ntTestsblobsasimplutilstringtosign[4].json | 90 +++++++ ...ntTestsblobsasimplutilstringtosign[5].json | 90 +++++++ ...ntTestsblobsasimplutilstringtosign[6].json | 90 +++++++ ...ntTestsblobsasimplutilstringtosign[7].json | 90 +++++++ ...ntTestsblobsasimplutilstringtosign[8].json | 90 +++++++ ...ntTestsblobsasimplutilstringtosign[9].json | 90 +++++++ ...lutilstringtosignuserdelegationkey[0].json | 90 +++++++ ...utilstringtosignuserdelegationkey[10].json | 90 +++++++ ...utilstringtosignuserdelegationkey[11].json | 90 +++++++ ...utilstringtosignuserdelegationkey[12].json | 90 +++++++ ...utilstringtosignuserdelegationkey[13].json | 90 +++++++ ...utilstringtosignuserdelegationkey[14].json | 90 +++++++ ...lutilstringtosignuserdelegationkey[1].json | 90 +++++++ ...lutilstringtosignuserdelegationkey[2].json | 90 +++++++ ...lutilstringtosignuserdelegationkey[3].json | 90 +++++++ ...lutilstringtosignuserdelegationkey[4].json | 90 +++++++ ...lutilstringtosignuserdelegationkey[5].json | 90 +++++++ ...lutilstringtosignuserdelegationkey[6].json | 90 +++++++ ...lutilstringtosignuserdelegationkey[7].json | 90 +++++++ ...lutilstringtosignuserdelegationkey[8].json | 90 +++++++ ...lutilstringtosignuserdelegationkey[9].json | 90 +++++++ ...blobservicesasnetworktestblobsnapshot.json | 197 ++++++++++++++++ ...ClientTestsensurestateillegalargument.json | 90 +++++++ ...tsensurestateresourceandpermission[0].json | 90 +++++++ ...tsensurestateresourceandpermission[1].json | 90 +++++++ ...tsensurestateresourceandpermission[2].json | 90 +++++++ .../SasClientTestsensurestateversion.json | 90 +++++++ .../SasClientTestsnetworktestblobsas.json | 158 +++++++++++++ ...SasClientTestsnetworktestblobsnapshot.json | 202 ++++++++++++++++ ...networktestblobsnapshotuserdelegation.json | 219 ++++++++++++++++++ ...entTestsnetworktestblobuserdelegation.json | 180 ++++++++++++++ ...stsnetworktestcontaineruserdelegation.json | 133 +++++++++++ ...assignaturevaluesnetworktestcontainer.json | 154 ++++++++++++ .../common/sas/AccountSasPermission.java | 2 +- .../common/sas/AccountSasQueryParameters.java | 5 + 45 files changed, 4606 insertions(+), 4 deletions(-) create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworkcreatecontainerfails.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworkcreatecontainersucceeds.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworktestblobdeletefailsnewapi.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworktestblobread.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[0].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[1].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[2].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[3].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[4].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[5].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[6].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[7].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[8].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[9].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[0].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[10].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[11].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[12].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[13].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[14].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[1].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[2].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[3].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[4].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[5].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[6].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[7].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[8].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[9].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobservicesasnetworktestblobsnapshot.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateillegalargument.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[0].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[1].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[2].json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateversion.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsas.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsnapshot.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsnapshotuserdelegation.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobuserdelegation.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestcontaineruserdelegation.json create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsservicesassignaturevaluesnetworktestcontainer.json 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 b351c6db02d5..07beaee1e321 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 @@ -158,7 +158,7 @@ public String generateUserDelegationSas(UserDelegationKey delegationKey, String * @param signature The signature of the Sas. * @return A String representing the Sas. */ - public String encode(UserDelegationKey userDelegationKey, String signature) { + private String encode(UserDelegationKey userDelegationKey, String signature) { /* We should be url-encoding each key and each value, but because we know all the keys and values will encode to themselves, we cheat except for the signature value. @@ -202,11 +202,12 @@ public String encode(UserDelegationKey userDelegationKey, String signature) { * Ensures that the builder's properties are in a consistent state. * 1. If there is no version, use latest. - * 2. Resource name is chosen by: + * 2. If there is no identifier set, ensure expiryTime and permissions are set. + * 3. Resource name is chosen by: * a. If "BlobName" is _not_ set, it is a container resource. * b. Otherwise, if "SnapshotId" is set, it is a blob snapshot resource. * c. Otherwise, it is a blob resource. - * 3. Reparse permissions depending on what the resource is. If it is an unrecognised resource, do nothing. + * 4. Reparse permissions depending on what the resource is. If it is an unrecognised resource, do nothing. * * Taken from: * https://github.com/Azure/azure-storage-blob-go/blob/master/azblob/sas_service.go#L33 @@ -217,6 +218,13 @@ private void ensureState() { version = BlobServiceVersion.getLatest().getVersion(); } + if (identifier == null) { + if (expiryTime == null || permissions == null) { + throw logger.logExceptionAsError(new IllegalStateException("If identifier is not set, expiry time " + + "and permissions must be set")); + } + } + if (CoreUtils.isNullOrEmpty(blobName)) { resource = SAS_CONTAINER_CONSTANT; } else if (snapshotId != null) { diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy index d74cbed851f6..24ed0b81538f 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy @@ -1,5 +1,6 @@ package com.azure.storage.blob +import com.azure.storage.blob.implementation.util.BlobSasImplUtil import com.azure.storage.blob.models.BlobAccessPolicy import com.azure.storage.blob.models.BlobProperties import com.azure.storage.blob.models.BlobSignedIdentifier @@ -10,12 +11,19 @@ import com.azure.storage.blob.sas.BlobSasPermission import com.azure.storage.blob.sas.BlobServiceSasSignatureValues import com.azure.storage.blob.specialized.BlockBlobClient import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder +import com.azure.storage.common.implementation.Constants +import com.azure.storage.common.implementation.StorageImplUtils import com.azure.storage.common.sas.AccountSasPermission import com.azure.storage.common.sas.AccountSasResourceType import com.azure.storage.common.sas.AccountSasService import com.azure.storage.common.sas.AccountSasSignatureValues import com.azure.storage.common.sas.SasIpRange import com.azure.storage.common.sas.SasProtocol +import spock.lang.Unroll + +import java.time.LocalDateTime +import java.time.OffsetDateTime +import java.time.ZoneOffset class SasClientTests extends APISpec { @@ -369,4 +377,168 @@ class SasClientTests extends APISpec { return key } + /* Blob SAS Impl Util Tests */ + def "ensure state version"() { + when: + BlobSasImplUtil implUtil = new BlobSasImplUtil(new BlobServiceSasSignatureValues("id"), "container") + implUtil.version = null + implUtil.ensureState() + + then: + implUtil.version // Version is set + implUtil.resource == "c" // Default resource is container + !implUtil.permissions // Identifier was used so permissions is null + } + + def "ensure state illegal argument"() { + when: + BlobSasImplUtil implUtil = new BlobSasImplUtil(new BlobServiceSasSignatureValues(), null) + + implUtil.ensureState() + + then: + thrown(IllegalStateException) + } + + @Unroll + def "ensure state resource and permission"() { + setup: + def expiryTime = OffsetDateTime.now().plusDays(1) + + expect: + BlobSasImplUtil implUtil = new BlobSasImplUtil(new BlobServiceSasSignatureValues(expiryTime, permission), container, blob, snapshot) + implUtil.ensureState() + implUtil.resource == resource + implUtil.permissions == permissionString + + where: + container | blob | snapshot | permission || resource | permissionString + "container" | null | null | new BlobContainerSasPermission().setReadPermission(true).setListPermission(true) || "c" | "rl" + "container" | "blob" | null | new BlobSasPermission().setReadPermission(true) || "b" | "r" + "container" | "blob" | "snapshot" | new BlobSasPermission().setReadPermission(true) || "bs" | "r" + } + + /* + This test will ensure that each field gets placed into the proper location within the string to sign and that null + values are handled correctly. We will validate the whole SAS with service calls as well as correct serialization of + individual parts later. + */ + + @Unroll + def "blob sas impl util string to sign"() { + when: + def e = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) + def p = new BlobSasPermission() + p.setReadPermission(true) + def v = new BlobServiceSasSignatureValues(e, p) + + def expected = String.format(expectedStringToSign, primaryCredential.getAccountName()) + + v.setStartTime(startTime) + + if (ipRange != null) { + def ipR = new SasIpRange() + ipR.setIpMin("ip") + v.setSasIpRange(ipR) + } + v.setIdentifier(identifier) + .setProtocol(protocol) + .setCacheControl(cacheControl) + .setContentDisposition(disposition) + .setContentEncoding(encoding) + .setContentLanguage(language) + .setContentType(type) + + def implUtil = new BlobSasImplUtil(v, "containerName", "blobName", snapId) + + def sasToken = implUtil.generateSas(primaryCredential) + + def token = BlobUrlParts.parse(cc.getBlobContainerUrl() + "?" + sasToken).getSasQueryParameters() + + then: + token.getSignature() == primaryCredential.computeHmac256(expected) + + /* + We don't test the blob or containerName properties because canonicalized resource is always added as at least + /blob/accountName. We test canonicalization of resources later. Again, this is not to test a fully functional + sas but the construction of the string to sign. + Signed resource is tested elsewhere, as we work some minor magic in choosing which value to use. + */ + 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" + 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 + def "blob sas impl util string to sign user delegation key"() { + when: + def e = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC) + def p = new BlobSasPermission() + p.setReadPermission(true) + def v = new BlobServiceSasSignatureValues(e, p) + + def expected = String.format(expectedStringToSign, primaryCredential.getAccountName()) + + v.setStartTime(startTime) + + if (ipRange != null) { + def ipR = new SasIpRange() + ipR.setIpMin("ip") + v.setSasIpRange(ipR) + } + v.setProtocol(protocol) + .setCacheControl(cacheControl) + .setContentDisposition(disposition) + .setContentEncoding(encoding) + .setContentLanguage(language) + .setContentType(type) + def key = new UserDelegationKey() + .setSignedObjectId(keyOid) + .setSignedTenantId(keyTid) + .setSignedStart(keyStart) + .setSignedExpiry(keyExpiry) + .setSignedService(keyService) + .setSignedVersion(keyVersion) + .setValue(keyValue) + + def implUtil = new BlobSasImplUtil(v, "containerName", "blobName", snapId) + + def sasToken = implUtil.generateUserDelegationSas(key, primaryCredential.getAccountName()) + + def token = BlobUrlParts.parse(cc.getBlobContainerUrl() + "?" + sasToken).getSasQueryParameters() + + then: + 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" + 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" + } + } diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworkcreatecontainerfails.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworkcreatecontainerfails.json new file mode 100644 index 000000000000..a35e56dfb3ed --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworkcreatecontainerfails.json @@ -0,0 +1,112 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworkcreatecontainerfails076243fee1aaef?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "dd3aee52-1d32-43b0-9137-0f79d7297a17" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3EA2B5A4", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:34 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "d921ddbf-401e-0028-45b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:34 GMT", + "x-ms-client-request-id" : "dd3aee52-1d32-43b0-9137-0f79d7297a17" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworkcreatecontainerfails076243fee1aaef/javablobaccountsasnetworkcreatecontainerfails1002608965aa", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "cc7772d1-e7d2-49ef-9254-0371879be922", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:34 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:34 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3EB0D38D", + "Content-Length" : "0", + "x-ms-request-id" : "329a251a-a01e-0020-07b3-a3e99c000000", + "x-ms-client-request-id" : "cc7772d1-e7d2-49ef-9254-0371879be922" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworkcreatecontainerfails235600aea25610?restype=container&sv=2019-02-02&ss=b&srt=sco&se=2019-11-26T17%3A09%3A34Z&sp=r&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "3f204df6-d2f2-491b-9a41-24a66eab3fe8" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "AuthorizationPermissionMismatch", + "retry-after" : "0", + "Content-Length" : "279", + "StatusCode" : "403", + "x-ms-request-id" : "d921ddc4-401e-0028-48b3-a3f393000000", + "Body" : "AuthorizationPermissionMismatchThis request is not authorized to perform this operation using this permission.\nRequestId:d921ddc4-401e-0028-48b3-a3f393000000\nTime:2019-11-25T17:09:34.6217728Z", + "Date" : "Mon, 25 Nov 2019 17:09:34 GMT", + "x-ms-client-request-id" : "3f204df6-d2f2-491b-9a41-24a66eab3fe8", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcaccountsasnetworkcreatecontainerfails&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "808c8d94-4616-4c63-9898-5795bf3ddbba" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a251d-a01e-0020-0ab3-a3e99c000000", + "Body" : "jtcaccountsasnetworkcreatecontainerfailsjtcaccountsasnetworkcreatecontainerfails076243fee1aaefMon, 25 Nov 2019 17:09:34 GMT\"0x8D771CA3EA2B5A4\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:34 GMT", + "x-ms-client-request-id" : "808c8d94-4616-4c63-9898-5795bf3ddbba", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworkcreatecontainerfails076243fee1aaef?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "c4e4157d-59c4-4369-aa1a-ffb637d2767d" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921ddc7-401e-0028-4bb3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:34 GMT", + "x-ms-client-request-id" : "c4e4157d-59c4-4369-aa1a-ffb637d2767d" + }, + "Exception" : null + } ], + "variables" : [ "jtcaccountsasnetworkcreatecontainerfails076243fee1aaef", "javablobaccountsasnetworkcreatecontainerfails1002608965aa", "2019-11-25T17:09:34.510036300Z", "jtcaccountsasnetworkcreatecontainerfails235600aea25610" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworkcreatecontainersucceeds.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworkcreatecontainersucceeds.json new file mode 100644 index 000000000000..003ce4409b93 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworkcreatecontainersucceeds.json @@ -0,0 +1,130 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworkcreatecontainersucceeds08444578c06ff?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "77246998-6b0e-4986-85f3-f0684dbd069b" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3EE6122B", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:34 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2522-a01e-0020-0fb3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:34 GMT", + "x-ms-client-request-id" : "77246998-6b0e-4986-85f3-f0684dbd069b" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworkcreatecontainersucceeds08444578c06ff/javablobaccountsasnetworkcreatecontainersucceeds16289375e8", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "f8618e85-6c37-4b53-9a30-3ee8280a26fc", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:34 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:34 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3EF44547", + "Content-Length" : "0", + "x-ms-request-id" : "d921ddcb-401e-0028-4eb3-a3f393000000", + "x-ms-client-request-id" : "f8618e85-6c37-4b53-9a30-3ee8280a26fc" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworkcreatecontainersucceeds2242025117420?restype=container&sv=2019-02-02&ss=b&srt=sco&se=2019-11-26T17%3A09%3A34Z&sp=rc&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "76b73494-3c02-4ca4-bc2f-52cf4b4f9dbf" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3F025210", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:35 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2528-a01e-0020-14b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:34 GMT", + "x-ms-client-request-id" : "76b73494-3c02-4ca4-bc2f-52cf4b4f9dbf" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcaccountsasnetworkcreatecontainersucceeds&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "7e3e052d-8f57-49ac-8f63-6a2d01247d3b" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "d921ddd1-401e-0028-54b3-a3f393000000", + "Body" : "jtcaccountsasnetworkcreatecontainersucceedsjtcaccountsasnetworkcreatecontainersucceeds08444578c06ffMon, 25 Nov 2019 17:09:34 GMT\"0x8D771CA3EE6122B\"unlockedavailable$account-encryption-keyfalsefalsefalsejtcaccountsasnetworkcreatecontainersucceeds2242025117420Mon, 25 Nov 2019 17:09:35 GMT\"0x8D771CA3F025210\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "x-ms-client-request-id" : "7e3e052d-8f57-49ac-8f63-6a2d01247d3b", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworkcreatecontainersucceeds08444578c06ff?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "6a3d1e04-2692-41f3-85d6-04421cde12a8" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "329a252a-a01e-0020-15b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "x-ms-client-request-id" : "6a3d1e04-2692-41f3-85d6-04421cde12a8" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworkcreatecontainersucceeds2242025117420?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "05e17388-cedb-4081-a9b9-d687fe0183de" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921ddd7-401e-0028-5ab3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "x-ms-client-request-id" : "05e17388-cedb-4081-a9b9-d687fe0183de" + }, + "Exception" : null + } ], + "variables" : [ "jtcaccountsasnetworkcreatecontainersucceeds08444578c06ff", "javablobaccountsasnetworkcreatecontainersucceeds16289375e8", "2019-11-25T17:09:34.952438Z", "jtcaccountsasnetworkcreatecontainersucceeds2242025117420" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworktestblobdeletefailsnewapi.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworktestblobdeletefailsnewapi.json new file mode 100644 index 000000000000..4c4def91eaa5 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworktestblobdeletefailsnewapi.json @@ -0,0 +1,112 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworktestblobdeletefailsnewapi07881604ae85?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "d247e5f8-80a0-4346-959d-0bf55f510aeb" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3E56F596", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:33 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2506-a01e-0020-7cb3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:33 GMT", + "x-ms-client-request-id" : "d247e5f8-80a0-4346-959d-0bf55f510aeb" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworktestblobdeletefailsnewapi07881604ae85/javablobaccountsasnetworktestblobdeletefailsnewapi191830c11", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "84d33a34-3955-43d8-bbfb-d95eed75c78f", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:34 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:33 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3E64885F", + "Content-Length" : "0", + "x-ms-request-id" : "d921ddad-401e-0028-36b3-a3f393000000", + "x-ms-client-request-id" : "84d33a34-3955-43d8-bbfb-d95eed75c78f" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworktestblobdeletefailsnewapi07881604ae85/javablobaccountsasnetworktestblobdeletefailsnewapi191830c11?sv=2019-02-02&ss=b&srt=sco&se=2019-11-26T17%3A09%3A34Z&sp=r&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "60e78f3e-ae7f-4dbf-a828-dc7ada190c5c" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "AuthorizationPermissionMismatch", + "retry-after" : "0", + "Content-Length" : "279", + "StatusCode" : "403", + "x-ms-request-id" : "329a250c-a01e-0020-80b3-a3e99c000000", + "Body" : "AuthorizationPermissionMismatchThis request is not authorized to perform this operation using this permission.\nRequestId:329a250c-a01e-0020-80b3-a3e99c000000\nTime:2019-11-25T17:09:34.1956005Z", + "Date" : "Mon, 25 Nov 2019 17:09:34 GMT", + "x-ms-client-request-id" : "60e78f3e-ae7f-4dbf-a828-dc7ada190c5c", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcaccountsasnetworktestblobdeletefailsnewapi&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "e3649be3-d6be-4fb4-abe3-fdb6431e3515" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "d921ddb6-401e-0028-3db3-a3f393000000", + "Body" : "jtcaccountsasnetworktestblobdeletefailsnewapijtcaccountsasnetworktestblobdeletefailsnewapi07881604ae85Mon, 25 Nov 2019 17:09:33 GMT\"0x8D771CA3E56F596\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:34 GMT", + "x-ms-client-request-id" : "e3649be3-d6be-4fb4-abe3-fdb6431e3515", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworktestblobdeletefailsnewapi07881604ae85?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "f0c3d472-dd66-4feb-ac43-930418ed5eed" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "329a2513-a01e-0020-04b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:34 GMT", + "x-ms-client-request-id" : "f0c3d472-dd66-4feb-ac43-930418ed5eed" + }, + "Exception" : null + } ], + "variables" : [ "jtcaccountsasnetworktestblobdeletefailsnewapi07881604ae85", "javablobaccountsasnetworktestblobdeletefailsnewapi191830c11", "2019-11-25T17:09:34.007531800Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworktestblobread.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworktestblobread.json new file mode 100644 index 000000000000..c209702e4218 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsaccountsasnetworktestblobread.json @@ -0,0 +1,120 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworktestblobread063965c8d0e1aec29b?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "8cfbc713-53dc-45e8-8db8-4878c76a593c" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3E14CD79", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:33 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "d921dd90-401e-0028-1eb3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:33 GMT", + "x-ms-client-request-id" : "8cfbc713-53dc-45e8-8db8-4878c76a593c" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworktestblobread063965c8d0e1aec29b/javablobaccountsasnetworktestblobread1912206cb7fd2946", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "798df3d4-4416-4efb-b8c0-3ab5aa60467e", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:33 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:33 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3E22EB68", + "Content-Length" : "0", + "x-ms-request-id" : "329a2502-a01e-0020-79b3-a3e99c000000", + "x-ms-client-request-id" : "798df3d4-4416-4efb-b8c0-3ab5aa60467e" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworktestblobread063965c8d0e1aec29b/javablobaccountsasnetworktestblobread1912206cb7fd2946?sv=2019-02-02&ss=b&srt=sco&se=2019-11-26T17%3A09%3A33Z&sp=r&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "20f4b810-052f-48f1-80e8-4531b3eb7375" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:33 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Mon, 25 Nov 2019 17:09:33 GMT", + "x-ms-blob-type" : "BlockBlob", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "ETag" : "0x8D771CA3E22EB68", + "x-ms-creation-time" : "Mon, 25 Nov 2019 17:09:33 GMT", + "Content-Length" : "7", + "x-ms-request-id" : "d921dd9e-401e-0028-29b3-a3f393000000", + "Body" : "[100, 101, 102, 97, 117, 108, 116]", + "x-ms-client-request-id" : "20f4b810-052f-48f1-80e8-4531b3eb7375", + "Content-Type" : "application/octet-stream" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcaccountsasnetworktestblobread&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "d3c129ae-3d86-4b57-b750-96981916402e" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2504-a01e-0020-7bb3-a3e99c000000", + "Body" : "jtcaccountsasnetworktestblobreadjtcaccountsasnetworktestblobread063965c8d0e1aec29bMon, 25 Nov 2019 17:09:33 GMT\"0x8D771CA3E14CD79\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:33 GMT", + "x-ms-client-request-id" : "d3c129ae-3d86-4b57-b750-96981916402e", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcaccountsasnetworktestblobread063965c8d0e1aec29b?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "d1f2bbeb-e588-4ee8-8fd0-cc9885d72512" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921dda6-401e-0028-2fb3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:33 GMT", + "x-ms-client-request-id" : "d1f2bbeb-e588-4ee8-8fd0-cc9885d72512" + }, + "Exception" : null + } ], + "variables" : [ "jtcaccountsasnetworktestblobread063965c8d0e1aec29b", "javablobaccountsasnetworktestblobread1912206cb7fd2946", "2019-11-25T17:09:33.582213300Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[0].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[0].json new file mode 100644 index 000000000000..9a2eaa5dba28 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[0].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0463058d41c166e0034?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "61dfa141-f23b-4437-ac70-5172049e4ccb" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA40468D53", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:37 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a255d-a01e-0020-3bb3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "x-ms-client-request-id" : "61dfa141-f23b-4437-ac70-5172049e4ccb" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0463058d41c166e0034/javablobblobsasimplutilstringtosign186708b2d0527e4f0", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "901cdf90-3451-4259-9830-0ac54ca1e0d5", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:37 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA4053D554", + "Content-Length" : "0", + "x-ms-request-id" : "d921de09-401e-0028-09b3-a3f393000000", + "x-ms-client-request-id" : "901cdf90-3451-4259-9830-0ac54ca1e0d5" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosign&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "90312fee-d521-457f-ae7d-357b439f04ea" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2569-a01e-0020-46b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignjtcblobsasimplutilstringtosign0463058d41c166e0034Mon, 25 Nov 2019 17:09:37 GMT\"0x8D771CA40468D53\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "x-ms-client-request-id" : "90312fee-d521-457f-ae7d-357b439f04ea", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0463058d41c166e0034?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "006d331b-7103-4afd-842c-28ac24d46cda" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de13-401e-0028-13b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "x-ms-client-request-id" : "006d331b-7103-4afd-842c-28ac24d46cda" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosign0463058d41c166e0034", "javablobblobsasimplutilstringtosign186708b2d0527e4f0" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[1].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[1].json new file mode 100644 index 000000000000..2725ca07b74a --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[1].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign087850670b2ec7202b4?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "d4dcca0c-a0bb-4090-bf24-a72c9f65272b" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA4080965B", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:37 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2570-a01e-0020-4cb3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "x-ms-client-request-id" : "d4dcca0c-a0bb-4090-bf24-a72c9f65272b" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign087850670b2ec7202b4/javablobblobsasimplutilstringtosign18797451d18f06bd1", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "ab3a11d6-a62d-4e51-91c2-e669874c4bd5", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:37 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA408DD165", + "Content-Length" : "0", + "x-ms-request-id" : "d921de17-401e-0028-17b3-a3f393000000", + "x-ms-client-request-id" : "ab3a11d6-a62d-4e51-91c2-e669874c4bd5" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosign&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "53fda710-7497-41f6-aad9-755c537bf9a2" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2575-a01e-0020-4fb3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignjtcblobsasimplutilstringtosign087850670b2ec7202b4Mon, 25 Nov 2019 17:09:37 GMT\"0x8D771CA4080965B\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "x-ms-client-request-id" : "53fda710-7497-41f6-aad9-755c537bf9a2", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign087850670b2ec7202b4?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "b1de0e8d-10ce-4a99-af9e-6432a68ea6dc" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de18-401e-0028-18b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "x-ms-client-request-id" : "b1de0e8d-10ce-4a99-af9e-6432a68ea6dc" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosign087850670b2ec7202b4", "javablobblobsasimplutilstringtosign18797451d18f06bd1" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[2].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[2].json new file mode 100644 index 000000000000..a63171b0f9b8 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[2].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign090609bcb7101a2f174?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "e1939d0b-5d22-40a4-a599-7216fdd53d9d" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA40B59543", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:37 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a257c-a01e-0020-56b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "x-ms-client-request-id" : "e1939d0b-5d22-40a4-a599-7216fdd53d9d" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign090609bcb7101a2f174/javablobblobsasimplutilstringtosign186054183160ba113", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "fd98bf01-0f60-4d46-abff-417b8fddbdb8", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:38 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA40C25186", + "Content-Length" : "0", + "x-ms-request-id" : "d921de19-401e-0028-19b3-a3f393000000", + "x-ms-client-request-id" : "fd98bf01-0f60-4d46-abff-417b8fddbdb8" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosign&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "19dec871-5786-4743-aad8-d186afb2930b" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a257f-a01e-0020-58b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignjtcblobsasimplutilstringtosign090609bcb7101a2f174Mon, 25 Nov 2019 17:09:37 GMT\"0x8D771CA40B59543\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "x-ms-client-request-id" : "19dec871-5786-4743-aad8-d186afb2930b", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign090609bcb7101a2f174?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "469bab9d-867d-4b78-9216-55f0409725e2" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de1a-401e-0028-1ab3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "x-ms-client-request-id" : "469bab9d-867d-4b78-9216-55f0409725e2" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosign090609bcb7101a2f174", "javablobblobsasimplutilstringtosign186054183160ba113" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[3].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[3].json new file mode 100644 index 000000000000..4eee63f43ba5 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[3].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0267443cd2712355c94?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "345fef6c-077f-4924-bcdc-f55ca7654777" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA40EA1F07", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:38 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2588-a01e-0020-61b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:37 GMT", + "x-ms-client-request-id" : "345fef6c-077f-4924-bcdc-f55ca7654777" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0267443cd2712355c94/javablobblobsasimplutilstringtosign111531dfa94dbd346", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "7bcb687e-ef12-4367-badc-791e4b59ea3b", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:38 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:38 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA40F6F2E2", + "Content-Length" : "0", + "x-ms-request-id" : "d921de26-401e-0028-22b3-a3f393000000", + "x-ms-client-request-id" : "7bcb687e-ef12-4367-badc-791e4b59ea3b" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosign&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "e8441d22-bf5d-4bba-a736-f38a56f0fab2" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25ac-a01e-0020-03b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignjtcblobsasimplutilstringtosign0267443cd2712355c94Mon, 25 Nov 2019 17:09:38 GMT\"0x8D771CA40EA1F07\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:38 GMT", + "x-ms-client-request-id" : "e8441d22-bf5d-4bba-a736-f38a56f0fab2", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0267443cd2712355c94?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "522bde73-b604-4edc-911b-7ee53612c2c4" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de2a-401e-0028-26b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:38 GMT", + "x-ms-client-request-id" : "522bde73-b604-4edc-911b-7ee53612c2c4" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosign0267443cd2712355c94", "javablobblobsasimplutilstringtosign111531dfa94dbd346" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[4].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[4].json new file mode 100644 index 000000000000..3c9c696f45b9 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[4].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0515273d0eef27af664?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "3379ddb5-bb2f-4a21-a7a2-ced8d9a8fff5" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA411EA8AB", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:38 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25b3-a01e-0020-08b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:38 GMT", + "x-ms-client-request-id" : "3379ddb5-bb2f-4a21-a7a2-ced8d9a8fff5" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0515273d0eef27af664/javablobblobsasimplutilstringtosign1762500bbee9f7129", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "dbe1ea3e-ea54-48c7-90e4-4cf8f569dbf5", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:38 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:38 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA412B4A33", + "Content-Length" : "0", + "x-ms-request-id" : "d921de30-401e-0028-2cb3-a3f393000000", + "x-ms-client-request-id" : "dbe1ea3e-ea54-48c7-90e4-4cf8f569dbf5" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosign&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "09a59b74-9043-47d9-9dd9-155b45ff11ef" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25b5-a01e-0020-09b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignjtcblobsasimplutilstringtosign0515273d0eef27af664Mon, 25 Nov 2019 17:09:38 GMT\"0x8D771CA411EA8AB\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:38 GMT", + "x-ms-client-request-id" : "09a59b74-9043-47d9-9dd9-155b45ff11ef", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0515273d0eef27af664?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "c39ffdf7-d6eb-47ed-b75f-f595a39e9bc2" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de34-401e-0028-30b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:38 GMT", + "x-ms-client-request-id" : "c39ffdf7-d6eb-47ed-b75f-f595a39e9bc2" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosign0515273d0eef27af664", "javablobblobsasimplutilstringtosign1762500bbee9f7129" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[5].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[5].json new file mode 100644 index 000000000000..bb973749770d --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[5].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign027365656db45c9ed74?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "8554f3f2-052f-4270-b0e7-01673bbf6bab" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA41530C84", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:38 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25b7-a01e-0020-0ab3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:38 GMT", + "x-ms-client-request-id" : "8554f3f2-052f-4270-b0e7-01673bbf6bab" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign027365656db45c9ed74/javablobblobsasimplutilstringtosign17271941f335d5f26", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "4c8b68be-9f0b-42f9-b400-d9ff8a6b516d", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:39 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:38 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA415FC6DA", + "Content-Length" : "0", + "x-ms-request-id" : "d921de3c-401e-0028-37b3-a3f393000000", + "x-ms-client-request-id" : "4c8b68be-9f0b-42f9-b400-d9ff8a6b516d" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosign&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "78033a9c-4e0d-448b-ace3-c8d355647164" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25ba-a01e-0020-0cb3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignjtcblobsasimplutilstringtosign027365656db45c9ed74Mon, 25 Nov 2019 17:09:38 GMT\"0x8D771CA41530C84\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:38 GMT", + "x-ms-client-request-id" : "78033a9c-4e0d-448b-ace3-c8d355647164", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign027365656db45c9ed74?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "4105900b-8bed-4e3f-a580-13c53bdbd73a" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de43-401e-0028-3eb3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:38 GMT", + "x-ms-client-request-id" : "4105900b-8bed-4e3f-a580-13c53bdbd73a" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosign027365656db45c9ed74", "javablobblobsasimplutilstringtosign17271941f335d5f26" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[6].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[6].json new file mode 100644 index 000000000000..edc3197162a6 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[6].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign091866176b5675be3b4?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "810e7fbb-cf52-4f2e-b210-193bf76e5d43" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA41865C1E", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:39 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25c1-a01e-0020-13b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "x-ms-client-request-id" : "810e7fbb-cf52-4f2e-b210-193bf76e5d43" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign091866176b5675be3b4/javablobblobsasimplutilstringtosign137927f07f39a8200", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "812838a6-3bbd-4a98-857f-7f69848b9d97", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:39 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA41930C1F", + "Content-Length" : "0", + "x-ms-request-id" : "d921de53-401e-0028-49b3-a3f393000000", + "x-ms-client-request-id" : "812838a6-3bbd-4a98-857f-7f69848b9d97" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosign&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "b2b5cce7-a364-4cee-a4cc-fea4c7a0f430" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25c4-a01e-0020-15b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignjtcblobsasimplutilstringtosign091866176b5675be3b4Mon, 25 Nov 2019 17:09:39 GMT\"0x8D771CA41865C1E\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "x-ms-client-request-id" : "b2b5cce7-a364-4cee-a4cc-fea4c7a0f430", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign091866176b5675be3b4?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "9864f68d-f933-4294-bcb8-17457230ab60" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de5a-401e-0028-50b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "x-ms-client-request-id" : "9864f68d-f933-4294-bcb8-17457230ab60" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosign091866176b5675be3b4", "javablobblobsasimplutilstringtosign137927f07f39a8200" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[7].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[7].json new file mode 100644 index 000000000000..748592a5b145 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[7].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0552562cc1b1eee54b4?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "3568f391-2caa-4174-9e79-9ea2afb63f27" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA41B95EC2", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:39 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25c6-a01e-0020-17b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "x-ms-client-request-id" : "3568f391-2caa-4174-9e79-9ea2afb63f27" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0552562cc1b1eee54b4/javablobblobsasimplutilstringtosign162570189752dce69", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1e4c8d4b-7cbb-4002-b192-0fdecb47bfc9", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:39 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA41C62A20", + "Content-Length" : "0", + "x-ms-request-id" : "d921de5b-401e-0028-51b3-a3f393000000", + "x-ms-client-request-id" : "1e4c8d4b-7cbb-4002-b192-0fdecb47bfc9" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosign&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1a146747-bd35-4c5c-926c-2eb3c601cf94" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25ca-a01e-0020-1ab3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignjtcblobsasimplutilstringtosign0552562cc1b1eee54b4Mon, 25 Nov 2019 17:09:39 GMT\"0x8D771CA41B95EC2\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "x-ms-client-request-id" : "1a146747-bd35-4c5c-926c-2eb3c601cf94", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign0552562cc1b1eee54b4?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "872ffd63-00a4-419e-ac6b-d329c09e0355" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de63-401e-0028-59b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "x-ms-client-request-id" : "872ffd63-00a4-419e-ac6b-d329c09e0355" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosign0552562cc1b1eee54b4", "javablobblobsasimplutilstringtosign162570189752dce69" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[8].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[8].json new file mode 100644 index 000000000000..37681c6a00cb --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[8].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign05318598eb9e81af1c4?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "82ba6078-98f7-45f5-a46b-8c3707962fc9" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA41ED733D", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:39 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25cc-a01e-0020-1cb3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "x-ms-client-request-id" : "82ba6078-98f7-45f5-a46b-8c3707962fc9" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign05318598eb9e81af1c4/javablobblobsasimplutilstringtosign1314354c0b61e35df", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "5ec46370-79a6-48b3-9b38-622b11ed921d", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:40 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA41FA59C1", + "Content-Length" : "0", + "x-ms-request-id" : "d921de65-401e-0028-5bb3-a3f393000000", + "x-ms-client-request-id" : "5ec46370-79a6-48b3-9b38-622b11ed921d" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosign&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "9e7644f6-30c9-4ccd-96d2-697d64414d9e" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25cf-a01e-0020-1eb3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignjtcblobsasimplutilstringtosign05318598eb9e81af1c4Mon, 25 Nov 2019 17:09:39 GMT\"0x8D771CA41ED733D\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "x-ms-client-request-id" : "9e7644f6-30c9-4ccd-96d2-697d64414d9e", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign05318598eb9e81af1c4?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "ba06f286-0ef0-4d13-975c-fe5a1cba82fa" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de67-401e-0028-5db3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:39 GMT", + "x-ms-client-request-id" : "ba06f286-0ef0-4d13-975c-fe5a1cba82fa" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosign05318598eb9e81af1c4", "javablobblobsasimplutilstringtosign1314354c0b61e35df" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[9].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[9].json new file mode 100644 index 000000000000..a3f2bd19d9b6 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosign[9].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign022823f54d248018564?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "2c9704ac-1b25-4866-83a5-c75ac6d9b2bc" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA4221FCB7", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:40 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25d3-a01e-0020-22b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "x-ms-client-request-id" : "2c9704ac-1b25-4866-83a5-c75ac6d9b2bc" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign022823f54d248018564/javablobblobsasimplutilstringtosign139652c1e391d21f0", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "a20c7bd7-b3b5-42ea-812c-0f77e5167d5e", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:40 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA422F2536", + "Content-Length" : "0", + "x-ms-request-id" : "d921de6a-401e-0028-5fb3-a3f393000000", + "x-ms-client-request-id" : "a20c7bd7-b3b5-42ea-812c-0f77e5167d5e" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosign&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "773a9382-7948-4610-a910-31f3b0ed0b96" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25d6-a01e-0020-24b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignjtcblobsasimplutilstringtosign022823f54d248018564Mon, 25 Nov 2019 17:09:40 GMT\"0x8D771CA4221FCB7\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "x-ms-client-request-id" : "773a9382-7948-4610-a910-31f3b0ed0b96", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosign022823f54d248018564?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "4ed1b3db-0752-4cb4-a766-5dbec552e9d6" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de74-401e-0028-68b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "x-ms-client-request-id" : "4ed1b3db-0752-4cb4-a766-5dbec552e9d6" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosign022823f54d248018564", "javablobblobsasimplutilstringtosign139652c1e391d21f0" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[0].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[0].json new file mode 100644 index 000000000000..cdc67a31822f --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[0].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey03929314ec0?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "17bf3bd0-45f0-438a-8728-ead5bc8548cb" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA425770FD", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:40 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25d9-a01e-0020-27b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "x-ms-client-request-id" : "17bf3bd0-45f0-438a-8728-ead5bc8548cb" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey03929314ec0/javablobblobsasimplutilstringtosignuserdelegationkey18484377", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "c1441cd8-bf6f-4300-b81a-313506e4808a", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:40 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA42641802", + "Content-Length" : "0", + "x-ms-request-id" : "d921de7b-401e-0028-6fb3-a3f393000000", + "x-ms-client-request-id" : "c1441cd8-bf6f-4300-b81a-313506e4808a" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "2b050d2b-1012-40fd-b3b7-5ca58024b26d" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25de-a01e-0020-2bb3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey03929314ec0Mon, 25 Nov 2019 17:09:40 GMT\"0x8D771CA425770FD\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "x-ms-client-request-id" : "2b050d2b-1012-40fd-b3b7-5ca58024b26d", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey03929314ec0?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "c2f7048a-0f8b-4f1a-bfa9-c2e03bef9400" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de84-401e-0028-78b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "x-ms-client-request-id" : "c2f7048a-0f8b-4f1a-bfa9-c2e03bef9400" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey03929314ec0", "javablobblobsasimplutilstringtosignuserdelegationkey18484377" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[10].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[10].json new file mode 100644 index 000000000000..4d11d89351ee --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[10].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey0911422df83?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "e2c7c4f3-f72d-4adf-b139-9ae403b05719" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA44743E15", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:44 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2634-a01e-0020-71b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "x-ms-client-request-id" : "e2c7c4f3-f72d-4adf-b139-9ae403b05719" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey0911422df83/javablobblobsasimplutilstringtosignuserdelegationkey17029077", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "07ff9eb9-c7f9-4de4-a409-e820600f60f7", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:44 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA44812BD3", + "Content-Length" : "0", + "x-ms-request-id" : "d921deee-401e-0028-5cb3-a3f393000000", + "x-ms-client-request-id" : "07ff9eb9-c7f9-4de4-a409-e820600f60f7" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "9c2ceb83-aab0-4db9-90de-04e2c0e46a24" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2636-a01e-0020-72b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey0911422df83Mon, 25 Nov 2019 17:09:44 GMT\"0x8D771CA44743E15\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "x-ms-client-request-id" : "9c2ceb83-aab0-4db9-90de-04e2c0e46a24", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey0911422df83?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "bc286259-1529-4755-80ee-06c9676d99cc" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921def7-401e-0028-65b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "x-ms-client-request-id" : "bc286259-1529-4755-80ee-06c9676d99cc" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey0911422df83", "javablobblobsasimplutilstringtosignuserdelegationkey17029077" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[11].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[11].json new file mode 100644 index 000000000000..018c7281272e --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[11].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey073672052c1?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "c8220a33-4d9c-495c-ad95-345a44f3e149" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA44A9D96E", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:44 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2638-a01e-0020-74b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "x-ms-client-request-id" : "c8220a33-4d9c-495c-ad95-345a44f3e149" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey073672052c1/javablobblobsasimplutilstringtosignuserdelegationkey14339622", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "88d7bde6-b5cc-4e41-a4f5-3e61df2ef113", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:44 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA44B66E35", + "Content-Length" : "0", + "x-ms-request-id" : "d921defc-401e-0028-6ab3-a3f393000000", + "x-ms-client-request-id" : "88d7bde6-b5cc-4e41-a4f5-3e61df2ef113" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "b4d1fcb3-c8f6-4699-96f8-ff61d4b0462e" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a263d-a01e-0020-78b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey073672052c1Mon, 25 Nov 2019 17:09:44 GMT\"0x8D771CA44A9D96E\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "x-ms-client-request-id" : "b4d1fcb3-c8f6-4699-96f8-ff61d4b0462e", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey073672052c1?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "e204e9f3-d4dd-4414-8442-4d6b23c168df" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921deff-401e-0028-6db3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "x-ms-client-request-id" : "e204e9f3-d4dd-4414-8442-4d6b23c168df" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey073672052c1", "javablobblobsasimplutilstringtosignuserdelegationkey14339622" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[12].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[12].json new file mode 100644 index 000000000000..8eef25ffad03 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[12].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey087868008c3?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "4b031ff5-ca8a-4b83-ad05-0f3eef129bd3" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA44DD034A", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:44 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a265a-a01e-0020-13b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "x-ms-client-request-id" : "4b031ff5-ca8a-4b83-ad05-0f3eef129bd3" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey087868008c3/javablobblobsasimplutilstringtosignuserdelegationkey176754ba", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "f22e68f2-58c9-449c-8987-5ca6f0c11bb4", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:44 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA44EA2814", + "Content-Length" : "0", + "x-ms-request-id" : "d921df02-401e-0028-70b3-a3f393000000", + "x-ms-client-request-id" : "f22e68f2-58c9-449c-8987-5ca6f0c11bb4" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "870478da-c203-4391-9e16-4077783088fe" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a265c-a01e-0020-14b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey087868008c3Mon, 25 Nov 2019 17:09:44 GMT\"0x8D771CA44DD034A\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "x-ms-client-request-id" : "870478da-c203-4391-9e16-4077783088fe", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey087868008c3?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "9c6ed92e-7e62-4d93-b6d9-aa786ce575bb" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921df08-401e-0028-73b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "x-ms-client-request-id" : "9c6ed92e-7e62-4d93-b6d9-aa786ce575bb" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey087868008c3", "javablobblobsasimplutilstringtosignuserdelegationkey176754ba" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[13].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[13].json new file mode 100644 index 000000000000..ee041df063d9 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[13].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey071397cb8b8?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "47442d80-8cb1-41cb-99dc-6718339993d8" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA4512525D", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:45 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2662-a01e-0020-1ab3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "x-ms-client-request-id" : "47442d80-8cb1-41cb-99dc-6718339993d8" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey071397cb8b8/javablobblobsasimplutilstringtosignuserdelegationkey1974360c", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "3f1c5377-62ae-442e-8072-74a24c9c94cb", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:45 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA451F41EE", + "Content-Length" : "0", + "x-ms-request-id" : "d921df0c-401e-0028-77b3-a3f393000000", + "x-ms-client-request-id" : "3f1c5377-62ae-442e-8072-74a24c9c94cb" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "9b635e35-c3c8-4186-adf1-4edc7d92488e" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2666-a01e-0020-1db3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey071397cb8b8Mon, 25 Nov 2019 17:09:45 GMT\"0x8D771CA4512525D\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:44 GMT", + "x-ms-client-request-id" : "9b635e35-c3c8-4186-adf1-4edc7d92488e", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey071397cb8b8?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1825ee2b-0841-429a-9c29-7e1b20dbb3b4" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921df13-401e-0028-7eb3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:45 GMT", + "x-ms-client-request-id" : "1825ee2b-0841-429a-9c29-7e1b20dbb3b4" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey071397cb8b8", "javablobblobsasimplutilstringtosignuserdelegationkey1974360c" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[14].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[14].json new file mode 100644 index 000000000000..b60c90395158 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[14].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey08761697965?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "46a71f5f-4b60-4f5d-8e93-f9e941f4975a" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA45522760", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:45 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a266e-a01e-0020-22b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:45 GMT", + "x-ms-client-request-id" : "46a71f5f-4b60-4f5d-8e93-f9e941f4975a" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey08761697965/javablobblobsasimplutilstringtosignuserdelegationkey18532120", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "812aa35b-d09d-4dfe-ae57-3b37360691e8", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:45 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:45 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA455EE171", + "Content-Length" : "0", + "x-ms-request-id" : "d921df17-401e-0028-02b3-a3f393000000", + "x-ms-client-request-id" : "812aa35b-d09d-4dfe-ae57-3b37360691e8" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "d20231f8-d8d3-4247-a81f-9e42ff4d45fb" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2678-a01e-0020-28b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey08761697965Mon, 25 Nov 2019 17:09:45 GMT\"0x8D771CA45522760\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:45 GMT", + "x-ms-client-request-id" : "d20231f8-d8d3-4247-a81f-9e42ff4d45fb", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey08761697965?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "04fe76a1-e261-4a62-aabb-6713f571b879" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921df1d-401e-0028-08b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:45 GMT", + "x-ms-client-request-id" : "04fe76a1-e261-4a62-aabb-6713f571b879" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey08761697965", "javablobblobsasimplutilstringtosignuserdelegationkey18532120" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[1].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[1].json new file mode 100644 index 000000000000..96d5021204a4 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[1].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey076590ba3a2?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "e2e8c27c-3861-4978-9aeb-5621a9f15bb9" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA428CE51F", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:41 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25e2-a01e-0020-2eb3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "x-ms-client-request-id" : "e2e8c27c-3861-4978-9aeb-5621a9f15bb9" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey076590ba3a2/javablobblobsasimplutilstringtosignuserdelegationkey14828914", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "4da07904-c3da-4c0e-a30d-e07db571ea0f", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:41 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA4299F510", + "Content-Length" : "0", + "x-ms-request-id" : "d921de87-401e-0028-7bb3-a3f393000000", + "x-ms-client-request-id" : "4da07904-c3da-4c0e-a30d-e07db571ea0f" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "cfda1de5-59f6-4938-815b-c60e35dca2e8" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25e6-a01e-0020-31b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey076590ba3a2Mon, 25 Nov 2019 17:09:41 GMT\"0x8D771CA428CE51F\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "x-ms-client-request-id" : "cfda1de5-59f6-4938-815b-c60e35dca2e8", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey076590ba3a2?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "bd56ebd5-40ab-444a-a2ae-b76993391517" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de8a-401e-0028-7eb3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:40 GMT", + "x-ms-client-request-id" : "bd56ebd5-40ab-444a-a2ae-b76993391517" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey076590ba3a2", "javablobblobsasimplutilstringtosignuserdelegationkey14828914" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[2].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[2].json new file mode 100644 index 000000000000..c298fa0f3b80 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[2].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey025795e26ed?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "7103f67b-3a77-47a0-ab28-18ab0fef0e92" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA42C0AB52", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:41 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25e7-a01e-0020-32b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:41 GMT", + "x-ms-client-request-id" : "7103f67b-3a77-47a0-ab28-18ab0fef0e92" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey025795e26ed/javablobblobsasimplutilstringtosignuserdelegationkey13714371", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "e71c0ff3-8ab5-4147-b8c0-9f3fbc123e14", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:41 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:41 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA42CD87F5", + "Content-Length" : "0", + "x-ms-request-id" : "d921de91-401e-0028-05b3-a3f393000000", + "x-ms-client-request-id" : "e71c0ff3-8ab5-4147-b8c0-9f3fbc123e14" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "cd9d80cf-5f7d-47ac-8fc6-13a75ec2eac1" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25eb-a01e-0020-35b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey025795e26edMon, 25 Nov 2019 17:09:41 GMT\"0x8D771CA42C0AB52\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:41 GMT", + "x-ms-client-request-id" : "cd9d80cf-5f7d-47ac-8fc6-13a75ec2eac1", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey025795e26ed?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "beff9c5a-99a9-4e9b-a278-216d4e98a20a" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de92-401e-0028-06b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:41 GMT", + "x-ms-client-request-id" : "beff9c5a-99a9-4e9b-a278-216d4e98a20a" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey025795e26ed", "javablobblobsasimplutilstringtosignuserdelegationkey13714371" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[3].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[3].json new file mode 100644 index 000000000000..077c257e7a6a --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[3].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey02017629dee?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "c7eafce6-9e33-419a-b024-7e3d664ef873" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA42FCD7C1", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:41 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25ef-a01e-0020-39b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:41 GMT", + "x-ms-client-request-id" : "c7eafce6-9e33-419a-b024-7e3d664ef873" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey02017629dee/javablobblobsasimplutilstringtosignuserdelegationkey1487395a", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "fcf0088c-bc82-4b4f-b863-7abd2ff52a22", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:41 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:41 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA430A1DB3", + "Content-Length" : "0", + "x-ms-request-id" : "d921de99-401e-0028-0cb3-a3f393000000", + "x-ms-client-request-id" : "fcf0088c-bc82-4b4f-b863-7abd2ff52a22" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "444e0192-6069-4832-862d-81f4f040601a" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25f5-a01e-0020-3eb3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey02017629deeMon, 25 Nov 2019 17:09:41 GMT\"0x8D771CA42FCD7C1\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:41 GMT", + "x-ms-client-request-id" : "444e0192-6069-4832-862d-81f4f040601a", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey02017629dee?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "62c90758-67a0-45c4-89c4-5614d6853ec6" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921dea2-401e-0028-14b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:41 GMT", + "x-ms-client-request-id" : "62c90758-67a0-45c4-89c4-5614d6853ec6" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey02017629dee", "javablobblobsasimplutilstringtosignuserdelegationkey1487395a" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[4].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[4].json new file mode 100644 index 000000000000..83bffc113e07 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[4].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey02473993d39?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "2f7cb5d5-08f6-4a0f-a233-56b88bad837e" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA4332E9E3", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:42 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25f8-a01e-0020-41b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:41 GMT", + "x-ms-client-request-id" : "2f7cb5d5-08f6-4a0f-a233-56b88bad837e" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey02473993d39/javablobblobsasimplutilstringtosignuserdelegationkey12957369", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "bdda2274-cc6e-4928-a0bf-8c965996888e", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:42 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:41 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA434724D2", + "Content-Length" : "0", + "x-ms-request-id" : "d921deaa-401e-0028-1bb3-a3f393000000", + "x-ms-client-request-id" : "bdda2274-cc6e-4928-a0bf-8c965996888e" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "55a8a088-e0d0-4abf-9394-a22c5335a534" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a25fc-a01e-0020-44b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey02473993d39Mon, 25 Nov 2019 17:09:42 GMT\"0x8D771CA4332E9E3\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:41 GMT", + "x-ms-client-request-id" : "55a8a088-e0d0-4abf-9394-a22c5335a534", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey02473993d39?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "34cdc826-6bf8-41d6-a701-6e87c0448899" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921deb1-401e-0028-22b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "x-ms-client-request-id" : "34cdc826-6bf8-41d6-a701-6e87c0448899" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey02473993d39", "javablobblobsasimplutilstringtosignuserdelegationkey12957369" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[5].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[5].json new file mode 100644 index 000000000000..c608e28d7826 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[5].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey063410f139f?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "588641a6-3e27-46ba-91b5-f9b352b76400" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA436E9FA5", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:42 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a25ff-a01e-0020-47b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "x-ms-client-request-id" : "588641a6-3e27-46ba-91b5-f9b352b76400" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey063410f139f/javablobblobsasimplutilstringtosignuserdelegationkey15231708", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "5e000009-d9b0-4e67-84a4-8d742f037b38", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:42 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA437B7B4A", + "Content-Length" : "0", + "x-ms-request-id" : "d921deba-401e-0028-2bb3-a3f393000000", + "x-ms-client-request-id" : "5e000009-d9b0-4e67-84a4-8d742f037b38" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "7679cfa3-3008-4b68-ae82-50b611604580" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2605-a01e-0020-4ab3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey063410f139fMon, 25 Nov 2019 17:09:42 GMT\"0x8D771CA436E9FA5\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "x-ms-client-request-id" : "7679cfa3-3008-4b68-ae82-50b611604580", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey063410f139f?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "be4c4b26-f15b-4237-86b1-420aadd1cb2b" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921dec1-401e-0028-31b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "x-ms-client-request-id" : "be4c4b26-f15b-4237-86b1-420aadd1cb2b" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey063410f139f", "javablobblobsasimplutilstringtosignuserdelegationkey15231708" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[6].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[6].json new file mode 100644 index 000000000000..11e44901c188 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[6].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey029045b1b81?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "51dcda44-364e-400f-a969-120bcf6d6d7f" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA43A39E85", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:42 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2607-a01e-0020-4cb3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "x-ms-client-request-id" : "51dcda44-364e-400f-a969-120bcf6d6d7f" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey029045b1b81/javablobblobsasimplutilstringtosignuserdelegationkey19564401", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "fedae4f4-3ada-4bd6-8043-0080f6587597", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:42 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA43B13130", + "Content-Length" : "0", + "x-ms-request-id" : "d921dec9-401e-0028-38b3-a3f393000000", + "x-ms-client-request-id" : "fedae4f4-3ada-4bd6-8043-0080f6587597" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "413f7f34-ffb9-4f4d-9c13-9d6ebea3dc44" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a260c-a01e-0020-50b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey029045b1b81Mon, 25 Nov 2019 17:09:42 GMT\"0x8D771CA43A39E85\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "x-ms-client-request-id" : "413f7f34-ffb9-4f4d-9c13-9d6ebea3dc44", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey029045b1b81?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "f27c654c-e491-44f2-9eb1-79dd86dfaf7d" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921dece-401e-0028-3db3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "x-ms-client-request-id" : "f27c654c-e491-44f2-9eb1-79dd86dfaf7d" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey029045b1b81", "javablobblobsasimplutilstringtosignuserdelegationkey19564401" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[7].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[7].json new file mode 100644 index 000000000000..4cbeb8bf3e1b --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[7].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey05135850d25?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "e9346af3-28e3-463d-a749-4f1f69bcf7df" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA43D8C749", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:43 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2610-a01e-0020-54b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "x-ms-client-request-id" : "e9346af3-28e3-463d-a749-4f1f69bcf7df" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey05135850d25/javablobblobsasimplutilstringtosignuserdelegationkey1064067d", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "4cc00dcd-2048-4bb5-89f1-cc25455ebac0", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:43 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA43E5FCDD", + "Content-Length" : "0", + "x-ms-request-id" : "d921ded2-401e-0028-41b3-a3f393000000", + "x-ms-client-request-id" : "4cc00dcd-2048-4bb5-89f1-cc25455ebac0" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "a70d7206-8a61-44ab-be99-94e595a86415" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2615-a01e-0020-58b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey05135850d25Mon, 25 Nov 2019 17:09:43 GMT\"0x8D771CA43D8C749\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:42 GMT", + "x-ms-client-request-id" : "a70d7206-8a61-44ab-be99-94e595a86415", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey05135850d25?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1960b173-a6a6-4b08-8369-f74dea612dd1" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921ded9-401e-0028-48b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "x-ms-client-request-id" : "1960b173-a6a6-4b08-8369-f74dea612dd1" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey05135850d25", "javablobblobsasimplutilstringtosignuserdelegationkey1064067d" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[8].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[8].json new file mode 100644 index 000000000000..8b9b91e65748 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[8].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey062690f6788?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1b7b4e56-245a-4cef-83fd-5dafa0db0a5c" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA440D2856", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:43 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2619-a01e-0020-5bb3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "x-ms-client-request-id" : "1b7b4e56-245a-4cef-83fd-5dafa0db0a5c" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey062690f6788/javablobblobsasimplutilstringtosignuserdelegationkey1301424f", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "35067472-55ca-46f3-a672-7b65065a6465", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:43 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA4419DE5A", + "Content-Length" : "0", + "x-ms-request-id" : "d921dee0-401e-0028-4fb3-a3f393000000", + "x-ms-client-request-id" : "35067472-55ca-46f3-a672-7b65065a6465" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "37a8d9b4-ae37-4e62-8c68-eadec0481be6" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2621-a01e-0020-62b3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey062690f6788Mon, 25 Nov 2019 17:09:43 GMT\"0x8D771CA440D2856\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "x-ms-client-request-id" : "37a8d9b4-ae37-4e62-8c68-eadec0481be6", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey062690f6788?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "d52840a9-fb7e-4fe0-8d82-dcab473ff939" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921dee3-401e-0028-52b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "x-ms-client-request-id" : "d52840a9-fb7e-4fe0-8d82-dcab473ff939" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey062690f6788", "javablobblobsasimplutilstringtosignuserdelegationkey1301424f" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[9].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[9].json new file mode 100644 index 000000000000..85080524a4f8 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobsasimplutilstringtosignuserdelegationkey[9].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey08747327bcc?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "b6150a2b-88ba-482e-8933-2989533a206c" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA4440C76C", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:43 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2627-a01e-0020-68b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "x-ms-client-request-id" : "b6150a2b-88ba-482e-8933-2989533a206c" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey08747327bcc/javablobblobsasimplutilstringtosignuserdelegationkey1203842b", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "4f747b0f-dd88-4121-8790-c525adb922f9", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:43 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA444D71D3", + "Content-Length" : "0", + "x-ms-request-id" : "d921dee4-401e-0028-53b3-a3f393000000", + "x-ms-client-request-id" : "4f747b0f-dd88-4121-8790-c525adb922f9" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobsasimplutilstringtosignuserdelegationkey&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "10d5415a-9a2d-47cd-a017-05d21bc44861" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2630-a01e-0020-6fb3-a3e99c000000", + "Body" : "jtcblobsasimplutilstringtosignuserdelegationkeyjtcblobsasimplutilstringtosignuserdelegationkey08747327bccMon, 25 Nov 2019 17:09:43 GMT\"0x8D771CA4440C76C\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "x-ms-client-request-id" : "10d5415a-9a2d-47cd-a017-05d21bc44861", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobsasimplutilstringtosignuserdelegationkey08747327bcc?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "9eb6bb8d-5bae-457d-9368-5c6739e02ae3" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921dee8-401e-0028-57b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:43 GMT", + "x-ms-client-request-id" : "9eb6bb8d-5bae-457d-9368-5c6739e02ae3" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobsasimplutilstringtosignuserdelegationkey08747327bcc", "javablobblobsasimplutilstringtosignuserdelegationkey1203842b" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobservicesasnetworktestblobsnapshot.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobservicesasnetworktestblobsnapshot.json new file mode 100644 index 000000000000..9ad3b844f492 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsblobservicesasnetworktestblobsnapshot.json @@ -0,0 +1,197 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobservicesasnetworktestblobsnapshot057825a9fde690?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1f44cfe0-ab8a-4c8d-b597-1056ab533f7c" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3C8E00AF", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:30 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a24b1-a01e-0020-3db3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:30 GMT", + "x-ms-client-request-id" : "1f44cfe0-ab8a-4c8d-b597-1056ab533f7c" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobservicesasnetworktestblobsnapshot057825a9fde690/javablobblobservicesasnetworktestblobsnapshot136413f6bd2f", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "4f682785-9445-4a1b-a2e8-ab520f9737d5", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:31 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:30 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3C9AEB92", + "Content-Length" : "0", + "x-ms-request-id" : "d921dd27-401e-0028-44b3-a3f393000000", + "x-ms-client-request-id" : "4f682785-9445-4a1b-a2e8-ab520f9737d5" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobservicesasnetworktestblobsnapshot057825a9fde690/javablobblobservicesasnetworktestblobsnapshot136413f6bd2f?comp=snapshot", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "c8870872-28d4-45f8-8ae0-6009013eebfb" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "x-ms-snapshot" : "2019-11-25T17:09:31.1292895Z", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3C9AEB92", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:31 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a24bc-a01e-0020-44b3-a3e99c000000", + "x-ms-request-server-encrypted" : "false", + "Date" : "Mon, 25 Nov 2019 17:09:30 GMT", + "x-ms-client-request-id" : "c8870872-28d4-45f8-8ae0-6009013eebfb" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobservicesasnetworktestblobsnapshot057825a9fde690/javablobblobservicesasnetworktestblobsnapshot136413f6bd2f?sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A31Z&se=2019-11-26T17%3A09%3A31Z&sip=0.0.0.0-255.255.255.255&sr=bs&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "171103a0-02b8-4b2b-8188-de23e67beab2" + }, + "Response" : { + "Server" : "Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "AuthenticationFailed", + "retry-after" : "0", + "Content-Length" : "447", + "StatusCode" : "403", + "x-ms-request-id" : "d921dd2f-401e-0028-4bb3-a3f393000000", + "Body" : "AuthenticationFailedServer failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nRequestId:d921dd2f-401e-0028-4bb3-a3f393000000\nTime:2019-11-25T17:09:31.2147725ZThe specified signed resource is not allowed for the this resource level", + "Date" : "Mon, 25 Nov 2019 17:09:30 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobservicesasnetworktestblobsnapshot057825a9fde690/javablobblobservicesasnetworktestblobsnapshot136413f6bd2f?snapshot=2019-11-25T17%3a09%3a31.1292895Z&sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A31Z&se=2019-11-26T17%3A09%3A31Z&sip=0.0.0.0-255.255.255.255&sr=bs&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "acdff660-793e-45f4-b116-9deb5acab1d3" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:31 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Mon, 25 Nov 2019 17:09:30 GMT", + "x-ms-blob-type" : "BlockBlob", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "Cache-Control" : "cache", + "ETag" : "0x8D771CA3C9AEB92", + "Content-Disposition" : "disposition", + "x-ms-creation-time" : "Mon, 25 Nov 2019 17:09:31 GMT", + "Content-Length" : "7", + "x-ms-request-id" : "329a24c3-a01e-0020-47b3-a3e99c000000", + "Body" : "default", + "x-ms-client-request-id" : "acdff660-793e-45f4-b116-9deb5acab1d3", + "Content-Language" : "language", + "Content-Type" : "type" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobservicesasnetworktestblobsnapshot057825a9fde690/javablobblobservicesasnetworktestblobsnapshot136413f6bd2f?snapshot=2019-11-25T17%3a09%3a31.1292895Z&sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A31Z&se=2019-11-26T17%3A09%3A31Z&sip=0.0.0.0-255.255.255.255&sr=bs&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "08758b9e-a78e-42d6-9962-b47a8b017b7c" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:31 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Mon, 25 Nov 2019 17:09:30 GMT", + "x-ms-blob-type" : "BlockBlob", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "Cache-Control" : "cache", + "ETag" : "0x8D771CA3C9AEB92", + "Content-Disposition" : "disposition", + "Content-Encoding" : "encoding", + "x-ms-creation-time" : "Mon, 25 Nov 2019 17:09:31 GMT", + "Content-Length" : "7", + "x-ms-request-id" : "d921dd37-401e-0028-53b3-a3f393000000", + "x-ms-client-request-id" : "08758b9e-a78e-42d6-9962-b47a8b017b7c", + "Content-Language" : "language", + "Content-Type" : "type" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcblobservicesasnetworktestblobsnapshot&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "9470105e-7885-4f46-812f-51b073db267a" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a24c4-a01e-0020-48b3-a3e99c000000", + "Body" : "jtcblobservicesasnetworktestblobsnapshotjtcblobservicesasnetworktestblobsnapshot057825a9fde690Mon, 25 Nov 2019 17:09:30 GMT\"0x8D771CA3C8E00AF\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:30 GMT", + "x-ms-client-request-id" : "9470105e-7885-4f46-812f-51b073db267a", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcblobservicesasnetworktestblobsnapshot057825a9fde690?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "75a8ba08-34bd-4e3d-9cac-1c64ea4c3a3c" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921dd44-401e-0028-5db3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:30 GMT", + "x-ms-client-request-id" : "75a8ba08-34bd-4e3d-9cac-1c64ea4c3a3c" + }, + "Exception" : null + } ], + "variables" : [ "jtcblobservicesasnetworktestblobsnapshot057825a9fde690", "javablobblobservicesasnetworktestblobsnapshot136413f6bd2f", "2019-11-25T17:09:31.104721500Z", "2019-11-25T17:09:31.104721500Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateillegalargument.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateillegalargument.json new file mode 100644 index 000000000000..597a5de858bc --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateillegalargument.json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateillegalargument079451bb4ed7a903b84a?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1c829f9c-6441-4ffe-abb5-089597b1b5f1" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3F6F36E1", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:35 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2538-a01e-0020-20b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "x-ms-client-request-id" : "1c829f9c-6441-4ffe-abb5-089597b1b5f1" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateillegalargument079451bb4ed7a903b84a/javablobensurestateillegalargument1735024ef73b455fa", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "5966c7ad-6979-488e-9423-f464a2492962", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:35 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3F7C3A0F", + "Content-Length" : "0", + "x-ms-request-id" : "d921dde0-401e-0028-63b3-a3f393000000", + "x-ms-client-request-id" : "5966c7ad-6979-488e-9423-f464a2492962" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcensurestateillegalargument&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "a42eedd9-5026-415a-b105-bf33f01f3d5a" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a253a-a01e-0020-21b3-a3e99c000000", + "Body" : "jtcensurestateillegalargumentjtcensurestateillegalargument079451bb4ed7a903b84aMon, 25 Nov 2019 17:09:35 GMT\"0x8D771CA3F6F36E1\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "x-ms-client-request-id" : "a42eedd9-5026-415a-b105-bf33f01f3d5a", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateillegalargument079451bb4ed7a903b84a?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "a2958187-6472-4e14-9053-9992d83790dd" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921dde3-401e-0028-66b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "x-ms-client-request-id" : "a2958187-6472-4e14-9053-9992d83790dd" + }, + "Exception" : null + } ], + "variables" : [ "jtcensurestateillegalargument079451bb4ed7a903b84a", "javablobensurestateillegalargument1735024ef73b455fa" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[0].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[0].json new file mode 100644 index 000000000000..4be15ef72253 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[0].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateresourceandpermission044225f9396c21d36?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "841416d0-62a4-4995-bc4f-d0b429e8525b" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3FA56F75", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:36 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2546-a01e-0020-2ab3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "x-ms-client-request-id" : "841416d0-62a4-4995-bc4f-d0b429e8525b" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateresourceandpermission044225f9396c21d36/javablobensurestateresourceandpermission19187238b020bb", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1df17c3d-27b1-4e78-bf4b-9d688c900d95", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:36 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3FB23DF3", + "Content-Length" : "0", + "x-ms-request-id" : "d921dde9-401e-0028-6cb3-a3f393000000", + "x-ms-client-request-id" : "1df17c3d-27b1-4e78-bf4b-9d688c900d95" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcensurestateresourceandpermission&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "e4b1464c-d4f6-4ab7-918b-2f3a28da8ced" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2549-a01e-0020-2cb3-a3e99c000000", + "Body" : "jtcensurestateresourceandpermissionjtcensurestateresourceandpermission044225f9396c21d36Mon, 25 Nov 2019 17:09:36 GMT\"0x8D771CA3FA56F75\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "x-ms-client-request-id" : "e4b1464c-d4f6-4ab7-918b-2f3a28da8ced", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateresourceandpermission044225f9396c21d36?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "2828ab16-2b9f-44ce-8dd9-a96b66ee39ff" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921ddeb-401e-0028-6eb3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "x-ms-client-request-id" : "2828ab16-2b9f-44ce-8dd9-a96b66ee39ff" + }, + "Exception" : null + } ], + "variables" : [ "jtcensurestateresourceandpermission044225f9396c21d36", "javablobensurestateresourceandpermission19187238b020bb" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[1].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[1].json new file mode 100644 index 000000000000..dc1fa056ca50 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[1].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateresourceandpermission067424a73973c26da?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1f73436c-0907-4d87-b210-c7a49431fe85" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3FD90C4B", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:36 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2550-a01e-0020-31b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "x-ms-client-request-id" : "1f73436c-0907-4d87-b210-c7a49431fe85" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateresourceandpermission067424a73973c26da/javablobensurestateresourceandpermission162311a8707d07", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "c3c3191d-b7e1-47db-95d8-5452fadf39f6", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:36 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3FE5F812", + "Content-Length" : "0", + "x-ms-request-id" : "d921ddef-401e-0028-72b3-a3f393000000", + "x-ms-client-request-id" : "c3c3191d-b7e1-47db-95d8-5452fadf39f6" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcensurestateresourceandpermission&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1126774b-1c92-4126-934e-1c03315d7c6c" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2554-a01e-0020-34b3-a3e99c000000", + "Body" : "jtcensurestateresourceandpermissionjtcensurestateresourceandpermission067424a73973c26daMon, 25 Nov 2019 17:09:36 GMT\"0x8D771CA3FD90C4B\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "x-ms-client-request-id" : "1126774b-1c92-4126-934e-1c03315d7c6c", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateresourceandpermission067424a73973c26da?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "ac57f5c2-423d-4eb2-97d8-4ec29758137d" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921ddf4-401e-0028-76b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "x-ms-client-request-id" : "ac57f5c2-423d-4eb2-97d8-4ec29758137d" + }, + "Exception" : null + } ], + "variables" : [ "jtcensurestateresourceandpermission067424a73973c26da", "javablobensurestateresourceandpermission162311a8707d07" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[2].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[2].json new file mode 100644 index 000000000000..82952fb9ad4b --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateresourceandpermission[2].json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateresourceandpermission007063c512bf3c775?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "5a3fb7d4-b1f0-49d8-901e-64ecef188895" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA400D95C5", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:36 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a2558-a01e-0020-37b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "x-ms-client-request-id" : "5a3fb7d4-b1f0-49d8-901e-64ecef188895" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateresourceandpermission007063c512bf3c775/javablobensurestateresourceandpermission186155a746a144", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "c8486568-bb4c-452a-b044-8619e01d0395", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:36 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA401AEB2B", + "Content-Length" : "0", + "x-ms-request-id" : "d921ddfc-401e-0028-7db3-a3f393000000", + "x-ms-client-request-id" : "c8486568-bb4c-452a-b044-8619e01d0395" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcensurestateresourceandpermission&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "161e87f7-ac8e-4bf1-9dfb-404a81fc2fb9" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a255c-a01e-0020-3ab3-a3e99c000000", + "Body" : "jtcensurestateresourceandpermissionjtcensurestateresourceandpermission007063c512bf3c775Mon, 25 Nov 2019 17:09:36 GMT\"0x8D771CA400D95C5\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "x-ms-client-request-id" : "161e87f7-ac8e-4bf1-9dfb-404a81fc2fb9", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateresourceandpermission007063c512bf3c775?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "92c86545-8830-4904-8ec1-11b3cbd93f10" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921de03-401e-0028-04b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:36 GMT", + "x-ms-client-request-id" : "92c86545-8830-4904-8ec1-11b3cbd93f10" + }, + "Exception" : null + } ], + "variables" : [ "jtcensurestateresourceandpermission007063c512bf3c775", "javablobensurestateresourceandpermission186155a746a144" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateversion.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateversion.json new file mode 100644 index 000000000000..51405130d192 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsensurestateversion.json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateversion0sasclienttestsensurestateversion7ef95525?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "32b2ae0f-3b31-4b50-b3ac-b1699511af61" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3F383C56", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:35 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a252f-a01e-0020-1ab3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "x-ms-client-request-id" : "32b2ae0f-3b31-4b50-b3ac-b1699511af61" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateversion0sasclienttestsensurestateversion7ef95525/javablobensurestateversion1174573473b33f9153412", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "141b6a76-1c5a-4b9b-93df-653a5295b9bc", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:35 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3F45E7E2", + "Content-Length" : "0", + "x-ms-request-id" : "d921ddd9-401e-0028-5cb3-a3f393000000", + "x-ms-client-request-id" : "141b6a76-1c5a-4b9b-93df-653a5295b9bc" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcensurestateversion&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "3baba14d-bbff-4dc9-ba14-186800eb83aa" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2536-a01e-0020-1eb3-a3e99c000000", + "Body" : "jtcensurestateversionjtcensurestateversion0sasclienttestsensurestateversion7ef95525Mon, 25 Nov 2019 17:09:35 GMT\"0x8D771CA3F383C56\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "x-ms-client-request-id" : "3baba14d-bbff-4dc9-ba14-186800eb83aa", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcensurestateversion0sasclienttestsensurestateversion7ef95525?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "7a92f80f-bbbb-4883-b79f-a8d0dbba9c03" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921dddd-401e-0028-60b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:35 GMT", + "x-ms-client-request-id" : "7a92f80f-bbbb-4883-b79f-a8d0dbba9c03" + }, + "Exception" : null + } ], + "variables" : [ "jtcensurestateversion0sasclienttestsensurestateversion7ef95525", "javablobensurestateversion1174573473b33f9153412" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsas.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsas.json new file mode 100644 index 000000000000..a9cd35dee6a5 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsas.json @@ -0,0 +1,158 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsas0sasclienttestsnetworktestblobsas20158403?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "ca96f59b-6c9c-460b-a023-8c66928ca518" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA39C4C7A9", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:26 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a23d7-a01e-0020-74b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:25 GMT", + "x-ms-client-request-id" : "ca96f59b-6c9c-460b-a023-8c66928ca518" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsas0sasclienttestsnetworktestblobsas20158403/javablobnetworktestblobsas169768633e6e3cc62e49b", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "b6e58c52-3095-4e76-b9fe-36dff3809899", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:26 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:25 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA39E5B692", + "Content-Length" : "0", + "x-ms-request-id" : "329a23dd-a01e-0020-77b3-a3e99c000000", + "x-ms-client-request-id" : "b6e58c52-3095-4e76-b9fe-36dff3809899" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsas0sasclienttestsnetworktestblobsas20158403/javablobnetworktestblobsas169768633e6e3cc62e49b?sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A26Z&se=2019-11-26T17%3A09%3A26Z&sip=0.0.0.0-255.255.255.255&sr=b&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "30576ea7-5b42-4468-80bb-7edcf0dd033d" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:26 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Mon, 25 Nov 2019 17:09:25 GMT", + "x-ms-blob-type" : "BlockBlob", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "Cache-Control" : "cache", + "ETag" : "0x8D771CA39E5B692", + "Content-Disposition" : "disposition", + "x-ms-creation-time" : "Mon, 25 Nov 2019 17:09:26 GMT", + "Content-Length" : "7", + "x-ms-request-id" : "329a23df-a01e-0020-79b3-a3e99c000000", + "Body" : "default", + "x-ms-client-request-id" : "30576ea7-5b42-4468-80bb-7edcf0dd033d", + "Content-Language" : "language", + "Content-Type" : "type" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsas0sasclienttestsnetworktestblobsas20158403/javablobnetworktestblobsas169768633e6e3cc62e49b?sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A26Z&se=2019-11-26T17%3A09%3A26Z&sip=0.0.0.0-255.255.255.255&sr=b&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "d72f4cf4-04ef-4d3f-be30-a1984f0fc437" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:26 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Mon, 25 Nov 2019 17:09:25 GMT", + "x-ms-blob-type" : "BlockBlob", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "Cache-Control" : "cache", + "ETag" : "0x8D771CA39E5B692", + "Content-Disposition" : "disposition", + "Content-Encoding" : "encoding", + "x-ms-creation-time" : "Mon, 25 Nov 2019 17:09:26 GMT", + "Content-Length" : "7", + "x-ms-request-id" : "329a23e1-a01e-0020-7bb3-a3e99c000000", + "x-ms-client-request-id" : "d72f4cf4-04ef-4d3f-be30-a1984f0fc437", + "Content-Language" : "language", + "Content-Type" : "type" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcnetworktestblobsas&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "2b506eaa-4fb3-4f28-ba44-c737a34271b2" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a23e3-a01e-0020-7db3-a3e99c000000", + "Body" : "jtcnetworktestblobsasjtcnetworktestblobsas0sasclienttestsnetworktestblobsas20158403Mon, 25 Nov 2019 17:09:26 GMT\"0x8D771CA39C4C7A9\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:26 GMT", + "x-ms-client-request-id" : "2b506eaa-4fb3-4f28-ba44-c737a34271b2", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsas0sasclienttestsnetworktestblobsas20158403?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "6032dbfd-d5fa-4b2f-b2f6-3029aa80f231" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "329a23e4-a01e-0020-7eb3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:26 GMT", + "x-ms-client-request-id" : "6032dbfd-d5fa-4b2f-b2f6-3029aa80f231" + }, + "Exception" : null + } ], + "variables" : [ "jtcnetworktestblobsas0sasclienttestsnetworktestblobsas20158403", "javablobnetworktestblobsas169768633e6e3cc62e49b", "2019-11-25T17:09:26.498760400Z", "2019-11-25T17:09:26.501760400Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsnapshot.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsnapshot.json new file mode 100644 index 000000000000..6ac33e16ac1f --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsnapshot.json @@ -0,0 +1,202 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshot02540570aba2cd3d9e46f?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "e09679a2-45d3-4bff-bdb6-f108d225fc1e" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3A49A677", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:27 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a23e8-a01e-0020-02b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:26 GMT", + "x-ms-client-request-id" : "e09679a2-45d3-4bff-bdb6-f108d225fc1e" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshot02540570aba2cd3d9e46f/javablobnetworktestblobsnapshot102035629499e132984", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "d11846ca-8d30-4a33-a0af-104f7c7230c6", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:27 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:26 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3A58C3C2", + "Content-Length" : "0", + "x-ms-request-id" : "329a23ec-a01e-0020-05b3-a3e99c000000", + "x-ms-client-request-id" : "d11846ca-8d30-4a33-a0af-104f7c7230c6" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshot02540570aba2cd3d9e46f/javablobnetworktestblobsnapshot2668120224a37c98254", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "e101a62d-b820-4910-9d33-55239c439a9b", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "Q7G6/s6+u/k=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:27 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:26 GMT", + "Content-MD5" : "CY9rzUYh03PK3k6DJie09g==", + "ETag" : "0x8D771CA3A68A2A6", + "Content-Length" : "0", + "x-ms-request-id" : "329a23ed-a01e-0020-06b3-a3e99c000000", + "x-ms-client-request-id" : "e101a62d-b820-4910-9d33-55239c439a9b" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshot02540570aba2cd3d9e46f/javablobnetworktestblobsnapshot2668120224a37c98254?comp=snapshot", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "4e6e9613-eefb-49c4-a848-213edd0f8047" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "x-ms-snapshot" : "2019-11-25T17:09:27.4562807Z", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3A68A2A6", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:27 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a23ef-a01e-0020-08b3-a3e99c000000", + "x-ms-request-server-encrypted" : "false", + "Date" : "Mon, 25 Nov 2019 17:09:26 GMT", + "x-ms-client-request-id" : "4e6e9613-eefb-49c4-a848-213edd0f8047" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshot02540570aba2cd3d9e46f/javablobnetworktestblobsnapshot2668120224a37c98254?snapshot=2019-11-25T17%3a09%3a27.4562807Z&sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A27Z&se=2019-11-26T17%3A09%3A27Z&sip=0.0.0.0-255.255.255.255&sr=bs&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "de5631bd-d957-40ac-8348-a6a66856921e" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:27 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Mon, 25 Nov 2019 17:09:26 GMT", + "x-ms-blob-type" : "BlockBlob", + "Content-MD5" : "CY9rzUYh03PK3k6DJie09g==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "Cache-Control" : "cache", + "ETag" : "0x8D771CA3A68A2A6", + "Content-Disposition" : "disposition", + "x-ms-creation-time" : "Mon, 25 Nov 2019 17:09:27 GMT", + "Content-Length" : "4", + "x-ms-request-id" : "329a23f0-a01e-0020-09b3-a3e99c000000", + "Body" : "test", + "x-ms-client-request-id" : "de5631bd-d957-40ac-8348-a6a66856921e", + "Content-Language" : "language", + "Content-Type" : "type" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshot02540570aba2cd3d9e46f/javablobnetworktestblobsnapshot2668120224a37c98254?snapshot=2019-11-25T17%3a09%3a27.4562807Z&sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A27Z&se=2019-11-26T17%3A09%3A27Z&sip=0.0.0.0-255.255.255.255&sr=bs&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1d2832ad-763d-4623-ae69-9b6694ed8a66" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:27 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Mon, 25 Nov 2019 17:09:26 GMT", + "x-ms-blob-type" : "BlockBlob", + "Content-MD5" : "CY9rzUYh03PK3k6DJie09g==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "Cache-Control" : "cache", + "ETag" : "0x8D771CA3A68A2A6", + "Content-Disposition" : "disposition", + "Content-Encoding" : "encoding", + "x-ms-creation-time" : "Mon, 25 Nov 2019 17:09:27 GMT", + "Content-Length" : "4", + "x-ms-request-id" : "329a23f2-a01e-0020-0bb3-a3e99c000000", + "x-ms-client-request-id" : "1d2832ad-763d-4623-ae69-9b6694ed8a66", + "Content-Language" : "language", + "Content-Type" : "type" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcnetworktestblobsnapshot&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "7fc65b94-64bb-4dc8-be1f-086e9d3e273b" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a23f3-a01e-0020-0cb3-a3e99c000000", + "Body" : "jtcnetworktestblobsnapshotjtcnetworktestblobsnapshot02540570aba2cd3d9e46fMon, 25 Nov 2019 17:09:27 GMT\"0x8D771CA3A49A677\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:26 GMT", + "x-ms-client-request-id" : "7fc65b94-64bb-4dc8-be1f-086e9d3e273b", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshot02540570aba2cd3d9e46f?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "2af744ba-b0d1-4941-9511-295d592f009e" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921dce2-401e-0028-0ab3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:27 GMT", + "x-ms-client-request-id" : "2af744ba-b0d1-4941-9511-295d592f009e" + }, + "Exception" : null + } ], + "variables" : [ "jtcnetworktestblobsnapshot02540570aba2cd3d9e46f", "javablobnetworktestblobsnapshot102035629499e132984", "javablobnetworktestblobsnapshot2668120224a37c98254", "2019-11-25T17:09:27.443868800Z", "2019-11-25T17:09:27.443868800Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsnapshotuserdelegation.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsnapshotuserdelegation.json new file mode 100644 index 000000000000..d78c4cd4f8fd --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobsnapshotuserdelegation.json @@ -0,0 +1,219 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshotuserdelegation03840477362e2e?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "b5d79c61-b4f7-4d5f-8c45-49b85715b9e4" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3CF78BD8", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:31 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a24c9-a01e-0020-4db3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:30 GMT", + "x-ms-client-request-id" : "b5d79c61-b4f7-4d5f-8c45-49b85715b9e4" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshotuserdelegation03840477362e2e/javablobnetworktestblobsnapshotuserdelegation120014caa048", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "2f41707f-4757-4141-af74-0b2bd05112cb", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:31 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:30 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3D04AA2E", + "Content-Length" : "0", + "x-ms-request-id" : "d921dd4f-401e-0028-66b3-a3f393000000", + "x-ms-client-request-id" : "2f41707f-4757-4141-af74-0b2bd05112cb" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshotuserdelegation03840477362e2e/javablobnetworktestblobsnapshotuserdelegation120014caa048?comp=snapshot", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1d5053ed-4914-4814-9a67-22873929f97f" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "x-ms-snapshot" : "2019-11-25T17:09:31.8122954Z", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3D04AA2E", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:31 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a24e4-a01e-0020-65b3-a3e99c000000", + "x-ms-request-server-encrypted" : "false", + "Date" : "Mon, 25 Nov 2019 17:09:30 GMT", + "x-ms-client-request-id" : "1d5053ed-4914-4814-9a67-22873929f97f" + }, + "Exception" : null + }, { + "Method" : "POST", + "Uri" : "https://gapradev.blob.core.windows.net?restype=service&comp=userdelegationkey", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "ecc43eea-ef70-43ee-b58a-bb7fde027d34", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "d921dd5f-401e-0028-73b3-a3f393000000", + "Body" : "7a56bc7f-2460-439c-8e22-cc8f44b161238ef2432d-93d8-4e9a-a756-f9a8ee5544d72019-11-24T17:09:31Z2019-11-26T17:09:31Zb2019-02-02UkVEQUNURUQ=", + "Date" : "Mon, 25 Nov 2019 17:09:32 GMT", + "x-ms-client-request-id" : "ecc43eea-ef70-43ee-b58a-bb7fde027d34", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshotuserdelegation03840477362e2e/javablobnetworktestblobsnapshotuserdelegation120014caa048?sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A31Z&se=2019-11-26T17%3A09%3A31Z&sip=0.0.0.0-255.255.255.255&skoid=c4f48289-bb84-4086-b250-6f94a8f64cee&sktid=72f988bf-86f1-41af-91ab-2d7cd011db47&skt=2019-11-24T17%3A09%3A31Z&ske=2019-11-26T17%3A09%3A31Z&sks=b&skv=2019-02-02&sr=bs&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "f16ddfaa-ba18-4c50-b868-9cbacd3ee66f" + }, + "Response" : { + "Server" : "Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "AuthenticationFailed", + "retry-after" : "0", + "Content-Length" : "447", + "StatusCode" : "403", + "x-ms-request-id" : "329a24eb-a01e-0020-6ab3-a3e99c000000", + "Body" : "AuthenticationFailedServer failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nRequestId:329a24eb-a01e-0020-6ab3-a3e99c000000\nTime:2019-11-25T17:09:32.2487938ZThe specified signed resource is not allowed for the this resource level", + "Date" : "Mon, 25 Nov 2019 17:09:32 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshotuserdelegation03840477362e2e/javablobnetworktestblobsnapshotuserdelegation120014caa048?snapshot=2019-11-25T17%3a09%3a31.8122954Z&sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A31Z&se=2019-11-26T17%3A09%3A31Z&sip=0.0.0.0-255.255.255.255&skoid=c4f48289-bb84-4086-b250-6f94a8f64cee&sktid=72f988bf-86f1-41af-91ab-2d7cd011db47&skt=2019-11-24T17%3A09%3A31Z&ske=2019-11-26T17%3A09%3A31Z&sks=b&skv=2019-02-02&sr=bs&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "5671c3f6-b71e-413d-a4a4-09cb0d167615" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:31 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Mon, 25 Nov 2019 17:09:32 GMT", + "x-ms-blob-type" : "BlockBlob", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "Cache-Control" : "cache", + "ETag" : "0x8D771CA3D04AA2E", + "Content-Disposition" : "disposition", + "x-ms-creation-time" : "Mon, 25 Nov 2019 17:09:31 GMT", + "Content-Length" : "7", + "x-ms-request-id" : "d921dd64-401e-0028-78b3-a3f393000000", + "Body" : "default", + "x-ms-client-request-id" : "5671c3f6-b71e-413d-a4a4-09cb0d167615", + "Content-Language" : "language", + "Content-Type" : "type" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshotuserdelegation03840477362e2e/javablobnetworktestblobsnapshotuserdelegation120014caa048?snapshot=2019-11-25T17%3a09%3a31.8122954Z&sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A31Z&se=2019-11-26T17%3A09%3A31Z&sip=0.0.0.0-255.255.255.255&skoid=c4f48289-bb84-4086-b250-6f94a8f64cee&sktid=72f988bf-86f1-41af-91ab-2d7cd011db47&skt=2019-11-24T17%3A09%3A31Z&ske=2019-11-26T17%3A09%3A31Z&sks=b&skv=2019-02-02&sr=bs&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "9b7b789f-1d56-4420-82a7-e0bc5b77894c" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:31 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Mon, 25 Nov 2019 17:09:32 GMT", + "x-ms-blob-type" : "BlockBlob", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "Cache-Control" : "cache", + "ETag" : "0x8D771CA3D04AA2E", + "Content-Disposition" : "disposition", + "Content-Encoding" : "encoding", + "x-ms-creation-time" : "Mon, 25 Nov 2019 17:09:31 GMT", + "Content-Length" : "7", + "x-ms-request-id" : "329a24ef-a01e-0020-6db3-a3e99c000000", + "x-ms-client-request-id" : "9b7b789f-1d56-4420-82a7-e0bc5b77894c", + "Content-Language" : "language", + "Content-Type" : "type" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcnetworktestblobsnapshotuserdelegation&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "6d37055a-8740-4595-ab9e-550797ac321c" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "d921dd69-401e-0028-7cb3-a3f393000000", + "Body" : "jtcnetworktestblobsnapshotuserdelegationjtcnetworktestblobsnapshotuserdelegation03840477362e2eMon, 25 Nov 2019 17:09:31 GMT\"0x8D771CA3CF78BD8\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:32 GMT", + "x-ms-client-request-id" : "6d37055a-8740-4595-ab9e-550797ac321c", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobsnapshotuserdelegation03840477362e2e?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "2ca2d15f-5d48-46bb-8a61-3aa7b451d190" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "329a24f5-a01e-0020-70b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:32 GMT", + "x-ms-client-request-id" : "2ca2d15f-5d48-46bb-8a61-3aa7b451d190" + }, + "Exception" : null + } ], + "variables" : [ "jtcnetworktestblobsnapshotuserdelegation03840477362e2e", "javablobnetworktestblobsnapshotuserdelegation120014caa048", "2019-11-25T17:09:31.787683Z", "2019-11-25T17:09:31.788682900Z", "2019-11-25T17:09:31.789653800Z", "2019-11-25T17:09:31.789653800Z", "c4f48289-bb84-4086-b250-6f94a8f64cee", "72f988bf-86f1-41af-91ab-2d7cd011db47" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobuserdelegation.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobuserdelegation.json new file mode 100644 index 000000000000..15edff51784b --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestblobuserdelegation.json @@ -0,0 +1,180 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobuserdelegation0458840195b4321c51?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "ed069f9e-50c5-4566-9845-5fff88ef61ac" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3B4336A9", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:28 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "d921dcfe-401e-0028-23b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:27 GMT", + "x-ms-client-request-id" : "ed069f9e-50c5-4566-9845-5fff88ef61ac" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobuserdelegation0458840195b4321c51/javablobnetworktestblobuserdelegation180269895b752a25", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "cc07b576-618a-45eb-9a32-54e5d2ba46ba", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:28 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:28 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3B509169", + "Content-Length" : "0", + "x-ms-request-id" : "329a2417-a01e-0020-28b3-a3e99c000000", + "x-ms-client-request-id" : "cc07b576-618a-45eb-9a32-54e5d2ba46ba" + }, + "Exception" : null + }, { + "Method" : "POST", + "Uri" : "https://gapradev.blob.core.windows.net?restype=service&comp=userdelegationkey", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "d666dfef-2455-41b2-bb8a-102b544c9fc6", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "d921dd0c-401e-0028-2db3-a3f393000000", + "Body" : "f2aa5e42-6670-410b-9f46-f8b1188ec239315a5043-2e30-41b6-b0d7-aa22296ae15d2019-11-24T17:09:28Z2019-11-26T17:09:28Zb2019-02-02UkVEQUNURUQ=", + "Date" : "Mon, 25 Nov 2019 17:09:29 GMT", + "x-ms-client-request-id" : "d666dfef-2455-41b2-bb8a-102b544c9fc6", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobuserdelegation0458840195b4321c51/javablobnetworktestblobuserdelegation180269895b752a25?sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A28Z&se=2019-11-26T17%3A09%3A28Z&sip=0.0.0.0-255.255.255.255&skoid=c4f48289-bb84-4086-b250-6f94a8f64cee&sktid=72f988bf-86f1-41af-91ab-2d7cd011db47&skt=2019-11-24T17%3A09%3A28Z&ske=2019-11-26T17%3A09%3A28Z&sks=b&skv=2019-02-02&sr=b&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "f8a58b97-5ac5-40c6-8324-138488a8ddb3" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:28 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Mon, 25 Nov 2019 17:09:29 GMT", + "x-ms-blob-type" : "BlockBlob", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "Cache-Control" : "cache", + "ETag" : "0x8D771CA3B509169", + "Content-Disposition" : "disposition", + "x-ms-creation-time" : "Mon, 25 Nov 2019 17:09:28 GMT", + "Content-Length" : "7", + "x-ms-request-id" : "329a243b-a01e-0020-48b3-a3e99c000000", + "Body" : "default", + "x-ms-client-request-id" : "f8a58b97-5ac5-40c6-8324-138488a8ddb3", + "Content-Language" : "language", + "Content-Type" : "type" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobuserdelegation0458840195b4321c51/javablobnetworktestblobuserdelegation180269895b752a25?sv=2019-02-02&spr=https%2Chttp&st=2019-11-24T17%3A09%3A28Z&se=2019-11-26T17%3A09%3A28Z&sip=0.0.0.0-255.255.255.255&skoid=c4f48289-bb84-4086-b250-6f94a8f64cee&sktid=72f988bf-86f1-41af-91ab-2d7cd011db47&skt=2019-11-24T17%3A09%3A28Z&ske=2019-11-26T17%3A09%3A28Z&sks=b&skv=2019-02-02&sr=b&sp=racwd&sig=REDACTED&rscc=cache&rscd=disposition&rsce=encoding&rscl=language&rsct=type", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "72266b1d-c83c-4826-ae6c-b05b38654242" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:28 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Mon, 25 Nov 2019 17:09:29 GMT", + "x-ms-blob-type" : "BlockBlob", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "Cache-Control" : "cache", + "ETag" : "0x8D771CA3B509169", + "Content-Disposition" : "disposition", + "Content-Encoding" : "encoding", + "x-ms-creation-time" : "Mon, 25 Nov 2019 17:09:28 GMT", + "Content-Length" : "7", + "x-ms-request-id" : "d921dd21-401e-0028-3fb3-a3f393000000", + "x-ms-client-request-id" : "72266b1d-c83c-4826-ae6c-b05b38654242", + "Content-Language" : "language", + "Content-Type" : "type" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcnetworktestblobuserdelegation&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "cda29162-14f6-4a3b-bbce-e3c5b70987c7" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a24ae-a01e-0020-3ab3-a3e99c000000", + "Body" : "jtcnetworktestblobuserdelegationjtcnetworktestblobuserdelegation0458840195b4321c51Mon, 25 Nov 2019 17:09:28 GMT\"0x8D771CA3B4336A9\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:29 GMT", + "x-ms-client-request-id" : "cda29162-14f6-4a3b-bbce-e3c5b70987c7", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestblobuserdelegation0458840195b4321c51?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "882b754a-ef49-4235-a37d-d69f821976b5" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "d921dd23-401e-0028-40b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:29 GMT", + "x-ms-client-request-id" : "882b754a-ef49-4235-a37d-d69f821976b5" + }, + "Exception" : null + } ], + "variables" : [ "jtcnetworktestblobuserdelegation0458840195b4321c51", "javablobnetworktestblobuserdelegation180269895b752a25", "2019-11-25T17:09:28.843991800Z", "2019-11-25T17:09:28.843991800Z", "2019-11-25T17:09:28.883984400Z", "2019-11-25T17:09:28.883984400Z", "c4f48289-bb84-4086-b250-6f94a8f64cee", "72f988bf-86f1-41af-91ab-2d7cd011db47" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestcontaineruserdelegation.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestcontaineruserdelegation.json new file mode 100644 index 000000000000..51eee75a70c9 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsnetworktestcontaineruserdelegation.json @@ -0,0 +1,133 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestcontaineruserdelegation0715539637c65f78?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "2faa7c3f-2353-404d-9872-fc7ff279003a" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3D969CD1", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:32 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "d921dd71-401e-0028-04b3-a3f393000000", + "Date" : "Mon, 25 Nov 2019 17:09:32 GMT", + "x-ms-client-request-id" : "2faa7c3f-2353-404d-9872-fc7ff279003a" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestcontaineruserdelegation0715539637c65f78/javablobnetworktestcontaineruserdelegation1670526fc60bd", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "ce8a9607-60fb-44ea-ad46-c3424eb65e76", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:32 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:32 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3DA4BACC", + "Content-Length" : "0", + "x-ms-request-id" : "329a24f6-a01e-0020-71b3-a3e99c000000", + "x-ms-client-request-id" : "ce8a9607-60fb-44ea-ad46-c3424eb65e76" + }, + "Exception" : null + }, { + "Method" : "POST", + "Uri" : "https://gapradev.blob.core.windows.net?restype=service&comp=userdelegationkey", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "756cdd31-d044-4410-95f5-03d770ce4703", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "d921dd82-401e-0028-11b3-a3f393000000", + "Body" : "c08759dd-0fce-4f53-969f-3ed0c1a66f2806bd9169-60ce-4847-a2a3-30749ad2b8382019-11-24T17:09:32Z2019-11-26T17:09:32Zb2019-02-02UkVEQUNURUQ=", + "Date" : "Mon, 25 Nov 2019 17:09:33 GMT", + "x-ms-client-request-id" : "756cdd31-d044-4410-95f5-03d770ce4703", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestcontaineruserdelegation0715539637c65f78?include=&restype=container&comp=list&sv=2019-02-02&se=2019-11-26T17%3A09%3A32Z&skoid=c4f48289-bb84-4086-b250-6f94a8f64cee&sktid=72f988bf-86f1-41af-91ab-2d7cd011db47&skt=2019-11-24T17%3A09%3A32Z&ske=2019-11-26T17%3A09%3A32Z&sks=b&skv=2019-02-02&sr=c&sp=racwdl&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "9d5e9ed0-76a8-4f49-9fa6-50e168a93d11" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a24fd-a01e-0020-76b3-a3e99c000000", + "Body" : "javablobnetworktestcontaineruserdelegation1670526fc60bdMon, 25 Nov 2019 17:09:32 GMTMon, 25 Nov 2019 17:09:32 GMT0x8D771CA3DA4BACC7application/octet-streamwh+Wm18D0z1D4E+PE252gg==BlockBlobHottrueunlockedavailabletrue", + "Date" : "Mon, 25 Nov 2019 17:09:33 GMT", + "x-ms-client-request-id" : "9d5e9ed0-76a8-4f49-9fa6-50e168a93d11", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcnetworktestcontaineruserdelegation&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "cc6b24df-eae3-457d-a128-d044b2d0dcc0" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "d921dd8c-401e-0028-1ab3-a3f393000000", + "Body" : "jtcnetworktestcontaineruserdelegationjtcnetworktestcontaineruserdelegation0715539637c65f78Mon, 25 Nov 2019 17:09:32 GMT\"0x8D771CA3D969CD1\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:33 GMT", + "x-ms-client-request-id" : "cc6b24df-eae3-457d-a128-d044b2d0dcc0", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcnetworktestcontaineruserdelegation0715539637c65f78?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "6f3c150e-1e30-4347-bb7c-de8cb5807760" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "329a24ff-a01e-0020-77b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:33 GMT", + "x-ms-client-request-id" : "6f3c150e-1e30-4347-bb7c-de8cb5807760" + }, + "Exception" : null + } ], + "variables" : [ "jtcnetworktestcontaineruserdelegation0715539637c65f78", "javablobnetworktestcontaineruserdelegation1670526fc60bd", "2019-11-25T17:09:32.746616Z", "2019-11-25T17:09:32.747615500Z", "2019-11-25T17:09:32.747615500Z", "c4f48289-bb84-4086-b250-6f94a8f64cee", "72f988bf-86f1-41af-91ab-2d7cd011db47" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsservicesassignaturevaluesnetworktestcontainer.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsservicesassignaturevaluesnetworktestcontainer.json new file mode 100644 index 000000000000..7f79fea04c1f --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/SasClientTestsservicesassignaturevaluesnetworktestcontainer.json @@ -0,0 +1,154 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcservicesassignaturevaluesnetworktestcontainer0249587958?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "f6512891-e5f8-47d1-9485-8fcf7c48fa5e" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3AE1C274", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:28 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "329a23fd-a01e-0020-13b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:27 GMT", + "x-ms-client-request-id" : "f6512891-e5f8-47d1-9485-8fcf7c48fa5e" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcservicesassignaturevaluesnetworktestcontainer0249587958/javablobservicesassignaturevaluesnetworktestcontainer113162b5", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "611f938d-968f-4a91-864a-fc9bb862e9a7", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:28 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Mon, 25 Nov 2019 17:09:27 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D771CA3AEF5E57", + "Content-Length" : "0", + "x-ms-request-id" : "d921dced-401e-0028-14b3-a3f393000000", + "x-ms-client-request-id" : "611f938d-968f-4a91-864a-fc9bb862e9a7" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gapradev.blob.core.windows.net/jtcservicesassignaturevaluesnetworktestcontainer0249587958?restype=container&comp=acl", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "22080f30-20b6-4858-9d77-545a366c2404", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D771CA3B001454", + "Last-Modified" : "Mon, 25 Nov 2019 17:09:28 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a2402-a01e-0020-17b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:27 GMT", + "x-ms-client-request-id" : "22080f30-20b6-4858-9d77-545a366c2404" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net/jtcservicesassignaturevaluesnetworktestcontainer0249587958?include=&restype=container&comp=list&sv=2019-02-02&si=0000&sr=c&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "3d64c283-d111-457b-8969-6214cae106f3" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "d921dcf0-401e-0028-17b3-a3f393000000", + "Body" : "javablobservicesassignaturevaluesnetworktestcontainer113162b5Mon, 25 Nov 2019 17:09:28 GMTMon, 25 Nov 2019 17:09:28 GMT0x8D771CA3AEF5E577application/octet-streamwh+Wm18D0z1D4E+PE252gg==BlockBlobHottrueunlockedavailabletrue", + "Date" : "Mon, 25 Nov 2019 17:09:27 GMT", + "x-ms-client-request-id" : "3d64c283-d111-457b-8969-6214cae106f3", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net/jtcservicesassignaturevaluesnetworktestcontainer0249587958?include=&restype=container&comp=list&sv=2019-02-02&se=2019-11-26T17%3A09%3A28Z&sr=c&sp=racwdl&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "1275df9c-6fe2-4bf2-b5ce-5da41aaf40da" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "329a240b-a01e-0020-1eb3-a3e99c000000", + "Body" : "javablobservicesassignaturevaluesnetworktestcontainer113162b5Mon, 25 Nov 2019 17:09:28 GMTMon, 25 Nov 2019 17:09:28 GMT0x8D771CA3AEF5E577application/octet-streamwh+Wm18D0z1D4E+PE252gg==BlockBlobHottrueunlockedavailabletrue", + "Date" : "Mon, 25 Nov 2019 17:09:27 GMT", + "x-ms-client-request-id" : "1275df9c-6fe2-4bf2-b5ce-5da41aaf40da", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gapradev.blob.core.windows.net?prefix=jtcservicesassignaturevaluesnetworktestcontainer&comp=list", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "8cd3bd90-4d5c-467b-8fca-74f903153378" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "d921dcf8-401e-0028-1db3-a3f393000000", + "Body" : "jtcservicesassignaturevaluesnetworktestcontainerjtcservicesassignaturevaluesnetworktestcontainer0249587958Mon, 25 Nov 2019 17:09:28 GMT\"0x8D771CA3B001454\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Mon, 25 Nov 2019 17:09:27 GMT", + "x-ms-client-request-id" : "8cd3bd90-4d5c-467b-8fca-74f903153378", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://gapradev.blob.core.windows.net/jtcservicesassignaturevaluesnetworktestcontainer0249587958?restype=container", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.1.0-beta.1 11.0.4; Windows 10 10.0", + "x-ms-client-request-id" : "71a3b729-6bef-4c5a-bf74-aefe7470d858" + }, + "Response" : { + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "329a240f-a01e-0020-22b3-a3e99c000000", + "Date" : "Mon, 25 Nov 2019 17:09:27 GMT", + "x-ms-client-request-id" : "71a3b729-6bef-4c5a-bf74-aefe7470d858" + }, + "Exception" : null + } ], + "variables" : [ "jtcservicesassignaturevaluesnetworktestcontainer0249587958", "javablobservicesassignaturevaluesnetworktestcontainer113162b5", "2019-11-25T17:09:28.210051100Z", "2019-11-25T17:09:28.315019800Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasPermission.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasPermission.java index 609db4b013ce..b7fcbb2104e6 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasPermission.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasPermission.java @@ -11,7 +11,7 @@ * This is a helper class to construct a string representing the permissions granted by an Account SAS. Setting a value * to true means that any SAS which uses these permissions will grant permissions for that operation. Once all the * values are set, this should be serialized with toString and set as the permissions field on - * {@link AccountSasSignatureValues#setPermissions(AccountSasPermission) AccountSasSignatureValues}. + * {@link AccountSasSignatureValues AccountSasSignatureValues}. * *

* It is possible to construct the permissions string without this class, but the order of the permissions is particular 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 080d4cffca4c..66ecfc39c8c3 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 @@ -14,7 +14,10 @@ * appended to a URL directly (though caution should be taken here in case there are existing query parameters, which * might affect the appropriate means of appending these query parameters). NOTE: Instances of this class are immutable * to ensure thread safety. + * @deprecated Please use the generate*Sas method on the desired service client after initializing + * {@link AccountSasSignatureValues}. */ +@Deprecated public final class AccountSasQueryParameters extends BaseSasQueryParameters { private final String services; @@ -80,6 +83,8 @@ public String getResourceTypes() { * Encodes all SAS query parameters into a string that can be appended to a URL. * * @return A {@code String} representing all SAS query parameters. + * @deprecated Please use the generate*Sas method on the desired service client after initializing + * {@link AccountSasSignatureValues}. */ @Deprecated public String encode() { From b4adb506356939a5259a6035786a403a9eb6a5b5 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Mon, 25 Nov 2019 10:29:27 -0800 Subject: [PATCH 04/17] Added more code snippets and comments --- .../azure/storage/blob/BlobAsyncClient.java | 8 +++ .../com/azure/storage/blob/BlobClient.java | 8 +++ .../blob/BlobContainerAsyncClient.java | 16 +++--- .../storage/blob/BlobContainerClient.java | 8 +++ .../implementation/util/BlobSasImplUtil.java | 10 ++-- .../blob/specialized/BlobAsyncClientBase.java | 53 ++++++++++++++----- .../blob/specialized/BlobClientBase.java | 53 ++++++++++++++----- .../BlobAsyncClientJavaDocCodeSnippets.java | 29 ++++++++++ .../blob/BlobClientJavaDocCodeSnippets.java | 31 +++++++++++ ...ntainerAsyncClientJavaDocCodeSnippets.java | 30 +++++++++++ ...lobContainerClientJavaDocCodeSnippets.java | 30 +++++++++++ ...lobAsyncClientBaseJavaDocCodeSnippets.java | 30 +++++++++++ .../BlobClientBaseJavaDocCodeSnippets.java | 30 +++++++++++ .../implementation/AccountSasImplUtil.java | 8 +++ .../common/implementation/SasImplUtils.java | 8 +++ .../implementation/StorageImplUtils.java | 3 -- .../common/sas/AccountSasSignatureValues.java | 19 +++---- 17 files changed, 324 insertions(+), 50 deletions(-) diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java index ff4e32bee6a4..203e7b832d4d 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java @@ -560,6 +560,10 @@ public Mono uploadFromFile(String filePath, ParallelTransferOptions parall * {@link BlobServiceSasSignatureValues}. * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} + * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @param userDelegationKey {@link UserDelegationKey} * @@ -575,6 +579,10 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.generateSas#BlobServiceSasSignatureValues} + * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * * @return A {@code String} representing all SAS query parameters. 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 96a60a895b5a..c13b8058965b 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 @@ -185,6 +185,10 @@ public void uploadFromFile(String filePath, ParallelTransferOptions parallelTran * {@link BlobServiceSasSignatureValues}. * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} + * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @param userDelegationKey {@link UserDelegationKey} * @@ -199,6 +203,10 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.generateSas#BlobServiceSasSignatureValues} + * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * * @return A {@code String} representing all SAS query parameters. 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 74f34e5821ee..2ed3cd08948d 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 @@ -82,14 +82,6 @@ public final class BlobContainerAsyncClient { private final ClientLogger logger = new ClientLogger(BlobContainerAsyncClient.class); private final AzureBlobStorageImpl azureBlobStorage; - /** - * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} - * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * - * @return A {@code String} representing all SAS query parameters. - */ private final String accountName; private final String containerName; private final BlobServiceVersion serviceVersion; @@ -917,6 +909,10 @@ Mono> getAccountInfoWithResponse(Context context) { * {@link BlobServiceSasSignatureValues}. * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} + * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @param userDelegationKey {@link UserDelegationKey} * @@ -932,6 +928,10 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic * Generates a service sas for the container using the specified {@link BlobServiceSasSignatureValues} * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.generateSas#BlobServiceSasSignatureValues} + * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * * @return A {@code String} representing all SAS query parameters. 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 112d1d084b70..5cd060168504 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 @@ -560,6 +560,10 @@ public Response getAccountInfoWithResponse(Duration timeout, * {@link BlobServiceSasSignatureValues}. * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} + * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @param userDelegationKey {@link UserDelegationKey} * @@ -574,6 +578,10 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic * Generates a service sas for the container using the specified {@link BlobServiceSasSignatureValues} * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobContainerClient.generateSas#BlobServiceSasSignatureValues} + * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * * @return A {@code String} representing all SAS query parameters. 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 07beaee1e321..e0805b945c2d 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 @@ -9,22 +9,24 @@ import com.azure.storage.blob.models.UserDelegationKey; import com.azure.storage.blob.sas.BlobContainerSasPermission; import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasQueryParameters; import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; 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 com.azure.storage.common.sas.SasIpRange; import com.azure.storage.common.sas.SasProtocol; import java.time.OffsetDateTime; -import java.util.Map; import java.util.Objects; import static com.azure.storage.common.implementation.SasImplUtils.formatQueryParameterDate; import static com.azure.storage.common.implementation.SasImplUtils.tryAppendQueryParameter; +/** + * This class provides helper methods for common blob service sas patterns. + * + * RESERVED FOR INTERNAL USE. + */ public class BlobSasImplUtil { /** * The SAS blob constant. @@ -41,7 +43,7 @@ public class BlobSasImplUtil { */ private static final String SAS_CONTAINER_CONSTANT = "c"; - private final ClientLogger logger = new ClientLogger(BlobServiceSasSignatureValues.class); + private final ClientLogger logger = new ClientLogger(BlobSasImplUtil.class); private String version; 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 81b5705756d6..acc17efe8632 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 @@ -128,19 +128,6 @@ protected BlobAsyncClientBase(HttpPipeline pipeline, String url, BlobServiceVers this.customerProvidedKey = customerProvidedKey; } - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey) { - return getBlobAsyncClient().generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); - } - - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { - return getBlobAsyncClient().generateSas(blobServiceSasSignatureValues); - } - - private BlobAsyncClient getBlobAsyncClient() { - return prepareBuilder().buildAsyncClient(); - } - BlobClientBuilder prepareBuilder() { BlobClientBuilder builder = new BlobClientBuilder() .pipeline(getHttpPipeline()) @@ -1417,4 +1404,44 @@ Mono> getAccountInfoWithResponse(Context context) { return new SimpleResponse<>(rb, new StorageAccountInfo(hd.getSkuName(), hd.getAccountKind())); }); } + + /** + * Generates a user delegation sas for the blob using the specified + * {@link BlobServiceSasSignatureValues}. + * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * @param userDelegationKey {@link UserDelegationKey} + * + * @return A {@code String} representing all SAS query parameters. + */ + public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, + UserDelegationKey userDelegationKey) { + return getBlobAsyncClient().generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); + } + + /** + * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} + * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.generateSas#BlobServiceSasSignatureValues} + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * + * @return A {@code String} representing all SAS query parameters. + */ + public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { + return getBlobAsyncClient().generateSas(blobServiceSasSignatureValues); + } + + private BlobAsyncClient getBlobAsyncClient() { + return prepareBuilder().buildAsyncClient(); + } + } 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 e49466f846ae..5c628603d974 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 @@ -64,19 +64,6 @@ protected BlobClientBase(BlobAsyncClientBase client) { this.client = client; } - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey) { - return getBlobClient().generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); - } - - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { - return getBlobClient().generateSas(blobServiceSasSignatureValues); - } - - private BlobClient getBlobClient() { - return this.client.prepareBuilder().buildClient(); - } - /** * Creates a new {@link BlobClientBase} linked to the {@code snapshot} of this blob resource. * @@ -814,4 +801,44 @@ public Response getAccountInfoWithResponse(Duration timeout, return blockWithOptionalTimeout(response, timeout); } + + + /** + * Generates a user delegation sas for the blob using the specified + * {@link BlobServiceSasSignatureValues}. + * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * @param userDelegationKey {@link UserDelegationKey} + * + * @return A {@code String} representing all SAS query parameters. + */ + public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, + UserDelegationKey userDelegationKey) { + return getBlobClient().generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); + } + + /** + * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} + * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobClientBase.generateSas#BlobServiceSasSignatureValues} + * + * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} + * + * @return A {@code String} representing all SAS query parameters. + */ + public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { + return getBlobClient().generateSas(blobServiceSasSignatureValues); + } + + private BlobClient getBlobClient() { + return this.client.prepareBuilder().buildClient(); + } } diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java index 26a0fa3c1399..3a2cd78d1567 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java @@ -12,6 +12,9 @@ import com.azure.storage.blob.models.DownloadRetryOptions; import com.azure.storage.blob.models.ParallelTransferOptions; import com.azure.storage.blob.models.RehydratePriority; +import com.azure.storage.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobSasPermission; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.blob.specialized.BlobAsyncClientBase; import reactor.core.publisher.Flux; @@ -40,6 +43,7 @@ public class BlobAsyncClientJavaDocCodeSnippets { private int blockSize = 50; private int numBuffers = 2; private String filePath = "filePath"; + private UserDelegationKey userDelegationKey; /** * Code snippet for {@link BlobAsyncClient#exists()} @@ -506,4 +510,29 @@ public void uploadFromFile2() { // END: com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions } + /** + * Code snippet for {@link BlobAsyncClient#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} + * and {@link BlobAsyncClient#generateSas(BlobServiceSasSignatureValues)} + */ + public void generateSas() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.generateSas#BlobServiceSasSignatureValues + OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); + BlobSasPermission permission = new BlobSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential + // END: com.azure.storage.blob.BlobAsyncClient.generateSas#BlobServiceSasSignatureValues + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); + BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateUserDelegationSas(values, userDelegationKey); + // END: com.azure.storage.blob.BlobAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + } } diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java index 41a89745bf91..2679d2be3ee2 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java @@ -15,6 +15,9 @@ import com.azure.storage.blob.models.ParallelTransferOptions; import com.azure.storage.blob.models.RehydratePriority; import com.azure.storage.blob.models.StorageAccountInfo; +import com.azure.storage.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobSasPermission; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.blob.specialized.BlobClientBase; import com.azure.storage.common.implementation.Constants; @@ -44,6 +47,7 @@ public class BlobClientJavaDocCodeSnippets { private String value1 = "val1"; private String value2 = "val2"; private String filePath = "filePath"; + private UserDelegationKey userDelegationKey; /** * Code snippets for {@link BlobClient#exists()} @@ -427,4 +431,31 @@ public void uploadFromFile2() throws IOException { } // END: com.azure.storage.blob.BlobClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions-Duration } + + + /** + * Code snippet for {@link BlobClient#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} + * and {@link BlobClient#generateSas(BlobServiceSasSignatureValues)} + */ + public void generateSas() { + // BEGIN: com.azure.storage.blob.BlobClient.generateSas#BlobServiceSasSignatureValues + OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); + BlobSasPermission permission = new BlobSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential + // END: com.azure.storage.blob.BlobClient.generateSas#BlobServiceSasSignatureValues + + // BEGIN: com.azure.storage.blob.BlobClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); + BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateUserDelegationSas(values, userDelegationKey); + // END: com.azure.storage.blob.BlobClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + } } diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java index adecfd3cf357..66eb22b8c290 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java @@ -10,6 +10,9 @@ import com.azure.storage.blob.models.BlobSignedIdentifier; import com.azure.storage.blob.models.ListBlobsOptions; import com.azure.storage.blob.models.PublicAccessType; +import com.azure.storage.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobContainerSasPermission; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import java.time.Duration; import java.time.OffsetDateTime; @@ -29,6 +32,7 @@ public class BlobContainerAsyncClientJavaDocCodeSnippets { private String leaseId = "leaseId"; private String proposedId = "proposedId"; private int leaseDuration = (int) Duration.ofSeconds(30).getSeconds(); + private UserDelegationKey userDelegationKey; /** * Code snippet for {@link BlobContainerAsyncClient#getBlobAsyncClient(String)} @@ -343,4 +347,30 @@ public void getContainerName() { System.out.println("The name of the blob is " + containerName); // END: com.azure.storage.blob.BlobContainerAsyncClient.getBlobContainerName } + + /** + * Code snippet for {@link BlobContainerAsyncClient#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} + * and {@link BlobContainerAsyncClient#generateSas(BlobServiceSasSignatureValues)} + */ + public void generateSas() { + // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.generateSas#BlobServiceSasSignatureValues + OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); + BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential + // END: com.azure.storage.blob.BlobContainerAsyncClient.generateSas#BlobServiceSasSignatureValues + + // BEGIN: com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); + BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateUserDelegationSas(values, userDelegationKey); + // END: com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + } } diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java index 30dedd456747..b901d1623225 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java @@ -15,6 +15,9 @@ 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.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobContainerSasPermission; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import java.time.Duration; import java.time.OffsetDateTime; @@ -32,6 +35,7 @@ public class BlobContainerClientJavaDocCodeSnippets { private String proposedId = "proposedId"; private int leaseDuration = (int) Duration.ofSeconds(30).getSeconds(); private Duration timeout = Duration.ofSeconds(30); + private UserDelegationKey userDelegationKey; /** * Code snippet for {@link BlobContainerClient#getBlobClient(String)} @@ -360,4 +364,30 @@ public void getContainerName() { System.out.println("The name of the blob is " + containerName); // END: com.azure.storage.blob.BlobContainerClient.getBlobContainerName } + + /** + * Code snippet for {@link BlobContainerClient#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} + * and {@link BlobContainerClient#generateSas(BlobServiceSasSignatureValues)} + */ + public void generateSas() { + // BEGIN: com.azure.storage.blob.BlobContainerClient.generateSas#BlobServiceSasSignatureValues + OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); + BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential + // END: com.azure.storage.blob.BlobContainerClient.generateSas#BlobServiceSasSignatureValues + + // BEGIN: com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); + BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateUserDelegationSas(values, userDelegationKey); + // END: com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + } } diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java index 88686e5c7278..ecb673d81817 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java @@ -15,6 +15,9 @@ import com.azure.storage.blob.models.DownloadRetryOptions; import com.azure.storage.blob.models.ParallelTransferOptions; import com.azure.storage.blob.models.RehydratePriority; +import com.azure.storage.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobSasPermission; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import reactor.core.publisher.Mono; import java.io.ByteArrayOutputStream; @@ -36,6 +39,7 @@ public class BlobAsyncClientBaseJavaDocCodeSnippets { private String copyId = "copyId"; private String url = "https://sample.com"; private String file = "file"; + private UserDelegationKey userDelegationKey; /** * Code snippet for {@link BlobAsyncClientBase#exists()} @@ -420,4 +424,30 @@ public void getAccountInfoWithResponseCodeSnippets() { response.getValue().getAccountKind(), response.getValue().getSkuName())); // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.getAccountInfoWithResponse } + + /** + * Code snippet for {@link BlobAsyncClientBase#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} + * and {@link BlobAsyncClientBase#generateSas(BlobServiceSasSignatureValues)} + */ + public void generateSas() { + // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateSas#BlobServiceSasSignatureValues + OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); + BlobSasPermission permission = new BlobSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential + // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateSas#BlobServiceSasSignatureValues + + // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); + BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateUserDelegationSas(values, userDelegationKey); + // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + } } diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java index 7dfa2e03e0c4..be7acb599963 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java @@ -19,6 +19,9 @@ import com.azure.storage.blob.models.ParallelTransferOptions; import com.azure.storage.blob.models.RehydratePriority; import com.azure.storage.blob.models.StorageAccountInfo; +import com.azure.storage.blob.models.UserDelegationKey; +import com.azure.storage.blob.sas.BlobSasPermission; +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.common.implementation.Constants; import java.io.ByteArrayOutputStream; @@ -44,6 +47,7 @@ public class BlobClientBaseJavaDocCodeSnippets { private String key2 = "key2"; private String value1 = "val1"; private String value2 = "val2"; + private UserDelegationKey userDelegationKey; /** * Code snippets for {@link BlobClientBase#exists()} @@ -375,4 +379,30 @@ public void getAccountInfoWithResponseCodeSnippets() { System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName()); // END: com.azure.storage.blob.specialized.BlobClientBase.getAccountInfoWithResponse#Duration-Context } + + /** + * Code snippet for {@link BlobClientBase#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} + * and {@link BlobClientBase#generateSas(BlobServiceSasSignatureValues)} + */ + public void generateSas() { + // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.generateSas#BlobServiceSasSignatureValues + OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); + BlobSasPermission permission = new BlobSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential + // END: com.azure.storage.blob.specialized.BlobClientBase.generateSas#BlobServiceSasSignatureValues + + // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); + BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true); + + BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) + .setStartTime(OffsetDateTime.now()); + + client.generateUserDelegationSas(values, userDelegationKey); + // END: com.azure.storage.blob.specialized.BlobClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey + } } diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/AccountSasImplUtil.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/AccountSasImplUtil.java index ed405430de95..2f2060ba5fc0 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/AccountSasImplUtil.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/AccountSasImplUtil.java @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.storage.common.implementation; import com.azure.core.util.CoreUtils; @@ -12,6 +15,11 @@ import static com.azure.storage.common.implementation.SasImplUtils.formatQueryParameterDate; import static com.azure.storage.common.implementation.SasImplUtils.tryAppendQueryParameter; +/** + * This class provides helper methods for common account sas patterns. + * + * RESERVED FOR INTERNAL USE. + */ public class AccountSasImplUtil { private String version; diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/SasImplUtils.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/SasImplUtils.java index fc0241ae7527..a6dc9e2af731 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/SasImplUtils.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/SasImplUtils.java @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.storage.common.implementation; import com.azure.core.http.HttpPipeline; @@ -7,6 +10,11 @@ import java.time.OffsetDateTime; +/** + * This class provides helper methods for sas. + * + * RESERVED FOR INTERNAL USE. + */ public class SasImplUtils { /** * Extracts the {@link StorageSharedKeyCredential} from a {@link HttpPipeline} 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 index 7dbdd994cd6d..605c74c5dc9b 100644 --- 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 @@ -3,11 +3,9 @@ package com.azure.storage.common.implementation; -import com.azure.core.http.HttpPipeline; import com.azure.core.util.UrlBuilder; import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.Utility; import java.net.MalformedURLException; import java.net.URL; @@ -21,7 +19,6 @@ import java.util.TreeMap; import java.util.function.Function; -import com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; 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 45ee5fa9e817..ad792c4cc91f 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 @@ -38,7 +38,8 @@ public final class AccountSasSignatureValues { /** * Initializes a new {@link AccountSasSignatureValues} object. - * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, AccountSasResourceType)} + * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, + * AccountSasResourceType)} */ @Deprecated public AccountSasSignatureValues() { @@ -133,8 +134,8 @@ public OffsetDateTime getExpiryTime() { * * @param expiryTime Expiry time to set * @return the updated AccountSasSignatureValues object. - * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, AccountSasResourceType)} - * to specify the expiry time. + * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, + * AccountSasResourceType)} to specify the expiry time. */ @Deprecated public AccountSasSignatureValues setExpiryTime(OffsetDateTime expiryTime) { @@ -159,8 +160,8 @@ public String getPermissions() { * @param permissions Permissions to set. * @return the updated AccountSasSignatureValues object. * @throws NullPointerException if {@code permissions} is null. - * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, AccountSasResourceType)} - * to specify the allowed permissions. + * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, + * AccountSasResourceType)} to specify the allowed permissions. */ @Deprecated public AccountSasSignatureValues setPermissions(AccountSasPermission permissions) { @@ -200,8 +201,8 @@ public String getServices() { * * @param services Allowed services string to set * @return the updated AccountSasSignatureValues object. - * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, AccountSasResourceType)} - * to specify the services being targeted. + * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, + * AccountSasResourceType)} to specify the services being targeted. */ @Deprecated public AccountSasSignatureValues setServices(String services) { @@ -223,8 +224,8 @@ public String getResourceTypes() { * * @param resourceTypes Allowed resource types string to set * @return the updated AccountSasSignatureValues object. - * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, AccountSasResourceType)} - * to specify the resource types being targeted. + * @deprecated Please use {@link #AccountSasSignatureValues(OffsetDateTime, AccountSasPermission, AccountSasService, + * AccountSasResourceType)} to specify the resource types being targeted. */ @Deprecated public AccountSasSignatureValues setResourceTypes(String resourceTypes) { From 617c3db2f3f51d3ebfae764001699ea922f5cc48 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Mon, 25 Nov 2019 11:32:53 -0800 Subject: [PATCH 05/17] fixing test java 11 issue --- sdk/storage/azure-storage-blob/pom.xml | 1 + .../azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java | 2 +- .../com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java | 2 +- .../blob/BlobContainerAsyncClientJavaDocCodeSnippets.java | 2 +- .../storage/blob/BlobContainerClientJavaDocCodeSnippets.java | 2 +- .../specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java | 2 +- .../blob/specialized/BlobClientBaseJavaDocCodeSnippets.java | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sdk/storage/azure-storage-blob/pom.xml b/sdk/storage/azure-storage-blob/pom.xml index 40d4889566f2..7c89e56b2d52 100644 --- a/sdk/storage/azure-storage-blob/pom.xml +++ b/sdk/storage/azure-storage-blob/pom.xml @@ -269,6 +269,7 @@ --add-opens com.azure.storage.common/com.azure.storage.common.implementation=ALL-UNNAMED --add-opens com.azure.storage.blob/com.azure.storage.blob=ALL-UNNAMED --add-opens com.azure.storage.blob/com.azure.storage.blob.implementation=ALL-UNNAMED + --add-opens com.azure.storage.blob/com.azure.storage.blob.implementation.util=ALL-UNNAMED --add-opens com.azure.storage.blob/com.azure.storage.blob.specialized=ALL-UNNAMED --add-reads com.azure.core=ALL-UNNAMED --add-reads com.azure.core.test=ALL-UNNAMED diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java index 3a2cd78d1567..245c28a9449b 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java @@ -43,7 +43,7 @@ public class BlobAsyncClientJavaDocCodeSnippets { private int blockSize = 50; private int numBuffers = 2; private String filePath = "filePath"; - private UserDelegationKey userDelegationKey; + private UserDelegationKey userDelegationKey = null; /** * Code snippet for {@link BlobAsyncClient#exists()} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java index 2679d2be3ee2..615975c6b54f 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java @@ -47,7 +47,7 @@ public class BlobClientJavaDocCodeSnippets { private String value1 = "val1"; private String value2 = "val2"; private String filePath = "filePath"; - private UserDelegationKey userDelegationKey; + private UserDelegationKey userDelegationKey = null; /** * Code snippets for {@link BlobClient#exists()} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java index 66eb22b8c290..3720c7e62eed 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java @@ -32,7 +32,7 @@ public class BlobContainerAsyncClientJavaDocCodeSnippets { private String leaseId = "leaseId"; private String proposedId = "proposedId"; private int leaseDuration = (int) Duration.ofSeconds(30).getSeconds(); - private UserDelegationKey userDelegationKey; + private UserDelegationKey userDelegationKey = null; /** * Code snippet for {@link BlobContainerAsyncClient#getBlobAsyncClient(String)} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java index b901d1623225..156f6c44ac16 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java @@ -35,7 +35,7 @@ public class BlobContainerClientJavaDocCodeSnippets { private String proposedId = "proposedId"; private int leaseDuration = (int) Duration.ofSeconds(30).getSeconds(); private Duration timeout = Duration.ofSeconds(30); - private UserDelegationKey userDelegationKey; + private UserDelegationKey userDelegationKey = null; /** * Code snippet for {@link BlobContainerClient#getBlobClient(String)} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java index ecb673d81817..ac870034dab3 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java @@ -39,7 +39,7 @@ public class BlobAsyncClientBaseJavaDocCodeSnippets { private String copyId = "copyId"; private String url = "https://sample.com"; private String file = "file"; - private UserDelegationKey userDelegationKey; + private UserDelegationKey userDelegationKey = null; /** * Code snippet for {@link BlobAsyncClientBase#exists()} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java index be7acb599963..42313fe3c89d 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java @@ -47,7 +47,7 @@ public class BlobClientBaseJavaDocCodeSnippets { private String key2 = "key2"; private String value1 = "val1"; private String value2 = "val2"; - private UserDelegationKey userDelegationKey; + private UserDelegationKey userDelegationKey = null; /** * Code snippets for {@link BlobClientBase#exists()} From cd2bf81fbc084477dde9e40abb16cea3ae7d2221 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Mon, 25 Nov 2019 11:44:08 -0800 Subject: [PATCH 06/17] removed unused imports --- .../src/main/java/com/azure/storage/blob/BlobClient.java | 2 -- 1 file changed, 2 deletions(-) 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 c3bed69cc99c..4d873e481e29 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 @@ -5,7 +5,6 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobRequestConditions; import com.azure.storage.blob.models.BlobHttpHeaders; @@ -18,7 +17,6 @@ import com.azure.storage.blob.specialized.PageBlobClient; import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Mono; From 8db1537ce9f43621cf7e89ef414dd4b6a1c7593a Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Mon, 25 Nov 2019 12:01:12 -0800 Subject: [PATCH 07/17] fixing code snippets --- .../storage/blob/BlobAsyncClientJavaDocCodeSnippets.java | 2 +- .../azure/storage/blob/BlobClientJavaDocCodeSnippets.java | 2 +- .../blob/BlobContainerAsyncClientJavaDocCodeSnippets.java | 2 +- .../blob/BlobContainerClientJavaDocCodeSnippets.java | 2 +- .../com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java | 6 ++++++ .../specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java | 3 ++- .../blob/specialized/BlobClientBaseJavaDocCodeSnippets.java | 3 ++- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java index 245c28a9449b..af925299744e 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java @@ -43,7 +43,7 @@ public class BlobAsyncClientJavaDocCodeSnippets { private int blockSize = 50; private int numBuffers = 2; private String filePath = "filePath"; - private UserDelegationKey userDelegationKey = null; + private UserDelegationKey userDelegationKey = JavaDocCodeSnippetsHelpers.getUserDelegationKey(); /** * Code snippet for {@link BlobAsyncClient#exists()} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java index 615975c6b54f..5f6e6f3fd64e 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java @@ -47,7 +47,7 @@ public class BlobClientJavaDocCodeSnippets { private String value1 = "val1"; private String value2 = "val2"; private String filePath = "filePath"; - private UserDelegationKey userDelegationKey = null; + private UserDelegationKey userDelegationKey = JavaDocCodeSnippetsHelpers.getUserDelegationKey(); /** * Code snippets for {@link BlobClient#exists()} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java index 3720c7e62eed..5c01f5bb5060 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerAsyncClientJavaDocCodeSnippets.java @@ -32,7 +32,7 @@ public class BlobContainerAsyncClientJavaDocCodeSnippets { private String leaseId = "leaseId"; private String proposedId = "proposedId"; private int leaseDuration = (int) Duration.ofSeconds(30).getSeconds(); - private UserDelegationKey userDelegationKey = null; + private UserDelegationKey userDelegationKey = JavaDocCodeSnippetsHelpers.getUserDelegationKey(); /** * Code snippet for {@link BlobContainerAsyncClient#getBlobAsyncClient(String)} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java index 156f6c44ac16..0629bc63bf5c 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobContainerClientJavaDocCodeSnippets.java @@ -35,7 +35,7 @@ public class BlobContainerClientJavaDocCodeSnippets { private String proposedId = "proposedId"; private int leaseDuration = (int) Duration.ofSeconds(30).getSeconds(); private Duration timeout = Duration.ofSeconds(30); - private UserDelegationKey userDelegationKey = null; + private UserDelegationKey userDelegationKey = JavaDocCodeSnippetsHelpers.getUserDelegationKey(); /** * Code snippet for {@link BlobContainerClient#getBlobClient(String)} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java index 2523d7b4bcef..04be7ae407b1 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java @@ -3,6 +3,8 @@ package com.azure.storage.blob; +import com.azure.storage.blob.models.UserDelegationKey; + final class JavaDocCodeSnippetsHelpers { static BlobContainerAsyncClient getContainerAsyncClient() { return new BlobContainerClientBuilder().buildAsyncClient(); @@ -27,4 +29,8 @@ static BlobServiceAsyncClient getBlobServiceAsyncClient() { static BlobServiceClient getBlobServiceClient() { return new BlobServiceClientBuilder().buildClient(); } + + static UserDelegationKey getUserDelegationKey() { + return getBlobServiceClient().getUserDelegationKey(null, null); + } } diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java index ac870034dab3..9058b8e3cb8a 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java @@ -5,6 +5,7 @@ import com.azure.core.http.RequestConditions; import com.azure.core.util.polling.PollerFlux; +import com.azure.storage.blob.BlobServiceClientBuilder; import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobCopyInfo; @@ -39,7 +40,7 @@ public class BlobAsyncClientBaseJavaDocCodeSnippets { private String copyId = "copyId"; private String url = "https://sample.com"; private String file = "file"; - private UserDelegationKey userDelegationKey = null; + private UserDelegationKey userDelegationKey = new BlobServiceClientBuilder().buildClient().getUserDelegationKey(null, null); /** * Code snippet for {@link BlobAsyncClientBase#exists()} diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java index 42313fe3c89d..2cd4e3c850d8 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java @@ -8,6 +8,7 @@ import com.azure.core.util.polling.LongRunningOperationStatus; import com.azure.core.util.polling.PollResponse; import com.azure.core.util.polling.SyncPoller; +import com.azure.storage.blob.BlobServiceClientBuilder; import com.azure.storage.blob.models.BlobProperties; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobCopyInfo; @@ -47,7 +48,7 @@ public class BlobClientBaseJavaDocCodeSnippets { private String key2 = "key2"; private String value1 = "val1"; private String value2 = "val2"; - private UserDelegationKey userDelegationKey = null; + private UserDelegationKey userDelegationKey = new BlobServiceClientBuilder().buildClient().getUserDelegationKey(null, null); /** * Code snippets for {@link BlobClientBase#exists()} From 486b7f639ac2e0688d8012970ac1e6fbb0cf9ddd Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Mon, 25 Nov 2019 14:10:39 -0800 Subject: [PATCH 08/17] Addressed CR comments --- sdk/storage/azure-storage-blob/CHANGELOG.md | 1 + .../azure/storage/blob/BlobAsyncClient.java | 35 ------------------ .../com/azure/storage/blob/BlobClient.java | 36 +------------------ .../blob/BlobContainerAsyncClient.java | 5 ++- .../storage/blob/BlobContainerClient.java | 5 ++- .../sas/BlobServiceSasQueryParameters.java | 3 -- .../sas/BlobServiceSasSignatureValues.java | 10 ++++-- .../blob/specialized/BlobAsyncClientBase.java | 20 ++++++----- .../blob/specialized/BlobClientBase.java | 16 ++++----- .../BlobAsyncClientJavaDocCodeSnippets.java | 26 -------------- .../blob/BlobClientJavaDocCodeSnippets.java | 27 -------------- sdk/storage/azure-storage-common/CHANGELOG.md | 3 ++ 12 files changed, 39 insertions(+), 148 deletions(-) diff --git a/sdk/storage/azure-storage-blob/CHANGELOG.md b/sdk/storage/azure-storage-blob/CHANGELOG.md index 42c8d853aad0..f379f716fe6d 100644 --- a/sdk/storage/azure-storage-blob/CHANGELOG.md +++ b/sdk/storage/azure-storage-blob/CHANGELOG.md @@ -11,6 +11,7 @@ and - Fixed a bug in the RetryPolicy that would apply the delay of a fixed retry policy to the first try. - Fixed a bug that could cause the overwrite flag to not be honored in cases where data was uploaded by another source after a parallel operation has already started. - Added overloads to accept an overwrite flag to commitBlockList and getBlobOutputStream. Note that this changes the default behavior of the min overload and these methods will now fail if they are attempting to overwrite data. +- Added generate*Sas methods on clients to improve discoverability and convenience of sas. Deprecated setContainerName, setBlobName, setSnapshotId, generateSasQueryParameters methods on BlobServiceSasSignatureValues to direct users to using the methods added on clients. ## Version 12.0.0 (2019-10-31) diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java index dd9639661a18..706581dccd93 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java @@ -568,42 +568,7 @@ public Mono uploadFromFile(String filePath, ParallelTransferOptions parall } } - /** - * Generates a user delegation sas for the blob using the specified - * {@link BlobServiceSasSignatureValues}. - * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. - * - *

Code Samples

- * - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey {@link UserDelegationKey} - * - * @return A {@code String} representing all SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey) { - return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(), getSnapshotId()) - .generateUserDelegationSas(userDelegationKey, getAccountName()); - } - /** - * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} - * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. - * - *

Code Samples

- * - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.generateSas#BlobServiceSasSignatureValues} - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * - * @return A {@code String} representing all SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { - return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(), getSnapshotId()) - .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline())); - } boolean uploadInBlocks(String filePath) { AsynchronousFileChannel channel = uploadFileResourceSupplier(filePath); 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 4d873e481e29..86c7f20646c4 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 @@ -22,6 +22,7 @@ import java.io.UncheckedIOException; import java.time.Duration; +import java.time.OffsetDateTime; import java.util.Map; /** @@ -186,39 +187,4 @@ public void uploadFromFile(String filePath, ParallelTransferOptions parallelTran throw logger.logExceptionAsError(e); } } - - /** - * Generates a user delegation sas for the blob using the specified - * {@link BlobServiceSasSignatureValues}. - * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. - * - *

Code Samples

- * - * {@codesnippet com.azure.storage.blob.BlobClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey {@link UserDelegationKey} - * - * @return A {@code String} representing all SAS query parameters. - */ - public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, - UserDelegationKey userDelegationKey) { - return this.client.generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); - } - - /** - * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} - * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. - * - *

Code Samples

- * - * {@codesnippet com.azure.storage.blob.BlobClient.generateSas#BlobServiceSasSignatureValues} - * - * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * - * @return A {@code String} representing all SAS query parameters. - */ - public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { - return this.client.generateSas(blobServiceSasSignatureValues); - } } 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 2ed3cd08948d..43a353c04b84 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 @@ -39,6 +39,7 @@ import reactor.core.publisher.Mono; import java.time.Duration; +import java.time.OffsetDateTime; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; @@ -914,7 +915,9 @@ Mono> getAccountInfoWithResponse(Context context) { * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey {@link UserDelegationKey} + * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. + * @see BlobServiceAsyncClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime) for more information on how to + * get a user delegation key. * * @return A {@code String} representing all SAS query parameters. */ 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 5cd060168504..6fcd1d75f0c4 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 @@ -22,6 +22,7 @@ import reactor.core.publisher.Mono; import java.time.Duration; +import java.time.OffsetDateTime; import java.util.List; import java.util.Map; @@ -565,7 +566,9 @@ public Response getAccountInfoWithResponse(Duration timeout, * {@codesnippet com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey {@link UserDelegationKey} + * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. + * @see BlobServiceClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime) for more information on how to get a + * user delegation key. * * @return A {@code String} representing all SAS query parameters. */ diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java index d1fe21d78da4..69f5e2515213 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java @@ -240,10 +240,7 @@ UserDelegationKey userDelegationKey() { * Encodes all SAS query parameters into a string that can be appended to a URL. * * @return A {@code String} representing all SAS query parameters. - * @deprecated Please use the generate*Sas method on the desired container/blob client after initializing - * {@link BlobServiceSasSignatureValues}. */ - @Deprecated public String encode() { /* We should be url-encoding each key and each value, but because we know all the keys and values will encode to 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 eb2a06ab47e5..cbfadfddc7a1 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 @@ -28,8 +28,6 @@ * @see Constructing a * User Delegation SAS */ - -// TODO (gapra) : Add code snippets for new workflow public final class BlobServiceSasSignatureValues { /** * The SAS blob constant. @@ -298,7 +296,10 @@ public BlobServiceSasSignatureValues setSasIpRange(SasIpRange sasIpRange) { * Gets the name of the container the SAS user may access. * * @return The name of the container the SAS user may access. + * @deprecated Container name is not auto-populated by the generate*Sas methods provided on the desired + * container/blob client. */ + @Deprecated public String getContainerName() { return containerName; } @@ -323,7 +324,9 @@ public BlobServiceSasSignatureValues setContainerName(String containerName) { * * @return The decoded name of the blob the SAS user may access. {@code null} or an empty string is returned when a * creating a container SAS. + * @deprecated Blob name is now auto-populated by the generate*Sas methods provided on the desired blob client. */ + @Deprecated public String getBlobName() { return blobName; } @@ -344,7 +347,10 @@ public BlobServiceSasSignatureValues setBlobName(String blobName) { /** * @return the specific snapshot the SAS user may access. + * @deprecated Snapshot id is now auto-populated by the generate*Sas methods provided on the desired (snapshot) blob + * client. */ + @Deprecated public String getSnapshotId() { return this.snapshotId; } 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 acc17efe8632..4661b0f45939 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 @@ -15,8 +15,8 @@ import com.azure.core.util.polling.LongRunningOperationStatus; import com.azure.core.util.polling.PollResponse; import com.azure.core.util.polling.PollerFlux; -import com.azure.storage.blob.BlobAsyncClient; import com.azure.storage.blob.BlobClientBuilder; +import com.azure.storage.blob.BlobServiceAsyncClient; import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.blob.HttpGetterInfo; import com.azure.storage.blob.ProgressReporter; @@ -25,6 +25,7 @@ import com.azure.storage.blob.implementation.models.BlobGetAccountInfoHeaders; import com.azure.storage.blob.implementation.models.BlobGetPropertiesHeaders; import com.azure.storage.blob.implementation.models.BlobStartCopyFromURLHeaders; +import com.azure.storage.blob.implementation.util.BlobSasImplUtil; import com.azure.storage.blob.implementation.util.ModelHelper; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.ArchiveStatus; @@ -48,6 +49,7 @@ import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -67,6 +69,7 @@ import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.time.Duration; +import java.time.OffsetDateTime; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.Lock; @@ -1415,13 +1418,16 @@ Mono> getAccountInfoWithResponse(Context context) { * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey {@link UserDelegationKey} + * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. + * @see BlobServiceAsyncClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime) for more information on how to + * get a user delegation key. * * @return A {@code String} representing all SAS query parameters. */ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey) { - return getBlobAsyncClient().generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); + return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(), getSnapshotId()) + .generateUserDelegationSas(userDelegationKey, getAccountName()); } /** @@ -1437,11 +1443,7 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic * @return A {@code String} representing all SAS query parameters. */ public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { - return getBlobAsyncClient().generateSas(blobServiceSasSignatureValues); + return new BlobSasImplUtil(blobServiceSasSignatureValues, getContainerName(), getBlobName(), getSnapshotId()) + .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline())); } - - private BlobAsyncClient getBlobAsyncClient() { - return prepareBuilder().buildAsyncClient(); - } - } 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 5c628603d974..39a482b5bf01 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 @@ -12,6 +12,7 @@ import com.azure.core.util.logging.ClientLogger; import com.azure.core.util.polling.SyncPoller; import com.azure.storage.blob.BlobClient; +import com.azure.storage.blob.BlobServiceClient; import com.azure.storage.blob.models.BlobProperties; import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.blob.models.AccessTier; @@ -39,6 +40,7 @@ import java.net.URL; import java.nio.file.FileAlreadyExistsException; import java.time.Duration; +import java.time.OffsetDateTime; import java.util.Map; import static com.azure.storage.common.implementation.StorageImplUtils.blockWithOptionalTimeout; @@ -802,7 +804,6 @@ public Response getAccountInfoWithResponse(Duration timeout, return blockWithOptionalTimeout(response, timeout); } - /** * Generates a user delegation sas for the blob using the specified * {@link BlobServiceSasSignatureValues}. @@ -813,13 +814,14 @@ public Response getAccountInfoWithResponse(Duration timeout, * {@codesnippet com.azure.storage.blob.specialized.BlobClientBase.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} - * @param userDelegationKey {@link UserDelegationKey} - * + * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. + * @see BlobServiceClient#getUserDelegationKey(OffsetDateTime, OffsetDateTime) for more information on how to get a + * user delegation key. * @return A {@code String} representing all SAS query parameters. */ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey) { - return getBlobClient().generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); + return this.client.generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey); } /** @@ -835,10 +837,6 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic * @return A {@code String} representing all SAS query parameters. */ public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) { - return getBlobClient().generateSas(blobServiceSasSignatureValues); - } - - private BlobClient getBlobClient() { - return this.client.prepareBuilder().buildClient(); + return this.client.generateSas(blobServiceSasSignatureValues); } } diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java index af925299744e..c843263a1131 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java @@ -509,30 +509,4 @@ public void uploadFromFile2() { .subscribe(completion -> System.out.println("Upload from file succeeded")); // END: com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions } - - /** - * Code snippet for {@link BlobAsyncClient#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} - * and {@link BlobAsyncClient#generateSas(BlobServiceSasSignatureValues)} - */ - public void generateSas() { - // BEGIN: com.azure.storage.blob.BlobAsyncClient.generateSas#BlobServiceSasSignatureValues - OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission permission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential - // END: com.azure.storage.blob.BlobAsyncClient.generateSas#BlobServiceSasSignatureValues - - // BEGIN: com.azure.storage.blob.BlobAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateUserDelegationSas(values, userDelegationKey); - // END: com.azure.storage.blob.BlobAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - } } diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java index 5f6e6f3fd64e..cffd347c8025 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java @@ -431,31 +431,4 @@ public void uploadFromFile2() throws IOException { } // END: com.azure.storage.blob.BlobClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions-Duration } - - - /** - * Code snippet for {@link BlobClient#generateUserDelegationSas(BlobServiceSasSignatureValues, UserDelegationKey)} - * and {@link BlobClient#generateSas(BlobServiceSasSignatureValues)} - */ - public void generateSas() { - // BEGIN: com.azure.storage.blob.BlobClient.generateSas#BlobServiceSasSignatureValues - OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission permission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential - // END: com.azure.storage.blob.BlobClient.generateSas#BlobServiceSasSignatureValues - - // BEGIN: com.azure.storage.blob.BlobClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); - BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true); - - BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) - .setStartTime(OffsetDateTime.now()); - - client.generateUserDelegationSas(values, userDelegationKey); - // END: com.azure.storage.blob.BlobClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey - } } diff --git a/sdk/storage/azure-storage-common/CHANGELOG.md b/sdk/storage/azure-storage-common/CHANGELOG.md index 169c45c8f3fa..25e39b7498eb 100644 --- a/sdk/storage/azure-storage-common/CHANGELOG.md +++ b/sdk/storage/azure-storage-common/CHANGELOG.md @@ -1,4 +1,7 @@ # Release History +## Version XX.X.X (XXXX-XX-XX) +- Added generateSas methods on service clients to improve discoverability and convenience of sas. Deprecated setters of required parameters, generateSasQueryParameters methods on AccountSasSignatureValues to direct users to using the methods added on clients. + ## Version 12.0.0 (2019-10-31) - Removed BaseClientBuilder - Renamed RequestRetryOptions maxTries, tryTimeout, secondaryHost, retryDelayInMs, maxRetryDelayInMs to getMaxTries, getTryTimeout, getSecondaryHosy, getRetryDelayInMs, getMaxRetryDelayInMs From 05980872697ebc724d2a9240e4066b722056ccc2 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Mon, 25 Nov 2019 14:20:29 -0800 Subject: [PATCH 09/17] removed imports --- .../src/main/java/com/azure/storage/blob/BlobAsyncClient.java | 4 ---- .../src/main/java/com/azure/storage/blob/BlobClient.java | 3 --- 2 files changed, 7 deletions(-) diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java index 706581dccd93..4c3c67ae36eb 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java @@ -7,7 +7,6 @@ import com.azure.core.http.rest.Response; import com.azure.core.util.FluxUtil; import com.azure.core.util.logging.ClientLogger; -import com.azure.storage.blob.implementation.util.BlobSasImplUtil; import com.azure.storage.blob.implementation.util.ModelHelper; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobHttpHeaders; @@ -17,15 +16,12 @@ import com.azure.storage.blob.models.CpkInfo; import com.azure.storage.blob.models.CustomerProvidedKey; import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.blob.specialized.AppendBlobAsyncClient; import com.azure.storage.blob.specialized.BlobAsyncClientBase; import com.azure.storage.blob.specialized.BlockBlobAsyncClient; import com.azure.storage.blob.specialized.PageBlobAsyncClient; import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder; import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.implementation.SasImplUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; 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 86c7f20646c4..718d9d4cf95b 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 @@ -9,8 +9,6 @@ import com.azure.storage.blob.models.BlobRequestConditions; import com.azure.storage.blob.models.BlobHttpHeaders; import com.azure.storage.blob.models.ParallelTransferOptions; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.blob.specialized.AppendBlobClient; import com.azure.storage.blob.specialized.BlobClientBase; import com.azure.storage.blob.specialized.BlockBlobClient; @@ -22,7 +20,6 @@ import java.io.UncheckedIOException; import java.time.Duration; -import java.time.OffsetDateTime; import java.util.Map; /** From 09532604bdf7f22ce08a3208302f9bf9114919e9 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Wed, 27 Nov 2019 07:15:18 -0800 Subject: [PATCH 10/17] Updated javadoc --- .../blob/BlobContainerAsyncClient.java | 9 ++++--- .../storage/blob/BlobContainerClient.java | 9 ++++--- .../storage/blob/BlobServiceAsyncClient.java | 4 ++-- .../azure/storage/blob/BlobServiceClient.java | 4 ++-- .../blob/specialized/BlobAsyncClientBase.java | 24 ++++--------------- .../blob/specialized/BlobClientBase.java | 9 ++++--- 6 files changed, 20 insertions(+), 39 deletions(-) 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 43a353c04b84..1fb63b6b0bf9 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 @@ -906,9 +906,8 @@ Mono> getAccountInfoWithResponse(Context context) { } /** - * Generates a user delegation sas for the container using the specified - * {@link BlobServiceSasSignatureValues}. - * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. + * Generates a user delegation SAS for the container using the specified {@link BlobServiceSasSignatureValues}. + *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

* *

Code Samples

* @@ -928,8 +927,8 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic } /** - * Generates a service sas for the container using the specified {@link BlobServiceSasSignatureValues} - * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. + * Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues} + *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

* *

Code Samples

* 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 6fcd1d75f0c4..9662fad39774 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 @@ -557,9 +557,8 @@ public Response getAccountInfoWithResponse(Duration timeout, } /** - * Generates a user delegation sas for the container using the specified - * {@link BlobServiceSasSignatureValues}. - * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. + * Generates a user delegation SAS for the container using the specified {@link BlobServiceSasSignatureValues}. + *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

* *

Code Samples

* @@ -578,8 +577,8 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic } /** - * Generates a service sas for the container using the specified {@link BlobServiceSasSignatureValues} - * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. + * Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues} + *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

* *

Code Samples

* 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 40fff379f1f4..43434d8d175c 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 @@ -556,8 +556,8 @@ public String getAccountName() { } /** - * Generates an account sas for the Azure Storage account using the specified {@link AccountSasSignatureValues}. - * @see AccountSasSignatureValues for more information on how to construct an account SAS. + * Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}. + *

See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.

* *

The snippet below generates a SAS that lasts for two days and gives the user read and list access to blob * containers and file shares.

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 1668483bfc59..a9dbbfeed6cc 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 @@ -375,8 +375,8 @@ public String getAccountName() { } /** - * Generates an account sas for the Azure Storage account using the specified {@link AccountSasSignatureValues}. - * @see AccountSasSignatureValues for more information on how to construct an account SAS. + * Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}. + *

See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.

* *

Generating an account SAS

*

The snippet below generates an AccountSasSignatureValues object that lasts for two days and gives the user 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 4661b0f45939..bbabd8818163 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 @@ -131,21 +131,6 @@ protected BlobAsyncClientBase(HttpPipeline pipeline, String url, BlobServiceVers this.customerProvidedKey = customerProvidedKey; } - BlobClientBuilder prepareBuilder() { - BlobClientBuilder builder = new BlobClientBuilder() - .pipeline(getHttpPipeline()) - .endpoint(getBlobUrl()) - .snapshot(getSnapshotId()) - .serviceVersion(getServiceVersion()); - - CpkInfo cpk = getCustomerProvidedKey(); - if (cpk != null) { - builder.customerProvidedKey(new CustomerProvidedKey(cpk.getEncryptionKey())); - } - - return builder; - } - /** * Creates a new {@link BlobAsyncClientBase} linked to the {@code snapshot} of this blob resource. * @@ -1409,9 +1394,8 @@ Mono> getAccountInfoWithResponse(Context context) { } /** - * Generates a user delegation sas for the blob using the specified - * {@link BlobServiceSasSignatureValues}. - * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. + * Generates a user delegation SAS for the blob using the specified {@link BlobServiceSasSignatureValues}. + *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

* *

Code Samples

* @@ -1431,8 +1415,8 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic } /** - * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} - * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. + * Generates a service SAS for the blob using the specified {@link BlobServiceSasSignatureValues} + *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

* *

Code Samples

* 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 39a482b5bf01..00e96722564d 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 @@ -805,9 +805,8 @@ public Response getAccountInfoWithResponse(Duration timeout, } /** - * Generates a user delegation sas for the blob using the specified - * {@link BlobServiceSasSignatureValues}. - * @see BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS. + * Generates a user delegation SAS for the blob using the specified {@link BlobServiceSasSignatureValues}. + *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a user delegation SAS.

* *

Code Samples

* @@ -825,8 +824,8 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic } /** - * Generates a service sas for the blob using the specified {@link BlobServiceSasSignatureValues} - * @see BlobServiceSasSignatureValues for more information on how to construct a service SAS. + * Generates a service SAS for the blob using the specified {@link BlobServiceSasSignatureValues} + *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

* *

Code Samples

* From ca1066222fa54c437892b51db05ec909edd3cdee Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Wed, 27 Nov 2019 08:38:41 -0800 Subject: [PATCH 11/17] Added Sas test, changed a few javadocs --- sdk/storage/azure-storage-blob/CHANGELOG.md | 2 +- .../blob/sas/BlobServiceSasSignatureValues.java | 16 ++++++++-------- .../blob/specialized/BlobAsyncClientBase.java | 2 -- .../common/sas/AccountSasQueryParameters.java | 4 ++-- .../common/sas/AccountSasSignatureValues.java | 5 ++--- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/sdk/storage/azure-storage-blob/CHANGELOG.md b/sdk/storage/azure-storage-blob/CHANGELOG.md index f379f716fe6d..f167978f499a 100644 --- a/sdk/storage/azure-storage-blob/CHANGELOG.md +++ b/sdk/storage/azure-storage-blob/CHANGELOG.md @@ -11,7 +11,7 @@ and - Fixed a bug in the RetryPolicy that would apply the delay of a fixed retry policy to the first try. - Fixed a bug that could cause the overwrite flag to not be honored in cases where data was uploaded by another source after a parallel operation has already started. - Added overloads to accept an overwrite flag to commitBlockList and getBlobOutputStream. Note that this changes the default behavior of the min overload and these methods will now fail if they are attempting to overwrite data. -- Added generate*Sas methods on clients to improve discoverability and convenience of sas. Deprecated setContainerName, setBlobName, setSnapshotId, generateSasQueryParameters methods on BlobServiceSasSignatureValues to direct users to using the methods added on clients. +- Added SAS generation methods on clients to improve discoverability and convenience of sas. Deprecated setContainerName, setBlobName, setSnapshotId, generateSasQueryParameters methods on BlobServiceSasSignatureValues to direct users to using the methods added on clients. ## Version 12.0.0 (2019-10-31) 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 cbfadfddc7a1..8daced5eef70 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 @@ -18,7 +18,7 @@ /** * Used to initialize parameters for a Shared Access Signature (SAS) for an Azure Blob Storage service. Once all the - * values here are set, use the appropriate generate*Sas method on the desired container/blob client to obtain a + * values here are set, use the appropriate SAS generation method on the desired container/blob client to obtain a * representation of the SAS which can then be applied to a new client using the .sasToken(String) method on the * desired client builder. * @@ -296,7 +296,7 @@ public BlobServiceSasSignatureValues setSasIpRange(SasIpRange sasIpRange) { * Gets the name of the container the SAS user may access. * * @return The name of the container the SAS user may access. - * @deprecated Container name is not auto-populated by the generate*Sas methods provided on the desired + * @deprecated Container name is now auto-populated by the SAS generation methods provided on the desired * container/blob client. */ @Deprecated @@ -309,7 +309,7 @@ public String getContainerName() { * * @param containerName The name of the container. * @return The updated BlobServiceSASSignatureValues object. - * @deprecated Please use the generate*Sas methods provided on the desired container/blob client that will + * @deprecated Please use the SAS generation methods provided on the desired container/blob client that will * auto-populate the container name. */ @Deprecated @@ -324,7 +324,7 @@ public BlobServiceSasSignatureValues setContainerName(String containerName) { * * @return The decoded name of the blob the SAS user may access. {@code null} or an empty string is returned when a * creating a container SAS. - * @deprecated Blob name is now auto-populated by the generate*Sas methods provided on the desired blob client. + * @deprecated Blob name is now auto-populated by the SAS generation methods provided on the desired blob client. */ @Deprecated public String getBlobName() { @@ -336,7 +336,7 @@ public String getBlobName() { * * @param blobName The name of the blob. Use {@code null} or an empty string to create a container SAS. * @return The updated BlobServiceSASSignatureValues object. - * @deprecated Please use the generate*Sas methods provided on the desired blob client that will auto-populate the + * @deprecated Please use the SAS generation methods provided on the desired blob client that will auto-populate the * blob name. */ @Deprecated @@ -347,8 +347,8 @@ public BlobServiceSasSignatureValues setBlobName(String blobName) { /** * @return the specific snapshot the SAS user may access. - * @deprecated Snapshot id is now auto-populated by the generate*Sas methods provided on the desired (snapshot) blob - * client. + * @deprecated Snapshot id is now auto-populated by the SAS generation methods provided on the desired (snapshot) + * blob client. */ @Deprecated public String getSnapshotId() { @@ -363,7 +363,7 @@ public String getSnapshotId() { * * @param snapshotId Identifier of the snapshot * @return the updated BlobServiceSASSignatureValues object - * @deprecated Please use the generate*Sas methods provided on the desired (snapshot) blob client that will + * @deprecated Please use the SAS generation methods provided on the desired (snapshot) blob client that will * auto-populate the snapshot id. */ @Deprecated 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 bbabd8818163..ebbe00be59f2 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 @@ -15,7 +15,6 @@ import com.azure.core.util.polling.LongRunningOperationStatus; import com.azure.core.util.polling.PollResponse; import com.azure.core.util.polling.PollerFlux; -import com.azure.storage.blob.BlobClientBuilder; import com.azure.storage.blob.BlobServiceAsyncClient; import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.blob.HttpGetterInfo; @@ -39,7 +38,6 @@ import com.azure.storage.blob.models.BlobStorageException; import com.azure.storage.blob.models.CopyStatusType; import com.azure.storage.blob.models.CpkInfo; -import com.azure.storage.blob.models.CustomerProvidedKey; import com.azure.storage.blob.models.DeleteSnapshotsOptionType; import com.azure.storage.blob.models.DownloadRetryOptions; import com.azure.storage.blob.models.ParallelTransferOptions; 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 66ecfc39c8c3..362d7faaabd6 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 @@ -14,7 +14,7 @@ * appended to a URL directly (though caution should be taken here in case there are existing query parameters, which * might affect the appropriate means of appending these query parameters). NOTE: Instances of this class are immutable * to ensure thread safety. - * @deprecated Please use the generate*Sas method on the desired service client after initializing + * @deprecated Please use the generateSas method on the desired service client after initializing * {@link AccountSasSignatureValues}. */ @Deprecated @@ -83,7 +83,7 @@ public String getResourceTypes() { * Encodes all SAS query parameters into a string that can be appended to a URL. * * @return A {@code String} representing all SAS query parameters. - * @deprecated Please use the generate*Sas method on the desired service client after initializing + * @deprecated Please use the generateSas method on the desired service client after initializing * {@link AccountSasSignatureValues}. */ @Deprecated 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 ad792c4cc91f..9cfff06b1ed4 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 @@ -12,9 +12,8 @@ /** * Used to initialize parameters for a Shared Access Signature (SAS) for an Azure Storage account. Once all the - * values here are set, use the appropriate generate*Sas method on the desired service client to obtain a - * representation of the SAS which can then be applied to a new client using the .sasToken(String) method on the - * desired client builder. + * values here are set, use the generateSas method on the desired service client to obtain a representation of the SAS + * which can then be applied to a new client using the .sasToken(String) method on the desired client builder. * * @see Storage SAS overview * @see Create an account SAS From 11f708236e93e3f8b487edb41d39324ae580416e Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Wed, 27 Nov 2019 11:24:47 -0800 Subject: [PATCH 12/17] Removed new lines --- .../src/main/java/com/azure/storage/blob/BlobAsyncClient.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java index 4c3c67ae36eb..0450df7d194d 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java @@ -564,8 +564,6 @@ public Mono uploadFromFile(String filePath, ParallelTransferOptions parall } } - - boolean uploadInBlocks(String filePath) { AsynchronousFileChannel channel = uploadFileResourceSupplier(filePath); boolean retVal; From cf69e8bd086b5a5e3f566592aee30c816e6142fb Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Wed, 27 Nov 2019 12:09:18 -0800 Subject: [PATCH 13/17] removed unnecessary java doc snippets class --- ...SasSignatureValuesJavaDocCodeSnippets.java | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobServiceSasSignatureValuesJavaDocCodeSnippets.java diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobServiceSasSignatureValuesJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobServiceSasSignatureValuesJavaDocCodeSnippets.java deleted file mode 100644 index 28545a360ab2..000000000000 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobServiceSasSignatureValuesJavaDocCodeSnippets.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized; - -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.sas.BlobServiceSasQueryParameters; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; -import com.azure.storage.common.StorageSharedKeyCredential; -import com.azure.storage.common.sas.SasProtocol; - -import java.time.OffsetDateTime; - -/** - * Code snippets for {@link BlobServiceSasSignatureValues}. - */ -public class BlobServiceSasSignatureValuesJavaDocCodeSnippets { - /** - * Generates a blob SAS with {@link StorageSharedKeyCredential} - */ - public void blobSas() { - // BEGIN: com.azure.storage.blob.specialized.BlobServiceSasSignatureValues.generateSasQueryParameters#StorageSharedKeyCredential - BlobSasPermission blobPermission = new BlobSasPermission().setReadPermission(true); - - // We are creating a SAS to a blob because we set both the container name and blob name. - BlobServiceSasSignatureValues builder = new BlobServiceSasSignatureValues() - .setProtocol(SasProtocol.HTTPS_ONLY) // Users MUST use HTTPS (not HTTP). - .setExpiryTime(OffsetDateTime.now().plusDays(2)) - .setContainerName("my-container") - .setBlobName("HelloWorld.txt") - .setPermissions(blobPermission); - - StorageSharedKeyCredential credential = new StorageSharedKeyCredential("account-name", "key"); - BlobServiceSasQueryParameters sasQueryParameters = builder.generateSasQueryParameters(credential); - // END: com.azure.storage.blob.specialized.BlobServiceSasSignatureValues.generateSasQueryParameters#StorageSharedKeyCredential - } - - /** - * Generates a container SAS using {@link UserDelegationKey}. - */ - public void userDelegationKey() { - // BEGIN: com.azure.storage.blob.specialized.BlobServiceSasSignatureValues.generateSasQueryParameters#UserDelegationKey-String - BlobSasPermission blobPermission = new BlobSasPermission() - .setReadPermission(true) - .setWritePermission(true); - - // We are creating a SAS to a container because only container name is set. - BlobServiceSasSignatureValues builder = new BlobServiceSasSignatureValues() - .setProtocol(SasProtocol.HTTPS_ONLY) // Users MUST use HTTPS (not HTTP). - .setExpiryTime(OffsetDateTime.now().plusDays(2)) - .setContainerName("my-container") - .setPermissions(blobPermission); - - // Get a user delegation key after signing in with Azure AD - UserDelegationKey credential = new UserDelegationKey(); - String account = "my-blob-storage-account"; - BlobServiceSasQueryParameters sasQueryParameters = builder.generateSasQueryParameters(credential, account); - // END: com.azure.storage.blob.specialized.BlobServiceSasSignatureValues.generateSasQueryParameters#UserDelegationKey-String - } -} From 3bbdc6b37e29f25acc3ce360e1bf23abea2237e2 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Mon, 2 Dec 2019 09:14:33 -0800 Subject: [PATCH 14/17] Removed unused imports --- .../azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java | 2 -- .../com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java index c843263a1131..eb3080f8d894 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java @@ -13,8 +13,6 @@ import com.azure.storage.blob.models.ParallelTransferOptions; import com.azure.storage.blob.models.RehydratePriority; import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.blob.specialized.BlobAsyncClientBase; import reactor.core.publisher.Flux; diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java index cffd347c8025..8050fdd08d73 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java @@ -16,8 +16,6 @@ import com.azure.storage.blob.models.RehydratePriority; import com.azure.storage.blob.models.StorageAccountInfo; import com.azure.storage.blob.models.UserDelegationKey; -import com.azure.storage.blob.sas.BlobSasPermission; -import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; import com.azure.storage.blob.specialized.BlobClientBase; import com.azure.storage.common.implementation.Constants; From 30fdc33b082137b3479e5772d5449381ec416f59 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Fri, 6 Dec 2019 14:46:45 -0800 Subject: [PATCH 15/17] Deprecated BlobServiceSasQueryParameters --- .../storage/blob/sas/BlobServiceSasQueryParameters.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java index 69f5e2515213..b5849cf6745a 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java @@ -21,7 +21,10 @@ * appended to a URL directly (though caution should be taken here in case there are existing query parameters, which * might affect the appropriate means of appending these query parameters). NOTE: Instances of this class are immutable * to ensure thread safety. + * @deprecated Please use the generateSas method on the desired blob/container client after initializing + * {@link BlobServiceSasSignatureValues}. */ +@Deprecated public final class BlobServiceSasQueryParameters extends BaseSasQueryParameters { private final String identifier; @@ -240,7 +243,10 @@ UserDelegationKey userDelegationKey() { * Encodes all SAS query parameters into a string that can be appended to a URL. * * @return A {@code String} representing all SAS query parameters. + * @deprecated Please use the generateSas method on the desired blob/container client after initializing + * {@link BlobServiceSasSignatureValues}. */ + @Deprecated public String encode() { /* We should be url-encoding each key and each value, but because we know all the keys and values will encode to From 8f27659c3ceaa843b37b16317ce0fcd62fe16546 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Fri, 6 Dec 2019 15:06:37 -0800 Subject: [PATCH 16/17] Added note that client must be authenticated via sharedkeycredential --- .../java/com/azure/storage/blob/BlobContainerAsyncClient.java | 2 ++ .../main/java/com/azure/storage/blob/BlobContainerClient.java | 2 ++ .../java/com/azure/storage/blob/BlobServiceAsyncClient.java | 2 ++ .../src/main/java/com/azure/storage/blob/BlobServiceClient.java | 2 ++ .../com/azure/storage/blob/specialized/BlobAsyncClientBase.java | 2 ++ .../java/com/azure/storage/blob/specialized/BlobClientBase.java | 2 ++ 6 files changed, 12 insertions(+) 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 1fb63b6b0bf9..d0456b868a42 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 @@ -33,6 +33,7 @@ import com.azure.storage.blob.models.StorageAccountInfo; import com.azure.storage.blob.models.UserDelegationKey; import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; +import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; @@ -928,6 +929,7 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic /** * Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues} + * Note : The client must be authenticated via {@link StorageSharedKeyCredential} *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

* *

Code Samples

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 9662fad39774..f5b48e7637a9 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 @@ -19,6 +19,7 @@ import com.azure.storage.blob.models.StorageAccountInfo; import com.azure.storage.blob.models.UserDelegationKey; import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; +import com.azure.storage.common.StorageSharedKeyCredential; import reactor.core.publisher.Mono; import java.time.Duration; @@ -578,6 +579,7 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic /** * Generates a service SAS for the container using the specified {@link BlobServiceSasSignatureValues} + * Note : The client must be authenticated via {@link StorageSharedKeyCredential} *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

* *

Code Samples

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 43434d8d175c..312ca68beafa 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 @@ -28,6 +28,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.StorageSharedKeyCredential; import com.azure.storage.common.implementation.AccountSasImplUtil; import com.azure.storage.common.implementation.Constants; import com.azure.storage.common.implementation.SasImplUtils; @@ -557,6 +558,7 @@ public String getAccountName() { /** * Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}. + * Note : The client must be authenticated via {@link StorageSharedKeyCredential} *

See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.

* *

The snippet below generates a SAS that lasts for two days and gives the user read and list access to blob 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 a9dbbfeed6cc..7ab7cc05ee3d 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,6 +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.StorageSharedKeyCredential; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.common.sas.AccountSasSignatureValues; import reactor.core.publisher.Mono; @@ -376,6 +377,7 @@ public String getAccountName() { /** * Generates an account SAS for the Azure Storage account using the specified {@link AccountSasSignatureValues}. + * Note : The client must be authenticated via {@link StorageSharedKeyCredential} *

See {@link AccountSasSignatureValues} for more information on how to construct an account SAS.

* *

Generating an account SAS

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 ebbe00be59f2..6d0ea56a2702 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 @@ -45,6 +45,7 @@ import com.azure.storage.blob.models.StorageAccountInfo; import com.azure.storage.blob.models.UserDelegationKey; import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; +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.SasImplUtils; @@ -1414,6 +1415,7 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic /** * Generates a service SAS for the blob using the specified {@link BlobServiceSasSignatureValues} + * Note : The client must be authenticated via {@link StorageSharedKeyCredential} *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

* *

Code Samples

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 00e96722564d..bc0df9fcc0c1 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 @@ -30,6 +30,7 @@ import com.azure.storage.blob.models.StorageAccountInfo; import com.azure.storage.blob.models.UserDelegationKey; import com.azure.storage.blob.sas.BlobServiceSasSignatureValues; +import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.Exceptions; import reactor.core.publisher.Mono; @@ -825,6 +826,7 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic /** * Generates a service SAS for the blob using the specified {@link BlobServiceSasSignatureValues} + * Note : The client must be authenticated via {@link StorageSharedKeyCredential} *

See {@link BlobServiceSasSignatureValues} for more information on how to construct a service SAS.

* *

Code Samples

From 8a6f98e92f87e3bddd92923a7812a8b6d3fef4ac Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Mon, 9 Dec 2019 09:39:17 -0800 Subject: [PATCH 17/17] Added deprecation tags to all public methods in sas query parameters --- .../sas/BlobServiceSasQueryParameters.java | 31 +++ .../common/sas/AccountSasQueryParameters.java | 8 + .../common/sas/BaseSasQueryParameters.java | 32 ++++ .../common/sas/CommonSasQueryParameters.java | 179 +++++++++++++++--- 4 files changed, 221 insertions(+), 29 deletions(-) diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java index b5849cf6745a..b87f119c34c7 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasQueryParameters.java @@ -59,7 +59,9 @@ public final class BlobServiceSasQueryParameters extends BaseSasQueryParameters * @param queryParamsMap All query parameters for the request as key-value pairs * @param removeSasParametersFromMap When {@code true}, the SAS query parameters will be removed from * queryParamsMap + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public BlobServiceSasQueryParameters(Map queryParamsMap, boolean removeSasParametersFromMap) { super(queryParamsMap, removeSasParametersFromMap); this.identifier = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SIGNED_IDENTIFIER, @@ -104,7 +106,9 @@ public BlobServiceSasQueryParameters(Map queryParamsMap, boole * @param resource A {@code String} representing the storage container or blob (only for Service SAS). * @param permissions A {@code String} representing the storage permissions or {@code null}. * @param signature A {@code String} representing the signature for the SAS token. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated BlobServiceSasQueryParameters(String version, SasProtocol protocol, OffsetDateTime startTime, OffsetDateTime expiryTime, SasIpRange sasIpRange, String identifier, String resource, String permissions, String signature, String cacheControl, String contentDisposition, String contentEncoding, @@ -140,95 +144,122 @@ public BlobServiceSasQueryParameters(Map queryParamsMap, boole * @return The signed identifier (only for {@link BlobServiceSasSignatureValues}) or {@code null}. Please see * here * for more information. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public String getIdentifier() { return identifier; } /** * @return The storage container or blob (only for {@link BlobServiceSasSignatureValues}). + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public String getResource() { return resource; } /** * @return The Cache-Control header value when a client accesses the resource with this sas token. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public String getCacheControl() { return cacheControl; } /** * @return The Content-Disposition header value when a client accesses the resource with this sas token. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public String getContentDisposition() { return contentDisposition; } /** * @return The Content-Encoding header value when a client accesses the resource with this sas token. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public String getContentEncoding() { return contentEncoding; } /** * @return The Content-Language header value when a client accesses the resource with this sas token. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public String getContentLanguage() { return contentLanguage; } /** * @return The Content-Type header value when a client accesses the resource with this sas token. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public String getContentType() { return contentType; } /** * @return the object ID of the key. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public String getKeyObjectId() { return keyObjectId; } /** * @return the tenant ID of the key. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public String getKeyTenantId() { return keyTenantId; } /** * @return the datetime when the key becomes active. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public OffsetDateTime getKeyStart() { return keyStart; } /** * @return the datetime when the key expires. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public OffsetDateTime getKeyExpiry() { return keyExpiry; } /** * @return the services that are permitted by the key. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public String getKeyService() { return keyService; } /** * @return the service version that created the key. + * @deprecated Please use {@link BlobServiceSasSignatureValues} */ + @Deprecated public String getKeyVersion() { return keyVersion; } + @Deprecated UserDelegationKey userDelegationKey() { return new UserDelegationKey() .setSignedExpiry(this.keyExpiry) 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 362d7faaabd6..05379804e6a1 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 @@ -30,7 +30,9 @@ public final class AccountSasQueryParameters extends BaseSasQueryParameters { * @param queryParamsMap All query parameters for the request as key-value pairs * @param removeSasParameters When {@code true}, the SAS query parameters will be removed from * queryParamsMap + * @deprecated Please use {@link AccountSasSignatureValues} */ + @Deprecated AccountSasQueryParameters(Map queryParamsMap, boolean removeSasParameters) { super(queryParamsMap, removeSasParameters); this.resourceTypes = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_RESOURCES_TYPES, @@ -54,7 +56,9 @@ public final class AccountSasQueryParameters extends BaseSasQueryParameters { * {@code null}. * @param permissions A {@code String} representing the storage permissions or {@code null}. * @param signature A {@code String} representing the signature for the SAS token. + * @deprecated Please use {@link AccountSasSignatureValues} */ + @Deprecated AccountSasQueryParameters(String version, String services, String resourceTypes, SasProtocol protocol, OffsetDateTime startTime, OffsetDateTime expiryTime, SasIpRange sasIpRange, String permissions, String signature) { @@ -66,7 +70,9 @@ public final class AccountSasQueryParameters extends BaseSasQueryParameters { /** * @return The storage services being accessed (only for Account SAS). Please refer to {@link AccountSasService} for * more details. + * @deprecated Please use {@link AccountSasSignatureValues} */ + @Deprecated public String getServices() { return services; } @@ -74,7 +80,9 @@ public String getServices() { /** * @return The storage resource types being accessed (only for Account SAS). Please refer to {@link * AccountSasResourceType} for more details. + * @deprecated Please use {@link AccountSasSignatureValues} */ + @Deprecated public String getResourceTypes() { return resourceTypes; } 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 e03c24a0f15a..d921afe1a8c1 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 @@ -18,7 +18,10 @@ * object to be constructed as part of a URL or it can be encoded into a {@code String} and appended to a URL directly * (though caution should be taken here in case there are existing query parameters, which might affect the appropriate * means of appending these query parameters). NOTE: Instances of this class are immutable to ensure thread safety. + * @deprecated Please use the generateSas method on the desired client after initializing the appropriate + * SasSignatureValues object. */ +@Deprecated public abstract class BaseSasQueryParameters { protected String version; @@ -41,7 +44,9 @@ public abstract class BaseSasQueryParameters { * @param queryParamsMap All query parameters for the request as key-value pairs * @param removeSASParametersFromMap When {@code true}, the SAS query parameters will be removed from * queryParamsMap + * @deprecated Please use SasSignatureValues */ + @Deprecated public BaseSasQueryParameters(Map queryParamsMap, boolean removeSASParametersFromMap) { this.version = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SERVICE_VERSION, removeSASParametersFromMap); @@ -66,7 +71,9 @@ public BaseSasQueryParameters(Map queryParamsMap, boolean remo * @param name The name of parameter to find. * @param remove Whether or not to remove the parameter from the map. * @return A String representing the query parameter + * @deprecated Please use SasSignatureValues */ + @Deprecated protected String getQueryParameter(Map parameters, String name, boolean remove) { return getQueryParameter(parameters, name, remove, value -> value); } @@ -80,7 +87,9 @@ protected String getQueryParameter(Map parameters, String name * @param remove Whether or not to remove the parameter from the map. * @param converter Function that transforms the value to a String. * @return The object + * @deprecated Please use SasSignatureValues */ + @Deprecated protected T getQueryParameter(Map parameters, String name, boolean remove, Function converter) { String[] parameterValue = parameters.get(name); @@ -107,7 +116,9 @@ protected T getQueryParameter(Map parameters, String name, * {@code null}. * @param permissions A {@code String} representing the storage permissions or {@code null}. * @param signature A {@code String} representing the signature for the SAS token. + * @deprecated Please use SasSignatureValues */ + @Deprecated public BaseSasQueryParameters(String version, SasProtocol protocol, OffsetDateTime startTime, OffsetDateTime expiryTime, SasIpRange sasIpRange, String permissions, String signature) { this.version = version; @@ -121,49 +132,63 @@ public BaseSasQueryParameters(String version, SasProtocol protocol, OffsetDateTi /** * @return The storage version + * @deprecated Please use SasSignatureValues */ + @Deprecated public String getVersion() { return version; } /** * @return The allowed HTTP protocol(s) or {@code null}. Please refer to {@link SasProtocol} for more details. + * @deprecated Please use SasSignatureValues */ + @Deprecated public SasProtocol getProtocol() { return protocol; } /** * @return The start time for this SAS token or {@code null}. + * @deprecated Please use SasSignatureValues */ + @Deprecated public OffsetDateTime getStartTime() { return startTime; } /** * @return The expiry time for this SAS token. + * @deprecated Please use SasSignatureValues */ + @Deprecated public OffsetDateTime getExpiryTime() { return expiryTime; } /** * @return {@link SasIpRange} + * @deprecated Please use SasSignatureValues */ + @Deprecated public SasIpRange getSasIpRange() { return sasIpRange; } /** * @return Please refer to *SASPermission classes for more details. + * @deprecated Please use SasSignatureValues */ + @Deprecated public String getPermissions() { return permissions; } /** * @return The signature for the SAS token. + * @deprecated Please use SasSignatureValues */ + @Deprecated public String getSignature() { return signature; } @@ -174,7 +199,9 @@ public String getSignature() { * @param sb The {@code StringBuilder} to append to. * @param param The {@code String} parameter to append. * @param value The value of the parameter to append. + * @deprecated Please use SasSignatureValues */ + @Deprecated protected void tryAppendQueryParameter(StringBuilder sb, String param, Object value) { SasImplUtils.tryAppendQueryParameter(sb, param, value); } @@ -184,7 +211,9 @@ protected void tryAppendQueryParameter(StringBuilder sb, String param, Object va * * @param dateTime The SAS date time. * @return A String representing the SAS date time. + * @deprecated Please use SasSignatureValues */ + @Deprecated protected String formatQueryParameterDate(OffsetDateTime dateTime) { return SasImplUtils.formatQueryParameterDate(dateTime); } @@ -193,6 +222,9 @@ protected String formatQueryParameterDate(OffsetDateTime dateTime) { * Encodes all SAS query parameters into a string that can be appended to a URL. * * @return A {@code String} representing all SAS query parameters. + * @deprecated Please use the generateSas method on the desired client after initializing the appropriate + * SasSignatureValues object. */ + @Deprecated public abstract String encode(); } diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/CommonSasQueryParameters.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/CommonSasQueryParameters.java index e40571a343fe..d894d1f16cb7 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/CommonSasQueryParameters.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/CommonSasQueryParameters.java @@ -5,16 +5,32 @@ import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.implementation.SasImplUtils; import java.time.OffsetDateTime; import java.util.Map; +import java.util.function.Function; /** * Represents the components that make up an Azure Storage SAS' query parameters. This type is not constructed directly * by the user; it is only generated by the URLParts type. NOTE: Instances of this class are immutable to ensure thread * safety. */ -public class CommonSasQueryParameters extends BaseSasQueryParameters { +public class CommonSasQueryParameters { + + private final String version; + + private final SasProtocol protocol; + + private final OffsetDateTime startTime; + + private final OffsetDateTime expiryTime; + + private final SasIpRange sasIpRange; + + private final String permissions; + + private final String signature; private final String services; @@ -47,14 +63,27 @@ public class CommonSasQueryParameters extends BaseSasQueryParameters { private final String contentType; /** - * Creates a new {@link AccountSasQueryParameters} object. + * Creates a new {@link CommonSasQueryParameters} object. * * @param queryParamsMap All query parameters for the request as key-value pairs * @param removeSasParametersFromMap When {@code true}, the SAS query parameters will be removed from * queryParamsMap */ public CommonSasQueryParameters(Map queryParamsMap, boolean removeSasParametersFromMap) { - super(queryParamsMap, removeSasParametersFromMap); + this.version = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SERVICE_VERSION, + removeSasParametersFromMap); + this.protocol = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_PROTOCOL, + removeSasParametersFromMap, SasProtocol::parse); + this.startTime = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_START_TIME, + removeSasParametersFromMap, Utility::parseDate); + this.expiryTime = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_EXPIRY_TIME, + removeSasParametersFromMap, Utility::parseDate); + this.sasIpRange = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_IP_RANGE, + removeSasParametersFromMap, SasIpRange::parse); + this.permissions = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SIGNED_PERMISSIONS, + removeSasParametersFromMap); + this.signature = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SIGNATURE, + removeSasParametersFromMap); this.resourceTypes = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_RESOURCES_TYPES, removeSasParametersFromMap); this.services = getQueryParameter(queryParamsMap, Constants.UrlConstants.SAS_SERVICES, @@ -87,43 +116,86 @@ public CommonSasQueryParameters(Map queryParamsMap, boolean re removeSasParametersFromMap); } - @Override + /** + * Helper method to get a query parameter + * + * @param parameters A {@code Map} of parameters to values to search. + * @param name The name of parameter to find. + * @param remove Whether or not to remove the parameter from the map. + * @return A String representing the query parameter + */ + private String getQueryParameter(Map parameters, String name, boolean remove) { + return getQueryParameter(parameters, name, remove, value -> value); + } + + /** + * Helper method to get a query parameter + * + * @param The object type. + * @param parameters A {@code Map} of parameters to values to search. + * @param name The name of parameter to find. + * @param remove Whether or not to remove the parameter from the map. + * @param converter Function that transforms the value to a String. + * @return The object + */ + private T getQueryParameter(Map parameters, String name, boolean remove, Function converter) { + String[] parameterValue = parameters.get(name); + if (parameterValue == null) { + return null; + } + + if (remove) { + parameters.remove(name); + } + + return converter.apply(parameterValue[0]); + } + + /** + * Encodes all SAS query parameters into a string that can be appended to a URL. + * + * @return A {@code String} representing all SAS query parameters. + */ public String encode() { - /* + /* We should be url-encoding each key and each value, but because we know all the keys and values will encode to themselves, we cheat except for the signature value. */ StringBuilder sb = new StringBuilder(); // Common - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SERVICE_VERSION, this.version); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_PROTOCOL, this.protocol); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_START_TIME, formatQueryParameterDate(this.startTime)); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_EXPIRY_TIME, formatQueryParameterDate(this.expiryTime)); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_IP_RANGE, this.sasIpRange); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_PERMISSIONS, this.permissions); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNATURE, this.signature); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SERVICE_VERSION, this.version); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_PROTOCOL, this.protocol); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_START_TIME, + SasImplUtils.formatQueryParameterDate(this.startTime)); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_EXPIRY_TIME, + SasImplUtils.formatQueryParameterDate(this.expiryTime)); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_IP_RANGE, this.sasIpRange); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_PERMISSIONS, this.permissions); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNATURE, this.signature); // Account - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SERVICES, this.services); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_RESOURCES_TYPES, this.resourceTypes); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SERVICES, this.services); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_RESOURCES_TYPES, this.resourceTypes); // Services - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_IDENTIFIER, this.identifier); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_OBJECT_ID, this.keyObjectId); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_TENANT_ID, this.keyTenantId); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_START, - formatQueryParameterDate(this.keyStart)); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_EXPIRY, - formatQueryParameterDate(this.keyExpiry)); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_SERVICE, this.keyService); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_VERSION, this.keyVersion); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_RESOURCE, this.resource); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CACHE_CONTROL, this.cacheControl); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_DISPOSITION, this.contentDisposition); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_ENCODING, this.contentEncoding); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_LANGUAGE, this.contentLanguage); - tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_TYPE, this.contentType); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_IDENTIFIER, this.identifier); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_OBJECT_ID, this.keyObjectId); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_TENANT_ID, this.keyTenantId); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_START, + SasImplUtils.formatQueryParameterDate(this.keyStart)); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_EXPIRY, + SasImplUtils.formatQueryParameterDate(this.keyExpiry)); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_SERVICE, this.keyService); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_KEY_VERSION, this.keyVersion); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_SIGNED_RESOURCE, this.resource); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CACHE_CONTROL, this.cacheControl); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_DISPOSITION, + this.contentDisposition); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_ENCODING, this.contentEncoding); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_LANGUAGE, this.contentLanguage); + SasImplUtils.tryAppendQueryParameter(sb, Constants.UrlConstants.SAS_CONTENT_TYPE, this.contentType); return sb.toString(); } @@ -235,4 +307,53 @@ public String getServices() { public String getResourceTypes() { return resourceTypes; } + + /** + * @return The storage version + */ + public String getVersion() { + return version; + } + + /** + * @return The allowed HTTP protocol(s) or {@code null}. Please refer to {@link SasProtocol} for more details. + */ + public SasProtocol getProtocol() { + return protocol; + } + + /** + * @return The start time for this SAS token or {@code null}. + */ + public OffsetDateTime getStartTime() { + return startTime; + } + + /** + * @return The expiry time for this SAS token. + */ + public OffsetDateTime getExpiryTime() { + return expiryTime; + } + + /** + * @return {@link SasIpRange} + */ + public SasIpRange getSasIpRange() { + return sasIpRange; + } + + /** + * @return Please refer to *SASPermission classes for more details. + */ + public String getPermissions() { + return permissions; + } + + /** + * @return The signature for the SAS token. + */ + public String getSignature() { + return signature; + } }