Ejemplo n.º 1
0
        public string Compose(HttpRequestForSigning request, string signatureAlgorithmName, HeaderName[] headerNames, DateTimeOffset timeOfComposing, TimeSpan expires, string nonce)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (signatureAlgorithmName == null)
            {
                throw new ArgumentNullException(nameof(signatureAlgorithmName));
            }
            if (headerNames == null)
            {
                throw new ArgumentNullException(nameof(headerNames));
            }

            var headerAppender = _headerAppenderFactory.Create(request, signatureAlgorithmName, timeOfComposing, expires);

            var sb = new StringBuilder();

            foreach (var headerName in headerNames.Where(h => h != HeaderName.Empty))
            {
                sb = sb.Append(headerAppender.BuildStringToAppend(headerName));
            }

            sb.Append(_nonceAppender.BuildStringToAppend(nonce));

            return(sb.ToString().Trim());
        }
        public string Compose(SigningStringCompositionRequest compositionRequest)
        {
            if (compositionRequest == null)
            {
                throw new ArgumentNullException(nameof(compositionRequest));
            }

            var headerAppender = _headerAppenderFactory.Create(
                compositionRequest.Request,
                compositionRequest.RequestTargetEscaping,
                compositionRequest.TimeOfComposing,
                compositionRequest.Expires);

            var sb = new StringBuilder();

            foreach (var headerName in compositionRequest.HeadersToInclude.Where(h => h != HeaderName.Empty))
            {
                sb = sb.Append(headerAppender.BuildStringToAppend(headerName));
            }

            sb.Append(_nonceAppender.BuildStringToAppend(compositionRequest.Nonce));

            return(sb.ToString().TrimStart());
        }