public string CanonicalizeHttpRequest(HttpRequestMessage request, string accountName)
        {
            // Add the Date HTTP header (or the x-ms-date header if it is being used)
            string dateHeaderValue = AuthenticationUtility.GetPreferredDateHeaderValue(request);
            CanonicalizedString canonicalizedString = new CanonicalizedString(dateHeaderValue, ExpectedCanonicalizedStringLength);

            // Add the canonicalized URI element
            string resourceString = AuthenticationUtility.GetCanonicalizedResourceString(request.RequestUri, accountName, true);

            canonicalizedString.AppendCanonicalizedElement(resourceString);

            return(canonicalizedString.ToString());
        }
示例#2
0
        /// <summary>
        /// Converts the specified HTTP request data into a standard form appropriate for signing.
        /// </summary>
        /// <param name="request">The HTTP request that needs to be signed.</param>
        /// <param name="accountName">The name of the storage account that the HTTP request will access.</param>
        /// <returns>The canonicalized string containing the HTTP request data in a standard form appropriate for signing.</returns>
        /// <seealso href="http://msdn.microsoft.com/en-us/library/windowsazure/dd179428.aspx">Authentication for the Windows Azure Storage Services</seealso>
        public string CanonicalizeHttpRequest(HttpWebRequest request, string accountName)
        {
            CommonUtility.AssertNotNull("request", request);

            // Add the x-ms-date or Date HTTP header
            string dateHeaderValue = AuthenticationUtility.GetPreferredDateHeaderValue(request);
            CanonicalizedString canonicalizedString = new CanonicalizedString(dateHeaderValue, ExpectedCanonicalizedStringLength);

            // Add the canonicalized URI element
            string resourceString = AuthenticationUtility.GetCanonicalizedResourceString(request.RequestUri, accountName, true);

            canonicalizedString.AppendCanonicalizedElement(resourceString);

            return(canonicalizedString.ToString());
        }