Class DigestAuthorizationHeaderBuilder
- 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
UnkeyedCryptoAlgorithmThe algorithm to use when computing HA1, HA2 and/or RESPONSE value(s).
Remarks
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
StringThe 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
DigestAuthorizationHeaderAn 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
IHeaderDictionaryAn 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
HttpResponseHeadersAn 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
Int32The 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
StringThe 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
StringThe password to include in the HA1 computed value.
method
StringThe HTTP method to include in the HA2 computed value.
entityBody
StringThe 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
StringThe 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
StringThe 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
StringThe password to include in the HA1 computed value.
Returns
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
StringThe HTTP method to include in the HA2 computed value.
entityBody
StringThe 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
StringThe HA1 to include in the RESPONSE computed value.
hash2
StringThe 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.