Esempio n. 1
0
        internal static string CanonicalizeHttpRequestForSharedKeyLite(HttpWebRequest request, ResourceUriComponents uriComponents, string date)
        {
            StringBuilder canonicalizedString = new StringBuilder(date);

            AppendStringToCanonicalizedString(canonicalizedString, MessageCanonicalizer.GetCanonicalizedResource(request.Address, uriComponents));

            return(canonicalizedString.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Signs the request appropriately to make it an authenticated request.
        /// Note that this method takes the URI components as decoding the URI components requires the knowledge
        /// of whether the URI is in path-style or host-style and a host-suffix if it's host-style.
        /// </summary>
        public void SignRequest(HttpWebRequest request, ResourceUriComponents uriComponents)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            string message = MessageCanonicalizer.CanonicalizeHttpRequest(request, uriComponents);
            string computedBase64Signature = ComputeMacSha(message);

            request.Headers.Add(HeaderNames.Authorization,
                                string.Format(CultureInfo.InvariantCulture,
                                              "{0} {1}:{2}",
                                              AuthenticationSchemeNames.SharedKeyAuthSchemeName,
                                              accountName,
                                              computedBase64Signature));
        }
Esempio n. 3
0
        public void SignRequestForSharedKeyLite(HttpWebRequest request, ResourceUriComponents uriComponents)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            // add the date header to the request
            string dateString = MessageCanonicalizer.ConvertDateTimeToHttpString(DateTime.UtcNow);

            request.Headers.Add(HeaderNames.StorageDateTime, dateString);

            // compute the signature and add the authentication scheme
            string message = MessageCanonicalizer.CanonicalizeHttpRequestForSharedKeyLite(request, uriComponents, dateString);
            string computedBase64Signature = ComputeMacSha(message);

            request.Headers.Add(HeaderNames.Authorization,
                                string.Format(CultureInfo.InvariantCulture,
                                              "{0} {1}:{2}",
                                              AuthenticationSchemeNames.SharedKeyLiteAuthSchemeName,
                                              accountName,
                                              computedBase64Signature));
        }