public void ComposeTest(SigningTestFixture signingTestFixture)
        {
            var authHeaderComposer = new AuthHeaderComposer();
            var authHeader = authHeaderComposer.Compose(
                signingTestFixture.config.ToEscherConfig(),
                signingTestFixture.config.accessKeyId,
                signingTestFixture.config.DateTime,
                signingTestFixture.headersToSign,
                signingTestFixture.expected.stringToSign,
                signingTestFixture.config.apiSecret
            );

            Assert.AreEqual(signingTestFixture.expected.authHeader, authHeader);
        }
예제 #2
0
        public TRequest SignRequest <TRequest>(TRequest request, string key, string secret, string[] headersToSign, DateTime currentTime) where TRequest : IEscherRequest
        {
            currentTime = currentTime.ToUniversalTime();

            AddMandatoryHeaders(request, currentTime);
            headersToSign = AddMandatoryHeadersToSign(headersToSign);

            var canonicalizedRequest = new RequestCanonicalizer().Canonicalize(request, headersToSign, Config);
            var stringToSign         = new StringToSignComposer().Compose(canonicalizedRequest, currentTime, Config);
            var authHeader           = new AuthHeaderComposer().Compose(Config, key, currentTime, headersToSign, stringToSign, secret);

            request.Headers.Add(new Header(Config.AuthHeaderName, authHeader));

            return(request);
        }