Class DigestAuthenticationUtility
Provides an isolated set of members to work with HTTP Digest access authentication.
Inheritance
Namespace: Cuemon.AspNetCore.Authentication
Assembly: Cuemon.AspNetCore.Authentication.dll
Syntax
public static class DigestAuthenticationUtility
Fields
| Improve this DocCredentialAlgorithm
The value of the header credential algorithm of a HTTP Digest access authentication.
Declaration
public const string CredentialAlgorithm = "algorithm"
Field Value
Type | Description |
---|---|
System.String |
CredentialClientNonce
The value of the header credential client nonce of a HTTP Digest access authentication.
Declaration
public const string CredentialClientNonce = "cnonce"
Field Value
Type | Description |
---|---|
System.String |
CredentialDigestUri
The value of the header credential digest URI of a HTTP Digest access authentication.
Declaration
public const string CredentialDigestUri = "uri"
Field Value
Type | Description |
---|---|
System.String |
CredentialNonce
The value of the header credential nonce of a HTTP Digest access authentication.
Declaration
public const string CredentialNonce = "nonce"
Field Value
Type | Description |
---|---|
System.String |
CredentialNonceCount
The value of the header credential nonce count of a HTTP Digest access authentication.
Declaration
public const string CredentialNonceCount = "nc"
Field Value
Type | Description |
---|---|
System.String |
CredentialOpaque
The value of the header credential opaque of a HTTP Digest access authentication.
Declaration
public const string CredentialOpaque = "opaque"
Field Value
Type | Description |
---|---|
System.String |
CredentialQualityOfProtection
The value of the header credential quality of protection of a HTTP Digest access authentication.
Declaration
public const string CredentialQualityOfProtection = "qop"
Field Value
Type | Description |
---|---|
System.String |
CredentialQualityOfProtectionOptions
The value of the header credential quality of protection options of a HTTP Digest access authentication.
Declaration
public const string CredentialQualityOfProtectionOptions = "auth,auth-int"
Field Value
Type | Description |
---|---|
System.String |
CredentialRealm
The value of the header credential realm of a HTTP Digest access authentication.
Declaration
public const string CredentialRealm = "realm"
Field Value
Type | Description |
---|---|
System.String |
CredentialResponse
The value of the header credential response of a HTTP Digest access authentication.
Declaration
public const string CredentialResponse = "response"
Field Value
Type | Description |
---|---|
System.String |
CredentialUserName
The value of the header credential user name of a HTTP Digest access authentication.
Declaration
public const string CredentialUserName = "username"
Field Value
Type | Description |
---|---|
System.String |
Methods
| Improve this DocComputeHash1(IDictionary<String, String>, String, HashAlgorithmType)
Computes a by parameter defined HashAlgorithmType hash value of the required values for the HTTP Digest access authentication HA1.
Declaration
public static string ComputeHash1(IDictionary<string, string> credentials, string password, HashAlgorithmType algorithm)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<System.String, System.String> | credentials | The credentials of the HA1 computed value (CredentialUserName, CredentialRealm). |
System.String | password | The password to include in the HA1 computed value. |
HashAlgorithmType | algorithm | The algorithm to use when computing the HA1 value. |
Returns
Type | Description |
---|---|
System.String | A System.String in the format of H(' |
ComputeHash2(IDictionary<String, String>, String, HashAlgorithmType)
Computes a by parameter defined HashAlgorithmType hash value of the required values for the HTTP Digest access authentication HA2.
Declaration
public static string ComputeHash2(IDictionary<string, string> credentials, string httpMethod, HashAlgorithmType algorithm)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<System.String, System.String> | credentials | The credentials of the HA2 computed value (CredentialDigestUri). |
System.String | httpMethod | The HTTP method to include in the HA2 computed value. |
HashAlgorithmType | algorithm | The algorithm to use when computing the HA2 value. |
Returns
Type | Description |
---|---|
System.String | A System.String in the format of H(' |
ComputeResponse(IDictionary<String, String>, String, String, HashAlgorithmType)
Computes a by parameter defined HashAlgorithmType hash value of the required values for the HTTP Digest access authentication RESPONSE.
Declaration
public static byte[] ComputeResponse(IDictionary<string, string> credentials, string hash1, string hash2, HashAlgorithmType algorithm)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<System.String, System.String> | credentials | The credentials of the RESPONSE computed value (CredentialNonce, CredentialNonceCount, CredentialClientNonce, CredentialQualityOfProtection). |
System.String | hash1 | The HA1 to include in the RESPONSE computed value. |
System.String | hash2 | The HA2 to include in the RESPONSE computed value. |
HashAlgorithmType | algorithm | The algorithm to use when computing the RESPONSE value. |
Returns
Type | Description |
---|---|
System.Byte[] | A System.String in the format of H(' |
DefaultNonceExpiredParser(String, TimeSpan)
A default implementation of a nonce parser.
Declaration
public static bool DefaultNonceExpiredParser(string nonce, TimeSpan timeToLive)
Parameters
Type | Name | Description |
---|---|---|
System.String | nonce | The nonce protocol. |
System.TimeSpan | timeToLive | The time-to-live (ttl) of the |
Returns
Type | Description |
---|---|
System.Boolean |
|
DefaultNonceGenerator(DateTime, String, Byte[])
A default implementation of a nonce generator.
Declaration
public static string DefaultNonceGenerator(DateTime timestamp, string entityTag, byte[] privateKey)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | timestamp | The System.DateTime value to include in the generated nonce. |
System.String | entityTag | An opaque identifier to include in the generated nonce. |
System.Byte[] | privateKey | A cryptographic private key to include as a cipher in the generated nonce. |
Returns
Type | Description |
---|---|
System.String | A nonce protocol in the format of ' |
DefaultOpaqueGenerator()
A default implementation of opaque generator.
Declaration
public static string DefaultOpaqueGenerator()
Returns
Type | Description |
---|---|
System.String | An opaque value consisting of hexadecimal characters with a length of 32 bytes. |
ParseAlgorithm(HashAlgorithmType)
Converts the specified algorithm
to its HTTP Digest access authentication header credential algorithm equivalent.
Declaration
public static string ParseAlgorithm(HashAlgorithmType algorithm)
Parameters
Type | Name | Description |
---|---|---|
HashAlgorithmType | algorithm | The algorithm to convert. |
Returns
Type | Description |
---|---|
System.String | A string containing either MD5, SHA-256 or SHA-512-256. |