Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@ -0,0 +1,13 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.IdentityModel.Configuration
{
internal class ApplicationServiceConfigurationElement : ConfigurationElementInterceptor
{
public ApplicationServiceConfigurationElement()
{
}
}
}

View File

@ -0,0 +1,41 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
namespace System.IdentityModel.Configuration
{
#pragma warning disable 1591
/// <summary>
/// Manages the configuration of an audience uri element within the audienceUris
/// configuration collection.
/// </summary>
public sealed partial class AudienceUriElement : ConfigurationElement
{
const string DefaultValue = " ";
[ConfigurationProperty(ConfigurationStrings.Value, IsRequired = true, DefaultValue = DefaultValue, IsKey = true)]
[StringValidator(MinLength = 1)]
public string Value
{
get { return (string)this[ConfigurationStrings.Value]; }
set { this[ConfigurationStrings.Value] = value; }
}
/// <summary>
/// Returns a value indicating whether this element has been configured with non-default values.
/// </summary>
internal bool IsConfigured
{
get
{
return ElementInformation.Properties[ConfigurationStrings.Value].ValueOrigin != PropertyValueOrigin.Default;
}
}
}
#pragma warning restore 1591
}

View File

@ -0,0 +1,58 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
using System.ComponentModel;
using System.Configuration;
using System.IdentityModel.Selectors;
namespace System.IdentityModel.Configuration
{
#pragma warning disable 1591
/// <summary>
/// Manages the configuration of the audienceUris section.
/// </summary>
[ConfigurationCollection(typeof(AudienceUriElement),
CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
public sealed partial class AudienceUriElementCollection : ConfigurationElementCollection
{
const AudienceUriMode DefaultAudienceUriMode = AudienceUriMode.Always;
protected override void Init()
{
base.Init();
}
protected override ConfigurationElement CreateNewElement()
{
return new AudienceUriElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((AudienceUriElement)element).Value;
}
/// <summary>
/// Audience restriction mode. Optional, default is Always.
/// </summary>
[ConfigurationProperty(ConfigurationStrings.Mode, IsRequired = false, DefaultValue = DefaultAudienceUriMode)]
[StandardRuntimeEnumValidator(typeof(AudienceUriMode))]
public AudienceUriMode Mode
{
get { return (AudienceUriMode)this[ConfigurationStrings.Mode]; }
set { this[ConfigurationStrings.Mode] = value; }
}
/// <summary>
/// Returns a value indicating whether this element has been configured with non-default values.
/// </summary>
internal bool IsConfigured
{
get
{
return ((ElementInformation.Properties[ConfigurationStrings.Mode].ValueOrigin != PropertyValueOrigin.Default) || (Count > 0));
}
}
}
#pragma warning restore 1591
}

View File

@ -0,0 +1,92 @@
using System.Configuration;
using System.Text;
using System.Xml;
namespace System.IdentityModel.Configuration
{
#pragma warning disable 1591
public partial class ConfigurationElementInterceptor : ConfigurationElement
{
private XmlDocument elementXml;
protected override void DeserializeElement( XmlReader reader, bool serializeCollectionKey )
{
elementXml = new XmlDocument();
elementXml.LoadXml( reader.ReadOuterXml() );
// Create a new XmlTextReader so this element can be loaded
// by the framework.
using ( XmlReader newReader = XmlDictionaryReader.CreateTextReader( Encoding.UTF8.GetBytes( elementXml.DocumentElement.OuterXml ), XmlDictionaryReaderQuotas.Max ) )
{
newReader.Read();
base.DeserializeElement( newReader, serializeCollectionKey );
}
}
// There are parts in the configuration where users can specify arbitrary elements and attributes.
// For example, when loading a custom token handler. The interceptor is implemented to
// specifically handle these cases. So return true when the Framework detects a unrecognized element
// or attribute to keep the parser running.
protected override bool OnDeserializeUnrecognizedAttribute( string name, string value )
{
return true;
}
protected override bool OnDeserializeUnrecognizedElement( string elementName, XmlReader reader )
{
return true;
}
//
// The Reset method is called in the nested vdir scenario,
// where the child inherits the parent's config section.
// The sequence of calls is as follows:
// 1. Application accesses the section in the child app
// 2. The config system walks up the inheritance chain and finds that it can instantiate the section at the parent level.
// 3. The config system populates the section with the values from the parent, including setting the custom XML property.
// 4. Now, the config system tries to instantiage the section at the child level. It creates a brand new instance of the section.
// 5. The config system takes the parent section as a template and uses it to initialize the child (by calling this Reset method).
// 6. Then the config system populates the child with values that were overwritten at the child level.
//
protected override void Reset( ConfigurationElement parentElement )
{
base.Reset( parentElement );
Reset( (ConfigurationElementInterceptor)parentElement );
}
public XmlElement ElementAsXml
{
get
{
if ( elementXml != null )
{
return elementXml.DocumentElement;
}
return null;
}
}
public XmlNodeList ChildNodes
{
get
{
if ( ( elementXml != null ) && ( ElementAsXml.ChildNodes.Count != 0 ) )
{
return ElementAsXml.ChildNodes;
}
return null;
}
}
//
// Copy custom properties from parent level.
//
private void Reset( ConfigurationElementInterceptor parentElement )
{
this.elementXml = parentElement.elementXml;
}
}
#pragma warning restore 1591
}

View File

@ -0,0 +1,94 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.IdentityModel.Configuration
{
static class ConfigurationStrings
{
public const string Add = "add";
public const string ApplicationService = "applicationService";
public const string AudienceUris = "audienceUris";
public const string AudienceUriMode = "audienceUriMode";
public const string Caches = "caches";
public const string Capacity = "capacity";
public const string CertificateReference = "certificateReference";
public const string ClaimsAuthenticationManager = "claimsAuthenticationManager";
public const string ClaimsAuthorizationManager = "claimsAuthorizationManager";
public const string Clear = "clear";
public const string Compression = "compression";
public const string CookieTransforms = "cookieTransforms";
public const string DefaultCollectionName = ""; // String.Empty
public const string DefaultConfigurationElementName = ""; // String.Empty
public const string DefaultServiceName = ""; // String.Empty
public const string DetectReplayedTokens = "detectReplayedTokens";
public const string Enabled = "enabled";
public const string ExpirationPeriod = "expirationPeriod";
public const string FederatedAuthentication = "federatedAuthentication";
public const string FindValue = "findValue";
public const string IsChainIncluded = "isChainIncluded";
public const string IssuerNameRegistry = "issuerNameRegistry";
public const string IssuerTokenResolver = "issuerTokenResolver";
public const string IssuerCertificateRevocationMode = "issuerCertificateRevocationMode";
public const string IssuerCertificateTrustedStoreLocation = "issuerCertificateTrustedStoreLocation";
public const string IssuerCertificateValidationMode = "issuerCertificateValidationMode";
public const string IssuerCertificateValidator = "issuerCertificateValidator";
public const string KerberosTokenHandlerRequirement = "kerberosTokenHandlerRequirement";
public const string Lifetime = "lifetime";
public const string MapToWindows = "mapToWindows";
public const string MaximumClockSkew = "maximumClockSkew";
public const string MembershipProviderName = "membershipProviderName";
public const string Mode = "mode";
public const string IdentityConfiguration = "identityConfiguration";
public const string SystemIdentityModel = "system.identityModel";
public const string Name = "name";
public const string NameClaimType = "nameClaimType";
public const string PersistentSessionLifetime = "persistentSessionLifetime";
public const string Protection = "protection";
public const string PurgeInterval = "purgeInterval";
public const string Remove = "remove";
public const string RoleClaimType = "roleClaimType";
public const string ServiceCertificate = "serviceCertificate";
public const string SamlSecurityTokenRequirement = "samlSecurityTokenRequirement";
public const string SaveBootstrapContext = "saveBootstrapContext";
public const string ServiceTokenResolver = "serviceTokenResolver";
public const string SecurityTokenHandlerConfiguration = "securityTokenHandlerConfiguration";
public const string SecurityTokenHandlers = "securityTokenHandlers";
public const string SessionSecurityTokenCache = "sessionSecurityTokenCache";
public const string SessionTokenRequirement = "sessionTokenRequirement";
public const string SecurityTokenCacheType = "securityTokenCacheType";
public const string SecurityTokenCacheSize = "securityTokenCacheSize";
public const string StoreLocation = "storeLocation";
public const string StoreName = "storeName";
public const string Thumbprint = "thumbprint";
public const string TimeSpanZero = "00:00:00";
public const string TimeSpanMaxValue = "10675199.02:48:05.4775807"; // TimeSpan.MaxValue is 10675199.02:48:05.4775807
public const string TokenReplayCache = "tokenReplayCache";
public const string TokenReplayDetection = "tokenReplayDetection";
public const string TransientSessionLifetime = "transientSessionLifetime";
public const string TrustedIssuers = "trustedIssuers";
public const string Type = "type";
public const string UserNameSecurityTokenHandlerRequirement = "userNameSecurityTokenHandlerRequirement";
public const string UseWindowsTokenService = "useWindowsTokenService";
public const string Value = "value";
public const string WindowsClaimsIdentity = "windowsClaimsIdentity";
public const string X509CertificateRevocationMode = "revocationMode";
public const string X509CertificateValidation = "certificateValidation";
public const string X509CertificateValidationMode = "certificateValidationMode";
public const string X509CertificateValidationModeChainTrust = "ChainTrust";
public const string X509CertificateValidationModeCustom = "Custom";
public const string X509CertificateValidationModeNone = "None";
public const string X509CertificateValidationModePeerTrust = "PeerTrust";
public const string X509CertificateValidationModePeerOrChainTrust = "PeerOrChainTrust";
public const string X509CertificateValidator = "certificateValidator";
public const string X509FindType = "x509FindType";
public const string X509RevocationModeNoCheck = "NoCheck";
public const string X509RevocationModeOnline = "Online";
public const string X509RevocationModeOffline = "Offline";
public const string X509SecurityTokenHandlerRequirement = "x509SecurityTokenHandlerRequirement";
public const string X509TrustedStoreLocation = "trustedStoreLocation";
public const string X509TrustedStoreLocationCurrentUser = "CurrentUser";
public const string X509TrustedStoreLocationLocalMachine = "LocalMachine";
}
}

View File

@ -0,0 +1,47 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
using System.ComponentModel;
using System.Configuration;
namespace System.IdentityModel.Configuration
{
#pragma warning disable 1591
public sealed partial class CustomTypeElement : ConfigurationElementInterceptor
{
public CustomTypeElement()
{
}
internal CustomTypeElement( Type typeName )
{
this.Type = typeName;
}
public static T Resolve<T>( CustomTypeElement customTypeElement ) where T : class
{
return TypeResolveHelper.Resolve<T>( customTypeElement, customTypeElement.Type );
}
/// <summary>
/// Returns a value indicating whether this element has been configured with non-default values.
/// </summary>
public bool IsConfigured
{
get
{
return ( ( ElementInformation.Properties[ConfigurationStrings.Type].ValueOrigin != PropertyValueOrigin.Default ) );
}
}
[ConfigurationProperty( ConfigurationStrings.Type, IsRequired = true, IsKey = true )]
[TypeConverter(typeof(System.Configuration.TypeNameConverter))]
public Type Type
{
get { return (Type)this[ConfigurationStrings.Type]; }
set { this[ConfigurationStrings.Type] = value; }
}
}
#pragma warning restore 1591
}

View File

@ -0,0 +1,22 @@
//-----------------------------------------------------------------------
// <copyright file="ICustomIdentityConfiguration.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace System.IdentityModel.Configuration
{
using System.Xml;
/// <summary>
/// Types that implement ICustomIdentityConfiguration can load custom configuration
/// </summary>
public interface ICustomIdentityConfiguration
{
/// <summary>
/// Override LoadCustomConfiguration to provide custom handling of configuration elements
/// </summary>
/// <param name="nodeList">Xml Nodes which contain custom configuration</param>
void LoadCustomConfiguration(XmlNodeList nodeList);
}
}

View File

@ -0,0 +1,144 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Configuration;
using System.IdentityModel.Tokens;
namespace System.IdentityModel.Configuration
{
#pragma warning disable 1591
public sealed partial class IdentityConfigurationElement : ConfigurationElement
{
[ConfigurationProperty(ConfigurationStrings.Name, Options = ConfigurationPropertyOptions.IsKey)]
[StringValidator(MinLength = 0)]
public string Name
{
get { return (string)this[ConfigurationStrings.Name]; }
set { this[ConfigurationStrings.Name] = value; }
}
[ConfigurationProperty(ConfigurationStrings.AudienceUris, IsRequired = false)]
public AudienceUriElementCollection AudienceUris
{
get { return (AudienceUriElementCollection)this[ConfigurationStrings.AudienceUris]; }
}
[ConfigurationProperty(ConfigurationStrings.Caches, IsRequired = false)]
public IdentityModelCachesElement Caches
{
get { return (IdentityModelCachesElement)this[ConfigurationStrings.Caches]; }
set { this[ConfigurationStrings.Caches] = value; }
}
[ConfigurationProperty(ConfigurationStrings.X509CertificateValidation, IsRequired = false)]
public X509CertificateValidationElement CertificateValidation
{
get { return (X509CertificateValidationElement)this[ConfigurationStrings.X509CertificateValidation]; }
set { this[ConfigurationStrings.X509CertificateValidation] = value; }
}
[ConfigurationProperty(ConfigurationStrings.ClaimsAuthenticationManager, IsRequired = false)]
public CustomTypeElement ClaimsAuthenticationManager
{
get { return (CustomTypeElement)this[ConfigurationStrings.ClaimsAuthenticationManager]; }
set { this[ConfigurationStrings.ClaimsAuthenticationManager] = value; }
}
[ConfigurationProperty(ConfigurationStrings.ClaimsAuthorizationManager, IsRequired = false)]
public CustomTypeElement ClaimsAuthorizationManager
{
get { return (CustomTypeElement)this[ConfigurationStrings.ClaimsAuthorizationManager]; }
set { this[ConfigurationStrings.ClaimsAuthorizationManager] = value; }
}
[ConfigurationProperty(ConfigurationStrings.IssuerNameRegistry, IsRequired = false)]
public IssuerNameRegistryElement IssuerNameRegistry
{
get { return (IssuerNameRegistryElement)this[ConfigurationStrings.IssuerNameRegistry]; }
set { this[ConfigurationStrings.IssuerNameRegistry] = value; }
}
[ConfigurationProperty(ConfigurationStrings.IssuerTokenResolver, IsRequired = false)]
public CustomTypeElement IssuerTokenResolver
{
get { return (CustomTypeElement)this[ConfigurationStrings.IssuerTokenResolver]; }
set { this[ConfigurationStrings.IssuerTokenResolver] = value; }
}
[ConfigurationProperty( ConfigurationStrings.MaximumClockSkew, IsRequired = false, DefaultValue = IdentityConfiguration.DefaultMaxClockSkewString )]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[IdentityModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan MaximumClockSkew
{
get { return (TimeSpan)this[ConfigurationStrings.MaximumClockSkew]; }
set { this[ConfigurationStrings.MaximumClockSkew] = value; }
}
[ConfigurationProperty(ConfigurationStrings.SaveBootstrapContext, IsRequired = false, DefaultValue = false)]
public bool SaveBootstrapContext
{
get { return (bool)this[ConfigurationStrings.SaveBootstrapContext]; }
set { this[ConfigurationStrings.SaveBootstrapContext] = value; }
}
[ConfigurationProperty(ConfigurationStrings.ServiceTokenResolver, IsRequired = false)]
public CustomTypeElement ServiceTokenResolver
{
get { return (CustomTypeElement)this[ConfigurationStrings.ServiceTokenResolver]; }
set { this[ConfigurationStrings.ServiceTokenResolver] = value; }
}
[ConfigurationProperty(ConfigurationStrings.TokenReplayDetection, IsRequired = false)]
public TokenReplayDetectionElement TokenReplayDetection
{
get { return (TokenReplayDetectionElement)this[ConfigurationStrings.TokenReplayDetection]; }
set { this[ConfigurationStrings.TokenReplayDetection] = value; }
}
/// <summary>
/// A collection of SecurityTokenHandlerCollection elements.
/// </summary>
[ConfigurationProperty(ConfigurationStrings.DefaultCollectionName, Options = ConfigurationPropertyOptions.IsDefaultCollection)]
public SecurityTokenHandlerSetElementCollection SecurityTokenHandlerSets
{
get { return (SecurityTokenHandlerSetElementCollection)this[ConfigurationStrings.DefaultConfigurationElementName]; }
}
// This config element is being marked as internal cause we need this just to make the App registration
// tool to work. We do not want the application to use it.
// FIP 6495
[ConfigurationProperty(ConfigurationStrings.ApplicationService, IsRequired = false)]
internal ApplicationServiceConfigurationElement ApplicationService
{
get { return (ApplicationServiceConfigurationElement)this[ConfigurationStrings.ApplicationService]; }
set { this[ConfigurationStrings.ApplicationService] = value; }
}
/// <summary>
/// Returns a value indicating whether this element has been configured with non-default values.
/// </summary>
internal bool IsConfigured
{
get
{
return ((ElementInformation.Properties[ConfigurationStrings.Name].ValueOrigin != PropertyValueOrigin.Default) ||
AudienceUris.IsConfigured ||
Caches.IsConfigured ||
CertificateValidation.IsConfigured ||
ClaimsAuthenticationManager.IsConfigured ||
ClaimsAuthorizationManager.IsConfigured ||
IssuerNameRegistry.IsConfigured ||
IssuerTokenResolver.IsConfigured ||
(ElementInformation.Properties[ConfigurationStrings.SaveBootstrapContext].ValueOrigin != PropertyValueOrigin.Default ) ||
(ElementInformation.Properties[ConfigurationStrings.MaximumClockSkew].ValueOrigin != PropertyValueOrigin.Default) ||
ServiceTokenResolver.IsConfigured ||
TokenReplayDetection.IsConfigured ||
SecurityTokenHandlerSets.IsConfigured);
}
}
}
#pragma warning restore 1591
}

View File

@ -0,0 +1,94 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
using System;
using System.Configuration;
namespace System.IdentityModel.Configuration
{
#pragma warning disable 1591
[ConfigurationCollection(typeof(IdentityConfigurationElement), AddItemName = ConfigurationStrings.IdentityConfiguration, CollectionType = ConfigurationElementCollectionType.BasicMap)]
public sealed partial class IdentityConfigurationElementCollection : ConfigurationElementCollection
{
// Note:This is a BasicMap collection type with ThrowOnDuplicate true.
// If there are two configuration elements defined with the same key the configuration system throws an error.
protected override bool ThrowOnDuplicate
{
get
{
return true;
}
}
protected override ConfigurationElement CreateNewElement()
{
return new IdentityConfigurationElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
if (element == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
IdentityConfigurationElement elementAsServiceElement = element as IdentityConfigurationElement;
if (elementAsServiceElement == null)
{
throw DiagnosticUtility.ThrowHelperInvalidOperation(SR.GetString(SR.ID7013));
}
return elementAsServiceElement.Name;
}
/// <summary>
/// Retrieves the ServiceElement with the specified name.
/// </summary>
/// <param name="name">The name of the ServiceElement to retrieve</param>
/// <returns>A ServiceElement instance</returns>
public IdentityConfigurationElement GetElement(string name)
{
if (name == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");
}
IdentityConfigurationElement result = base.BaseGet(name) as IdentityConfigurationElement;
if (!StringComparer.Ordinal.Equals(name, ConfigurationStrings.DefaultConfigurationElementName) && result == null)
{
throw DiagnosticUtility.ThrowHelperInvalidOperation(SR.GetString(SR.ID7012, name));
}
return result;
}
protected override void BaseAdd(ConfigurationElement element)
{
string name = GetElementKey(element) as string;
IdentityConfigurationElement result = base.BaseGet(name) as IdentityConfigurationElement;
if (result != null)
{
throw DiagnosticUtility.ThrowHelperInvalidOperation(SR.GetString(SR.ID7029, "<identityConfiguation>", name));
}
base.BaseAdd(element);
}
/// <summary>
/// Returns a value indicating whether this element has been configured with non-default values.
/// </summary>
internal bool IsConfigured
{
get
{
return (Count > 0);
}
}
}
#pragma warning restore 1591
}

View File

@ -0,0 +1,61 @@
//-----------------------------------------------------------------------
// <copyright file="IdentityModelCaches.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace System.IdentityModel.Configuration
{
using System.IdentityModel.Tokens;
/// <summary>
/// Defines caches supported by IdentityModel for TokenReplay and SecuritySessionTokens
/// </summary>
public sealed class IdentityModelCaches
{
private TokenReplayCache tokenReplayCache = new DefaultTokenReplayCache();
private SessionSecurityTokenCache sessionSecurityTokenCache = new MruSessionSecurityTokenCache();
/// <summary>
/// Gets or sets the TokenReplayCache that is used to determine replayed token.
/// </summary>
public TokenReplayCache TokenReplayCache
{
get
{
return this.tokenReplayCache;
}
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
this.tokenReplayCache = value;
}
}
/// <summary>
/// Gets or sets the SessionSecurityTokenCache that is used to cache the <see cref="SessionSecurityToken"/>
/// </summary>
public SessionSecurityTokenCache SessionSecurityTokenCache
{
get
{
return this.sessionSecurityTokenCache;
}
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
this.sessionSecurityTokenCache = value;
}
}
}
}

View File

@ -0,0 +1,52 @@
//-----------------------------------------------------------------------
// <copyright file="IdentityModelCaches.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace System.IdentityModel.Configuration
{
using System.ComponentModel;
using System.Configuration;
/// <summary>
/// The <c>IdentityModelCachesElement</c> class provides XML configuration for WIF caching services.
/// </summary>
public sealed partial class IdentityModelCachesElement : ConfigurationElement
{
/// <summary>
/// Gets or sets the <see cref="TokenReplayCache"/> type. This element is optional and the specified custom replay cache
/// must derive from <see cref="System.IdentityModel.Tokens.TokenReplayCache"/>.
/// To enable replay detection, configure the <see cref="System.IdentityModel.Configuration.TokenReplayDetectionElement"/>.
/// </summary>
[ConfigurationProperty(ConfigurationStrings.TokenReplayCache, IsRequired = false)]
public CustomTypeElement TokenReplayCache
{
get { return (CustomTypeElement)this[ConfigurationStrings.TokenReplayCache]; }
set { this[ConfigurationStrings.TokenReplayCache] = value; }
}
/// <summary>
/// Gets or sets the <see cref="SessionSecurityTokenCache"/> type. This element is optional and the specified custom cache
/// must derive from <see cref="System.IdentityModel.Tokens.SessionSecurityTokenCache"/>.
/// This cache is used for caching <see cref="System.IdentityModel.Tokens.SessionSecurityToken" />.
/// </summary>
[ConfigurationProperty(ConfigurationStrings.SessionSecurityTokenCache, IsRequired = false)]
public CustomTypeElement SessionSecurityTokenCache
{
get { return (CustomTypeElement)this[ConfigurationStrings.SessionSecurityTokenCache]; }
set { this[ConfigurationStrings.SessionSecurityTokenCache] = value; }
}
/// <summary>
/// Gets a value indicating whether this element has been configured.
/// </summary>
public bool IsConfigured
{
get
{
return this.TokenReplayCache != null || this.SessionSecurityTokenCache != null;
}
}
}
}

View File

@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.IdentityModel.Configuration
{
using System;
using System.Configuration;
using System.Runtime;
[AttributeUsage(AttributeTargets.Property)]
sealed class IdentityModelTimeSpanValidatorAttribute : ConfigurationValidatorAttribute
{
TimeSpanValidatorAttribute innerValidatorAttribute;
public IdentityModelTimeSpanValidatorAttribute()
{
this.innerValidatorAttribute = new TimeSpanValidatorAttribute();
this.innerValidatorAttribute.MaxValueString = TimeoutHelper.MaxWait.ToString();
}
public override ConfigurationValidatorBase ValidatorInstance
{
get
{
return new TimeSpanOrInfiniteValidator(MinValue, MaxValue);
}
}
public TimeSpan MinValue
{
get
{
return this.innerValidatorAttribute.MinValue;
}
}
public string MinValueString
{
get
{
return this.innerValidatorAttribute.MinValueString;
}
set
{
this.innerValidatorAttribute.MinValueString = value;
}
}
public TimeSpan MaxValue
{
get
{
return this.innerValidatorAttribute.MaxValue;
}
}
public string MaxValueString
{
get
{
return this.innerValidatorAttribute.MaxValueString;
}
set
{
this.innerValidatorAttribute.MaxValueString = value;
}
}
}
}

View File

@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
using System.Configuration;
namespace System.IdentityModel.Configuration
{
public sealed partial class IssuerNameRegistryElement : ConfigurationElementInterceptor
{
public IssuerNameRegistryElement()
{
}
internal IssuerNameRegistryElement(string type)
{
Type = type;
}
/// <summary>
/// Special case: type may be omitted but inner configuration may be present
/// </summary>
internal bool IsConfigured
{
get
{
return (ElementInformation.Properties[ConfigurationStrings.Type].ValueOrigin != PropertyValueOrigin.Default) || ((ChildNodes != null) && (ChildNodes.Count > 0));
}
}
[ConfigurationProperty(ConfigurationStrings.Type, IsRequired = false, IsKey = false)]
[StringValidator(MinLength = 0)]
public string Type
{
get { return (string)this[ConfigurationStrings.Type]; }
set { this[ConfigurationStrings.Type] = value; }
}
}
}

View File

@ -0,0 +1,253 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
// This code was produced by a tool, ConfigPropertyGenerator.exe, by reflecting over
// System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
// Please add this file to the project that built the assembly.
// Doing so will provide better performance for retrieving the ConfigurationElement Properties.
// If compilation errors occur, make sure that the Properties property has not
// already been provided. If it has, decide if you want the version produced by
// this tool or by the developer.
// If build errors result, make sure the config class is marked with the partial keyword.
// To regenerate a new Properties.cs after changes to the configuration OM for
// this assembly, simply run Indigo\Suites\Configuration\Infrastructure\ConfigPropertyGenerator.
// If any changes affect this file, the suite will fail. Instructions on how to
// update Properties.cs will be included in the tests output file (ConfigPropertyGenerator.out).
using System.Configuration;
using System.Globalization;
// configType.Name: AudienceUriElement
namespace System.IdentityModel.Configuration
{
public sealed partial class AudienceUriElement
{
ConfigurationPropertyCollection properties;
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty("value", typeof(System.String), " ", null, new System.Configuration.StringValidator(1, 2147483647, null), System.Configuration.ConfigurationPropertyOptions.IsRequired | System.Configuration.ConfigurationPropertyOptions.IsKey));
this.properties = properties;
}
return this.properties;
}
}
}
}
// configType.Name: AudienceUriElementCollection
namespace System.IdentityModel.Configuration
{
public sealed partial class AudienceUriElementCollection
{
ConfigurationPropertyCollection properties;
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty("mode", typeof(System.IdentityModel.Selectors.AudienceUriMode), System.IdentityModel.Selectors.AudienceUriMode.Always, null, new System.IdentityModel.Configuration.StandardRuntimeEnumValidator(typeof(System.IdentityModel.Selectors.AudienceUriMode)), System.Configuration.ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}
// configType.Name: CustomTypeElement
namespace System.IdentityModel.Configuration
{
public sealed partial class CustomTypeElement
{
ConfigurationPropertyCollection properties;
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty("type", typeof(System.Type), null, new System.Configuration.TypeNameConverter(), null, System.Configuration.ConfigurationPropertyOptions.IsRequired | System.Configuration.ConfigurationPropertyOptions.IsKey));
this.properties = properties;
}
return this.properties;
}
}
}
}
// configType.Name: IdentityModelCachesElement
namespace System.IdentityModel.Configuration
{
public sealed partial class IdentityModelCachesElement
{
ConfigurationPropertyCollection properties;
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty("tokenReplayCache", typeof(System.IdentityModel.Configuration.CustomTypeElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("sessionSecurityTokenCache", typeof(System.IdentityModel.Configuration.CustomTypeElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}
// configType.Name: IssuerNameRegistryElement
namespace System.IdentityModel.Configuration
{
public sealed partial class IssuerNameRegistryElement
{
ConfigurationPropertyCollection properties;
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty("type", typeof(System.String), string.Empty, null, new System.Configuration.StringValidator(0, 2147483647, null), System.Configuration.ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}
// configType.Name: X509CertificateValidationElement
namespace System.IdentityModel.Configuration
{
public sealed partial class X509CertificateValidationElement
{
ConfigurationPropertyCollection properties;
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty("certificateValidationMode", typeof(System.ServiceModel.Security.X509CertificateValidationMode), System.ServiceModel.Security.X509CertificateValidationMode.PeerOrChainTrust, null, new System.IdentityModel.Configuration.StandardRuntimeEnumValidator(typeof(System.ServiceModel.Security.X509CertificateValidationMode)), System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("revocationMode", typeof(System.Security.Cryptography.X509Certificates.X509RevocationMode), System.Security.Cryptography.X509Certificates.X509RevocationMode.Online, null, new System.IdentityModel.Configuration.StandardRuntimeEnumValidator(typeof(System.Security.Cryptography.X509Certificates.X509RevocationMode)), System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("trustedStoreLocation", typeof(System.Security.Cryptography.X509Certificates.StoreLocation), System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine, null, new System.IdentityModel.Configuration.StandardRuntimeEnumValidator(typeof(System.Security.Cryptography.X509Certificates.StoreLocation)), System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("certificateValidator", typeof(System.IdentityModel.Configuration.CustomTypeElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}
// configType.Name: SecurityTokenHandlerConfigurationElement
namespace System.IdentityModel.Configuration
{
public sealed partial class SecurityTokenHandlerConfigurationElement
{
ConfigurationPropertyCollection properties;
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty("audienceUris", typeof(System.IdentityModel.Configuration.AudienceUriElementCollection), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("caches", typeof(System.IdentityModel.Configuration.IdentityModelCachesElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("certificateValidation", typeof(System.IdentityModel.Configuration.X509CertificateValidationElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("issuerNameRegistry", typeof(System.IdentityModel.Configuration.IssuerNameRegistryElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("issuerTokenResolver", typeof(System.IdentityModel.Configuration.CustomTypeElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("name", typeof(System.String), string.Empty, null, new System.Configuration.StringValidator(0, 2147483647, null), System.Configuration.ConfigurationPropertyOptions.IsKey));
properties.Add(new ConfigurationProperty("saveBootstrapContext", typeof(System.Boolean), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("maximumClockSkew", typeof(System.TimeSpan), System.TimeSpan.Parse("00:05:00", CultureInfo.InvariantCulture), new System.IdentityModel.Configuration.TimeSpanOrInfiniteConverter(), new System.IdentityModel.Configuration.TimeSpanOrInfiniteValidator(System.TimeSpan.Parse("00:00:00", CultureInfo.InvariantCulture), System.TimeSpan.Parse("24.20:31:23.6470000", CultureInfo.InvariantCulture)), System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("serviceTokenResolver", typeof(System.IdentityModel.Configuration.CustomTypeElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("tokenReplayDetection", typeof(System.IdentityModel.Configuration.TokenReplayDetectionElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}
// configType.Name: SecurityTokenHandlerElementCollection
namespace System.IdentityModel.Configuration
{
public sealed partial class SecurityTokenHandlerElementCollection
{
ConfigurationPropertyCollection properties;
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty("name", typeof(System.String), string.Empty, null, new System.Configuration.StringValidator(0, 2147483647, null), System.Configuration.ConfigurationPropertyOptions.IsKey));
properties.Add(new ConfigurationProperty("securityTokenHandlerConfiguration", typeof(System.IdentityModel.Configuration.SecurityTokenHandlerConfigurationElement), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}
// configType.Name: TokenReplayDetectionElement
namespace System.IdentityModel.Configuration
{
public sealed partial class TokenReplayDetectionElement
{
ConfigurationPropertyCollection properties;
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty("enabled", typeof(System.Boolean), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("expirationPeriod", typeof(System.TimeSpan), System.TimeSpan.Parse("10675199.02:48:05.4775807", CultureInfo.InvariantCulture), new System.IdentityModel.Configuration.TimeSpanOrInfiniteConverter(), new System.IdentityModel.Configuration.TimeSpanOrInfiniteValidator(System.TimeSpan.Parse("00:00:00", CultureInfo.InvariantCulture), System.TimeSpan.Parse("10675199.02:48:05.4775807", CultureInfo.InvariantCulture)), System.Configuration.ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}

View File

@ -0,0 +1,120 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Configuration;
using System.IdentityModel.Tokens;
namespace System.IdentityModel.Configuration
{
#pragma warning disable 1591
/// <summary>
/// Manages configuration for all the Security Token Handlers.
/// </summary>
public sealed partial class SecurityTokenHandlerConfigurationElement : ConfigurationElement
{
public SecurityTokenHandlerConfigurationElement()
{
}
protected override void Init()
{
Name = SecurityTokenHandlerCollectionManager.Usage.Default;
}
[ConfigurationProperty( ConfigurationStrings.AudienceUris, IsRequired = false )]
public AudienceUriElementCollection AudienceUris
{
get { return (AudienceUriElementCollection)this[ConfigurationStrings.AudienceUris]; }
}
[ConfigurationProperty(ConfigurationStrings.Caches, IsRequired = false)]
public IdentityModelCachesElement Caches
{
get { return (IdentityModelCachesElement)this[ConfigurationStrings.Caches]; }
set { this[ConfigurationStrings.Caches] = value; }
}
[ConfigurationProperty(ConfigurationStrings.X509CertificateValidation, IsRequired = false)]
public X509CertificateValidationElement CertificateValidation
{
get { return (X509CertificateValidationElement)this[ConfigurationStrings.X509CertificateValidation]; }
set { this[ConfigurationStrings.X509CertificateValidation] = value; }
}
[ConfigurationProperty( ConfigurationStrings.IssuerNameRegistry, IsRequired = false )]
public IssuerNameRegistryElement IssuerNameRegistry
{
get { return (IssuerNameRegistryElement)this[ConfigurationStrings.IssuerNameRegistry]; }
set { this[ConfigurationStrings.IssuerNameRegistry] = value; }
}
[ConfigurationProperty( ConfigurationStrings.IssuerTokenResolver, IsRequired = false )]
public CustomTypeElement IssuerTokenResolver
{
get { return (CustomTypeElement)this[ConfigurationStrings.IssuerTokenResolver]; }
set { this[ConfigurationStrings.IssuerTokenResolver] = value; }
}
[ConfigurationProperty( ConfigurationStrings.Name, IsRequired = false, Options = ConfigurationPropertyOptions.IsKey )]
[StringValidator(MinLength = 0)]
public string Name
{
get { return (string)this[ConfigurationStrings.Name]; }
set { this[ConfigurationStrings.Name] = value; }
}
[ConfigurationProperty( ConfigurationStrings.SaveBootstrapContext, IsRequired = false, DefaultValue = false )]
public bool SaveBootstrapContext
{
get { return (bool)this[ConfigurationStrings.SaveBootstrapContext]; }
set { this[ConfigurationStrings.SaveBootstrapContext] = value; }
}
[ConfigurationProperty( ConfigurationStrings.MaximumClockSkew, IsRequired = false, DefaultValue = IdentityConfiguration.DefaultMaxClockSkewString )]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[IdentityModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan MaximumClockSkew
{
get { return (TimeSpan)this[ConfigurationStrings.MaximumClockSkew]; }
set { this[ConfigurationStrings.MaximumClockSkew] = value; }
}
[ConfigurationProperty( ConfigurationStrings.ServiceTokenResolver, IsRequired = false )]
public CustomTypeElement ServiceTokenResolver
{
get { return (CustomTypeElement)this[ConfigurationStrings.ServiceTokenResolver]; }
set { this[ConfigurationStrings.ServiceTokenResolver] = value; }
}
[ConfigurationProperty( ConfigurationStrings.TokenReplayDetection, IsRequired = false )]
public TokenReplayDetectionElement TokenReplayDetection
{
get { return (TokenReplayDetectionElement)this[ConfigurationStrings.TokenReplayDetection]; }
set { this[ConfigurationStrings.TokenReplayDetection] = value; }
}
/// <summary>
/// Returns a value indicating whether this element has been configured with non-default values.
/// </summary>
internal bool IsConfigured
{
get
{
return ( AudienceUris.IsConfigured ||
Caches.IsConfigured ||
CertificateValidation.IsConfigured ||
IssuerNameRegistry.IsConfigured ||
IssuerTokenResolver.IsConfigured ||
( ElementInformation.Properties[ConfigurationStrings.Name].ValueOrigin != PropertyValueOrigin.Default ) ||
( ElementInformation.Properties[ConfigurationStrings.SaveBootstrapContext].ValueOrigin != PropertyValueOrigin.Default ) ||
( ElementInformation.Properties[ConfigurationStrings.MaximumClockSkew].ValueOrigin != PropertyValueOrigin.Default ) ||
ServiceTokenResolver.IsConfigured ||
TokenReplayDetection.IsConfigured );
}
}
}
#pragma warning restore 1591
}

View File

@ -0,0 +1,74 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.IdentityModel.Configuration
{
using System.Configuration;
using System.IdentityModel.Tokens;
#pragma warning disable 1591
[ConfigurationCollection( typeof( CustomTypeElement ), CollectionType = ConfigurationElementCollectionType.BasicMap )]
public sealed partial class SecurityTokenHandlerElementCollection : ConfigurationElementCollection
{
public SecurityTokenHandlerElementCollection()
{
}
protected override ConfigurationElement CreateNewElement()
{
return new CustomTypeElement();
}
protected override object GetElementKey( ConfigurationElement element )
{
return ( (CustomTypeElement)element ).Type;
}
protected override void Init()
{
//
// Keep this list synchronized with SecurityTokenHandlerCollection.CreateDefaultSecurityTokenHandlerCollection
//
BaseAdd( new CustomTypeElement( typeof( SamlSecurityTokenHandler ) ) );
BaseAdd( new CustomTypeElement( typeof( Saml2SecurityTokenHandler ) ) );
BaseAdd( new CustomTypeElement( typeof( WindowsUserNameSecurityTokenHandler ) ) );
BaseAdd( new CustomTypeElement( typeof( X509SecurityTokenHandler ) ) );
BaseAdd( new CustomTypeElement( typeof( KerberosSecurityTokenHandler ) ) );
BaseAdd( new CustomTypeElement( typeof( RsaSecurityTokenHandler ) ) );
BaseAdd( new CustomTypeElement( typeof( SessionSecurityTokenHandler ) ) );
BaseAdd( new CustomTypeElement( typeof( EncryptedSecurityTokenHandler ) ) );
}
[ConfigurationProperty( ConfigurationStrings.Name, Options = ConfigurationPropertyOptions.IsKey )]
[StringValidator(MinLength = 0)]
public string Name
{
get { return (string)this[ConfigurationStrings.Name]; }
set { this[ConfigurationStrings.Name] = value; }
}
[ConfigurationProperty( ConfigurationStrings.SecurityTokenHandlerConfiguration, IsRequired = false )]
public SecurityTokenHandlerConfigurationElement SecurityTokenHandlerConfiguration
{
get { return (SecurityTokenHandlerConfigurationElement)this[ConfigurationStrings.SecurityTokenHandlerConfiguration]; }
set { this[ConfigurationStrings.SecurityTokenHandlerConfiguration] = value; }
}
/// <summary>
/// Returns a value indicating whether this element has been configured with non-default values.
/// </summary>
internal bool IsConfigured
{
get
{
return ( ( ElementInformation.Properties[ConfigurationStrings.Name].ValueOrigin != PropertyValueOrigin.Default ) ||
SecurityTokenHandlerConfiguration.IsConfigured ||
Count > 0 );
}
}
}
#pragma warning restore 1591
}

View File

@ -0,0 +1,64 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
using System.Configuration;
namespace System.IdentityModel.Configuration
{
#pragma warning disable 1591
/// <summary>
/// A collection of SecurityTokenHandlerElementCollection objects.
/// </summary>
[ConfigurationCollection( typeof( SecurityTokenHandlerElementCollection ), AddItemName = ConfigurationStrings.SecurityTokenHandlers, CollectionType = ConfigurationElementCollectionType.BasicMap )]
public sealed partial class SecurityTokenHandlerSetElementCollection : ConfigurationElementCollection
{
public SecurityTokenHandlerSetElementCollection()
{
}
protected override bool ThrowOnDuplicate
{
get
{
return true;
}
}
protected override ConfigurationElement CreateNewElement()
{
return new SecurityTokenHandlerElementCollection();
}
protected override object GetElementKey( ConfigurationElement element )
{
return ( (SecurityTokenHandlerElementCollection)element ).Name;
}
protected override void BaseAdd(ConfigurationElement element)
{
string name = GetElementKey(element) as string;
SecurityTokenHandlerElementCollection result = base.BaseGet(name) as SecurityTokenHandlerElementCollection;
if (result != null)
{
throw DiagnosticUtility.ThrowHelperInvalidOperation(SR.GetString(SR.ID7029, "<securityTokenHandlers>", name));
}
base.BaseAdd(element);
}
/// <summary>
/// Returns a value indicating whether this element has been configured with non-default values.
/// </summary>
public bool IsConfigured
{
get
{
return ( Count > 0 );
}
}
}
#pragma warning restore 1591
}

View File

@ -0,0 +1,441 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
using System;
using System.Collections.ObjectModel;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using SecurityTokenTypes = System.IdentityModel.Tokens.SecurityTokenTypes;
using STS = System.IdentityModel.SecurityTokenService;
using System.Security.Cryptography.X509Certificates;
using System.IdentityModel.Protocols.WSTrust;
namespace System.IdentityModel.Configuration
{
/// <summary>
/// Defines the configuration specific to a SecurityTokenService.
/// </summary>
public class SecurityTokenServiceConfiguration : IdentityConfiguration
{
string _tokenIssuerName;
SigningCredentials _signingCredentials;
TimeSpan _defaultTokenLifetime = TimeSpan.FromHours(1.0);
TimeSpan _maximumTokenLifetime = TimeSpan.FromDays(1);
string _defaultTokenType = SecurityTokenTypes.SamlTokenProfile11;
internal const int DefaultKeySizeInBitsConstant = 256;
int _defaultSymmetricKeySizeInBits = DefaultKeySizeInBitsConstant;
int _defaultMaxSymmetricKeySizeInBits = 1024;
bool _disableWsdl;
Type _securityTokenServiceType;
//
// Trust Serializers.
//
WSTrust13RequestSerializer _wsTrust13RequestSerializer = new WSTrust13RequestSerializer();
WSTrust13ResponseSerializer _wsTrust13ResponseSerializer = new WSTrust13ResponseSerializer();
WSTrustFeb2005RequestSerializer _wsTrustFeb2005RequestSerializer = new WSTrustFeb2005RequestSerializer();
WSTrustFeb2005ResponseSerializer _wsTrustFeb2005ResponseSerializer = new WSTrustFeb2005ResponseSerializer();
/// <summary>
/// Initializes an instance of <see cref="SecurityTokenServiceConfiguration"/>
/// </summary>
/// <remarks>
/// IssuerName must be set before the <see cref="SecurityTokenService"/> is used to create a token.
/// </remarks>
public SecurityTokenServiceConfiguration()
: this(null, null)
{
}
/// <summary>
/// Initializes an instance of <see cref="SecurityTokenServiceConfiguration"/>
/// </summary>
/// <param name="loadConfig">Whether or not config should be loaded.</param>
/// <remarks>
/// IssuerName must be set before the <see cref="SecurityTokenService"/> is used to create a token.
/// </remarks>
public SecurityTokenServiceConfiguration(bool loadConfig)
: this(null, null, loadConfig)
{
}
/// <summary>
/// Initializes an instance of <see cref="SecurityTokenServiceConfiguration"/>
/// </summary>
/// <param name="issuerName">The issuer name.</param>
/// <remarks>
/// If issuerName is null, IssuerName must be set before the <see cref="SecurityTokenService"/>
/// is used to create a token.
/// </remarks>
public SecurityTokenServiceConfiguration(string issuerName)
: this(issuerName, null)
{
}
/// <summary>
/// Initializes an instance of <see cref="SecurityTokenServiceConfiguration"/>
/// </summary>
/// <param name="issuerName">The issuer name.</param>
/// <param name="loadConfig">Whether or not config should be loaded.</param>
/// <remarks>
/// If issuerName is null, IssuerName must be set before the <see cref="SecurityTokenService"/>
/// is used to create a token.
/// </remarks>
public SecurityTokenServiceConfiguration(string issuerName, bool loadConfig)
: this(issuerName, null, loadConfig)
{
}
/// <summary>
/// Initializes an instance of <see cref="SecurityTokenServiceConfiguration"/>
/// </summary>
/// <param name="issuerName">The issuer name.</param>
/// <param name="signingCredentials">The signing credential for the STS.</param>
/// <remarks>
/// If issuerName is null, IssuerName must be set before the <see cref="SecurityTokenService"/>
/// is used to create a token.
/// </remarks>
public SecurityTokenServiceConfiguration(string issuerName, SigningCredentials signingCredentials)
: base()
{
_tokenIssuerName = issuerName;
_signingCredentials = signingCredentials;
}
/// <summary>
/// Initializes an instance of <see cref="SecurityTokenServiceConfiguration"/>
/// </summary>
/// <param name="issuerName">The issuer name.</param>
/// <param name="signingCredentials">The signing credential for the STS.</param>
/// <param name="loadConfig">Whether or not config should be loaded.</param>
/// <remarks>
/// If issuerName is null, IssuerName must be set before the <see cref="SecurityTokenService"/>
/// is used to create a token.
/// </remarks>
public SecurityTokenServiceConfiguration(string issuerName, SigningCredentials signingCredentials, bool loadConfig)
: base(loadConfig)
{
_tokenIssuerName = issuerName;
_signingCredentials = signingCredentials;
}
/// <summary>
/// Initializes an instance of <see cref="SecurityTokenServiceConfiguration"/>
/// </summary>
/// <param name="issuerName">The issuer name.</param>
/// <param name="signingCredentials">The signing credential for the STS.</param>
/// <param name="serviceName">The name of the &lt;service> element from which configuration is to be loaded.</param>
/// <remarks>
/// If issuerName is null, IssuerName must be set before the <see cref="SecurityTokenService"/>
/// is used to create a token.
/// </remarks>
public SecurityTokenServiceConfiguration(string issuerName, SigningCredentials signingCredentials, string serviceName)
: base(serviceName)
{
_tokenIssuerName = issuerName;
_signingCredentials = signingCredentials;
}
/// <summary>
/// Gets or sets the type of the SecurityTokenService.
/// </summary>
/// <exception cref="ArgumentNullException">The provided value is null.</exception>
public Type SecurityTokenService
{
get
{
return _securityTokenServiceType;
}
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
if (!typeof(System.IdentityModel.SecurityTokenService).IsAssignableFrom(value))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("value", SR.GetString(SR.ID2069));
}
_securityTokenServiceType = value;
}
}
/// <summary>
/// Creates an instance of SecurityTokenService from the type specified in
/// SecurityTokenServiceConfiguration.SecurityTokenService. The method
/// expects the type to implement a constructor that takes in the SecurityTokenServiceConfiguration.
/// </summary>
/// <returns>Instance of SecurityTokenService.</returns>
/// <exception cref="InvalidOperationException">Unable to create a SecurityTokenService instance from the configuration.</exception>
public virtual STS CreateSecurityTokenService()
{
Type stsType = this.SecurityTokenService;
if (stsType == null)
{
throw DiagnosticUtility.ThrowHelperInvalidOperation(SR.GetString(SR.ID2073));
}
if (!typeof(STS).IsAssignableFrom(stsType))
{
throw DiagnosticUtility.ThrowHelperInvalidOperation(SR.GetString(SR.ID2074, stsType, typeof(STS)));
}
return Activator.CreateInstance(stsType, this) as STS;
}
/// <summary>
/// Gets or sets the default key size in bits used in the issued token.
/// </summary>
/// <remarks>
/// This only applies to the symmetric key case.
/// </remarks>
public int DefaultSymmetricKeySizeInBits
{
get
{
return _defaultSymmetricKeySizeInBits;
}
set
{
if (value <= 0)
{
throw DiagnosticUtility.ThrowHelperArgumentOutOfRange("value", SR.GetString(SR.ID0002));
}
_defaultSymmetricKeySizeInBits = value;
}
}
/// <summary>
/// Gets or sets the default key size limit in bits used check if the KeySize specified in the request
/// is within this limit.
/// </summary>
/// <remarks>
/// This only applies to the symmetric key case.
/// </remarks>
public int DefaultMaxSymmetricKeySizeInBits
{
get
{
return _defaultMaxSymmetricKeySizeInBits;
}
set
{
if (value <= 0)
{
throw DiagnosticUtility.ThrowHelperArgumentOutOfRange("value", SR.GetString(SR.ID0002));
}
_defaultMaxSymmetricKeySizeInBits = value;
}
}
/// <summary>
/// Gets or sets the default lifetime used in the issued tokens.
/// </summary>
public TimeSpan DefaultTokenLifetime
{
get
{
return _defaultTokenLifetime;
}
set
{
_defaultTokenLifetime = value;
}
}
/// <summary>
/// Gets or sets the default token type used in token issuance.
/// </summary>
/// <exception cref="ArgumentNullException">The provided value is null or empty.</exception>
/// <exception cref="ArgumentException">The provided value is not defined in the token handlers.</exception>
public string DefaultTokenType
{
get
{
return _defaultTokenType;
}
set
{
if (string.IsNullOrEmpty(value))
{
throw DiagnosticUtility.ThrowHelperArgumentNullOrEmptyString("value");
}
if (SecurityTokenHandlers[value] == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("value", SR.GetString(SR.ID2015, value));
}
_defaultTokenType = value;
}
}
/// <summary>
/// Gets or Sets a boolean that specifies if WSDL generation for the
/// Service should be enabled. Default is false.
/// </summary>
public bool DisableWsdl
{
get
{
return _disableWsdl;
}
set
{
_disableWsdl = value;
}
}
/// <summary>
/// Gets or sets the maximum token lifetime for issued tokens.
/// </summary>
public TimeSpan MaximumTokenLifetime
{
get
{
return _maximumTokenLifetime;
}
set
{
if (value <= TimeSpan.Zero)
{
throw DiagnosticUtility.ThrowHelperArgumentOutOfRange("value", SR.GetString(SR.ID0016));
}
_maximumTokenLifetime = value;
}
}
/// <summary>
/// Gets or sets the signing credentials.
/// </summary>
public SigningCredentials SigningCredentials
{
get
{
return _signingCredentials;
}
set
{
_signingCredentials = value;
}
}
/// <summary>
/// Gets the issuer name so that it can be reflected in the issued token.
/// </summary>
/// <exception cref="ArgumentNullException">The value being set is null or empty string.</exception>
public string TokenIssuerName
{
get
{
return _tokenIssuerName;
}
set
{
if (string.IsNullOrEmpty(value))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
_tokenIssuerName = value;
}
}
/// <summary>
/// Gets or sets the WS-Trust 1.3 Request (RST) serializer.
/// </summary>
/// <exception cref="ArgumentNullException">The provided value is null.</exception>
public WSTrust13RequestSerializer WSTrust13RequestSerializer
{
get
{
return _wsTrust13RequestSerializer;
}
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
_wsTrust13RequestSerializer = value;
}
}
/// <summary>
/// Gets or sets the WS-Trust 1.3 Response (RSTR) serializer.
/// </summary>
/// <exception cref="ArgumentNullException">The provided value is null.</exception>
public WSTrust13ResponseSerializer WSTrust13ResponseSerializer
{
get
{
return _wsTrust13ResponseSerializer;
}
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
_wsTrust13ResponseSerializer = value;
}
}
/// <summary>
/// Gets or sets the WS-Trust Feb 2005 Request (RST) serializer.
/// </summary>
/// <exception cref="ArgumentNullException">The provided value is null.</exception>
public WSTrustFeb2005RequestSerializer WSTrustFeb2005RequestSerializer
{
get
{
return _wsTrustFeb2005RequestSerializer;
}
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
_wsTrustFeb2005RequestSerializer = value;
}
}
/// <summary>
/// Gets or sets the WS-Trust Feb 2005 Response (RSTR) serializer.
/// </summary>
/// <exception cref="ArgumentNullException">The provided value is null.</exception>
public WSTrustFeb2005ResponseSerializer WSTrustFeb2005ResponseSerializer
{
get
{
return _wsTrustFeb2005ResponseSerializer;
}
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
_wsTrustFeb2005ResponseSerializer = value;
}
}
}
}

View File

@ -0,0 +1,33 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.IdentityModel.Configuration
{
using System;
using System.ComponentModel;
using System.Configuration;
internal class StandardRuntimeEnumValidator : ConfigurationValidatorBase
{
Type enumType;
public StandardRuntimeEnumValidator(Type enumType)
{
this.enumType = enumType;
}
public override bool CanValidate(Type type)
{
return (type.IsEnum);
}
public override void Validate(object value)
{
if (!Enum.IsDefined(enumType, value))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("value", (int)value, enumType));
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More