//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.Configuration { using System.Configuration; using System.Diagnostics.Contracts; /// /// Represents the <oauth> element in the host's .config file. /// internal class OAuth2Element : ConfigurationSection { /// /// The name of the oauth section. /// private const string SectionName = DotNetOpenAuthSection.SectionName + "/oauth2"; /// /// The name of the <client> sub-element. /// private const string ClientElementName = "client"; /// /// The name of the <authorizationServer> sub-element. /// private const string AuthorizationServerElementName = "authorizationServer"; /// /// The name of the <resourceServer> sub-element. /// private const string ResourceServerElementName = "resourceServer"; /// /// Initializes a new instance of the class. /// internal OAuth2Element() { } /// /// Gets the configuration section from the .config file. /// public static OAuth2Element Configuration { get { Contract.Ensures(Contract.Result() != null); return (OAuth2Element)ConfigurationManager.GetSection(SectionName) ?? new OAuth2Element(); } } /// /// Gets or sets the configuration specific for Clients. /// [ConfigurationProperty(ClientElementName)] internal OAuth2ClientElement Client { get { return (OAuth2ClientElement)this[ClientElementName] ?? new OAuth2ClientElement(); } set { this[ClientElementName] = value; } } /// /// Gets or sets the configuration specific for Authorization Servers. /// [ConfigurationProperty(AuthorizationServerElementName)] internal OAuth2AuthorizationServerElement AuthorizationServer { get { return (OAuth2AuthorizationServerElement)this[AuthorizationServerElementName] ?? new OAuth2AuthorizationServerElement(); } set { this[AuthorizationServerElementName] = value; } } /// /// Gets or sets the configuration specific for Resource Servers. /// [ConfigurationProperty(ResourceServerElementName)] internal OAuth2ResourceServerElement ResourceServer { get { return (OAuth2ResourceServerElement)this[ResourceServerElementName] ?? new OAuth2ResourceServerElement(); } set { this[ResourceServerElementName] = value; } } } }