Show / Hide Table of Contents

Class SamlIdentityProvider

Provides Identity Provider (IdP) support for web browser single sign-on.

Inheritance
System.Object
SamlProvider
SamlIdentityProvider
Implements
ISamlIdentityProvider
ISamlProvider
IArtifactResolver
Inherited Members
SamlProvider.SetConfigurationNameAsync(String)
SamlProvider.PeekMessageTypeAsync()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: ComponentSpace.Saml2
Assembly: ComponentSpace.Saml2.dll
Syntax
public class SamlIdentityProvider : SamlProvider, ISamlIdentityProvider, ISamlProvider, IArtifactResolver

Constructors

SamlIdentityProvider(IHttpContextAccessor, ISamlConfigurationNameResolver, ISamlConfigurationResolver, ICertificateManager, ICertificateLoader, IIDCache, ISsoSessionStore, IHttpPostBinding, IHttpRedirectBinding, IHttpArtifactBinding, IArtifactCache, ISoapBinding, IUrlUtility, ISamlSchemaValidator, IXmlSignature, IXmlEncryption, IOptionsMonitor<CookiePolicyOptions>, ILoggerFactory)

Initializes a new instance of the SamlIdentityProvider class.

Declaration
public SamlIdentityProvider(IHttpContextAccessor httpContextAccessor, ISamlConfigurationNameResolver samlConfigurationNameResolver, ISamlConfigurationResolver samlConfigurationResolver, ICertificateManager certificateManager, ICertificateLoader certificateLoader, IIDCache idCache, ISsoSessionStore ssoSessionStore, IHttpPostBinding httpPostBinding, IHttpRedirectBinding httpRedirectBinding, IHttpArtifactBinding httpArtifactBinding, IArtifactCache artifactCache, ISoapBinding soapBinding, IUrlUtility urlUtility, ISamlSchemaValidator samlSchemaValidator, IXmlSignature xmlSignature, IXmlEncryption xmlEncryption, IOptionsMonitor<CookiePolicyOptions> cookiePolicyOptions, ILoggerFactory loggerFactory)
Parameters
Type Name Description
Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor

The HTTP context accessor.

ISamlConfigurationNameResolver samlConfigurationNameResolver

The SAML configuration name resolver.

ISamlConfigurationResolver samlConfigurationResolver

The SAML configuration resolver.

ICertificateManager certificateManager

The certificate manager.

ICertificateLoader certificateLoader

The certificate loader.

IIDCache idCache

The ID cache.

ISsoSessionStore ssoSessionStore

The SSO session store.

IHttpPostBinding httpPostBinding

The HTTP Post binding.

IHttpRedirectBinding httpRedirectBinding

The HTTP Redirect binding.

IHttpArtifactBinding httpArtifactBinding

The HTTP Artifact binding.

IArtifactCache artifactCache

The HTTP Artifact cache.

ISoapBinding soapBinding

The SOAP binding.

IUrlUtility urlUtility

The URL utility.

ISamlSchemaValidator samlSchemaValidator

The SAML XML schema validator.

IXmlSignature xmlSignature

The XML signature provider.

IXmlEncryption xmlEncryption

The XML encryption provider.

Microsoft.Extensions.Options.IOptionsMonitor<Microsoft.AspNetCore.Builder.CookiePolicyOptions> cookiePolicyOptions

The cookie policy options.

Microsoft.Extensions.Logging.ILoggerFactory loggerFactory

The logger factory.

Properties

Events

Gets or sets the optional events associated with SAML SSO and SLO.

Declaration
public ISamlIdentityProviderEvents Events { get; set; }
Property Value
Type Description
ISamlIdentityProviderEvents

The optional events associated with SAML SSO and SLO.

Methods

ClearSessionAsync(String)

Clears the current SAML session state for all partners or for the specified partner only.

Declaration
public override async Task ClearSessionAsync(string partnerName = null)
Parameters
Type Name Description
System.String partnerName

The partner name or null if none.

Returns
Type Description
System.Threading.Tasks.Task

A task that represents the operation.

Overrides
SamlProvider.ClearSessionAsync(String)
Exceptions
Type Condition
SamlException

Thrown when the SAML session state cannot be cleared.

GetStatusAsync()

Returns the current SSO status.

Declaration
public override async Task<ISsoStatus> GetStatusAsync()
Returns
Type Description
System.Threading.Tasks.Task<ISsoStatus>

A task that represents the operation and returns the current SSO status.

Overrides
SamlProvider.GetStatusAsync()
Exceptions
Type Condition
SamlException

Thrown when the starts cannot be retrieved.

InitiateSloAsync(String, String)

Initiates single logout from the identity provider to the service providers (ie. IdP-initiated SLO).

A logout request is sent to the service providers that are signed in.

Declaration
public async Task InitiateSloAsync(string logoutReason, string relayState)
Parameters
Type Name Description
System.String logoutReason

The logout reason or null if none.

System.String relayState

The relay state or null if none.

Returns
Type Description
System.Threading.Tasks.Task

A task that represents the operation.

Exceptions
Type Condition
SamlException

Thrown when the single logout fails.

InitiateSsoAsync(String, String, IList<SamlAttribute>, String, String, String)

Initiates single sign-on from the identity provider to the service provider (ie. IdP-initiated SSO).

A SAML response containing a SAML assertion is sent to the service provider.

Declaration
public async Task InitiateSsoAsync(string partnerName, string userID, IList<SamlAttribute> attributes, string relayState, string authnContext, string nameIDFormat)
Parameters
Type Name Description
System.String partnerName

The partner service provider name or null to specify the default.

System.String userID

The user ID to include in the SAML assertion or null if none.

System.Collections.Generic.IList<SamlAttribute> attributes

The attributes to include in the SAML assertion or null if none.

System.String relayState

The relay state (eg target URL) or null if none.

System.String authnContext

The authentication context identifying how the user was authenticated or null if the configured value is to be used.

System.String nameIDFormat

The name identifier format or null if the configured value is to be used.

Returns
Type Description
System.Threading.Tasks.Task

A task that represents the operation.

Exceptions
Type Condition
SamlException

Thrown when the single sign-on fails.

See Also
SamlConstants.AuthnContextClasses
SamlConstants.NameIdentifierFormats

ReceiveSloAsync()

Receives a single logout request (ie. SP-initiated SLO) or single logout response (ie. IdP-initiated SLO) from a service provider.

Declaration
public async Task<ISloResult> ReceiveSloAsync()
Returns
Type Description
System.Threading.Tasks.Task<ISloResult>

A task that represents the operation and returns the SLO result.

Exceptions
Type Condition
SamlException

Thrown when the single logout fails.

ReceiveSsoAsync()

Receives a single sign-on request from a service provider (ie. SP-initiated SSO).

An authn request is received from the service provider.

Declaration
public async Task<IIdpSsoResult> ReceiveSsoAsync()
Returns
Type Description
System.Threading.Tasks.Task<IIdpSsoResult>

A task that represents the operationand returns the SSO result.

Exceptions
Type Condition
SamlException

Thrown when the single sign-on fails.

ResolveArtifactAsync()

Receives an artifact resolve request and sends an artifact response,.

Declaration
public override async Task ResolveArtifactAsync()
Returns
Type Description
System.Threading.Tasks.Task

A task that represents the operation.

Overrides
SamlProvider.ResolveArtifactAsync()
Exceptions
Type Condition
SamlException

Thrown when the artifact resolve request cannot be processed.

SendSloAsync(String, String)

Sends a single logout message to a service provider (ie. SP-initiated SLO).

Declaration
public async Task SendSloAsync(string errorMessage, string correlationID)
Parameters
Type Name Description
System.String errorMessage

The error message or null if logout was successful.

System.String correlationID

The correlation ID identifying the logout request to respond to.

Returns
Type Description
System.Threading.Tasks.Task

A task that represents the operation.

Exceptions
Type Condition
SamlException

Thrown when the single logout fails.

SendSsoAsync(Status, String)

Sends a single sign-on error response as part of SP-initiated SSO.

A SAML error response is sent to the service provider.

Declaration
public async Task SendSsoAsync(Status status, string correlationID)
Parameters
Type Name Description
Status status

The error status.

System.String correlationID

The correlation ID identifying the authentication request to respond to.

Returns
Type Description
System.Threading.Tasks.Task

A task that represents the operation.

Exceptions
Type Condition
SamlException

Thrown when the single sign-on fails.

SendSsoAsync(String, IList<SamlAttribute>, String, String, String)

Sends a single sign-on response as part of SP-initiated SSO.

A SAML response containing a SAML assertion is sent to the service provider.

Declaration
public async Task SendSsoAsync(string userID, IList<SamlAttribute> attributes, string authnContext, string nameIDFormat, string correlationID)
Parameters
Type Name Description
System.String userID

The user ID to include in the SAML assertion or null if none.

System.Collections.Generic.IList<SamlAttribute> attributes

The attributes to include in the SAML assertion or null if none.

System.String authnContext

The authentication context identifying how the user was authenticated or null if the configured value is to be used.

System.String nameIDFormat

The name identifier format or null if the configured value is to be used.

System.String correlationID

The correlation ID identifying the authentication request to respond to.

Returns
Type Description
System.Threading.Tasks.Task

A task that represents the operation.

Exceptions
Type Condition
SamlException

Thrown when the single sign-on fails.

See Also
SamlConstants.AuthnContextClasses
SamlConstants.NameIdentifierFormats

Implements

ISamlIdentityProvider
ISamlProvider
IArtifactResolver
In This Article
Back to top Copyright © ComponentSpace Pty Ltd 2017-2022. All rights reserved.