private static HttpWebRequest BlobGetRequest(KeyValuePair <long, int> blockOffsetAndLength, CloudBlockBlob blob)
        {
            StorageCredentials credentials = blob.ServiceClient.Credentials;
            var transformedUri             = credentials.TransformUri(blob.Uri);

            // Prepare the HttpWebRequest to download data from the chunk.
            HttpWebRequest blobGetRequest = BlobHttpWebRequestFactory.Get(
                transformedUri,
                Timeout,
                snapshot: null,
                offset: blockOffsetAndLength.Key,
                count: blockOffsetAndLength.Value,
                rangeContentMD5: false,
                accessCondition: AccessCondition.GenerateEmptyCondition(),
                operationContext: new OperationContext());

            if (credentials.IsSharedKey)
            {
                IAuthenticationHandler authenticationHandler = new SharedKeyAuthenticationHandler(
                    SharedKeyCanonicalizer.Instance,
                    credentials,
                    credentials.AccountName);
                authenticationHandler.SignRequest(blobGetRequest, new OperationContext());
            }
            return(blobGetRequest);
        }
        public virtual async Task SignRequestAsync(HttpWebRequest request, TenantRoute route)
        {
            var account = await GetStorageAccountAsync(route.TenantId, route.Purpose);

            var a = new SharedKeyAuthenticationHandler(SharedKeyCanonicalizer.Instance, account.Credentials, account.Credentials.AccountName);

            a.SignRequest(request, null);
        }
Ejemplo n.º 3
0
        public static void SignRequest(HttpWebRequest request, BlobContext context)
        {
            Assert.IsNotNull(request);
            Assert.IsNotNull(context);

            OperationContext opContext             = new OperationContext();
            SharedKeyAuthenticationHandler handler = new SharedKeyAuthenticationHandler(
                SharedKeyCanonicalizer.Instance,
                context.Credentials,
                context.Account);

            handler.SignRequest(request, opContext);

            BlobTestUtils.AuthorizationHeader(request, true, context.Account);
            BlobTestUtils.DateHeader(request, true);
        }