/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ using Amazon.Runtime.Internal; using Amazon.Runtime.Internal.Auth; using Amazon.Runtime.Internal.Util; using System.Collections.Generic; using System.IO; namespace Amazon.Runtime.SharedInterfaces { /// /// Interface for an asymmetric SigV4 (SigV4a) signer /// public interface IAWSSigV4aProvider { /// /// Protocol for the requests being signed /// ClientProtocol Protocol { get; } /// /// Calculates and signs the specified request using the asymmetric Sigv4 (Sigv4a) signing protocol. /// The resulting signature is added to the request headers as 'Authorization'. Parameters supplied in the request, either in /// the resource path as a query string or in the Parameters collection must not have been /// uri encoded. If they have, use the SignRequest method to obtain a signature. /// /// /// The request to compute the signature for. Additional headers mandated by the AWS4a protocol /// ('host' and 'x-amz-date') will be added to the request before signing. /// /// /// Client configuration data encompassing the service call (notably authentication /// region, endpoint and service name). /// /// /// Metrics for the request /// /// /// The AWS credentials for the account making the service call. /// void Sign(IRequest request, IClientConfig clientConfig, RequestMetrics metrics, ImmutableCredentials credentials); /// /// Calculates and signs the specified request using the asymmetric Sigv4 (Sigv4a) signing protocol. /// The resulting signature is added to the request headers as 'Authorization'. Parameters supplied in the request, either in /// the resource path as a query string or in the Parameters collection must not have been /// uri encoded. If they have, use the SignRequest method to obtain a signature. /// /// /// The request to compute the signature for. Additional headers mandated by the AWS4a protocol /// ('host' and 'x-amz-date') will be added to the request before signing. /// /// /// Client configuration data encompassing the service call (notably authentication /// region, endpoint and service name). /// /// /// Metrics for the request /// /// /// The AWS credentials for the account making the service call. /// /// AWS4a Signing Result AWS4aSigningResult SignRequest(IRequest request, IClientConfig clientConfig, RequestMetrics metrics, ImmutableCredentials credentials); /// /// Calculates the asymmetric Sigv4 (Sigv4a) signature for a presigned url. /// /// /// The request to compute the signature for. /// /// /// Adding supporting data for the service call required by the signer (notably authentication /// region, endpoint and service name). /// /// /// Metrics for the request /// /// /// The AWS credentials for the account making the service call. /// /// /// The service to sign for /// /// /// The region to sign to, if null then the region the client is configured for will be used. /// /// AWS4a Signing Result AWS4aSigningResult Presign4a(IRequest request, IClientConfig clientConfig, RequestMetrics metrics, ImmutableCredentials credentials, string service, string overrideSigningRegion); /// /// Calculates the signature for a single chunk of a chunked SigV4a request /// /// Content of the current chunk /// Signature of the previous chunk /// Signing result of the request's header /// Unpadded SigV4a signature of the given chunk string SignChunk(Stream chunkBody, string previousSignature, AWS4aSigningResult headerSigningResult); /// /// Signs the final chunk containing trailing headers /// /// Trailing header keys and values /// Signature of the previous chunk /// Signing result of the request's header /// Signature of the trailing header chunk string SignTrailingHeaderChunk(IDictionary trailingHeaders, string previousSignature, AWS4aSigningResult headerSigningResult); } }