//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.Configuration { using System; using System.Configuration; using DotNetOpenAuth.Messaging.Bindings; using DotNetOpenAuth.OAuth2.ChannelElements; /// /// Represents the <oauth2/authorizationServer> section in the host's .config file. /// internal class OAuth2AuthorizationServerSection : ConfigurationSection { /// /// The name of the oauth2/authorizationServer section. /// private const string SectionName = OAuth2SectionGroup.SectionName + "/authorizationServer"; /// /// The name of the <clientAuthenticationModules> sub-element. /// private const string ClientAuthenticationModulesElementName = "clientAuthenticationModules"; /// /// The built-in set of client authentication modules. /// private static readonly TypeConfigurationCollection defaultClientAuthenticationModules = new TypeConfigurationCollection(new Type[] { typeof(ClientCredentialHttpBasicReader), typeof(ClientCredentialMessagePartReader) }); /// /// Initializes a new instance of the class. /// internal OAuth2AuthorizationServerSection() { } /// /// Gets the configuration section from the .config file. /// internal static OAuth2AuthorizationServerSection Configuration { get { return (OAuth2AuthorizationServerSection)ConfigurationManager.GetSection(SectionName) ?? new OAuth2AuthorizationServerSection(); } } /// /// Gets or sets the services to use for discovering service endpoints for identifiers. /// /// /// If no discovery services are defined in the (web) application's .config file, /// the default set of discovery services built into the library are used. /// [ConfigurationProperty(ClientAuthenticationModulesElementName, IsDefaultCollection = false)] [ConfigurationCollection(typeof(TypeConfigurationCollection))] internal TypeConfigurationCollection ClientAuthenticationModules { get { var configResult = (TypeConfigurationCollection)this[ClientAuthenticationModulesElementName]; return configResult != null && configResult.Count > 0 ? configResult : defaultClientAuthenticationModules; } set { this[ClientAuthenticationModulesElementName] = value; } } } }