public override HttpRequest SignRequest(ISigner signer, Credential credential, FormatType?format, ProductDomain domain)
        {
            if (this.BodyParameters != null && this.BodyParameters.Count > 0)
            {
                Dictionary <String, String> formParams = new Dictionary <String, String>(this.BodyParameters);
                string formStr  = ConcatQueryString(formParams);
                byte[] formData = System.Text.Encoding.UTF8.GetBytes(formStr);
                this.SetContent(formData, "UTF-8", FormatType.FORM);
            }

            Dictionary <string, string> imutableMap = new Dictionary <string, string>(this.Headers);

            if (null != signer && null != credential)
            {
                string accessKeyId  = credential.AccessKeyId;
                string accessSecret = credential.AccessSecret;
                imutableMap = this.Composer.RefreshSignParameters(Headers, signer, accessKeyId, format);
                string strToSign = this.Composer.ComposeStringToSign(Method, uriPattern, signer, QueryParameters, imutableMap, pathParameters);
                string signature = signer.SignString(strToSign, accessSecret);
                DictionaryUtil.Add(imutableMap, "Authorization", "acs " + accessKeyId + ":" + signature);
            }
            Url          = this.ComposeUrl(domain.DomianName, QueryParameters);
            this.Headers = imutableMap;
            return(this);
        }
Ejemplo n.º 2
0
        public override HttpRequest SignRequest(ISigner signer, Credential credential, FormatType?format, ProductDomain domain)
        {
            Dictionary <String, String> imutableMap = new Dictionary <String, String>(QueryParameters);

            if (null != signer && null != credential)
            {
                String accessKeyId  = credential.AccessKeyId;
                String accessSecret = credential.AccessSecret;
                imutableMap = this.Composer.RefreshSignParameters(QueryParameters, signer, accessKeyId, format);
                imutableMap.Add("RegionId", RegionId);

                Dictionary <String, String> paramsToSign = new Dictionary <String, String>(imutableMap);
                if (this.BodyParameters != null && this.BodyParameters.Count > 0)
                {
                    Dictionary <String, String> formParams = new Dictionary <String, String>(this.BodyParameters);
                    string formStr  = ConcatQueryString(formParams);
                    byte[] formData = System.Text.Encoding.UTF8.GetBytes(formStr);
                    this.SetContent(formData, "UTF-8", FormatType.FORM);
                    foreach (var formParam in formParams)
                    {
                        DictionaryUtil.Add(paramsToSign, formParam.Key, formParam.Value);
                    }
                }
                String strToSign = this.Composer.ComposeStringToSign(Method, null, signer, paramsToSign, null, null);
                String signature = signer.SignString(strToSign, accessSecret + "&");
                imutableMap.Add("Signature", signature);
            }

            String url = ComposeUrl(domain.DomianName, imutableMap);

            this.Url = url;
            return(this);
        }
Ejemplo n.º 3
0
        public override HttpRequest SignRequest(ISigner signer, Credential credential, FormatType?format, ProductDomain domain)
        {
            var imutableMap = new Dictionary <string, string>(Headers);

            if (null != signer && null != credential)
            {
                var accessKeyId  = credential.AccessKeyId;
                var accessSecret = credential.AccessSecret;
                imutableMap = Composer.RefreshSignParameters(Headers, signer, accessKeyId, format);
                var strToSign = Composer.ComposeStringToSign(Method, UriPattern, signer, QueryParameters, imutableMap, PathParameters);
                var signature = signer.SignString(strToSign, accessSecret);
                DictionaryUtil.Add(imutableMap, "Authorization", $"acs {accessKeyId}:{signature}");
            }
            Url     = ComposeUrl(domain.DomianName, QueryParameters);
            Headers = imutableMap;
            return(this);
        }
Ejemplo n.º 4
0
        public override HttpRequest SignRequest(ISigner signer, Credential credential, FormatType?format, ProductDomain domain)
        {
            Dictionary <string, string> imutableMap = new Dictionary <string, string>(this.Headers);

            if (null != signer && null != credential)
            {
                string accessKeyId  = credential.AccessKeyId;
                string accessSecret = credential.AccessSecret;
                imutableMap = this.Composer.RefreshSignParameters(Headers, signer, accessKeyId, format);
                string strToSign = this.Composer.ComposeStringToSign(Method, uriPattern, signer, QueryParameters, imutableMap, pathParameters);
                string signature = signer.SignString(strToSign, accessSecret);
                DictionaryUtil.Add(imutableMap, "Authorization", "acs " + accessKeyId + ":" + signature);
            }
            Url          = this.ComposeUrl(domain.DomianName, QueryParameters);
            this.Headers = imutableMap;
            return(this);
        }
Ejemplo n.º 5
0
        public override HttpRequest SignRequest(ISigner signer, Credential credential, FormatType?format, ProductDomain domain)
        {
            Dictionary <String, String> imutableMap = new Dictionary <String, String>(QueryParameters);

            if (null != signer && null != credential)
            {
                String accessKeyId  = credential.AccessKeyId;
                String accessSecret = credential.AccessSecret;
                imutableMap = this.Composer.RefreshSignParameters(QueryParameters, signer, accessKeyId, format);
                imutableMap.Add("RegionId", RegionId);
                String strToSign = this.Composer.ComposeStringToSign(Method, null, signer, imutableMap, null, null);
                String signature = signer.SignString(strToSign, accessSecret + "&");
                imutableMap.Add("Signature", signature);
            }
            HttpRequest request = new HttpRequest(ComposeUrl(domain.DomianName, imutableMap));

            request.Method = this.Method;
            return(request);
        }
Ejemplo n.º 6
0
 public virtual string CreateSignature(string hash, string privKey)
 {
     return(_signer.SignString(hash, privKey));
 }