Class Aws4HmacAuthorizationHeader
- Namespace
- Codebelt.Extensions.AwsSignature4
- Assembly
- Codebelt.Extensions.AwsSignature4.dll
Provides a representation of a HTTP AWS4-HMAC-SHA256 Authentication header.
public class Aws4HmacAuthorizationHeader : HmacAuthorizationHeader
- Inheritance
-
Aws4HmacAuthorizationHeader
- Inherited Members
Examples
Examples
This example demonstrates how to parse an existing AWS Signature Version 4 authorization header string:
using System;
using Codebelt.Extensions.AwsSignature4;
namespace Aws4Example;
class Program
{
static void Main()
{
// Parse an AWS4 authorization header string
var headerString = "AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20220710/eu-west-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=3d2c4a14b38d0283bb697176ade57b2118110de0f00c387d7f0ef58c55a5b91d";
var header = Aws4HmacAuthorizationHeader.Create(headerString);
Console.WriteLine($"Client ID: {header.ClientId}");
Console.WriteLine($"Credential Scope: {header.CredentialScope}");
Console.WriteLine($"Signed Headers: {header.SignedHeaders}");
Console.WriteLine($"Signature: {header.Signature}");
}
}
Constructors
Aws4HmacAuthorizationHeader(string, string, string, string)
Initializes a new instance of the Aws4HmacAuthorizationHeader class.
public Aws4HmacAuthorizationHeader(string clientId, string credentialScope, string signedHeaders, string signature)
Parameters
clientIdstringThe client identifier that is the public key of the signing process.
credentialScopestringThe credential scope that defines the remote resource.
signedHeadersstringThe headers that will be part of the signing process.
signaturestringThe signature that represents the integrity of this header.
Methods
Create(string, Action<AuthorizationHeaderOptions>)
Creates an instance of Aws4HmacAuthorizationHeader from the specified parameters.
public static HmacAuthorizationHeader Create(string authorizationHeader, Action<AuthorizationHeaderOptions> setup = null)
Parameters
authorizationHeaderstringThe raw HTTP authorization header.
setupAction<AuthorizationHeaderOptions>The AuthorizationHeaderOptions which may be configured.
Returns
- HmacAuthorizationHeader
An instance of Aws4HmacAuthorizationHeader.
Exceptions
- ArgumentNullException
authorizationHeadercannot be null.- ArgumentException
authorizationHeadercannot be empty or consist only of white-space characters.