diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2011-07-02 20:34:38 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2011-07-02 20:34:38 -0700 |
commit | 05f80cd62a2cab69598cebade7f906c31b7b2f7b (patch) | |
tree | a45d6c8e8043cf9b5e9341bc321af11a44ca50ca | |
parent | ac7b3b8bd58a220bb1d9e310456e75f601b99b58 (diff) | |
download | DotNetOpenAuth-05f80cd62a2cab69598cebade7f906c31b7b2f7b.zip DotNetOpenAuth-05f80cd62a2cab69598cebade7f906c31b7b2f7b.tar.gz DotNetOpenAuth-05f80cd62a2cab69598cebade7f906c31b7b2f7b.tar.bz2 |
OAuth project now builds.
8 files changed, 56 insertions, 18 deletions
diff --git a/src/DotNetOpenAuth.Messaging/Reporting.cs b/src/DotNetOpenAuth.Messaging/Reporting.cs index 65eddfe..fcd35c7 100644 --- a/src/DotNetOpenAuth.Messaging/Reporting.cs +++ b/src/DotNetOpenAuth.Messaging/Reporting.cs @@ -28,7 +28,7 @@ namespace DotNetOpenAuth { /// The statistical reporting mechanism used so this library's project authors /// know what versions and features are in use. /// </summary> - public static class Reporting { + public class Reporting { /// <summary> /// A UTF8 encoder that doesn't emit the preamble. Used for mid-stream writers. /// </summary> @@ -142,10 +142,14 @@ namespace DotNetOpenAuth { } } + internal static PersistentHashSet ObservedFeatures { + get { return observedFeatures; } + } + /// <summary> /// Gets the configuration to use for reporting. /// </summary> - private static ReportingElement Configuration { + internal static ReportingElement Configuration { get { return DotNetOpenAuthSection.Configuration.Reporting; } } @@ -482,7 +486,7 @@ namespace DotNetOpenAuth { /// Called by every internal/public method on this class to give /// periodic operations a chance to run. /// </summary> - private static void Touch() { + protected static void Touch() { // Publish stats if it's time to do so. lock (publishingConsiderationLock) { if (DateTime.Now - lastPublished > Configuration.MinimumReportingInterval) { @@ -596,7 +600,7 @@ namespace DotNetOpenAuth { /// <summary> /// A set of values that persist the set to disk. /// </summary> - private class PersistentHashSet : IDisposable { + internal class PersistentHashSet : IDisposable { /// <summary> /// The isolated persistent storage. /// </summary> diff --git a/src/DotNetOpenAuth.OAuth/Configuration/OAuthElement.cs b/src/DotNetOpenAuth.OAuth/Configuration/OAuthElement.cs index 282bdba..f425527 100644 --- a/src/DotNetOpenAuth.OAuth/Configuration/OAuthElement.cs +++ b/src/DotNetOpenAuth.OAuth/Configuration/OAuthElement.cs @@ -6,11 +6,17 @@ namespace DotNetOpenAuth.Configuration { using System.Configuration; + using System.Diagnostics.Contracts; /// <summary> /// Represents the <oauth> element in the host's .config file. /// </summary> - internal class OAuthElement : ConfigurationElement { + internal class OAuthElement : ConfigurationSection { + /// <summary> + /// The name of the oauth section. + /// </summary> + private const string SectionName = "oauth"; + /// <summary> /// The name of the <consumer> sub-element. /// </summary> @@ -28,6 +34,16 @@ namespace DotNetOpenAuth.Configuration { } /// <summary> + /// Gets the configuration section from the .config file. + /// </summary> + public static OAuthElement Configuration { + get { + Contract.Ensures(Contract.Result<OAuthElement>() != null); + return (OAuthElement)ConfigurationManager.GetSection(SectionName) ?? new OAuthElement(); + } + } + + /// <summary> /// Gets or sets the configuration specific for Consumers. /// </summary> [ConfigurationProperty(ConsumerElementName)] diff --git a/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj b/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj index 02e1e7b..e1a07b6 100644 --- a/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj +++ b/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj @@ -375,7 +375,16 @@ http://opensource.org/licenses/ms-pl.html <SignDependsOn Include="BuildUnifiedProduct" /> <DelaySignedAssemblies Include="$(ILMergeOutputAssembly);
 $(OutputPath)CodeContracts\$(ProductName).Contracts.dll;
 " /> </ItemGroup> - <ItemGroup /> + <ItemGroup> + <ProjectReference Include="..\DotNetOpenAuth.Messaging\DotNetOpenAuth.Messaging.csproj"> + <Project>{60426312-6AE5-4835-8667-37EDEA670222}</Project> + <Name>DotNetOpenAuth.Messaging</Name> + </ProjectReference> + <ProjectReference Include="..\DotNetOpenAuth.OpenId\DotNetOpenAuth.OpenId.csproj"> + <Project>{3896A32A-E876-4C23-B9B8-78E17D134CD3}</Project> + <Name>DotNetOpenAuth.OpenId</Name> + </ProjectReference> + </ItemGroup> <PropertyGroup> <!-- Don't sign the non-unified version of the assembly. --> <SuppressTargetPathDelaySignedAssembly>true</SuppressTargetPathDelaySignedAssembly> diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs index 31b5149..24382fe 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs @@ -154,7 +154,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { Contract.Requires<ArgumentNullException>(message != null); Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(message.HttpMethod)); Contract.Requires<ArgumentNullException>(messageDictionary != null); - Contract.Requires<ArgumentException>(messageDictionary.Message == message); + ErrorUtilities.VerifyArgument(messageDictionary.Message == message, "Message references are not equal."); List<string> signatureBaseStringElements = new List<string>(3); diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ConsumerBase.cs b/src/DotNetOpenAuth.OAuth/OAuth/ConsumerBase.cs index d9fa889..c02ca79 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ConsumerBase.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ConsumerBase.cs @@ -32,11 +32,11 @@ namespace DotNetOpenAuth.OAuth { ITamperProtectionChannelBindingElement signingElement = serviceDescription.CreateTamperProtectionElement(); INonceStore store = new NonceMemoryStore(StandardExpirationBindingElement.MaximumMessageAge); - this.SecuritySettings = DotNetOpenAuthSection.Configuration.OAuth.Consumer.SecuritySettings.CreateSecuritySettings(); + this.SecuritySettings = OAuthElement.Configuration.Consumer.SecuritySettings.CreateSecuritySettings(); this.OAuthChannel = new OAuthChannel(signingElement, store, tokenManager, this.SecuritySettings); this.ServiceProvider = serviceDescription; - Reporting.RecordFeatureAndDependencyUse(this, serviceDescription, tokenManager, null); + OAuthReporting.RecordFeatureAndDependencyUse(this, serviceDescription, tokenManager, null); } /// <summary> diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ServiceProvider.cs b/src/DotNetOpenAuth.OAuth/OAuth/ServiceProvider.cs index ec9206e..78857c1 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ServiceProvider.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ServiceProvider.cs @@ -68,7 +68,7 @@ namespace DotNetOpenAuth.OAuth { /// <param name="tokenManager">The host's method of storing and recalling tokens and secrets.</param> /// <param name="messageTypeProvider">An object that can figure out what type of message is being received for deserialization.</param> public ServiceProvider(ServiceProviderDescription serviceDescription, IServiceProviderTokenManager tokenManager, OAuthServiceProviderMessageFactory messageTypeProvider) - : this(serviceDescription, tokenManager, DotNetOpenAuthSection.Configuration.OAuth.ServiceProvider.ApplicationStore.CreateInstance(HttpApplicationStore), messageTypeProvider) { + : this(serviceDescription, tokenManager, OAuthElement.Configuration.ServiceProvider.ApplicationStore.CreateInstance(HttpApplicationStore), messageTypeProvider) { Contract.Requires<ArgumentNullException>(serviceDescription != null); Contract.Requires<ArgumentNullException>(tokenManager != null); Contract.Requires<ArgumentNullException>(messageTypeProvider != null); @@ -99,11 +99,11 @@ namespace DotNetOpenAuth.OAuth { var signingElement = serviceDescription.CreateTamperProtectionElement(); this.ServiceDescription = serviceDescription; - this.SecuritySettings = DotNetOpenAuthSection.Configuration.OAuth.ServiceProvider.SecuritySettings.CreateSecuritySettings(); + this.SecuritySettings = OAuthElement.Configuration.ServiceProvider.SecuritySettings.CreateSecuritySettings(); this.OAuthChannel = new OAuthChannel(signingElement, nonceStore, tokenManager, this.SecuritySettings, messageTypeProvider); this.TokenGenerator = new StandardTokenGenerator(); - Reporting.RecordFeatureAndDependencyUse(this, serviceDescription, tokenManager, nonceStore); + OAuthReporting.RecordFeatureAndDependencyUse(this, serviceDescription, tokenManager, nonceStore); } /// <summary> diff --git a/src/DotNetOpenAuth.OAuth/OAuthReporting.cs b/src/DotNetOpenAuth.OAuth/OAuthReporting.cs index ba4e9a1..062f9dc 100644 --- a/src/DotNetOpenAuth.OAuth/OAuthReporting.cs +++ b/src/DotNetOpenAuth.OAuth/OAuthReporting.cs @@ -1,13 +1,20 @@ -namespace DotNetOpenAuth { +//----------------------------------------------------------------------- +// <copyright file="OAuthReporting.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth { using System; using System.Collections.Generic; + using System.Diagnostics.Contracts; using System.Linq; using System.Text; - using System.Diagnostics.Contracts; + using DotNetOpenAuth.Messaging.Bindings; using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.ChannelElements; - internal static class OAuthReporting { + internal class OAuthReporting : Reporting { /// <summary> /// Records the feature and dependency use. /// </summary> @@ -25,7 +32,7 @@ return; } - if (Enabled && Configuration.IncludeFeatureUsage) { + if (Reporting.Enabled && Reporting.Configuration.IncludeFeatureUsage) { StringBuilder builder = new StringBuilder(); builder.Append(value.GetType().Name); builder.Append(" "); @@ -38,8 +45,8 @@ builder.Append(service.Version); builder.Append(" "); builder.Append(service.UserAuthorizationEndpoint); - observedFeatures.Add(builder.ToString()); - Touch(); + Reporting.ObservedFeatures.Add(builder.ToString()); + Reporting.Touch(); } } } diff --git a/src/DotNetOpenAuth.OpenId/Properties/AssemblyInfo.cs b/src/DotNetOpenAuth.OpenId/Properties/AssemblyInfo.cs index b7b5a45..2fe391c 100644 --- a/src/DotNetOpenAuth.OpenId/Properties/AssemblyInfo.cs +++ b/src/DotNetOpenAuth.OpenId/Properties/AssemblyInfo.cs @@ -51,6 +51,8 @@ using System.Web.UI; [assembly: AllowPartiallyTrustedCallers] [assembly: InternalsVisibleTo("DotNetOpenAuth.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100AD093C3765257C89A7010E853F2C7C741FF92FA8ACE06D7B8254702CAD5CF99104447F63AB05F8BB6F51CE0D81C8C93D2FCE8C20AAFF7042E721CBA16EAAE98778611DED11C0ABC8900DC5667F99B50A9DADEC24DBD8F2C91E3E8AD300EF64F1B4B9536CEB16FB440AF939F57624A9B486F867807C649AE4830EAB88C6C03998")] +[assembly: InternalsVisibleTo("DotNetOpenAuth.OAuth, PublicKey=0024000004800000940000000602000000240000525341310004000001000100AD093C3765257C89A7010E853F2C7C741FF92FA8ACE06D7B8254702CAD5CF99104447F63AB05F8BB6F51CE0D81C8C93D2FCE8C20AAFF7042E721CBA16EAAE98778611DED11C0ABC8900DC5667F99B50A9DADEC24DBD8F2C91E3E8AD300EF64F1B4B9536CEB16FB440AF939F57624A9B486F867807C649AE4830EAB88C6C03998")] #else [assembly: InternalsVisibleTo("DotNetOpenAuth.Test")] +[assembly: InternalsVisibleTo("DotNetOpenAuth.OAuth")] #endif |