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()); }
/// <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(StorageHttpConstants.HeaderNames.Authorization, string.Format(CultureInfo.InvariantCulture, "{0} {1}:{2}", StorageHttpConstants.AuthenticationSchemeNames.SharedKeyAuthSchemeName, accountName, computedBase64Signature)); }
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(StorageHttpConstants.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(StorageHttpConstants.HeaderNames.Authorization, string.Format(CultureInfo.InvariantCulture, "{0} {1}:{2}", StorageHttpConstants.AuthenticationSchemeNames.SharedKeyLiteAuthSchemeName, accountName, computedBase64Signature)); }