SecurityTokenServiceConfiguration SecurityTokenServiceConfiguration SecurityTokenServiceConfiguration SecurityTokenServiceConfiguration Class

Definition

Defines the configuration for a security token service (STS). Classes that implement STSs derive from the SecurityTokenService class.

public ref class SecurityTokenServiceConfiguration : System::IdentityModel::Configuration::IdentityConfiguration
public class SecurityTokenServiceConfiguration : System.IdentityModel.Configuration.IdentityConfiguration
type SecurityTokenServiceConfiguration = class
    inherit IdentityConfiguration
Public Class SecurityTokenServiceConfiguration
Inherits IdentityConfiguration
Inheritance
SecurityTokenServiceConfigurationSecurityTokenServiceConfigurationSecurityTokenServiceConfigurationSecurityTokenServiceConfiguration

Examples

The code examples that are used in the SecurityTokenService topics are taken from the Custom Token sample. This sample provides custom classes that enable processing of Simple Web Tokens (SWT) and it includes an implementation of a passive STS that is capable of serving an SWT token. For an example of how to implement an active STS, you can see the Federation Metadata sample. For information about these samples and other samples available for WIF and about where to download them, see WIF Code Sample Index. The following code shows a custom implementation of the SecurityTokenServiceConfiguration class to support a passive STS that processes SWT tokens. The configuration is initialized and stored in the HTTP application state the first time the static Current property is accessed. The constructor initializes the properties of the custom configuration with the type of the custom STS, a custom issuer token resolver, and the default token type (the URI of the SWT token type). It also adds an SWT token handler to the default handler collection.

namespace PassiveSTS
{
    /// <summary>
    /// Extends the Microsoft.IdentityModel.Services.SecurityTokenServiceConfiguration class to 
    /// be consumed by the CustomSecurityTokenService.
    /// </summary>
    public class CustomSecurityTokenServiceConfiguration : SecurityTokenServiceConfiguration
    {
        static readonly object syncRoot = new object();
        static string CustomSecurityTokenServiceConfigurationKey = "CustomSecurityTokenServiceConfigurationKey";
        static string Base64SymmetricKey = "wAVkldQiFypTQ+kdNdGWCYCHRcee8XmXxOvgmak8vSY=";

        public static CustomSecurityTokenServiceConfiguration Current
        {
            get
            {
                HttpApplicationState httpAppState = HttpContext.Current.Application;

                CustomSecurityTokenServiceConfiguration myConfiguration = httpAppState.Get( CustomSecurityTokenServiceConfigurationKey ) as CustomSecurityTokenServiceConfiguration;

                if ( myConfiguration != null )
                {
                    return myConfiguration;
                }

                lock ( syncRoot )
                {
                    myConfiguration = httpAppState.Get( CustomSecurityTokenServiceConfigurationKey ) as CustomSecurityTokenServiceConfiguration;

                    if ( myConfiguration == null )
                    {
                        myConfiguration = new CustomSecurityTokenServiceConfiguration();
                        httpAppState.Add( CustomSecurityTokenServiceConfigurationKey, myConfiguration );
                    }

                    return myConfiguration;
                }
            }
        }

        public CustomSecurityTokenServiceConfiguration()
            : base( "PassiveSTS" )
        {
            this.SecurityTokenService = typeof( PassiveSTS.CustomSecurityTokenService );
            SimpleWebTokenHandler tokenHandler = new SimpleWebTokenHandler();
            this.SecurityTokenHandlers.Add(tokenHandler);
            
            CustomIssuerTokenResolver  customTokenResolver =  new SimpleWebToken.CustomIssuerTokenResolver();
            customTokenResolver.AddAudienceKeyPair("http://localhost:19851/", Base64SymmetricKey);
            this.IssuerTokenResolver = customTokenResolver;

            this.DefaultTokenType = SimpleWebTokenHandler.SimpleWebTokenTypeUri;
        }
    }
}

The following code shows how to invoke a custom passive STS to process a WS-Federation request by calling the FederatedPassiveSecurityTokenServiceOperations.ProcessRequest(HttpRequest, ClaimsPrincipal, SecurityTokenService, HttpResponse) method from the code behind in the default.aspx.cs file. The CreateSecurityTokenService method initializes an instance of the PassiveSTS.CustomSecurityTokenService class using the properties set on the CustomSecurityTokenServiceConfiguration class shown in the previous example.

using System;
using System.IdentityModel.Services;
using System.Security.Claims;

namespace PassiveSTS
{
    public partial class _Default : System.Web.UI.Page
    {
        /// <summary>
        /// We perform the WS-Federation Passive Protocol processing in this method. 
        /// </summary>
        protected void Page_PreRender( object sender, EventArgs e ) 
        {
            FederatedPassiveSecurityTokenServiceOperations.ProcessRequest( Request, User as ClaimsPrincipal, CustomSecurityTokenServiceConfiguration.Current.CreateSecurityTokenService(), Response );
        }
    }
}

Constructors

SecurityTokenServiceConfiguration() SecurityTokenServiceConfiguration() SecurityTokenServiceConfiguration() SecurityTokenServiceConfiguration()

Initializes a new instance of the SecurityTokenServiceConfiguration class.

SecurityTokenServiceConfiguration(Boolean) SecurityTokenServiceConfiguration(Boolean) SecurityTokenServiceConfiguration(Boolean) SecurityTokenServiceConfiguration(Boolean)

Initializes a new instance of the SecurityTokenServiceConfiguration class. Optionally loads settings from the current configuration.

SecurityTokenServiceConfiguration(String) SecurityTokenServiceConfiguration(String) SecurityTokenServiceConfiguration(String) SecurityTokenServiceConfiguration(String)

Initializes a new instance of the SecurityTokenServiceConfiguration class that has the specified issuer name.

SecurityTokenServiceConfiguration(String, Boolean) SecurityTokenServiceConfiguration(String, Boolean) SecurityTokenServiceConfiguration(String, Boolean) SecurityTokenServiceConfiguration(String, Boolean)

Initializes a new instance of the SecurityTokenServiceConfiguration class that has the specified issuer name. Optionally loads settings from the current configuration.

SecurityTokenServiceConfiguration(String, SigningCredentials) SecurityTokenServiceConfiguration(String, SigningCredentials) SecurityTokenServiceConfiguration(String, SigningCredentials) SecurityTokenServiceConfiguration(String, SigningCredentials)

Initializes a new instance of the SecurityTokenServiceConfiguration class that has the specified issuer name and signing credentials.

SecurityTokenServiceConfiguration(String, SigningCredentials, Boolean) SecurityTokenServiceConfiguration(String, SigningCredentials, Boolean) SecurityTokenServiceConfiguration(String, SigningCredentials, Boolean) SecurityTokenServiceConfiguration(String, SigningCredentials, Boolean)

Initializes a new instance of the SecurityTokenServiceConfiguration class that has the specified issuer name and signing credentials. Optionally loads settings from the current configuration.

SecurityTokenServiceConfiguration(String, SigningCredentials, String) SecurityTokenServiceConfiguration(String, SigningCredentials, String) SecurityTokenServiceConfiguration(String, SigningCredentials, String) SecurityTokenServiceConfiguration(String, SigningCredentials, String)

Initializes a new instance of the SecurityTokenServiceConfiguration class that has the specified issuer name and signing credentials. Settings are loaded from the specified named configuration.

Properties

AudienceRestriction AudienceRestriction AudienceRestriction AudienceRestriction

Gets or sets the configured AudienceRestriction.

(Inherited from IdentityConfiguration)
Caches Caches Caches Caches

Gets or sets the configured IdentityModelCaches.

(Inherited from IdentityConfiguration)
CertificateValidationMode CertificateValidationMode CertificateValidationMode CertificateValidationMode

Gets or sets the certificate validation mode used by handlers to validate issuer certificates.

(Inherited from IdentityConfiguration)
CertificateValidator CertificateValidator CertificateValidator CertificateValidator

Gets or sets the certificate validator used by handlers to validate issuer certificates.

(Inherited from IdentityConfiguration)
ClaimsAuthenticationManager ClaimsAuthenticationManager ClaimsAuthenticationManager ClaimsAuthenticationManager

Gets or sets the claims authentication manager. The default is an instance of the ClaimsAuthenticationManager class.

(Inherited from IdentityConfiguration)
ClaimsAuthorizationManager ClaimsAuthorizationManager ClaimsAuthorizationManager ClaimsAuthorizationManager

Gets or sets the claims authorization manager.

(Inherited from IdentityConfiguration)
DefaultMaxSymmetricKeySizeInBits DefaultMaxSymmetricKeySizeInBits DefaultMaxSymmetricKeySizeInBits DefaultMaxSymmetricKeySizeInBits

Gets or sets the default key size limit in bits used check if the KeySize specified in the request is within this limit.

DefaultSymmetricKeySizeInBits DefaultSymmetricKeySizeInBits DefaultSymmetricKeySizeInBits DefaultSymmetricKeySizeInBits

Gets or sets the default key size in bits used in the issued token.

DefaultTokenLifetime DefaultTokenLifetime DefaultTokenLifetime DefaultTokenLifetime

Gets or sets the default lifetime used in the issued tokens.

DefaultTokenType DefaultTokenType DefaultTokenType DefaultTokenType

Gets or sets the default token type that is used in token issuance.

DetectReplayedTokens DetectReplayedTokens DetectReplayedTokens DetectReplayedTokens

Gets or sets a value in the default handler configuration that indicates whether handlers should detect replayed tokens.

(Inherited from IdentityConfiguration)
DisableWsdl DisableWsdl DisableWsdl DisableWsdl

Gets or sets a value that specifies whether WSDL generation should be enabled for the security token service (STS).

IsInitialized IsInitialized IsInitialized IsInitialized

Gets or sets a value that indicates whether the Initialize() method has been called.

(Inherited from IdentityConfiguration)
IssuerNameRegistry IssuerNameRegistry IssuerNameRegistry IssuerNameRegistry

Gets or sets the issuer name registry used to resolve issuer names.

(Inherited from IdentityConfiguration)
IssuerTokenResolver IssuerTokenResolver IssuerTokenResolver IssuerTokenResolver

Gets or sets the issuer token resolver.

(Inherited from IdentityConfiguration)
MaxClockSkew MaxClockSkew MaxClockSkew MaxClockSkew

Gets or sets the maximum allowable time difference between the system clocks of the two parties that are communicating.

(Inherited from IdentityConfiguration)
MaximumTokenLifetime MaximumTokenLifetime MaximumTokenLifetime MaximumTokenLifetime

Gets or sets the maximum token lifetime for issued tokens.

Name Name Name Name

Gets the service name of this configuration.

(Inherited from IdentityConfiguration)
RevocationMode RevocationMode RevocationMode RevocationMode

Gets or sets the revocation mode used by handlers to validate issuer certificates.

(Inherited from IdentityConfiguration)
SaveBootstrapContext SaveBootstrapContext SaveBootstrapContext SaveBootstrapContext

Gets or sets a value that indicates whether the BootstrapContext object is saved in the ClaimsIdentity and Sessions after token validation.

(Inherited from IdentityConfiguration)
SecurityTokenHandlerCollectionManager SecurityTokenHandlerCollectionManager SecurityTokenHandlerCollectionManager SecurityTokenHandlerCollectionManager

Gets the SecurityTokenHandlerCollectionManager containing the set of SecurityTokenHandler objects that are used to serialize and validate tokens found in WS-Trust messages.

(Inherited from IdentityConfiguration)
SecurityTokenHandlers SecurityTokenHandlers SecurityTokenHandlers SecurityTokenHandlers

Gets the collection of SecurityTokenHandler objects used to serialize and validate tokens found in WS-Trust messages.

(Inherited from IdentityConfiguration)
SecurityTokenService SecurityTokenService SecurityTokenService SecurityTokenService

Gets or sets the Type of the security token service (STS).

ServiceCertificate ServiceCertificate ServiceCertificate ServiceCertificate

Gets or sets the service certificate.

(Inherited from IdentityConfiguration)
ServiceTokenResolver ServiceTokenResolver ServiceTokenResolver ServiceTokenResolver

Gets or sets the service token resolver.

(Inherited from IdentityConfiguration)
SigningCredentials SigningCredentials SigningCredentials SigningCredentials

Gets or sets the signing credentials.

TokenIssuerName TokenIssuerName TokenIssuerName TokenIssuerName

Gets or sets the issuer name so that it can be set in the issued token.

TokenReplayCacheExpirationPeriod TokenReplayCacheExpirationPeriod TokenReplayCacheExpirationPeriod TokenReplayCacheExpirationPeriod

Gets or sets the expiration period for items placed in the TokenReplayCache.

(Inherited from IdentityConfiguration)
TrustedStoreLocation TrustedStoreLocation TrustedStoreLocation TrustedStoreLocation

Gets or sets the trusted store location used by handlers to validate issuer certificates.

(Inherited from IdentityConfiguration)
WSTrust13RequestSerializer WSTrust13RequestSerializer WSTrust13RequestSerializer WSTrust13RequestSerializer

Gets or sets the WS-Trust 1.3 Request (RST) serializer.

WSTrust13ResponseSerializer WSTrust13ResponseSerializer WSTrust13ResponseSerializer WSTrust13ResponseSerializer

Gets or sets the WS-Trust 1.3 Response (RSTR) serializer.

WSTrustFeb2005RequestSerializer WSTrustFeb2005RequestSerializer WSTrustFeb2005RequestSerializer WSTrustFeb2005RequestSerializer

Gets or sets the WS-Trust Feb 2005 Request (RST) serializer.

WSTrustFeb2005ResponseSerializer WSTrustFeb2005ResponseSerializer WSTrustFeb2005ResponseSerializer WSTrustFeb2005ResponseSerializer

Gets or sets the WS-Trust Feb 2005 Response (RSTR) serializer.

Methods

CreateSecurityTokenService() CreateSecurityTokenService() CreateSecurityTokenService() CreateSecurityTokenService()

Creates an security token service (STS) instance from the Type specified in the SecurityTokenService property.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
Initialize() Initialize() Initialize() Initialize()

Updates properties in the SecurityTokenHandlerConfiguration objects for the SecurityTokenHandlerCollection objects contained in the SecurityTokenHandlerCollectionManager to be consistent with the property values on this IdentityConfiguration instance.

(Inherited from IdentityConfiguration)
LoadConfiguration(IdentityConfigurationElement) LoadConfiguration(IdentityConfigurationElement) LoadConfiguration(IdentityConfigurationElement) LoadConfiguration(IdentityConfigurationElement)

Loads the settings for this IdentityConfiguration instance from the application or Web configuration file.

(Inherited from IdentityConfiguration)
LoadHandlerConfiguration(IdentityConfigurationElement) LoadHandlerConfiguration(IdentityConfigurationElement) LoadHandlerConfiguration(IdentityConfigurationElement) LoadHandlerConfiguration(IdentityConfigurationElement)

Loads a SecurityTokenHandlerConfiguration by using the elements directly under the specified IdentityConfigurationElement.

(Inherited from IdentityConfiguration)
LoadHandlerConfiguration(SecurityTokenHandlerConfiguration, SecurityTokenHandlerConfigurationElement) LoadHandlerConfiguration(SecurityTokenHandlerConfiguration, SecurityTokenHandlerConfigurationElement) LoadHandlerConfiguration(SecurityTokenHandlerConfiguration, SecurityTokenHandlerConfigurationElement) LoadHandlerConfiguration(SecurityTokenHandlerConfiguration, SecurityTokenHandlerConfigurationElement)

Loads configuration elements pertaining to the SecurityTokenHandlerCollection.

(Inherited from IdentityConfiguration)
LoadHandlers(IdentityConfigurationElement) LoadHandlers(IdentityConfigurationElement) LoadHandlers(IdentityConfigurationElement) LoadHandlers(IdentityConfigurationElement)

Loads the SecurityTokenHandlerCollectionManager defined for the specified service.

(Inherited from IdentityConfiguration)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Fields

DefaultServiceName DefaultServiceName DefaultServiceName DefaultServiceName

The default service name; an empty string.

(Inherited from IdentityConfiguration)

Applies to

See also