示例#1
0
        public static string GetCanonicalizedResourceVer1(Uri uri, NephosUriComponents uriComponents, string rawUrl = null)
        {
            NephosAssertionException.Assert((uriComponents == null ? false : !string.IsNullOrEmpty(uriComponents.AccountName)), "Resource account name must be non-empty.");
            StringBuilder stringBuilder = new StringBuilder("/");

            stringBuilder.Append(uriComponents.AccountName);
            string uriStringToSign = MessageCanonicalizer.GetUriStringToSign(uri.AbsolutePath, rawUrl);

            stringBuilder.Append(MessageCanonicalizer.GetUriWithoutSecondarySuffix(uriStringToSign, uriComponents));
            MessageCanonicalizer.CanonicalizedString canonicalizedString = new MessageCanonicalizer.CanonicalizedString(stringBuilder.ToString());
            NameValueCollection nameValueCollection  = HttpUtility.ParseQueryString(uri.Query);
            NameValueCollection nameValueCollection1 = new NameValueCollection();

            foreach (string key in nameValueCollection.Keys)
            {
                object[] values = nameValueCollection.GetValues(key);
                Array.Sort <object>(values);
                StringBuilder stringBuilder1 = new StringBuilder();
                object[]      objArray       = values;
                for (int i = 0; i < (int)objArray.Length; i++)
                {
                    object obj = objArray[i];
                    if (stringBuilder1.Length > 0)
                    {
                        stringBuilder1.Append(",");
                    }
                    stringBuilder1.Append(obj.ToString());
                }
                nameValueCollection1.Add((key == null ? key : key.ToLowerInvariant()), stringBuilder1.ToString());
            }
            string[] allKeys = nameValueCollection1.AllKeys;
            Array.Sort <string>(allKeys);
            string[] strArrays = allKeys;
            for (int j = 0; j < (int)strArrays.Length; j++)
            {
                string        str            = strArrays[j];
                StringBuilder stringBuilder2 = new StringBuilder(string.Empty);
                stringBuilder2.Append(str);
                stringBuilder2.Append(":");
                stringBuilder2.Append(nameValueCollection1[str]);
                canonicalizedString.AppendCanonicalizedElement(stringBuilder2.ToString());
            }
            return(canonicalizedString.Value);
        }
示例#2
0
        public static string GetCanonicalizedResource(Uri address, NephosUriComponents uriComponents, string rawUrl = null)
        {
            NephosAssertionException.Assert(!string.IsNullOrEmpty(uriComponents.AccountName), "Resource account name must be non-empty.");
            StringBuilder stringBuilder = new StringBuilder("/");

            stringBuilder.Append(uriComponents.AccountName);
            string uriStringToSign = MessageCanonicalizer.GetUriStringToSign(address.AbsolutePath, rawUrl);

            stringBuilder.Append(MessageCanonicalizer.GetUriWithoutSecondarySuffix(uriStringToSign, uriComponents));
            string item = HttpUtility.ParseQueryString(address.Query)["comp"];

            if (item != null)
            {
                stringBuilder.Append("?");
                stringBuilder.Append("comp");
                stringBuilder.Append("=");
                stringBuilder.Append(item);
            }
            return(stringBuilder.ToString());
        }