Table of Contents

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

request IHttpRequest

The HTTP request.

response IHttpResponse

The HTTP response.

loggerFactory ILoggerFactory

The logger factory.

Methods

GenerateSignature(AsymmetricAlgorithm, string, byte[])

Generates a signature.

protected virtual byte[] GenerateSignature(AsymmetricAlgorithm key, string signatureAlgorithm, byte[] dataToSign)

Parameters

key AsymmetricAlgorithm

The key.

signatureAlgorithm string

The signature algorithm.

dataToSign byte[]

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

signatureAlgorithm string

The 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

true if the current HTTP request is valid for the binding; otherwise false.

ReceiveMessageAsync(AsymmetricAlgorithm)

Receives a SAML message.

public virtual Task<ReceiveResult> ReceiveMessageAsync(AsymmetricAlgorithm key)

Parameters

key AsymmetricAlgorithm

The key to verify the signature or null if 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

url string

The URL to receive the SAML message.

message string

The SAML message XML.

isResponse bool

The flag indicating whether a SAML request or response.

relayState string

The relay state or null if none.

key AsymmetricAlgorithm

The key to generate the signature or null if no signature is to be generated.

signatureAlgorithm string

The signature algorithm or null to 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

key AsymmetricAlgorithm

The key.

signedData byte[]

The signed data.

signature byte[]

The signature.

signatureAlgorithm string

The signature algorithm.

Returns

bool

true if the signature verifies; otherwise false.

VerifySignatureAsync(AsymmetricAlgorithm)

Verifies the signature.

public virtual Task<bool> VerifySignatureAsync(AsymmetricAlgorithm key)

Parameters

key AsymmetricAlgorithm

The key to verify the signature.

Returns

Task<bool>

A task that represents the operation and returns true if the signature verifies; otherwise false

Exceptions

SamlSignatureException

Thrown if the signature verification fails.