C# Class Amazon.Runtime.Internal.Auth.AWS4Signer

Inheritance: AbstractAWSSigner
Afficher le fichier Open project: aws/aws-sdk-net Class Usage Examples

Méthodes publiques

Свойство Type Description
TerminatorBytes byte[]

Méthodes publiques

Méthode Description
ComposeSigningKey ( string awsSecretAccessKey, string region, string date, string service ) : byte[]

Compute and return the multi-stage signing key for the request.

ComputeHash ( byte data ) : byte[]

Computes the non-keyed hash of the supplied data

ComputeHash ( string data ) : byte[]

Computes the non-keyed hash of the supplied data

ComputeKeyedHash ( SigningAlgorithm algorithm, byte key, byte data ) : byte[]

Compute and return the hash of a data blob using the specified key

ComputeKeyedHash ( SigningAlgorithm algorithm, byte key, string data ) : byte[]

Compute and return the hash of a data blob using the specified key

ComputeSignature ( ImmutableCredentials credentials, string region, System.DateTime signedAt, string service, string signedHeaders, string canonicalRequest ) : AWS4SigningResult

Computes and returns an AWS4 signature for the specified canonicalized request

ComputeSignature ( string awsAccessKey, string awsSecretAccessKey, string region, System.DateTime signedAt, string service, string signedHeaders, string canonicalRequest ) : AWS4SigningResult

Computes and returns an AWS4 signature for the specified canonicalized request

ComputeSignature ( string awsAccessKey, string awsSecretAccessKey, string region, System.DateTime signedAt, string service, string signedHeaders, string canonicalRequest, RequestMetrics metrics ) : AWS4SigningResult

Computes and returns an AWS4 signature for the specified canonicalized request

DetermineSigningRegion ( IClientConfig clientConfig, string serviceName, RegionEndpoint alternateEndpoint, IRequest request ) : string
FormatDateTime ( System.DateTime dt, string formatString ) : string

Formats the supplied date and time for use in AWS4 signing, where various formats are used.

InitializeHeaders ( string>.IDictionary headers, Uri requestEndpoint ) : System.DateTime

Sets the AWS4 mandated 'host' and 'x-amz-date' headers, returning the date/time that will be used throughout the signing process in various elements and formats.

InitializeHeaders ( string>.IDictionary headers, Uri requestEndpoint, System.DateTime requestDateTime ) : System.DateTime

Sets the AWS4 mandated 'host' and 'x-amz-date' headers, accepting and returning the date/time that will be used throughout the signing process in various elements and formats.

SetRequestBodyHash ( IRequest request ) : string

If the caller has already set the x-amz-content-sha256 header with a pre-computed content hash, or it is present as ContentStreamHash on the request instance, return the value to be used in request canonicalization. If not set as a header or in the request, attempt to compute a hash based on inspection of the style of the request content.

Sign ( IRequest request, IClientConfig clientConfig, RequestMetrics metrics, string awsAccessKeyId, string awsSecretAccessKey ) : void

Calculates and signs the specified request using the AWS4 signing protocol by using the AWS account credentials given in the method parameters. 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.

SignBlob ( byte key, byte data ) : byte[]

Returns the HMAC256 for an arbitrary blob using the specified key

SignBlob ( byte key, string data ) : byte[]

Returns the HMAC256 for an arbitrary blob using the specified key

SignRequest ( IRequest request, IClientConfig clientConfig, RequestMetrics metrics, string awsAccessKeyId, string awsSecretAccessKey ) : AWS4SigningResult

Calculates and signs the specified request using the AWS4 signing protocol by using the AWS account credentials given in the method parameters.

Parameters passed as part of the resource path should be uri-encoded prior to entry to the signer. Parameters passed in the request.Parameters collection should be not be encoded; encoding will be done for these parameters as part of the construction of the canonical request.

Méthodes protégées

Méthode Description
CanonicalizeHeaderNames ( string>.IEnumerable sortedHeaders ) : string

Returns the set of headers included in the signature as a flattened, ;-delimited string

CanonicalizeHeaders ( string>.IEnumerable sortedHeaders ) : string

Computes the canonical headers with values for the request. Only headers included in the signature are included in the canonicalization process.

CanonicalizeQueryParameters ( string>.IDictionary parameters ) : string
CanonicalizeQueryParameters ( string>.IDictionary parameters, bool uriEncodeParameters ) : string

Computes and returns the canonicalized query string, if query parameters have been supplied. Parameters with no value will be canonicalized as 'param='. The expectation is that parameters have not already been url encoded prior to canonicalization.

CanonicalizeQueryParameters ( string queryString ) : string
CanonicalizeQueryParameters ( string queryString, bool uriEncodeParameters ) : string

Computes and returns the canonicalized query string, if query parameters have been supplied. Parameters with no value will be canonicalized as 'param='. The expectation is that parameters have not already been url encoded prior to canonicalization.

CanonicalizeRequest ( Uri endpoint, string resourcePath, string httpMethod, string>.IDictionary sortedHeaders, string canonicalQueryString, string precomputedBodyHash ) : string

Computes and returns the canonical request

GetParametersToCanonicalize ( IRequest request ) : string>.IDictionary

Collects the subresource and query string parameters into one collection ready for canonicalization

SortAndPruneHeaders ( string>.IEnumerable requestHeaders ) : string>.IDictionary

Reorders the headers for the request for canonicalization.

For AWS4 signing, all headers are considered viable for inclusion

Private Methods

Méthode Description
CleanHeaders ( string>.IDictionary headers ) : void
CompressSpaces ( string data ) : string
DetermineService ( IClientConfig clientConfig ) : string
GetRequestPayloadBytes ( IRequest request ) : byte[]

Returns the request parameters in the form of a query string.

Method Details

CanonicalizeHeaderNames() protected static méthode

Returns the set of headers included in the signature as a flattened, ;-delimited string
protected static CanonicalizeHeaderNames ( string>.IEnumerable sortedHeaders ) : string
sortedHeaders string>.IEnumerable The headers included in the signature
Résultat string

CanonicalizeHeaders() protected static méthode

Computes the canonical headers with values for the request. Only headers included in the signature are included in the canonicalization process.
protected static CanonicalizeHeaders ( string>.IEnumerable sortedHeaders ) : string
sortedHeaders string>.IEnumerable All request headers, sorted into canonical order
Résultat string

CanonicalizeQueryParameters() protected static méthode

protected static CanonicalizeQueryParameters ( string>.IDictionary parameters ) : string
parameters string>.IDictionary
Résultat string

CanonicalizeQueryParameters() protected static méthode

Computes and returns the canonicalized query string, if query parameters have been supplied. Parameters with no value will be canonicalized as 'param='. The expectation is that parameters have not already been url encoded prior to canonicalization.
protected static CanonicalizeQueryParameters ( string>.IDictionary parameters, bool uriEncodeParameters ) : string
parameters string>.IDictionary The set of parameters to be encoded in the query string
uriEncodeParameters bool /// Parameters must be uri encoded into the canonical request and by default the signer expects /// that the supplied collection contains non-encoded data. Set this to false if the encoding was /// done prior to signer entry. ///
Résultat string

CanonicalizeQueryParameters() protected static méthode

protected static CanonicalizeQueryParameters ( string queryString ) : string
queryString string
Résultat string

CanonicalizeQueryParameters() protected static méthode

Computes and returns the canonicalized query string, if query parameters have been supplied. Parameters with no value will be canonicalized as 'param='. The expectation is that parameters have not already been url encoded prior to canonicalization.
protected static CanonicalizeQueryParameters ( string queryString, bool uriEncodeParameters ) : string
queryString string The set of parameters being passed on the uri
uriEncodeParameters bool /// Parameters must be uri encoded into the canonical request and by default the signer expects /// that the supplied collection contains non-encoded data. Set this to false if the encoding was /// done prior to signer entry. ///
Résultat string

CanonicalizeRequest() protected static méthode

Computes and returns the canonical request
protected static CanonicalizeRequest ( Uri endpoint, string resourcePath, string httpMethod, string>.IDictionary sortedHeaders, string canonicalQueryString, string precomputedBodyHash ) : string
endpoint System.Uri The endpoint URL
resourcePath string the path of the resource being operated on
httpMethod string The http method used for the request
sortedHeaders string>.IDictionary The full request headers, sorted into canonical order
canonicalQueryString string The query parameters for the request
precomputedBodyHash string /// The hash of the binary request body if present. If not supplied, the routine /// will look for the hash as a header on the request. ///
Résultat string

ComposeSigningKey() public static méthode

Compute and return the multi-stage signing key for the request.
public static ComposeSigningKey ( string awsSecretAccessKey, string region, string date, string service ) : byte[]
awsSecretAccessKey string The clear-text AWS secret key, if not held in secureKey
region string The region in which the service request will be processed
date string Date of the request, in yyyyMMdd format
service string The name of the service being called by the request
Résultat byte[]

ComputeHash() public static méthode

Computes the non-keyed hash of the supplied data
public static ComputeHash ( byte data ) : byte[]
data byte
Résultat byte[]

ComputeHash() public static méthode

Computes the non-keyed hash of the supplied data
public static ComputeHash ( string data ) : byte[]
data string
Résultat byte[]

ComputeKeyedHash() public static méthode

Compute and return the hash of a data blob using the specified key
public static ComputeKeyedHash ( SigningAlgorithm algorithm, byte key, byte data ) : byte[]
algorithm SigningAlgorithm Algorithm to use for hashing
key byte Hash key
data byte Data blob
Résultat byte[]

ComputeKeyedHash() public static méthode

Compute and return the hash of a data blob using the specified key
public static ComputeKeyedHash ( SigningAlgorithm algorithm, byte key, string data ) : byte[]
algorithm SigningAlgorithm Algorithm to use for hashing
key byte Hash key
data string Data blob
Résultat byte[]

ComputeSignature() public static méthode

Computes and returns an AWS4 signature for the specified canonicalized request
public static ComputeSignature ( ImmutableCredentials credentials, string region, System.DateTime signedAt, string service, string signedHeaders, string canonicalRequest ) : AWS4SigningResult
credentials Amazon.Runtime.ImmutableCredentials
region string
signedAt System.DateTime
service string
signedHeaders string
canonicalRequest string
Résultat AWS4SigningResult

ComputeSignature() public static méthode

Computes and returns an AWS4 signature for the specified canonicalized request
public static ComputeSignature ( string awsAccessKey, string awsSecretAccessKey, string region, System.DateTime signedAt, string service, string signedHeaders, string canonicalRequest ) : AWS4SigningResult
awsAccessKey string
awsSecretAccessKey string
region string
signedAt System.DateTime
service string
signedHeaders string
canonicalRequest string
Résultat AWS4SigningResult

ComputeSignature() public static méthode

Computes and returns an AWS4 signature for the specified canonicalized request
public static ComputeSignature ( string awsAccessKey, string awsSecretAccessKey, string region, System.DateTime signedAt, string service, string signedHeaders, string canonicalRequest, RequestMetrics metrics ) : AWS4SigningResult
awsAccessKey string
awsSecretAccessKey string
region string
signedAt System.DateTime
service string
signedHeaders string
canonicalRequest string
metrics Amazon.Runtime.Internal.Util.RequestMetrics
Résultat AWS4SigningResult

DetermineSigningRegion() public static méthode

public static DetermineSigningRegion ( IClientConfig clientConfig, string serviceName, RegionEndpoint alternateEndpoint, IRequest request ) : string
clientConfig IClientConfig
serviceName string
alternateEndpoint RegionEndpoint
request IRequest
Résultat string

FormatDateTime() public static méthode

Formats the supplied date and time for use in AWS4 signing, where various formats are used.
public static FormatDateTime ( System.DateTime dt, string formatString ) : string
dt System.DateTime
formatString string The required format
Résultat string

GetParametersToCanonicalize() protected static méthode

Collects the subresource and query string parameters into one collection ready for canonicalization
protected static GetParametersToCanonicalize ( IRequest request ) : string>.IDictionary
request IRequest The in-flight request being signed
Résultat string>.IDictionary

InitializeHeaders() public static méthode

Sets the AWS4 mandated 'host' and 'x-amz-date' headers, returning the date/time that will be used throughout the signing process in various elements and formats.
public static InitializeHeaders ( string>.IDictionary headers, Uri requestEndpoint ) : System.DateTime
headers string>.IDictionary The current set of headers
requestEndpoint System.Uri
Résultat System.DateTime

InitializeHeaders() public static méthode

Sets the AWS4 mandated 'host' and 'x-amz-date' headers, accepting and returning the date/time that will be used throughout the signing process in various elements and formats.
public static InitializeHeaders ( string>.IDictionary headers, Uri requestEndpoint, System.DateTime requestDateTime ) : System.DateTime
headers string>.IDictionary The current set of headers
requestEndpoint System.Uri
requestDateTime System.DateTime
Résultat System.DateTime

SetRequestBodyHash() public static méthode

If the caller has already set the x-amz-content-sha256 header with a pre-computed content hash, or it is present as ContentStreamHash on the request instance, return the value to be used in request canonicalization. If not set as a header or in the request, attempt to compute a hash based on inspection of the style of the request content.
public static SetRequestBodyHash ( IRequest request ) : string
request IRequest
Résultat string

Sign() public méthode

Calculates and signs the specified request using the AWS4 signing protocol by using the AWS account credentials given in the method parameters. 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.
/// If any problems are encountered while signing the request. ///
public Sign ( IRequest request, IClientConfig clientConfig, RequestMetrics metrics, string awsAccessKeyId, string awsSecretAccessKey ) : void
request IRequest /// The request to compute the signature for. Additional headers mandated by the AWS4 protocol /// ('host' and 'x-amz-date') will be added to the request before signing. ///
clientConfig IClientConfig /// Client configuration data encompassing the service call (notably authentication /// region, endpoint and service name). ///
metrics Amazon.Runtime.Internal.Util.RequestMetrics /// Metrics for the request ///
awsAccessKeyId string /// The AWS public key for the account making the service call. ///
awsSecretAccessKey string /// The AWS secret key for the account making the call, in clear text. ///
Résultat void

SignBlob() public static méthode

Returns the HMAC256 for an arbitrary blob using the specified key
public static SignBlob ( byte key, byte data ) : byte[]
key byte
data byte
Résultat byte[]

SignBlob() public static méthode

Returns the HMAC256 for an arbitrary blob using the specified key
public static SignBlob ( byte key, string data ) : byte[]
key byte
data string
Résultat byte[]

SignRequest() public méthode

Calculates and signs the specified request using the AWS4 signing protocol by using the AWS account credentials given in the method parameters.
Parameters passed as part of the resource path should be uri-encoded prior to entry to the signer. Parameters passed in the request.Parameters collection should be not be encoded; encoding will be done for these parameters as part of the construction of the canonical request.
/// If any problems are encountered while signing the request. ///
public SignRequest ( IRequest request, IClientConfig clientConfig, RequestMetrics metrics, string awsAccessKeyId, string awsSecretAccessKey ) : AWS4SigningResult
request IRequest /// The request to compute the signature for. Additional headers mandated by the AWS4 protocol /// ('host' and 'x-amz-date') will be added to the request before signing. ///
clientConfig IClientConfig /// Client configuration data encompassing the service call (notably authentication /// region, endpoint and service name). ///
metrics Amazon.Runtime.Internal.Util.RequestMetrics /// Metrics for the request. ///
awsAccessKeyId string /// The AWS public key for the account making the service call. ///
awsSecretAccessKey string /// The AWS secret key for the account making the call, in clear text. ///
Résultat AWS4SigningResult

SortAndPruneHeaders() protected static méthode

Reorders the headers for the request for canonicalization.
For AWS4 signing, all headers are considered viable for inclusion
protected static SortAndPruneHeaders ( string>.IEnumerable requestHeaders ) : string>.IDictionary
requestHeaders string>.IEnumerable The set of proposed headers for the request
Résultat string>.IDictionary

Property Details

TerminatorBytes public_oe static_oe property

public static byte[] TerminatorBytes
Résultat byte[]