Class HttpRedirectBinding
- Namespace
- ComponentSpace.Saml2.Bindings.Redirect
- Assembly
- ComponentSpace.Saml2.dll
Supports the HTTP redirect binding.
public class HttpRedirectBinding : IHttpRedirectBinding
- Inheritance
-
HttpRedirectBinding
- Implements
- Inherited Members
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.
public HttpRedirectBinding(IHttpRequest request, IHttpResponse response, ILoggerFactory loggerFactory)
Parameters
requestIHttpRequestThe HTTP request.
responseIHttpResponseThe HTTP response.
loggerFactoryILoggerFactoryThe logger factory.
Methods
GenerateSignature(AsymmetricAlgorithm, string, byte[])
Generates a signature.
protected virtual byte[] GenerateSignature(AsymmetricAlgorithm key, string signatureAlgorithm, byte[] dataToSign)
Parameters
keyAsymmetricAlgorithmThe key.
signatureAlgorithmstringThe signature algorithm.
dataToSignbyte[]The data to sign.
Returns
- byte[]
The signature.
GetHashAlgorithmName(string)
Gets the hash algorithm name for the specified signature algorithm.
protected virtual HashAlgorithmName GetHashAlgorithmName(string signatureAlgorithm)
Parameters
signatureAlgorithmstringThe signature algorithm.
Returns
- HashAlgorithmName
The hash algorithm name.
IsValid()
Indicates whether the current HTTP request is valid for the binding.
public virtual bool IsValid()
Returns
- bool
trueif the current HTTP request is valid for the binding; otherwisefalse.
ReceiveMessageAsync(AsymmetricAlgorithm)
Receives a SAML message.
public virtual Task<ReceiveResult> ReceiveMessageAsync(AsymmetricAlgorithm key)
Parameters
keyAsymmetricAlgorithmThe key to verify the signature or
nullif no signature is to be verified.
Returns
- Task<ReceiveResult>
A task that represents the operation and returns the HTTP Redirect result.
Exceptions
- SamlBindingException
Thrown if the SAML message cannot be received.
SendMessageAsync(string, string, bool, string, AsymmetricAlgorithm, string)
Sends a SAML message.
public virtual Task SendMessageAsync(string url, string message, bool isResponse, string relayState, AsymmetricAlgorithm key, string signatureAlgorithm)
Parameters
urlstringThe URL to receive the SAML message.
messagestringThe SAML message XML.
isResponseboolThe flag indicating whether a SAML request or response.
relayStatestringThe relay state or
nullif none.keyAsymmetricAlgorithmThe key to generate the signature or
nullif no signature is to be generated.signatureAlgorithmstringThe signature algorithm or
nullto default to http://www.w3.org/2001/04/xmldsig-more#rsa-sha256.
Returns
- Task
A task that represents the operation.
Exceptions
- SamlBindingException
Thrown if the SAML message cannot be sent.
VerifySignature(AsymmetricAlgorithm, byte[], byte[], string)
Verifies a signature.
protected virtual bool VerifySignature(AsymmetricAlgorithm key, byte[] signedData, byte[] signature, string signatureAlgorithm)
Parameters
keyAsymmetricAlgorithmThe key.
signedDatabyte[]The signed data.
signaturebyte[]The signature.
signatureAlgorithmstringThe signature algorithm.
Returns
- bool
trueif the signature verifies; otherwisefalse.
VerifySignatureAsync(AsymmetricAlgorithm)
Verifies the signature.
public virtual Task<bool> VerifySignatureAsync(AsymmetricAlgorithm key)
Parameters
keyAsymmetricAlgorithmThe key to verify the signature.
Returns
- Task<bool>
A task that represents the operation and returns
trueif the signature verifies; otherwisefalse
Exceptions
- SamlSignatureException
Thrown if the signature verification fails.