SecurityTokenServiceConfiguration Class

.NET Framework 4.5

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

System.Object
  System.IdentityModel.Configuration.IdentityConfiguration
    System.IdentityModel.Configuration.SecurityTokenServiceConfiguration

Namespace:  System.IdentityModel.Configuration
Assembly:  System.IdentityModel (in System.IdentityModel.dll)

public class SecurityTokenServiceConfiguration : IdentityConfiguration

The SecurityTokenServiceConfiguration type exposes the following members.

  NameDescription
Public methodSecurityTokenServiceConfiguration()Initializes a new instance of the SecurityTokenServiceConfiguration class.
Public methodSecurityTokenServiceConfiguration(Boolean)Initializes a new instance of the SecurityTokenServiceConfiguration class. Optionally loads settings from the current configuration.
Public methodSecurityTokenServiceConfiguration(String)Initializes a new instance of the SecurityTokenServiceConfiguration class that has the specified issuer name.
Public methodSecurityTokenServiceConfiguration(String, Boolean)Initializes a new instance of the SecurityTokenServiceConfiguration class that has the specified issuer name. Optionally loads settings from the current configuration.
Public methodSecurityTokenServiceConfiguration(String, SigningCredentials)Initializes a new instance of the SecurityTokenServiceConfiguration class that has the specified issuer name and signing credentials.
Public methodSecurityTokenServiceConfiguration(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.
Public methodSecurityTokenServiceConfiguration(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.
Top

  NameDescription
Public propertyAudienceRestrictionGets or sets the configured AudienceRestriction. (Inherited from IdentityConfiguration.)
Public propertyCachesGets or sets the configured IdentityModelCaches. (Inherited from IdentityConfiguration.)
Public propertyCertificateValidationModeGets or sets the certificate validation mode used by handlers to validate issuer certificates. (Inherited from IdentityConfiguration.)
Public propertyCertificateValidatorGets or sets the certificate validator used by handlers to validate issuer certificates. (Inherited from IdentityConfiguration.)
Public propertyClaimsAuthenticationManagerGets or sets the claims authentication manager. The default is an instance of the ClaimsAuthenticationManager class. (Inherited from IdentityConfiguration.)
Public propertyClaimsAuthorizationManagerGets or sets the claims authorization manager. (Inherited from IdentityConfiguration.)
Public propertyDefaultMaxSymmetricKeySizeInBitsGets or sets the default key size limit in bits used check if the KeySize specified in the request is within this limit.
Public propertyDefaultSymmetricKeySizeInBitsGets or sets the default key size in bits used in the issued token.
Public propertyDefaultTokenLifetimeGets or sets the default lifetime used in the issued tokens.
Public propertyDefaultTokenTypeGets or sets the default token type that is used in token issuance.
Public propertyDetectReplayedTokensGets or sets a value in the default handler configuration that indicates whether handlers should detect replayed tokens. (Inherited from IdentityConfiguration.)
Public propertyDisableWsdlGets or sets a value that specifies whether WSDL generation should be enabled for the security token service (STS).
Public propertyIsInitializedGets or sets a value that indicates whether the Initialize method has been called. (Inherited from IdentityConfiguration.)
Public propertyIssuerNameRegistryGets or sets the issuer name registry used to resolve issuer names. (Inherited from IdentityConfiguration.)
Public propertyIssuerTokenResolverGets or sets the issuer token resolver. (Inherited from IdentityConfiguration.)
Public propertyMaxClockSkewGets or sets the maximum allowable time difference between the system clocks of the two parties that are communicating. (Inherited from IdentityConfiguration.)
Public propertyMaximumTokenLifetimeGets or sets the maximum token lifetime for issued tokens.
Public propertyNameGets the service name of this configuration. (Inherited from IdentityConfiguration.)
Public propertyRevocationModeGets or sets the revocation mode used by handlers to validate issuer certificates. (Inherited from IdentityConfiguration.)
Public propertySaveBootstrapContextGets or sets a value that indicates whether the BootstrapContext object is saved in the ClaimsIdentity and Sessions after token validation. (Inherited from IdentityConfiguration.)
Public propertySecurityTokenHandlerCollectionManagerGets the SecurityTokenHandlerCollectionManager containing the set of SecurityTokenHandler objects that are used to serialize and validate tokens found in WS-Trust messages. (Inherited from IdentityConfiguration.)
Public propertySecurityTokenHandlersGets the collection of SecurityTokenHandler objects used to serialize and validate tokens found in WS-Trust messages. (Inherited from IdentityConfiguration.)
Public propertySecurityTokenServiceGets or sets the Type of the security token service (STS).
Public propertyServiceCertificateGets or sets the service certificate. (Inherited from IdentityConfiguration.)
Public propertyServiceTokenResolverGets or sets the service token resolver. (Inherited from IdentityConfiguration.)
Public propertySigningCredentialsGets or sets the signing credentials.
Public propertyTokenIssuerNameGets or sets the issuer name so that it can be set in the issued token.
Public propertyTokenReplayCacheExpirationPeriodGets or sets the expiration period for items placed in the TokenReplayCache. (Inherited from IdentityConfiguration.)
Public propertyTrustedStoreLocationGets or sets the trusted store location used by handlers to validate issuer certificates. (Inherited from IdentityConfiguration.)
Public propertyWSTrust13RequestSerializerGets or sets the WS-Trust 1.3 Request (RST) serializer.
Public propertyWSTrust13ResponseSerializerGets or sets the WS-Trust 1.3 Response (RSTR) serializer.
Public propertyWSTrustFeb2005RequestSerializerGets or sets the WS-Trust Feb 2005 Request (RST) serializer.
Public propertyWSTrustFeb2005ResponseSerializerGets or sets the WS-Trust Feb 2005 Response (RSTR) serializer.
Top

  NameDescription
Public methodCreateSecurityTokenServiceCreates an security token service (STS) instance from the Type specified in the SecurityTokenService property.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeUpdates 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.)
Protected methodLoadConfigurationLoads the settings for this IdentityConfiguration instance from the application or Web configuration file. (Inherited from IdentityConfiguration.)
Protected methodLoadHandlerConfiguration(IdentityConfigurationElement)Loads a SecurityTokenHandlerConfiguration by using the elements directly under the specified IdentityConfigurationElement. (Inherited from IdentityConfiguration.)
Protected methodLoadHandlerConfiguration(SecurityTokenHandlerConfiguration, SecurityTokenHandlerConfigurationElement)Loads configuration elements pertaining to the SecurityTokenHandlerCollection. (Inherited from IdentityConfiguration.)
Protected methodLoadHandlersLoads the SecurityTokenHandlerCollectionManager defined for the specified service. (Inherited from IdentityConfiguration.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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 );
        }
    }
}

.NET Framework

Supported in: 4.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft