summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OAuth2.AuthorizationServer/Configuration/OAuth2AuthorizationServerSection.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-04-18 21:21:34 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2012-04-18 21:21:34 -0700
commit548147a67be56f046a7d4515d61a8210d78677de (patch)
tree95ad7e72f40c60637569b30f292cd5ad9f583737 /src/DotNetOpenAuth.OAuth2.AuthorizationServer/Configuration/OAuth2AuthorizationServerSection.cs
parent1cefb24fd021a0292c13d6bfd61bd81543d4dfce (diff)
downloadDotNetOpenAuth-548147a67be56f046a7d4515d61a8210d78677de.zip
DotNetOpenAuth-548147a67be56f046a7d4515d61a8210d78677de.tar.gz
DotNetOpenAuth-548147a67be56f046a7d4515d61a8210d78677de.tar.bz2
Fixed up the configuration story for OAuth 2.
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2.AuthorizationServer/Configuration/OAuth2AuthorizationServerSection.cs')
-rw-r--r--src/DotNetOpenAuth.OAuth2.AuthorizationServer/Configuration/OAuth2AuthorizationServerSection.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/Configuration/OAuth2AuthorizationServerSection.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/Configuration/OAuth2AuthorizationServerSection.cs
new file mode 100644
index 0000000..6511a11
--- /dev/null
+++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/Configuration/OAuth2AuthorizationServerSection.cs
@@ -0,0 +1,70 @@
+//-----------------------------------------------------------------------
+// <copyright file="OAuth2AuthorizationServerSection.cs" company="Outercurve Foundation">
+// Copyright (c) Outercurve Foundation. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Configuration {
+ using System;
+ using System.Configuration;
+ using System.Diagnostics.Contracts;
+ using DotNetOpenAuth.Messaging.Bindings;
+ using DotNetOpenAuth.OAuth2.ChannelElements;
+
+ /// <summary>
+ /// Represents the &lt;oauth2/authorizationServer&gt; section in the host's .config file.
+ /// </summary>
+ internal class OAuth2AuthorizationServerSection : ConfigurationSection {
+ /// <summary>
+ /// The name of the oauth2/authorizationServer section.
+ /// </summary>
+ private const string SectionName = OAuth2SectionGroup.SectionName + "/authorizationServer";
+
+ /// <summary>
+ /// The name of the &lt;clientAuthenticationModules&gt; sub-element.
+ /// </summary>
+ private const string ClientAuthenticationModulesElementName = "clientAuthenticationModules";
+
+ /// <summary>
+ /// The built-in set of client authentication modules.
+ /// </summary>
+ private static readonly TypeConfigurationCollection<ClientAuthenticationModule> defaultClientAuthenticationModules =
+ new TypeConfigurationCollection<ClientAuthenticationModule>(new Type[] { typeof(ClientCredentialHttpBasicReader), typeof(ClientCredentialMessagePartReader) });
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="OAuth2AuthorizationServerSection"/> class.
+ /// </summary>
+ internal OAuth2AuthorizationServerSection() {
+ }
+
+ /// <summary>
+ /// Gets the configuration section from the .config file.
+ /// </summary>
+ internal static OAuth2AuthorizationServerSection Configuration {
+ get {
+ Contract.Ensures(Contract.Result<OAuth2AuthorizationServerSection>() != null);
+ return (OAuth2AuthorizationServerSection)ConfigurationManager.GetSection(SectionName) ?? new OAuth2AuthorizationServerSection();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the services to use for discovering service endpoints for identifiers.
+ /// </summary>
+ /// <remarks>
+ /// 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.
+ /// </remarks>
+ [ConfigurationProperty(ClientAuthenticationModulesElementName, IsDefaultCollection = false)]
+ [ConfigurationCollection(typeof(TypeConfigurationCollection<ClientAuthenticationModule>))]
+ internal TypeConfigurationCollection<ClientAuthenticationModule> ClientAuthenticationModules {
+ get {
+ var configResult = (TypeConfigurationCollection<ClientAuthenticationModule>)this[ClientAuthenticationModulesElementName];
+ return configResult != null && configResult.Count > 0 ? configResult : defaultClientAuthenticationModules;
+ }
+
+ set {
+ this[ClientAuthenticationModulesElementName] = value;
+ }
+ }
+ }
+}