Class HttpRedirectBinding
Supports the HTTP redirect binding.
Inheritance
Implements
Inherited Members
Namespace: ComponentSpace.Saml2.Bindings.Redirect
Assembly: ComponentSpace.Saml2.dll
Syntax
public class HttpRedirectBinding : IHttpRedirectBinding
Remarks
Refer to the Bindings for the OASIS Security Assertion Markup Language (SAML) V2.0 specification for further details.
Constructors
HttpRedirectBinding(IHttpRequest, IHttpResponse, ILoggerFactory)
Initializes a new instance of the HttpRedirectBinding
class.
Declaration
public HttpRedirectBinding(IHttpRequest request, IHttpResponse response, ILoggerFactory loggerFactory)
Parameters
Type | Name | Description |
---|---|---|
IHttpRequest | request | The HTTP request. |
IHttpResponse | response | The HTTP response. |
Microsoft.Extensions.Logging.ILoggerFactory | loggerFactory | The logger factory. |
Methods
GenerateSignature(AsymmetricAlgorithm, String, Byte[])
Generates a signature.
Declaration
protected virtual byte[] GenerateSignature(AsymmetricAlgorithm key, string signatureAlgorithm, byte[] dataToSign)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Cryptography.AsymmetricAlgorithm | key | The key. |
System.String | signatureAlgorithm | The signature algorithm. |
System.Byte[] | dataToSign | The data to sign. |
Returns
Type | Description |
---|---|
System.Byte[] | The signature. |
GetHashAlgorithmName(String)
Gets the hash algorithm name for the specified signature algorithm.
Declaration
protected virtual HashAlgorithmName GetHashAlgorithmName(string signatureAlgorithm)
Parameters
Type | Name | Description |
---|---|---|
System.String | signatureAlgorithm | The signature algorithm. |
Returns
Type | Description |
---|---|
System.Security.Cryptography.HashAlgorithmName | The hash algorithm name. |
IsValid()
Indicates whether the current HTTP request is valid for the binding.
Declaration
public virtual bool IsValid()
Returns
Type | Description |
---|---|
System.Boolean |
|
ReceiveMessageAsync(AsymmetricAlgorithm)
Receives a SAML message.
Declaration
public virtual Task<ReceiveResult> ReceiveMessageAsync(AsymmetricAlgorithm key)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Cryptography.AsymmetricAlgorithm | key | The key to verify the signature or |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ReceiveResult> | A task that represents the operation and returns the HTTP Redirect result. |
Exceptions
Type | Condition |
---|---|
SamlBindingException | Thrown if the SAML message cannot be received. |
SendMessageAsync(String, String, Boolean, String, AsymmetricAlgorithm, String)
Sends a SAML message.
Declaration
public virtual Task SendMessageAsync(string url, string message, bool isResponse, string relayState, AsymmetricAlgorithm key, string signatureAlgorithm)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | The URL to receive the SAML message. |
System.String | message | The SAML message XML. |
System.Boolean | isResponse | The flag indicating whether a SAML request or response. |
System.String | relayState | The relay state or |
System.Security.Cryptography.AsymmetricAlgorithm | key | The key to generate the signature or |
System.String | signatureAlgorithm | The signature algorithm or |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task that represents the operation. |
Exceptions
Type | Condition |
---|---|
SamlBindingException | Thrown if the SAML message cannot be sent. |
VerifySignature(AsymmetricAlgorithm, Byte[], Byte[], String)
Verifies a signature.
Declaration
protected virtual bool VerifySignature(AsymmetricAlgorithm key, byte[] signedData, byte[] signature, string signatureAlgorithm)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Cryptography.AsymmetricAlgorithm | key | The key. |
System.Byte[] | signedData | The signed data. |
System.Byte[] | signature | The signature. |
System.String | signatureAlgorithm | The signature algorithm. |
Returns
Type | Description |
---|---|
System.Boolean |
|
VerifySignatureAsync(AsymmetricAlgorithm)
Verifies the signature.
Declaration
public virtual Task<bool> VerifySignatureAsync(AsymmetricAlgorithm key)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Cryptography.AsymmetricAlgorithm | key | The key to verify the signature. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | A task that represents the operation and returns |
Exceptions
Type | Condition |
---|---|
SamlSignatureException | Thrown if the signature verification fails. |