Table of Contents

Class DigestAuthorizationHeaderBuilder

Namespace
Cuemon.AspNetCore.Authentication.Digest
Assembly
Cuemon.AspNetCore.Authentication.dll

Provides a way to fluently represent a HTTP Digest Access Authentication header.

public class DigestAuthorizationHeaderBuilder : AuthorizationHeaderBuilder<DigestAuthorizationHeader, DigestAuthorizationHeaderBuilder>
Inheritance
DigestAuthorizationHeaderBuilder
Inherited Members

Constructors

DigestAuthorizationHeaderBuilder(UnkeyedCryptoAlgorithm)

Initializes a new instance of the DigestAuthorizationHeaderBuilder class.

public DigestAuthorizationHeaderBuilder(UnkeyedCryptoAlgorithm algorithm = UnkeyedCryptoAlgorithm.Sha256)

Parameters

algorithm UnkeyedCryptoAlgorithm

The algorithm to use when computing HA1, HA2 and/or RESPONSE value(s).

Remarks

Allowed values for algorithm are: Md5, Sha256 and Sha512.

Properties

Algorithm

Gets the algorithm of the HTTP Digest Access Authentication.

public UnkeyedCryptoAlgorithm Algorithm { get; }

Property Value

UnkeyedCryptoAlgorithm

The algorithm of the HTTP Digest Access Authentication.

Methods

AddCnonce(String)

Associates the ClientNonce field with the specified clientNonce.

public DigestAuthorizationHeaderBuilder AddCnonce(string clientNonce = null)

Parameters

clientNonce String

The cryptographic client nonce to use in the authentication process.

Returns

DigestAuthorizationHeaderBuilder

An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.

AddFromDigestAuthorizationHeader(DigestAuthorizationHeader)

Associates any Digest fields found in the HTTP Authorization header from the specified header.

public DigestAuthorizationHeaderBuilder AddFromDigestAuthorizationHeader(DigestAuthorizationHeader header)

Parameters

header DigestAuthorizationHeader

An instance of DigestAuthorizationHeader.

Returns

DigestAuthorizationHeaderBuilder

An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.

AddFromWwwAuthenticateHeader(IHeaderDictionary)

Associates any Digest fields found in the HTTP WWW-Authenticate header from the specified headers.

public DigestAuthorizationHeaderBuilder AddFromWwwAuthenticateHeader(IHeaderDictionary headers)

Parameters

headers IHeaderDictionary

An implementation of Microsoft.AspNetCore.Http.IHeaderDictionary.

Returns

DigestAuthorizationHeaderBuilder

An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.

AddFromWwwAuthenticateHeader(HttpResponseHeaders)

Associates any Digest fields found in the HTTP WWW-Authenticate header from the specified headers.

public DigestAuthorizationHeaderBuilder AddFromWwwAuthenticateHeader(HttpResponseHeaders headers)

Parameters

headers HttpResponseHeaders

An instance of HttpResponseHeaders.

Returns

DigestAuthorizationHeaderBuilder

An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.

AddNc(Int32)

Associates the NonceCount field with the specified nonceCount.

public DigestAuthorizationHeaderBuilder AddNc(int nonceCount)

Parameters

nonceCount Int32

The count of the number of requests to use in the authentication process.

Returns

DigestAuthorizationHeaderBuilder

An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.

AddQopAuthentication()

Associates the QualityOfProtection field with "auth".

public DigestAuthorizationHeaderBuilder AddQopAuthentication()

Returns

DigestAuthorizationHeaderBuilder

An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.

AddQopAuthenticationIntegrity()

Associates the QualityOfProtection field with "auth-int".

public DigestAuthorizationHeaderBuilder AddQopAuthenticationIntegrity()

Returns

DigestAuthorizationHeaderBuilder

An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.

AddRealm(String)

Associates the Realm field with the specified realm.

public DigestAuthorizationHeaderBuilder AddRealm(string realm)

Parameters

realm String

The realm that defines the remote resource.

Returns

DigestAuthorizationHeaderBuilder

An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.

AddResponse(String, String, String)

Associates the Response field with the computed values of ComputeHash1(String), ComputeHash2(String, String) and ComputeResponse(String, String).

public DigestAuthorizationHeaderBuilder AddResponse(string password, string method, string entityBody = null)

Parameters

password String

The password to include in the HA1 computed value.

method String

The HTTP method to include in the HA2 computed value.

entityBody String

The entity body to apply in the signature when qop is set to auth-int.

Returns

DigestAuthorizationHeaderBuilder

An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.

AddUri(String)

Associates the DigestUri field with the specified digestUri.

public DigestAuthorizationHeaderBuilder AddUri(string digestUri)

Parameters

digestUri String

The effective request URI to use in the authentication process.

Returns

DigestAuthorizationHeaderBuilder

An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.

AddUserName(String)

Associates the UserName field with the specified username.

public DigestAuthorizationHeaderBuilder AddUserName(string username)

Parameters

username String

The username to use in the authentication process.

Returns

DigestAuthorizationHeaderBuilder

An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.

Build()

Returns a String that represents this instance.

public override DigestAuthorizationHeader Build()

Returns

DigestAuthorizationHeader

A String that represents this instance.

ComputeHash1(String)

Computes a by parameter defined UnkeyedCryptoAlgorithm hash value of the required values for the HTTP Digest access authentication HA1.

public virtual string ComputeHash1(string password)

Parameters

password String

The password to include in the HA1 computed value.

Returns

String

A String in the format of H(UserName:Realm:password). H is determined by Algorithm.

ComputeHash2(String, String)

Computes a by parameter defined UnkeyedCryptoAlgorithm hash value of the required values for the HTTP Digest access authentication HA2.

public virtual string ComputeHash2(string method, string entityBody = null)

Parameters

method String

The HTTP method to include in the HA2 computed value.

entityBody String

The entity body to apply in the signature when qop is set to auth-int.

Returns

String

A String in the format of H(method:DigestUri) OR H(method:DigestUri:H(entityBody)). H is determined by Algorithm.

ComputeResponse(String, String)

Computes a by parameter defined UnkeyedCryptoAlgorithm hash value of the required values for the HTTP Digest access authentication RESPONSE.

public virtual string ComputeResponse(string hash1, string hash2)

Parameters

hash1 String

The HA1 to include in the RESPONSE computed value.

hash2 String

The HA2 to include in the RESPONSE computed value.

Returns

String

A String in the format of H(hash1:Nonce:NonceCount:ClientNonce:QualityOfProtection:hash2). H is determined by Algorithm.