public Dictionary <string, string> RefreshSignParameters(Dictionary <string, string> parameters,
                                                                 Signer signer, string accessKeyId, FormatType?format)
        {
            var immutableMap = new Dictionary <string, string>(parameters);

            DictionaryUtil.Add(immutableMap, "Timestamp", ParameterHelper.FormatIso8601Date(DateTime.UtcNow));
            DictionaryUtil.Add(immutableMap, "SignatureMethod", signer.GetSignerName());
            DictionaryUtil.Add(immutableMap, "SignatureVersion", signer.GetSignerVersion());
            DictionaryUtil.Add(immutableMap, "SignatureNonce", Guid.NewGuid().ToString());
            DictionaryUtil.Add(immutableMap, "AccessKeyId", accessKeyId);

            if (null != format)
            {
                DictionaryUtil.Add(immutableMap, "Format", format.ToString());
            }

            if (signer.GetSignerType() != null)
            {
                DictionaryUtil.Add(immutableMap, "SignatureType", signer.GetSignerType());
            }

            return(immutableMap);
        }
        public string ComposeStringToSign(MethodType?method, string uriPattern, Signer signer,
                                          Dictionary <string, string> queries, Dictionary <string, string> headers,
                                          Dictionary <string, string> paths)
        {
            var sb = new StringBuilder();

            sb.Append(method).Append(HEADER_SEPARATOR);
            if (headers.ContainsKey("Accept"))
            {
                sb.Append(headers["Accept"]);
            }

            sb.Append(HEADER_SEPARATOR);
            if (headers.ContainsKey("Content-MD5"))
            {
                sb.Append(headers["Content-MD5"]);
            }

            sb.Append(HEADER_SEPARATOR);
            if (headers.ContainsKey("Content-Type"))
            {
                sb.Append(headers["Content-Type"]);
            }

            sb.Append(HEADER_SEPARATOR);
            if (headers.ContainsKey("Date"))
            {
                sb.Append(headers["Date"]);
            }

            sb.Append(HEADER_SEPARATOR);
            var uri = ReplaceOccupiedParameters(uriPattern, paths);

            sb.Append(BuildCanonicalHeaders(headers, "x-acs-"));
            sb.Append(BuildQuerystring(uri, queries));
            return(sb.ToString());
        }