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()
Initializes a new instance of the DigestAuthorizationHeaderBuilder class.
public DigestAuthorizationHeaderBuilder()
DigestAuthorizationHeaderBuilder(DigestCryptoAlgorithm)
Initializes a new instance of the DigestAuthorizationHeaderBuilder class.
public DigestAuthorizationHeaderBuilder(DigestCryptoAlgorithm algorithm)
Parameters
algorithmDigestCryptoAlgorithmThe algorithm to use when computing HA1, HA2 and/or RESPONSE value(s).
DigestAuthorizationHeaderBuilder(UnkeyedCryptoAlgorithm)
Initializes a new instance of the DigestAuthorizationHeaderBuilder class.
[Obsolete("This constructor is obsolete and will be removed in a future version. Use DigestAlgorithm variant instead.")]
public DigestAuthorizationHeaderBuilder(UnkeyedCryptoAlgorithm algorithm)
Parameters
algorithmUnkeyedCryptoAlgorithmThe algorithm to use when computing HA1, HA2 and/or RESPONSE value(s).
Remarks
Properties
Algorithm
Gets the algorithm of the HTTP Digest Access Authentication.
[Obsolete("This member is obsolete and will be removed in a future version. Use DigestAlgorithm property instead.")]
public UnkeyedCryptoAlgorithm Algorithm { get; }
Property Value
- UnkeyedCryptoAlgorithm
The algorithm of the HTTP Digest Access Authentication.
DigestAlgorithm
Gets the algorithm of the HTTP Digest Access Authentication.
public DigestCryptoAlgorithm DigestAlgorithm { get; }
Property Value
- DigestCryptoAlgorithm
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
clientNoncestringThe 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
headerDigestAuthorizationHeaderAn 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
headersIHeaderDictionaryAn implementation of 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
headersHttpResponseHeadersAn instance of HttpResponseHeaders.
Returns
- DigestAuthorizationHeaderBuilder
An DigestAuthorizationHeaderBuilder that can be used to further build the HTTP Digest Access Authentication header.
AddNc(int)
Associates the NonceCount field with the specified nonceCount.
public DigestAuthorizationHeaderBuilder AddNc(int nonceCount)
Parameters
nonceCountintThe 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
realmstringThe 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
passwordstringThe password to include in the HA1 computed value.
methodstringThe HTTP method to include in the HA2 computed value.
entityBodystringThe 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
digestUristringThe 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
usernamestringThe 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
passwordstringThe password to include in the HA1 computed value.
Returns
- string
A string in the format of H(UserName:Realm:
password). H is determined by DigestAlgorithm.
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
methodstringThe HTTP method to include in the HA2 computed value.
entityBodystringThe 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 DigestAlgorithm.
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
hash1stringThe HA1 to include in the RESPONSE computed value.
hash2stringThe 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 DigestAlgorithm.