diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-09 20:56:19 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-09 20:56:19 -0700 |
commit | 21145c4c7cc2c2a8daa36862b555766a6306c552 (patch) | |
tree | 7c417a24022479f2219dfb48fb011a6124ed58cc /src | |
parent | 07047811a7dfd1218de8f20393a282391e2f35cc (diff) | |
parent | 9938982dc1ae0c2125291667262b713550a0cf8c (diff) | |
download | DotNetOpenAuth-21145c4c7cc2c2a8daa36862b555766a6306c552.zip DotNetOpenAuth-21145c4c7cc2c2a8daa36862b555766a6306c552.tar.gz DotNetOpenAuth-21145c4c7cc2c2a8daa36862b555766a6306c552.tar.bz2 |
Merge branch 'v3.4' into oauth2
Conflicts:
samples/OAuthConsumer/Web.config
src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd
src/DotNetOpenAuth/DotNetOpenAuth.csproj
Diffstat (limited to 'src')
55 files changed, 663 insertions, 172 deletions
diff --git a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj index 365bec5..7993ed5 100644 --- a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj +++ b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj @@ -27,6 +27,7 @@ <IsWebBootstrapper>false</IsWebBootstrapper> <UseApplicationTrust>false</UseApplicationTrust> <BootstrapperEnabled>true</BootstrapperEnabled> + <CodeContractsAssemblyMode>1</CodeContractsAssemblyMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -64,6 +65,7 @@ <CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel> <CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + <CodeContractsExtraRewriteOptions /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -119,6 +121,7 @@ <Compile Include="NativeMethods.cs" /> <Compile Include="ParseMaster.cs" /> <Compile Include="PathSegment.cs" /> + <Compile Include="PrepareOhlohRelease.cs" /> <Compile Include="Publicize.cs" /> <Compile Include="Purge.cs" /> <Compile Include="ReSignDelaySignedAssemblies.cs" /> diff --git a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln index f3e3982..dbc8e60 100644 --- a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln +++ b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln @@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\..\tools\DotNetOpenAuth.targets = ..\..\tools\DotNetOpenAuth.targets ..\..\tools\DotNetOpenAuth.Versioning.targets = ..\..\tools\DotNetOpenAuth.Versioning.targets ..\..\tools\drop.proj = ..\..\tools\drop.proj + ..\..\tools\ohloh.proj = ..\..\tools\ohloh.proj ..\..\projecttemplates\projecttemplates.proj = ..\..\projecttemplates\projecttemplates.proj ..\..\samples\Samples.proj = ..\..\samples\Samples.proj ..\..\samples\tools.proj = ..\..\samples\tools.proj diff --git a/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs b/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs index 1d60ca4..dfb3468 100644 --- a/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs +++ b/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs @@ -10,6 +10,11 @@ using Microsoft.Build.Utilities; namespace DotNetOpenAuth.BuildTasks { public class GetBuildVersion : Task { + /// <summary> + /// Initializes a new instance of the <see cref="GetBuildVersion"/> class. + /// </summary> + public GetBuildVersion() { + } /// <summary> /// Gets the version string to use in the compiled assemblies. @@ -18,6 +23,12 @@ namespace DotNetOpenAuth.BuildTasks { public string Version { get; private set; } /// <summary> + /// Gets the version string to use in the official release name (lacks revision number). + /// </summary> + [Output] + public string SimpleVersion { get; private set; } + + /// <summary> /// Gets the Git revision control commit id for HEAD (the current source code version). /// </summary> [Output] @@ -37,9 +48,11 @@ namespace DotNetOpenAuth.BuildTasks { public override bool Execute() { try { Version typedVersion = ReadVersionFromFile(); - typedVersion = new Version(typedVersion.Major, typedVersion.Minor, typedVersion.Build, CalculateJDate(DateTime.Now)); - Version = typedVersion.ToString(); + SimpleVersion = typedVersion.ToString(); + var fullVersion = new Version(typedVersion.Major, typedVersion.Minor, typedVersion.Build, CalculateJDate(DateTime.Now)); + Version = fullVersion.ToString(); + this.GitCommitId = GetGitHeadCommitId(); } catch (ArgumentOutOfRangeException ex) { Log.LogErrorFromException(ex); diff --git a/src/DotNetOpenAuth.BuildTasks/HardLinkCopy.cs b/src/DotNetOpenAuth.BuildTasks/HardLinkCopy.cs index af2d1d0..fa7ca06 100644 --- a/src/DotNetOpenAuth.BuildTasks/HardLinkCopy.cs +++ b/src/DotNetOpenAuth.BuildTasks/HardLinkCopy.cs @@ -7,11 +7,11 @@ namespace DotNetOpenAuth.BuildTasks { using System; using System.Collections.Generic; + using System.IO; using System.Linq; using System.Text; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; - using System.IO; public class HardLinkCopy : Task { [Required] diff --git a/src/DotNetOpenAuth.BuildTasks/PathSegment.cs b/src/DotNetOpenAuth.BuildTasks/PathSegment.cs index 56655ff..1f17b5e 100644 --- a/src/DotNetOpenAuth.BuildTasks/PathSegment.cs +++ b/src/DotNetOpenAuth.BuildTasks/PathSegment.cs @@ -16,7 +16,6 @@ namespace DotNetOpenAuth.BuildTasks { internal class PathSegment { private const float ParentChildResizeThreshold = 0.30f; - private readonly PathSegment parent; private readonly string originalName; private string currentName; private bool minimized; @@ -34,14 +33,16 @@ namespace DotNetOpenAuth.BuildTasks { Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(originalName)); Contract.Requires<ArgumentNullException>(parent != null); this.currentName = this.originalName = originalName; - this.parent = parent; + this.Parent = parent; this.minimized = false; } + internal PathSegment Parent { get; private set; } + internal string OriginalPath { get { - if (this.parent != null) { - return Path.Combine(this.parent.OriginalPath, this.originalName); + if (this.Parent != null) { + return Path.Combine(this.Parent.OriginalPath, this.originalName); } else { return this.originalName; } @@ -50,8 +51,8 @@ namespace DotNetOpenAuth.BuildTasks { internal string CurrentPath { get { - if (this.parent != null) { - return Path.Combine(this.parent.CurrentPath, this.currentName); + if (this.Parent != null) { + return Path.Combine(this.Parent.CurrentPath, this.currentName); } else { return this.currentName; } @@ -68,15 +69,15 @@ namespace DotNetOpenAuth.BuildTasks { private int SegmentCount { get { - int parents = this.parent != null ? this.parent.SegmentCount : 0; + int parents = this.Parent != null ? this.Parent.SegmentCount : 0; return parents + 1; } } internal int FullLength { get { - if (this.parent != null) { - int parentLength = this.parent.FullLength; + if (this.Parent != null) { + int parentLength = this.Parent.FullLength; if (parentLength > 0) { parentLength++; // allow for an in between slash } @@ -108,10 +109,10 @@ namespace DotNetOpenAuth.BuildTasks { internal IEnumerable<PathSegment> Ancestors { get { - PathSegment parent = this.parent; + PathSegment parent = this.Parent; while (parent != null) { yield return parent; - parent = parent.parent; + parent = parent.Parent; } } } @@ -143,7 +144,7 @@ namespace DotNetOpenAuth.BuildTasks { } internal IEnumerable<PathSegment> Siblings { - get { return this.parent != null ? this.parent.Children : Enumerable.Empty<PathSegment>(); } + get { return this.Parent != null ? this.Parent.Children : Enumerable.Empty<PathSegment>(); } } internal Collection<PathSegment> Children { get; private set; } @@ -160,8 +161,8 @@ namespace DotNetOpenAuth.BuildTasks { path += "\\"; } - if (this.parent != null) { - path = parent.ToString() + path; + if (this.Parent != null) { + path = Parent.ToString() + path; } return path; @@ -182,7 +183,7 @@ namespace DotNetOpenAuth.BuildTasks { internal int EnsureSelfAndChildrenNoLongerThan(int maxLength) { Contract.Requires<ArgumentOutOfRangeException>(maxLength > 0, "A path can only have a positive length."); - Contract.Requires<ArgumentOutOfRangeException>(this.parent == null || maxLength > this.parent.FullLength + 1, "A child path cannot possibly be made shorter than its parent."); + Contract.Requires<ArgumentOutOfRangeException>(this.Parent == null || maxLength > this.Parent.FullLength + 1, "A child path cannot possibly be made shorter than its parent."); Contract.Ensures(Contract.Result<int>() <= maxLength); const int uniqueBase = 16; diff --git a/src/DotNetOpenAuth.BuildTasks/PrepareOhlohRelease.cs b/src/DotNetOpenAuth.BuildTasks/PrepareOhlohRelease.cs new file mode 100644 index 0000000..fe13824 --- /dev/null +++ b/src/DotNetOpenAuth.BuildTasks/PrepareOhlohRelease.cs @@ -0,0 +1,138 @@ +//----------------------------------------------------------------------- +// <copyright file="PrepareOhlohRelease.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.BuildTasks { + using System; + using System.Collections.Generic; + using System.Globalization; + using System.IO; + using System.Linq; + using System.Text; + using System.Text.RegularExpressions; + using System.Xml; + using System.Xml.Linq; + using Microsoft.Build.Framework; + using Microsoft.Build.Utilities; + + /// <summary> + /// Creates an Ohloh.net upload instruct XLM file and bash script that uses it. + /// </summary> + public class PrepareOhlohRelease : Task { + /// <summary> + /// Initializes a new instance of the <see cref="PrepareOhlohUpload"/> class. + /// </summary> + public PrepareOhlohRelease() { + } + + [Required] + public string Release { get; set; } + + public string ReleaseNotes { get; set; } + + [Required] + public string InstructFile { get; set; } + + [Required] + public string UploadScript { get; set; } + + [Required] + public string OhlohUser { get; set; } + + [Required] + public string OhlohProject { get; set; } + + [Required] + public ITaskItem[] RedistributableFiles { get; set; } + + public override bool Execute() { + this.WriteInstructFile(); + this.WriteUploadScript(); + + return !this.Log.HasLoggedErrors; + } + + private void WriteInstructFile() { + var packages = from redist in this.RedistributableFiles + let file = new { Path = redist.ItemSpec, Package = redist.GetMetadata("Package"), Platform = redist.GetMetadata("Platform"), Icon = redist.GetMetadata("Icon") } + group file by file.Package into package + select new XElement( + "package", + new XAttribute("name", package.Key), + new XElement( + "releases", + new XElement( + "release", + new XAttribute("name", this.Release), + new XAttribute("date", XmlConvert.ToString(DateTime.Now)), + new XElement("notes", this.ReleaseNotes), + new XElement( + "files", + package.Select( + f => new XElement( + "file", + new XAttribute("name", Path.GetFileName(f.Path)), + new XAttribute("date", XmlConvert.ToString(DateTime.Now)), + new XAttribute("platform", f.Platform), + new XAttribute("icon", f.Icon) + ) + ) + ) + ) + ) + ); + + var instructXml = new XElement("packages", packages); + + var writerSettings = new XmlWriterSettings { + OmitXmlDeclaration = true, + Indent = true, + IndentChars = "\t", + }; + using (var writer = XmlWriter.Create(this.InstructFile, writerSettings)) { + instructXml.Save(writer); + } + + this.Log.LogMessage("Ohloh instruct file written to: \"{0}\"", this.InstructFile); + + } + + private void WriteUploadScript() { + int longestPath = Math.Max( + GetLinuxPath(Path.GetFullPath(this.InstructFile)).Length, + this.RedistributableFiles.Max(f => GetLinuxPath(f.GetMetadata("FullPath")).Length)); + + using (StreamWriter writer = new StreamWriter(this.UploadScript)) { + writer.WriteLine("#!/bin/bash"); + writer.WriteLine(); + foreach (var file in this.RedistributableFiles) { + writer.WriteLine("scp {0,-" + longestPath + "} {1}@upload.ohloh.net:{2}/files", GetLinuxPath(file.GetMetadata("FullPath")), this.OhlohUser, this.OhlohProject); + } + + writer.WriteLine(); + writer.WriteLine("scp {0,-" + longestPath + "} {1}@upload.ohloh.net:{2}/instructs", GetLinuxPath(Path.GetFullPath(this.InstructFile)), this.OhlohUser, this.OhlohProject); + writer.WriteLine(); + writer.WriteLine("# Download the instruct log by executing this command:"); + writer.WriteLine("# scp {0}@upload.ohloh.net:{1}/logs/upload.log .", this.OhlohUser, this.OhlohProject); + } + + this.Log.LogMessage("Ohloh upload script written to: \"{0}\".", this.UploadScript); + } + + private static string GetLinuxPath(string windowsPath) { + if (String.IsNullOrEmpty(windowsPath)) { + throw new ArgumentNullException("windowsPath"); + } + + string linuxPath = Regex.Replace( + windowsPath, + @"^([A-Za-z])\:", + m => "/" + m.Groups[1].Value) + .Replace('\\', '/') + .Replace(" ", "\\ "); + return linuxPath; + } + } +} diff --git a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj index b2c0dd3..596c499 100644 --- a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj +++ b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj @@ -4,6 +4,7 @@ <ProjectRoot Condition="'$(ProjectRoot)' == ''">$(MSBuildProjectDirectory)\..\..\</ProjectRoot> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <CodeContractsAssemblyMode>1</CodeContractsAssemblyMode> </PropertyGroup> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.props" /> <PropertyGroup> @@ -68,6 +69,10 @@ <CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure> <CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + <CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions> + <CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs> + <CodeContractsExtraRewriteOptions /> + <CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -101,6 +106,10 @@ <CodeContractsRunInBackground>True</CodeContractsRunInBackground> <CodeContractsShowSquigglies>False</CodeContractsShowSquigglies> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + <CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions> + <CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs> + <CodeContractsExtraRewriteOptions /> + <CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CodeAnalysis|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -136,6 +145,10 @@ <CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires> <CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + <CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions> + <CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs> + <CodeContractsExtraRewriteOptions /> + <CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly> </PropertyGroup> <ItemGroup> <Reference Include="log4net" /> @@ -307,7 +320,6 @@ <ProjectReference Include="..\DotNetOpenAuth\DotNetOpenAuth.csproj"> <Project>{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}</Project> <Name>DotNetOpenAuth</Name> - <Shadow>true</Shadow> </ProjectReference> </ItemGroup> <ItemGroup> diff --git a/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs b/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs index d22c2f7..5d31d40 100644 --- a/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs +++ b/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs @@ -254,8 +254,7 @@ namespace DotNetOpenAuth.Test.Messaging { new TestMessageFactory(), new MockSigningBindingElement(), new MockSigningBindingElement()); - Channel_Accessor accessor = Channel_Accessor.AttachShadow(channel); - accessor.ProcessOutgoingMessage(new TestSignedDirectedMessage()); + channel.ProcessOutgoingMessageTestHook(new TestSignedDirectedMessage()); } [TestCase] diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs index 0bb35bc..99520a2 100644 --- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs +++ b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs @@ -200,13 +200,11 @@ namespace DotNetOpenAuth.Test.Mocks { } protected override IDictionary<string, string> ReadFromResponseCore(IncomingWebResponse response) { - Channel_Accessor accessor = Channel_Accessor.AttachShadow(this.wrappedChannel); - return accessor.ReadFromResponseCore(response); + return this.wrappedChannel.ReadFromResponseCoreTestHook(response); } protected override void ProcessIncomingMessage(IProtocolMessage message) { - Channel_Accessor accessor = Channel_Accessor.AttachShadow(this.wrappedChannel); - accessor.ProcessIncomingMessage(message); + this.wrappedChannel.ProcessIncomingMessageTestHook(message); } /// <summary> @@ -254,8 +252,7 @@ namespace DotNetOpenAuth.Test.Mocks { private static IMessageFactory GetMessageFactory(Channel channel) { Contract.Requires<ArgumentNullException>(channel != null); - Channel_Accessor accessor = Channel_Accessor.AttachShadow(channel); - return accessor.MessageFactory; + return channel.MessageFactoryTestHook; } private IDictionary<string, string> AwaitIncomingMessage(out MessageReceivingEndpoint recipient) { diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs index 38088bd..e1ff959 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs @@ -16,9 +16,9 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { public void SignatureTest() { UnauthorizedTokenRequest message = SigningBindingElementBaseTests.CreateTestRequestTokenMessage(this.MessageDescriptions, null); - HmacSha1SigningBindingElement_Accessor hmac = new HmacSha1SigningBindingElement_Accessor(); + var hmac = new HmacSha1SigningBindingElement(); hmac.Channel = new TestChannel(this.MessageDescriptions); - Assert.AreEqual("kR0LhH8UqylaLfR/esXVVlP4sQI=", hmac.GetSignature(message)); + Assert.AreEqual("kR0LhH8UqylaLfR/esXVVlP4sQI=", hmac.GetSignatureTestHook(message)); } } } diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs index b7168a7..dd6738f 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs @@ -24,7 +24,6 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { [TestFixture] public class OAuthChannelTests : TestBase { private OAuthChannel channel; - private OAuthChannel_Accessor accessor; private TestWebRequestHandler webRequestHandler; private SigningBindingElementBase signingElement; private INonceStore nonceStore; @@ -37,7 +36,6 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { this.signingElement = new RsaSha1SigningBindingElement(new InMemoryTokenManager()); this.nonceStore = new NonceMemoryStore(StandardExpirationBindingElement.MaximumMessageAge); this.channel = new OAuthChannel(this.signingElement, this.nonceStore, new InMemoryTokenManager(), new TestMessageFactory()); - this.accessor = OAuthChannel_Accessor.AttachShadow(this.channel); this.channel.WebRequestHandler = this.webRequestHandler; } @@ -149,8 +147,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { writer.Write(MessagingUtilities.CreateQueryString(fields)); writer.Flush(); ms.Seek(0, SeekOrigin.Begin); - Channel_Accessor channelAccessor = Channel_Accessor.AttachShadow(this.channel); - IDictionary<string, string> deserializedFields = channelAccessor.ReadFromResponseCore(new CachedDirectWebResponse { CachedResponseStream = ms }); + IDictionary<string, string> deserializedFields = this.channel.ReadFromResponseCoreTestHook(new CachedDirectWebResponse { CachedResponseStream = ms }); Assert.AreEqual(fields.Count, deserializedFields.Count); foreach (string key in fields.Keys) { Assert.AreEqual(fields[key], deserializedFields[key]); @@ -238,13 +235,13 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { [TestCase] public void SendDirectMessageResponseHonorsHttpStatusCodes() { IProtocolMessage message = MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired); - OutgoingWebResponse directResponse = this.accessor.PrepareDirectResponse(message); + OutgoingWebResponse directResponse = this.channel.PrepareDirectResponseTestHook(message); Assert.AreEqual(HttpStatusCode.OK, directResponse.Status); var httpMessage = new TestDirectResponseMessageWithHttpStatus(); MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired, httpMessage); httpMessage.HttpStatusCode = HttpStatusCode.NotAcceptable; - directResponse = this.accessor.PrepareDirectResponse(httpMessage); + directResponse = this.channel.PrepareDirectResponseTestHook(httpMessage); Assert.AreEqual(HttpStatusCode.NotAcceptable, directResponse.Status); } diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs index 61e6b43..2ef7e9a 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs @@ -22,7 +22,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetRequestToken", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.GetRequest)); Assert.AreEqual( "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F", - SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message, MessageDictionary_Accessor.AttachShadow(this.MessageDescriptions.GetAccessor(message)))); + SigningBindingElementBase.ConstructSignatureBaseString(message, this.MessageDescriptions.GetAccessor(message))); // Test HTTP GET with an attached query string. We're elevating the scope parameter to the query string // and removing it from the extradata dictionary. This should NOT affect the base signature string. @@ -32,7 +32,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { message.ExtraData.Remove("scope"); // remove it from ExtraData since we put it in the URL Assert.AreEqual( "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F", - SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message, MessageDictionary_Accessor.AttachShadow(this.MessageDescriptions.GetAccessor(message)))); + SigningBindingElementBase.ConstructSignatureBaseString(message, this.MessageDescriptions.GetAccessor(message))); // Test HTTP POST, with query string as well message = CreateTestRequestTokenMessage( @@ -41,7 +41,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { message.ExtraData.Remove("scope"); // remove it from ExtraData since we put it in the URL Assert.AreEqual( "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F", - SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message, MessageDictionary_Accessor.AttachShadow(this.MessageDescriptions.GetAccessor(message)))); + SigningBindingElementBase.ConstructSignatureBaseString(message, this.MessageDescriptions.GetAccessor(message))); // Test HTTP POST, with query string, but not using the Authorization header message = CreateTestRequestTokenMessage( @@ -50,7 +50,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { message.ExtraData.Remove("scope"); // remove it from ExtraData since we put it in the URL Assert.AreEqual( "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F", - SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message, MessageDictionary_Accessor.AttachShadow(this.MessageDescriptions.GetAccessor(message)))); + SigningBindingElementBase.ConstructSignatureBaseString(message, this.MessageDescriptions.GetAccessor(message))); // This is a simulation of receiving the message, where the query string is still in the URL, // but has been read into ExtraData, so parameters in the query string appear twice. @@ -59,7 +59,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetRequestToken?scope=http://www.google.com/m8/feeds/", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.PostRequest)); Assert.AreEqual( "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F", - SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message, MessageDictionary_Accessor.AttachShadow(this.MessageDescriptions.GetAccessor(message)))); + SigningBindingElementBase.ConstructSignatureBaseString(message, this.MessageDescriptions.GetAccessor(message))); } internal static UnauthorizedTokenRequest CreateTestRequestTokenMessage(MessageDescriptionCollection messageDescriptions, MessageReceivingEndpoint endpoint) { diff --git a/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs b/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs index 8c2b5bd..390a5f1 100644 --- a/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/AssociationHandshakeTests.cs @@ -81,23 +81,21 @@ namespace DotNetOpenAuth.Test.OpenId { // Receive initial request for an HMAC-SHA256 association. AutoResponsiveRequest req = (AutoResponsiveRequest)op.GetRequest(); - AutoResponsiveRequest_Accessor reqAccessor = AutoResponsiveRequest_Accessor.AttachShadow(req); - AssociateRequest associateRequest = (AssociateRequest)reqAccessor.RequestMessage; + AssociateRequest associateRequest = (AssociateRequest)req.RequestMessage; Assert.AreEqual(protocol.Args.SignatureAlgorithm.HMAC_SHA256, associateRequest.AssociationType); // Ensure that the response is a suggestion that the RP try again with HMAC-SHA1 - AssociateUnsuccessfulResponse renegotiateResponse = (AssociateUnsuccessfulResponse)reqAccessor.ResponseMessage; + AssociateUnsuccessfulResponse renegotiateResponse = (AssociateUnsuccessfulResponse)req.ResponseMessageTestHook; Assert.AreEqual(protocol.Args.SignatureAlgorithm.HMAC_SHA1, renegotiateResponse.AssociationType); op.SendResponse(req); // Receive second attempt request for an HMAC-SHA1 association. req = (AutoResponsiveRequest)op.GetRequest(); - reqAccessor = AutoResponsiveRequest_Accessor.AttachShadow(req); - associateRequest = (AssociateRequest)reqAccessor.RequestMessage; + associateRequest = (AssociateRequest)req.RequestMessage; Assert.AreEqual(protocol.Args.SignatureAlgorithm.HMAC_SHA1, associateRequest.AssociationType); // Ensure that the response is a success response. - AssociateSuccessfulResponse successResponse = (AssociateSuccessfulResponse)reqAccessor.ResponseMessage; + AssociateSuccessfulResponse successResponse = (AssociateSuccessfulResponse)req.ResponseMessageTestHook; Assert.AreEqual(protocol.Args.SignatureAlgorithm.HMAC_SHA1, successResponse.AssociationType); op.SendResponse(req); }); @@ -352,11 +350,9 @@ namespace DotNetOpenAuth.Test.OpenId { }; coordinator.Run(); - var associationManagerAccessor = AssociationManager_Accessor.AttachShadow(coordinator.RelyingParty.AssociationManager); - if (expectSuccess) { Assert.IsNotNull(rpAssociation); - Assert.AreSame(rpAssociation, associationManagerAccessor.associationStore.GetAssociation(opDescription.Uri, rpAssociation.Handle)); + Assert.AreSame(rpAssociation, coordinator.RelyingParty.AssociationManager.AssociationStoreTestHook.GetAssociation(opDescription.Uri, rpAssociation.Handle)); opAssociation = coordinator.Provider.AssociationStore.GetAssociation(AssociationRelyingPartyType.Smart, rpAssociation.Handle); Assert.IsNotNull(opAssociation, "The Provider should have stored the association."); @@ -375,7 +371,7 @@ namespace DotNetOpenAuth.Test.OpenId { var unencryptedResponse = (AssociateUnencryptedResponse)associateSuccessfulResponse; } } else { - Assert.IsNull(associationManagerAccessor.associationStore.GetAssociation(opDescription.Uri, new RelyingPartySecuritySettings())); + Assert.IsNull(coordinator.RelyingParty.AssociationManager.AssociationStoreTestHook.GetAssociation(opDescription.Uri, new RelyingPartySecuritySettings())); Assert.IsNull(coordinator.Provider.AssociationStore.GetAssociation(AssociationRelyingPartyType.Smart, new ProviderSecuritySettings())); } } diff --git a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs index 97a40e8..eaaef34 100644 --- a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs @@ -24,14 +24,12 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { public class OpenIdChannelTests : TestBase { private static readonly TimeSpan maximumMessageAge = TimeSpan.FromHours(3); // good for tests, too long for production private OpenIdChannel channel; - private OpenIdChannel_Accessor accessor; private Mocks.TestWebRequestHandler webHandler; [SetUp] public void Setup() { this.webHandler = new Mocks.TestWebRequestHandler(); this.channel = new OpenIdChannel(new AssociationMemoryStore<Uri>(), new NonceMemoryStore(maximumMessageAge), new RelyingPartySecuritySettings()); - this.accessor = OpenIdChannel_Accessor.AttachShadow(this.channel); this.channel.WebRequestHandler = this.webHandler; } @@ -59,7 +57,7 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { Recipient = new Uri("http://host"), Name = "Andrew", }; - HttpWebRequest httpRequest = this.accessor.CreateHttpRequest(requestMessage); + HttpWebRequest httpRequest = this.channel.CreateHttpRequestTestHook(requestMessage); Assert.AreEqual("POST", httpRequest.Method); StringAssert.Contains("Name=Andrew", this.webHandler.RequestEntityAsString); } @@ -78,9 +76,9 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { IProtocolMessage message = MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired); MessageDictionary messageFields = this.MessageDescriptions.GetAccessor(message); byte[] expectedBytes = KeyValueFormEncoding.GetBytes(messageFields); - string expectedContentType = OpenIdChannel_Accessor.KeyValueFormContentType; + string expectedContentType = OpenIdChannel.KeyValueFormContentType; - OutgoingWebResponse directResponse = this.accessor.PrepareDirectResponse(message); + OutgoingWebResponse directResponse = this.channel.PrepareDirectResponseTestHook(message); Assert.AreEqual(expectedContentType, directResponse.Headers[HttpResponseHeader.ContentType]); byte[] actualBytes = new byte[directResponse.ResponseStream.Length]; directResponse.ResponseStream.Read(actualBytes, 0, actualBytes.Length); @@ -99,7 +97,7 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { var response = new CachedDirectWebResponse { CachedResponseStream = new MemoryStream(KeyValueFormEncoding.GetBytes(fields)), }; - Assert.IsTrue(MessagingUtilities.AreEquivalent(fields, this.accessor.ReadFromResponseCore(response))); + Assert.IsTrue(MessagingUtilities.AreEquivalent(fields, this.channel.ReadFromResponseCoreTestHook(response))); } /// <summary> @@ -108,13 +106,13 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { [TestCase] public void SendDirectMessageResponseHonorsHttpStatusCodes() { IProtocolMessage message = MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired); - OutgoingWebResponse directResponse = this.accessor.PrepareDirectResponse(message); + OutgoingWebResponse directResponse = this.channel.PrepareDirectResponseTestHook(message); Assert.AreEqual(HttpStatusCode.OK, directResponse.Status); var httpMessage = new TestDirectResponseMessageWithHttpStatus(); MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired, httpMessage); httpMessage.HttpStatusCode = HttpStatusCode.NotAcceptable; - directResponse = this.accessor.PrepareDirectResponse(httpMessage); + directResponse = this.channel.PrepareDirectResponseTestHook(httpMessage); Assert.AreEqual(HttpStatusCode.NotAcceptable, directResponse.Status); } } diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperOPTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperOPTests.cs index 1b1dd49..bcafc41 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperOPTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperOPTests.cs @@ -132,8 +132,8 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { private void ParameterizedAXTest(AXAttributeFormats format) { var axInjected = new FetchRequest(); - axInjected.Attributes.AddOptional(ExtensionsInteropHelper_Accessor.TransformAXFormat(WellKnownAttributes.Name.Alias, format)); - axInjected.Attributes.AddRequired(ExtensionsInteropHelper_Accessor.TransformAXFormat(WellKnownAttributes.Name.FullName, format)); + axInjected.Attributes.AddOptional(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, format)); + axInjected.Attributes.AddRequired(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.FullName, format)); this.extensions.Add(axInjected); var sreg = ExtensionsInteropHelper.UnifyExtensionsAsSreg(this.request); Assert.AreSame(sreg, this.request.GetExtension<ClaimsRequest>()); @@ -147,7 +147,7 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { ExtensionsInteropHelper.ConvertSregToMatchRequest(this.request); var extensions = this.GetResponseExtensions(); var axResponse = extensions.OfType<FetchResponse>().Single(); - Assert.AreEqual("andy", axResponse.GetAttributeValue(ExtensionsInteropHelper_Accessor.TransformAXFormat(WellKnownAttributes.Name.Alias, format))); + Assert.AreEqual("andy", axResponse.GetAttributeValue(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, format))); } } } diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPRequestTests.cs index 44a629a..d477e9b 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPRequestTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPRequestTests.cs @@ -76,8 +76,8 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { ExtensionsInteropHelper.SpreadSregToAX(this.authReq, AXAttributeFormats.AXSchemaOrg | AXAttributeFormats.SchemaOpenIdNet); var ax = this.authReq.AppliedExtensions.OfType<FetchRequest>().Single(); Assert.IsTrue(ax.Attributes.Contains(WellKnownAttributes.Name.Alias)); - Assert.IsTrue(ax.Attributes.Contains(ExtensionsInteropHelper_Accessor.TransformAXFormat(WellKnownAttributes.Name.Alias, AXAttributeFormats.SchemaOpenIdNet))); - Assert.IsFalse(ax.Attributes.Contains(ExtensionsInteropHelper_Accessor.TransformAXFormat(WellKnownAttributes.Name.Alias, AXAttributeFormats.OpenIdNetSchema))); + Assert.IsTrue(ax.Attributes.Contains(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.SchemaOpenIdNet))); + Assert.IsFalse(ax.Attributes.Contains(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.OpenIdNetSchema))); } /// <summary> @@ -100,7 +100,7 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { this.InjectAdvertisedTypeUri(WellKnownAttributes.Name.FullName); ExtensionsInteropHelper.SpreadSregToAX(this.authReq, AXAttributeFormats.OpenIdNetSchema); var ax = this.authReq.AppliedExtensions.OfType<FetchRequest>().Single(); - Assert.IsFalse(ax.Attributes.Contains(ExtensionsInteropHelper_Accessor.TransformAXFormat(WellKnownAttributes.Contact.Email, AXAttributeFormats.OpenIdNetSchema))); + Assert.IsFalse(ax.Attributes.Contains(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Contact.Email, AXAttributeFormats.OpenIdNetSchema))); Assert.IsTrue(ax.Attributes.Contains(WellKnownAttributes.Contact.Email)); } @@ -109,9 +109,9 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { /// </summary> [TestCase] public void TransformAXFormatTest() { - Assert.AreEqual(WellKnownAttributes.Name.Alias, ExtensionsInteropHelper_Accessor.TransformAXFormat(WellKnownAttributes.Name.Alias, AXAttributeFormats.AXSchemaOrg)); - Assert.AreEqual("http://schema.openid.net/namePerson/friendly", ExtensionsInteropHelper_Accessor.TransformAXFormat(WellKnownAttributes.Name.Alias, AXAttributeFormats.SchemaOpenIdNet)); - Assert.AreEqual("http://openid.net/schema/namePerson/friendly", ExtensionsInteropHelper_Accessor.TransformAXFormat(WellKnownAttributes.Name.Alias, AXAttributeFormats.OpenIdNetSchema)); + Assert.AreEqual(WellKnownAttributes.Name.Alias, ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.AXSchemaOrg)); + Assert.AreEqual("http://schema.openid.net/namePerson/friendly", ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.SchemaOpenIdNet)); + Assert.AreEqual("http://openid.net/schema/namePerson/friendly", ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.OpenIdNetSchema)); } /// <summary> diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPResponseTests.cs index 7b528d0..e7db6e6 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPResponseTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPResponseTests.cs @@ -74,7 +74,7 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { [TestCase] public void UnifyExtensionsasSregFromSchemaOpenIdNet() { var axInjected = new FetchResponse(); - axInjected.Attributes.Add(ExtensionsInteropHelper_Accessor.TransformAXFormat(WellKnownAttributes.Name.Alias, AXAttributeFormats.SchemaOpenIdNet), "nate"); + axInjected.Attributes.Add(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.SchemaOpenIdNet), "nate"); this.extensions.Add(axInjected); var sreg = ExtensionsInteropHelper.UnifyExtensionsAsSreg(this.response, true); Assert.AreEqual("nate", sreg.Nickname); diff --git a/src/DotNetOpenAuth.Test/OpenId/Messages/IndirectSignedResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/Messages/IndirectSignedResponseTests.cs index ad6b15d..406a48b 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Messages/IndirectSignedResponseTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Messages/IndirectSignedResponseTests.cs @@ -63,25 +63,23 @@ namespace DotNetOpenAuth.Test.OpenId.Messages { [TestCase] public void ResponseNonceSetter() { const string HybridValue = CreationDateString + "UNIQUE"; - var responseAccessor = IndirectSignedResponse_Accessor.AttachShadow(this.response); IReplayProtectedProtocolMessage responseReplay = this.response; - responseAccessor.ResponseNonce = HybridValue; - Assert.AreEqual(HybridValue, responseAccessor.ResponseNonce); + this.response.ResponseNonceTestHook = HybridValue; + Assert.AreEqual(HybridValue, this.response.ResponseNonceTestHook); Assert.AreEqual(this.creationDate, responseReplay.UtcCreationDate); Assert.AreEqual("UNIQUE", responseReplay.Nonce); - responseAccessor.ResponseNonce = null; + this.response.ResponseNonceTestHook = null; Assert.IsNull(responseReplay.Nonce); } [TestCase] public void ResponseNonceGetter() { - var responseAccessor = IndirectSignedResponse_Accessor.AttachShadow(this.response); IReplayProtectedProtocolMessage responseReplay = this.response; responseReplay.Nonce = "UnIqUe"; responseReplay.UtcCreationDate = this.creationDate; - Assert.AreEqual(CreationDateString + "UnIqUe", responseAccessor.ResponseNonce); + Assert.AreEqual(CreationDateString + "UnIqUe", this.response.ResponseNonceTestHook); Assert.AreEqual("UnIqUe", responseReplay.Nonce); Assert.AreEqual(this.creationDate, responseReplay.UtcCreationDate); } diff --git a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs index c7df99a..414585f 100644 --- a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs +++ b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs @@ -89,11 +89,9 @@ namespace DotNetOpenAuth.Test.OpenId { /// <param name="providerEndpoint">The provider endpoint.</param> /// <param name="association">The association.</param> internal static void StoreAssociation(OpenIdRelyingParty relyingParty, Uri providerEndpoint, Association association) { - var associationManagerAccessor = AssociationManager_Accessor.AttachShadow(relyingParty.AssociationManager); - // Only store the association if the RP is not in stateless mode. - if (associationManagerAccessor.associationStore != null) { - associationManagerAccessor.associationStore.StoreAssociation(providerEndpoint, association); + if (relyingParty.AssociationManager.AssociationStoreTestHook != null) { + relyingParty.AssociationManager.AssociationStoreTestHook.StoreAssociation(providerEndpoint, association); } } diff --git a/src/DotNetOpenAuth.Test/OpenId/Provider/AuthenticationRequestTest.cs b/src/DotNetOpenAuth.Test/OpenId/Provider/AuthenticationRequestTest.cs index dc5b3e3..39b4355 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Provider/AuthenticationRequestTest.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Provider/AuthenticationRequestTest.cs @@ -35,8 +35,8 @@ namespace DotNetOpenAuth.Test.OpenId.Provider { // Now construct a new request as if it had just come in. HttpRequestInfo httpRequest = new HttpRequestInfo { UrlBeforeRewriting = userSetupUrl }; - var setupRequest = AuthenticationRequest_Accessor.AttachShadow(provider.GetRequest(httpRequest)); - CheckIdRequest_Accessor setupRequestMessage = setupRequest.RequestMessage; + var setupRequest = (AuthenticationRequest)provider.GetRequest(httpRequest); + var setupRequestMessage = (CheckIdRequest)setupRequest.RequestMessage; // And make sure all the right properties are set. Assert.IsFalse(setupRequestMessage.Immediate); diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs index 001f3fa..793669a 100644 --- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs @@ -86,8 +86,8 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { authRequest.AddExtension(sregRequest); // Construct the actual authentication request message. - var authRequestAccessor = AuthenticationRequest_Accessor.AttachShadow(authRequest); - var req = authRequestAccessor.CreateRequestMessage(); + var authRequestAccessor = (AuthenticationRequest)authRequest; + var req = authRequestAccessor.CreateRequestMessageTestHook(); Assert.IsNotNull(req); // Verify that callback arguments were included. diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs index 25b0607..fc7ed0f 100644 --- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs @@ -35,7 +35,6 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { assertion.Extensions.Add(extension); var rp = CreateRelyingParty(); var authResponse = new PositiveAuthenticationResponse(assertion, rp); - var authResponseAccessor = PositiveAuthenticationResponse_Accessor.AttachShadow(authResponse); Assert.AreEqual(AuthenticationStatus.Authenticated, authResponse.Status); Assert.IsNull(authResponse.Exception); Assert.AreEqual((string)assertion.ClaimedIdentifier, (string)authResponse.ClaimedIdentifier); diff --git a/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs b/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs index 5b015ff..e6bed2f 100644 --- a/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs @@ -133,6 +133,10 @@ namespace DotNetOpenAuth.Test.OpenId { Assert.AreEqual("http://abc/", new UriIdentifier("HTTP://ABC").ToString()); Assert.AreEqual("http://abc/?q", new UriIdentifier("HTTP://ABC?q").ToString()); Assert.AreEqual("http://abc/#f", new UriIdentifier("HTTP://ABC#f").ToString()); + + Assert.AreEqual("http://blog.nerdbank.net/", new UriIdentifier("blog.nerdbank.net").ToString()); + Assert.AreEqual("http://blog.nerdbank.net/a", new UriIdentifier("BLOG.nerdbank.net/a").ToString()); + Assert.AreEqual("https://blog.nerdbank.net/", new UriIdentifier("blog.nerdbank.net", true).ToString()); }); } @@ -297,14 +301,14 @@ namespace DotNetOpenAuth.Test.OpenId { private static void TestAsFullAndPartialTrust(Action<bool> action) { // Test a bunch of interesting URLs both with scheme substitution on and off. - Assert.IsTrue(UriIdentifier_Accessor.schemeSubstitution, "Expected scheme substitution to be working."); + Assert.IsTrue(UriIdentifier.SchemeSubstitutionTestHook, "Expected scheme substitution to be working."); action(true); - UriIdentifier_Accessor.schemeSubstitution = false; + UriIdentifier.SchemeSubstitutionTestHook = false; try { action(false); } finally { - UriIdentifier_Accessor.schemeSubstitution = true; + UriIdentifier.SchemeSubstitutionTestHook = true; } } } diff --git a/src/DotNetOpenAuth.sln b/src/DotNetOpenAuth.sln index 60dffe6..8353bac 100644 --- a/src/DotNetOpenAuth.sln +++ b/src/DotNetOpenAuth.sln @@ -152,6 +152,7 @@ Global CodeAnalysis|Any CPU = CodeAnalysis|Any CPU Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU + ReleaseNoUI|Any CPU = ReleaseNoUI|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU @@ -160,84 +161,99 @@ Global {3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}.Debug|Any CPU.Build.0 = Debug|Any CPU {3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}.Release|Any CPU.ActiveCfg = Release|Any CPU {3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}.Release|Any CPU.Build.0 = Release|Any CPU + {3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}.ReleaseNoUI|Any CPU.ActiveCfg = ReleaseNoUI|Any CPU + {3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}.ReleaseNoUI|Any CPU.Build.0 = ReleaseNoUI|Any CPU {4376ECC9-C346-4A99-B13C-FA93C0FBD2C9}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU {4376ECC9-C346-4A99-B13C-FA93C0FBD2C9}.CodeAnalysis|Any CPU.Build.0 = CodeAnalysis|Any CPU {4376ECC9-C346-4A99-B13C-FA93C0FBD2C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4376ECC9-C346-4A99-B13C-FA93C0FBD2C9}.Debug|Any CPU.Build.0 = Debug|Any CPU {4376ECC9-C346-4A99-B13C-FA93C0FBD2C9}.Release|Any CPU.ActiveCfg = Release|Any CPU {4376ECC9-C346-4A99-B13C-FA93C0FBD2C9}.Release|Any CPU.Build.0 = Release|Any CPU + {4376ECC9-C346-4A99-B13C-FA93C0FBD2C9}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {AA78D112-D889-414B-A7D4-467B34C7B663}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU {AA78D112-D889-414B-A7D4-467B34C7B663}.CodeAnalysis|Any CPU.Build.0 = CodeAnalysis|Any CPU {AA78D112-D889-414B-A7D4-467B34C7B663}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA78D112-D889-414B-A7D4-467B34C7B663}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA78D112-D889-414B-A7D4-467B34C7B663}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA78D112-D889-414B-A7D4-467B34C7B663}.Release|Any CPU.Build.0 = Release|Any CPU + {AA78D112-D889-414B-A7D4-467B34C7B663}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {47A84EF7-68C3-4D47-926A-9CCEA6518531}.CodeAnalysis|Any CPU.ActiveCfg = Debug|Any CPU {47A84EF7-68C3-4D47-926A-9CCEA6518531}.CodeAnalysis|Any CPU.Build.0 = Debug|Any CPU {47A84EF7-68C3-4D47-926A-9CCEA6518531}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {47A84EF7-68C3-4D47-926A-9CCEA6518531}.Debug|Any CPU.Build.0 = Debug|Any CPU {47A84EF7-68C3-4D47-926A-9CCEA6518531}.Release|Any CPU.ActiveCfg = Debug|Any CPU {47A84EF7-68C3-4D47-926A-9CCEA6518531}.Release|Any CPU.Build.0 = Debug|Any CPU + {47A84EF7-68C3-4D47-926A-9CCEA6518531}.ReleaseNoUI|Any CPU.ActiveCfg = Debug|Any CPU {2A59DE0A-B76A-4B42-9A33-04D34548353D}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU {2A59DE0A-B76A-4B42-9A33-04D34548353D}.CodeAnalysis|Any CPU.Build.0 = CodeAnalysis|Any CPU {2A59DE0A-B76A-4B42-9A33-04D34548353D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2A59DE0A-B76A-4B42-9A33-04D34548353D}.Debug|Any CPU.Build.0 = Debug|Any CPU {2A59DE0A-B76A-4B42-9A33-04D34548353D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2A59DE0A-B76A-4B42-9A33-04D34548353D}.Release|Any CPU.Build.0 = Release|Any CPU + {2A59DE0A-B76A-4B42-9A33-04D34548353D}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {AEA29D4D-396F-47F6-BC81-B58D4B855245}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU {AEA29D4D-396F-47F6-BC81-B58D4B855245}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU {AEA29D4D-396F-47F6-BC81-B58D4B855245}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AEA29D4D-396F-47F6-BC81-B58D4B855245}.Debug|Any CPU.Build.0 = Debug|Any CPU {AEA29D4D-396F-47F6-BC81-B58D4B855245}.Release|Any CPU.ActiveCfg = Release|Any CPU {AEA29D4D-396F-47F6-BC81-B58D4B855245}.Release|Any CPU.Build.0 = Release|Any CPU + {AEA29D4D-396F-47F6-BC81-B58D4B855245}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {6EB90284-BD15-461C-BBF2-131CF55F7C8B}.CodeAnalysis|Any CPU.ActiveCfg = Debug|Any CPU {6EB90284-BD15-461C-BBF2-131CF55F7C8B}.CodeAnalysis|Any CPU.Build.0 = Debug|Any CPU {6EB90284-BD15-461C-BBF2-131CF55F7C8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EB90284-BD15-461C-BBF2-131CF55F7C8B}.Debug|Any CPU.Build.0 = Debug|Any CPU {6EB90284-BD15-461C-BBF2-131CF55F7C8B}.Release|Any CPU.ActiveCfg = Debug|Any CPU {6EB90284-BD15-461C-BBF2-131CF55F7C8B}.Release|Any CPU.Build.0 = Debug|Any CPU + {6EB90284-BD15-461C-BBF2-131CF55F7C8B}.ReleaseNoUI|Any CPU.ActiveCfg = Debug|Any CPU {07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU {07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU {07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}.Debug|Any CPU.Build.0 = Debug|Any CPU {07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}.Release|Any CPU.ActiveCfg = Release|Any CPU {07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}.Release|Any CPU.Build.0 = Release|Any CPU + {07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {1E8AEA89-BF69-47A1-B290-E8B0FE588700}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU {1E8AEA89-BF69-47A1-B290-E8B0FE588700}.CodeAnalysis|Any CPU.Build.0 = CodeAnalysis|Any CPU {1E8AEA89-BF69-47A1-B290-E8B0FE588700}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1E8AEA89-BF69-47A1-B290-E8B0FE588700}.Debug|Any CPU.Build.0 = Debug|Any CPU {1E8AEA89-BF69-47A1-B290-E8B0FE588700}.Release|Any CPU.ActiveCfg = Release|Any CPU {1E8AEA89-BF69-47A1-B290-E8B0FE588700}.Release|Any CPU.Build.0 = Release|Any CPU + {1E8AEA89-BF69-47A1-B290-E8B0FE588700}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {BBACD972-014D-478F-9B07-56B9E1D4CC73}.CodeAnalysis|Any CPU.ActiveCfg = Debug|Any CPU {BBACD972-014D-478F-9B07-56B9E1D4CC73}.CodeAnalysis|Any CPU.Build.0 = Debug|Any CPU {BBACD972-014D-478F-9B07-56B9E1D4CC73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BBACD972-014D-478F-9B07-56B9E1D4CC73}.Debug|Any CPU.Build.0 = Debug|Any CPU {BBACD972-014D-478F-9B07-56B9E1D4CC73}.Release|Any CPU.ActiveCfg = Debug|Any CPU {BBACD972-014D-478F-9B07-56B9E1D4CC73}.Release|Any CPU.Build.0 = Debug|Any CPU + {BBACD972-014D-478F-9B07-56B9E1D4CC73}.ReleaseNoUI|Any CPU.ActiveCfg = Debug|Any CPU {6EC36418-DBC5-4AD1-A402-413604AA7A08}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU {6EC36418-DBC5-4AD1-A402-413604AA7A08}.CodeAnalysis|Any CPU.Build.0 = CodeAnalysis|Any CPU {6EC36418-DBC5-4AD1-A402-413604AA7A08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EC36418-DBC5-4AD1-A402-413604AA7A08}.Debug|Any CPU.Build.0 = Debug|Any CPU {6EC36418-DBC5-4AD1-A402-413604AA7A08}.Release|Any CPU.ActiveCfg = Release|Any CPU {6EC36418-DBC5-4AD1-A402-413604AA7A08}.Release|Any CPU.Build.0 = Release|Any CPU + {6EC36418-DBC5-4AD1-A402-413604AA7A08}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {5C65603B-235F-47E6-B536-06385C60DE7F}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU {5C65603B-235F-47E6-B536-06385C60DE7F}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU {5C65603B-235F-47E6-B536-06385C60DE7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5C65603B-235F-47E6-B536-06385C60DE7F}.Debug|Any CPU.Build.0 = Debug|Any CPU {5C65603B-235F-47E6-B536-06385C60DE7F}.Release|Any CPU.ActiveCfg = Release|Any CPU {5C65603B-235F-47E6-B536-06385C60DE7F}.Release|Any CPU.Build.0 = Release|Any CPU + {5C65603B-235F-47E6-B536-06385C60DE7F}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {A78F8FC6-7B03-4230-BE41-761E400D6810}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU {A78F8FC6-7B03-4230-BE41-761E400D6810}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU {A78F8FC6-7B03-4230-BE41-761E400D6810}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A78F8FC6-7B03-4230-BE41-761E400D6810}.Debug|Any CPU.Build.0 = Debug|Any CPU {A78F8FC6-7B03-4230-BE41-761E400D6810}.Release|Any CPU.ActiveCfg = Release|Any CPU {A78F8FC6-7B03-4230-BE41-761E400D6810}.Release|Any CPU.Build.0 = Release|Any CPU + {A78F8FC6-7B03-4230-BE41-761E400D6810}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {17932639-1F50-48AF-B0A5-E2BF832F82CC}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU {17932639-1F50-48AF-B0A5-E2BF832F82CC}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU {17932639-1F50-48AF-B0A5-E2BF832F82CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {17932639-1F50-48AF-B0A5-E2BF832F82CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {17932639-1F50-48AF-B0A5-E2BF832F82CC}.Release|Any CPU.ActiveCfg = Release|Any CPU {17932639-1F50-48AF-B0A5-E2BF832F82CC}.Release|Any CPU.Build.0 = Release|Any CPU + {17932639-1F50-48AF-B0A5-E2BF832F82CC}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.CodeAnalysis|Any CPU.ActiveCfg = Debug|Any CPU {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.CodeAnalysis|Any CPU.Build.0 = Debug|Any CPU {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.CodeAnalysis|Any CPU.Deploy.0 = Debug|Any CPU @@ -247,42 +263,49 @@ Global {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.Release|Any CPU.Build.0 = Release|Any CPU {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.Release|Any CPU.Deploy.0 = Release|Any CPU + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {152B7BAB-E884-4A59-8067-440971A682B3}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU {152B7BAB-E884-4A59-8067-440971A682B3}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU {152B7BAB-E884-4A59-8067-440971A682B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {152B7BAB-E884-4A59-8067-440971A682B3}.Debug|Any CPU.Build.0 = Debug|Any CPU {152B7BAB-E884-4A59-8067-440971A682B3}.Release|Any CPU.ActiveCfg = Release|Any CPU {152B7BAB-E884-4A59-8067-440971A682B3}.Release|Any CPU.Build.0 = Release|Any CPU + {152B7BAB-E884-4A59-8067-440971A682B3}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {B64A1E7E-6A15-4B91-AF13-7D48F7DA5942}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU {B64A1E7E-6A15-4B91-AF13-7D48F7DA5942}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU {B64A1E7E-6A15-4B91-AF13-7D48F7DA5942}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B64A1E7E-6A15-4B91-AF13-7D48F7DA5942}.Debug|Any CPU.Build.0 = Debug|Any CPU {B64A1E7E-6A15-4B91-AF13-7D48F7DA5942}.Release|Any CPU.ActiveCfg = Release|Any CPU {B64A1E7E-6A15-4B91-AF13-7D48F7DA5942}.Release|Any CPU.Build.0 = Release|Any CPU + {B64A1E7E-6A15-4B91-AF13-7D48F7DA5942}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {0B4EB2A8-283D-48FB-BCD0-85B8DFFE05E4}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU {0B4EB2A8-283D-48FB-BCD0-85B8DFFE05E4}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU {0B4EB2A8-283D-48FB-BCD0-85B8DFFE05E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0B4EB2A8-283D-48FB-BCD0-85B8DFFE05E4}.Debug|Any CPU.Build.0 = Debug|Any CPU {0B4EB2A8-283D-48FB-BCD0-85B8DFFE05E4}.Release|Any CPU.ActiveCfg = Release|Any CPU {0B4EB2A8-283D-48FB-BCD0-85B8DFFE05E4}.Release|Any CPU.Build.0 = Release|Any CPU + {0B4EB2A8-283D-48FB-BCD0-85B8DFFE05E4}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {F289B925-4307-4BEC-B411-885CE70E3379}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU {F289B925-4307-4BEC-B411-885CE70E3379}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU {F289B925-4307-4BEC-B411-885CE70E3379}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F289B925-4307-4BEC-B411-885CE70E3379}.Debug|Any CPU.Build.0 = Debug|Any CPU {F289B925-4307-4BEC-B411-885CE70E3379}.Release|Any CPU.ActiveCfg = Release|Any CPU {F289B925-4307-4BEC-B411-885CE70E3379}.Release|Any CPU.Build.0 = Release|Any CPU + {F289B925-4307-4BEC-B411-885CE70E3379}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {9529606E-AF76-4387-BFB7-3D10A5B399AA}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU {9529606E-AF76-4387-BFB7-3D10A5B399AA}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU {9529606E-AF76-4387-BFB7-3D10A5B399AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9529606E-AF76-4387-BFB7-3D10A5B399AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {9529606E-AF76-4387-BFB7-3D10A5B399AA}.Release|Any CPU.ActiveCfg = Release|Any CPU {9529606E-AF76-4387-BFB7-3D10A5B399AA}.Release|Any CPU.Build.0 = Release|Any CPU + {9529606E-AF76-4387-BFB7-3D10A5B399AA}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU {E135F455-0669-49F8-9207-07FCA8C8FC79}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU {E135F455-0669-49F8-9207-07FCA8C8FC79}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU {E135F455-0669-49F8-9207-07FCA8C8FC79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E135F455-0669-49F8-9207-07FCA8C8FC79}.Debug|Any CPU.Build.0 = Debug|Any CPU {E135F455-0669-49F8-9207-07FCA8C8FC79}.Release|Any CPU.ActiveCfg = Release|Any CPU {E135F455-0669-49F8-9207-07FCA8C8FC79}.Release|Any CPU.Build.0 = Release|Any CPU + {E135F455-0669-49F8-9207-07FCA8C8FC79}.ReleaseNoUI|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd b/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd index 9913017..6265706 100644 --- a/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd +++ b/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd @@ -206,6 +206,18 @@ </xs:documentation> </xs:annotation> </xs:attribute> + <xs:attribute name="strict" type="xs:boolean" default="true"> + <xs:annotation> + <xs:documentation> + Whether remote parties will be held strictly to the protocol specifications. + Strict will require that remote parties adhere strictly to the specifications, + even when a loose interpretation would not compromise security. + true is a good default because it shakes out interoperability bugs in remote services + so they can be identified and corrected. But some web sites want things to Just Work + more than they want to file bugs against others, so false is the setting for them. + </xs:documentation> + </xs:annotation> + </xs:attribute> <xs:attribute name="relaxSslRequirements" type="xs:boolean" default="false"> <xs:annotation> <xs:documentation> diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj index 150006f..9b0b2a6 100644 --- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj +++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj @@ -4,6 +4,7 @@ <ProjectRoot Condition="'$(ProjectRoot)' == ''">$(MSBuildProjectDirectory)\..\..\</ProjectRoot> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <CodeContractsAssemblyMode>1</CodeContractsAssemblyMode> </PropertyGroup> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.props" /> <PropertyGroup> @@ -14,6 +15,7 @@ <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>DotNetOpenAuth</RootNamespace> <AssemblyName>DotNetOpenAuth</AssemblyName> + <AssemblyName Condition=" '$(NoUIControls)' == 'true' ">DotNetOpenAuth.NoUI</AssemblyName> <FileAlignment>512</FileAlignment> <StandardCopyright> Copyright (c) 2009, Andrew Arnott. All rights reserved. @@ -41,7 +43,7 @@ http://opensource.org/licenses/ms-pl.html <UseApplicationTrust>false</UseApplicationTrust> <BootstrapperEnabled>true</BootstrapperEnabled> <ApplicationIcon>DotNetOpenAuth.ico</ApplicationIcon> - <DocumentationFile>$(OutputPath)DotNetOpenAuth.xml</DocumentationFile> + <DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -83,6 +85,7 @@ http://opensource.org/licenses/ms-pl.html <CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions> <CodeContractsReferenceAssembly>Build</CodeContractsReferenceAssembly> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + <CodeContractsExtraRewriteOptions /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -123,6 +126,45 @@ http://opensource.org/licenses/ms-pl.html <CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions> <CodeContractsReferenceAssembly>Build</CodeContractsReferenceAssembly> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + <CodeContractsExtraRewriteOptions /> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseNoUI|AnyCPU'"> + <DefineConstants>TRACE;NoUIControls</DefineConstants> + <NoUIControls>true</NoUIControls> + <Optimize>true</Optimize> + <NoWarn>;1607</NoWarn> + <DebugType>pdbonly</DebugType> + <PlatformTarget>AnyCPU</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking> + <CodeContractsCustomRewriterAssembly> + </CodeContractsCustomRewriterAssembly> + <CodeContractsCustomRewriterClass> + </CodeContractsCustomRewriterClass> + <CodeContractsRuntimeCheckingLevel>ReleaseRequires</CodeContractsRuntimeCheckingLevel> + <CodeContractsRunCodeAnalysis>False</CodeContractsRunCodeAnalysis> + <CodeContractsBuildReferenceAssembly>True</CodeContractsBuildReferenceAssembly> + <CodeContractsNonNullObligations>False</CodeContractsNonNullObligations> + <CodeContractsBoundsObligations>False</CodeContractsBoundsObligations> + <CodeContractsLibPaths> + </CodeContractsLibPaths> + <CodeContractsPlatformPath> + </CodeContractsPlatformPath> + <CodeContractsExtraAnalysisOptions> + </CodeContractsExtraAnalysisOptions> + <CodeContractsBaseLineFile> + </CodeContractsBaseLineFile> + <CodeContractsUseBaseLine>False</CodeContractsUseBaseLine> + <CodeContractsRunInBackground>True</CodeContractsRunInBackground> + <CodeContractsShowSquigglies>False</CodeContractsShowSquigglies> + <CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations> + <CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface> + <CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure> + <CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires> + <CodeContractsEmitXMLDocs>True</CodeContractsEmitXMLDocs> + <CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions> + <CodeContractsReferenceAssembly>Build</CodeContractsReferenceAssembly> + <CodeContractsExtraRewriteOptions /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CodeAnalysis|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -164,6 +206,7 @@ http://opensource.org/licenses/ms-pl.html <CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions> <CodeContractsReferenceAssembly>Build</CodeContractsReferenceAssembly> <CodeAnalysisRuleSet>Migrated rules for DotNetOpenAuth.ruleset</CodeAnalysisRuleSet> + <CodeContractsExtraRewriteOptions /> </PropertyGroup> <ItemGroup> <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL"> @@ -260,16 +303,12 @@ http://opensource.org/licenses/ms-pl.html <Compile Include="Configuration\HostNameElement.cs" /> <Compile Include="Configuration\XriResolverElement.cs" /> <Compile Include="InfoCard\ClaimType.cs" /> - <Compile Include="InfoCard\ReceivingTokenEventArgs.cs" /> - <Compile Include="InfoCard\TokenProcessingErrorEventArgs.cs" /> <Compile Include="InfoCard\InfoCardImage.cs" /> - <Compile Include="InfoCard\InfoCardSelector.cs" /> <Compile Include="InfoCard\InfoCardStrings.Designer.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> <DependentUpon>InfoCardStrings.resx</DependentUpon> </Compile> - <Compile Include="InfoCard\ReceivedTokenEventArgs.cs" /> <Compile Include="InfoCard\Token\InformationCardException.cs" /> <Compile Include="InfoCard\Token\Token.cs" /> <Compile Include="InfoCard\Token\TokenUtility.cs" /> @@ -303,7 +342,6 @@ http://opensource.org/licenses/ms-pl.html <Compile Include="Messaging\Reflection\IMessagePartNullEncoder.cs" /> <Compile Include="Messaging\Reflection\IMessagePartOriginalEncoder.cs" /> <Compile Include="Messaging\Reflection\MessageDescriptionCollection.cs" /> - <Compile Include="Mvc\OpenIdHelper.cs" /> <Compile Include="Mvc\OpenIdAjaxOptions.cs" /> <Compile Include="Messaging\StandardMessageFactory.cs" /> <Compile Include="OAuth2\AuthorizationServerBase.cs" /> @@ -538,8 +576,6 @@ http://opensource.org/licenses/ms-pl.html <Compile Include="OpenId\Provider\IAuthenticationRequest.cs" /> <Compile Include="OpenId\Provider\IDirectedIdentityIdentifierProvider.cs" /> <Compile Include="OpenId\Provider\IHostProcessedRequest.cs" /> - <Compile Include="OpenId\Provider\IdentityEndpoint.cs" /> - <Compile Include="OpenId\Provider\IdentityEndpointNormalizationEventArgs.cs" /> <Compile Include="OpenId\Provider\IErrorReporting.cs" /> <Compile Include="OpenId\Provider\IProviderApplicationStore.cs" /> <Compile Include="OpenId\Provider\IProviderBehavior.cs" /> @@ -582,23 +618,10 @@ http://opensource.org/licenses/ms-pl.html <Compile Include="OpenId\RelyingParty\AuthenticationRequestMode.cs" /> <Compile Include="OpenId\RelyingParty\DuplicateRequestedHostsComparer.cs" /> <Compile Include="OpenId\RelyingParty\IProviderEndpoint.cs" /> - <Compile Include="OpenId\RelyingParty\OpenIdAjaxRelyingParty.cs" /> - <Compile Include="OpenId\RelyingParty\SelectorButtonContract.cs" /> - <Compile Include="OpenId\RelyingParty\SelectorProviderButton.cs" /> - <Compile Include="OpenId\RelyingParty\SelectorOpenIdButton.cs" /> - <Compile Include="OpenId\RelyingParty\SelectorInfoCardButton.cs" /> <Compile Include="OpenId\RelyingParty\IRelyingPartyBehavior.cs" /> - <Compile Include="OpenId\RelyingParty\OpenIdSelector.cs" /> - <Compile Include="OpenId\RelyingParty\OpenIdRelyingPartyAjaxControlBase.cs" /> <Compile Include="OpenId\RelyingParty\IAuthenticationRequestContract.cs" /> <Compile Include="OpenId\RelyingParty\NegativeAuthenticationResponse.cs" /> - <Compile Include="OpenId\RelyingParty\OpenIdAjaxTextBox.cs" /> - <Compile Include="OpenId\RelyingParty\OpenIdButton.cs" /> <Compile Include="OpenId\RelyingParty\OpenIdEventArgs.cs" /> - <Compile Include="OpenId\RelyingParty\OpenIdLogin.cs" /> - <Compile Include="OpenId\RelyingParty\OpenIdMobileTextBox.cs" Condition=" '$(ClrVersion)' != '4' " /> - <Compile Include="OpenId\RelyingParty\OpenIdRelyingPartyControlBase.cs" /> - <Compile Include="OpenId\RelyingParty\OpenIdTextBox.cs" /> <Compile Include="OpenId\RelyingParty\PopupBehavior.cs" /> <Compile Include="OpenId\RelyingParty\PositiveAnonymousResponse.cs" /> <Compile Include="OpenId\RelyingParty\PositiveAuthenticationResponse.cs" /> @@ -620,7 +643,6 @@ http://opensource.org/licenses/ms-pl.html <Compile Include="OpenId\RelyingParty\PositiveAuthenticationResponseSnapshot.cs" /> <Compile Include="OpenId\RelyingParty\PrivateSecretManager.cs" /> <Compile Include="OpenId\RelyingParty\RelyingPartySecuritySettings.cs" /> - <Compile Include="OpenId\RelyingParty\SelectorButton.cs" /> <Compile Include="OpenId\IdentifierDiscoveryResult.cs" /> <Compile Include="OpenId\OpenIdXrdsHelper.cs" /> <Compile Include="OpenId\RelyingParty\SimpleXrdsProviderEndpoint.cs" /> @@ -660,7 +682,6 @@ http://opensource.org/licenses/ms-pl.html <DependentUpon>Strings.resx</DependentUpon> </Compile> <Compile Include="UriUtil.cs" /> - <Compile Include="XrdsPublisher.cs" /> <Compile Include="Xrds\XrdsStrings.Designer.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> @@ -677,6 +698,30 @@ http://opensource.org/licenses/ms-pl.html <Compile Include="Xrds\XrdsNode.cs" /> <Compile Include="Yadis\Yadis.cs" /> </ItemGroup> + <ItemGroup Condition=" '$(NoUIControls)' != 'true' "> + <Compile Include="OpenId\RelyingParty\OpenIdTextBox.cs"/> + <Compile Include="OpenId\RelyingParty\OpenIdLogin.cs"/> + <Compile Include="OpenId\RelyingParty\OpenIdAjaxRelyingParty.cs"/> + <Compile Include="OpenId\RelyingParty\SelectorButtonContract.cs"/> + <Compile Include="OpenId\RelyingParty\SelectorProviderButton.cs"/> + <Compile Include="OpenId\RelyingParty\SelectorOpenIdButton.cs"/> + <Compile Include="XrdsPublisher.cs"/> + <Compile Include="InfoCard\ReceivingTokenEventArgs.cs"/> + <Compile Include="InfoCard\TokenProcessingErrorEventArgs.cs"/> + <Compile Include="InfoCard\InfoCardSelector.cs"/> + <Compile Include="InfoCard\ReceivedTokenEventArgs.cs"/> + <Compile Include="Mvc\OpenIdHelper.cs"/> + <Compile Include="OpenId\RelyingParty\SelectorButton.cs"/> + <Compile Include="OpenId\Provider\IdentityEndpoint.cs"/> + <Compile Include="OpenId\Provider\IdentityEndpointNormalizationEventArgs.cs"/> + <Compile Include="OpenId\RelyingParty\SelectorInfoCardButton.cs"/> + <Compile Include="OpenId\RelyingParty\OpenIdMobileTextBox.cs" Condition=" '$(ClrVersion)' != '4' "/> + <Compile Include="OpenId\RelyingParty\OpenIdAjaxTextBox.cs"/> + <Compile Include="OpenId\RelyingParty\OpenIdSelector.cs"/> + <Compile Include="OpenId\RelyingParty\OpenIdRelyingPartyAjaxControlBase.cs"/> + <Compile Include="OpenId\RelyingParty\OpenIdButton.cs"/> + <Compile Include="OpenId\RelyingParty\OpenIdRelyingPartyControlBase.cs"/> + </ItemGroup> <ItemGroup> <None Include="Configuration\DotNetOpenAuth.xsd" /> <None Include="Migrated rules for DotNetOpenAuth.ruleset" /> @@ -801,7 +846,6 @@ http://opensource.org/licenses/ms-pl.html <SignDependsOn Include="BuildUnifiedProduct" /> <DelaySignedAssemblies Include="$(ILMergeOutputAssembly);
 $(OutputPath)CodeContracts\$(ProductName).Contracts.dll;
 " /> </ItemGroup> - <ItemGroup /> <PropertyGroup> <!-- Don't sign the non-unified version of the assembly. --> <SuppressTargetPathDelaySignedAssembly>true</SuppressTargetPathDelaySignedAssembly> @@ -812,4 +856,4 @@ http://opensource.org/licenses/ms-pl.html </Target> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.targets" /> -</Project>
\ No newline at end of file +</Project> diff --git a/src/DotNetOpenAuth/Messaging/Channel.cs b/src/DotNetOpenAuth/Messaging/Channel.cs index 0633cd4..f168f6f 100644 --- a/src/DotNetOpenAuth/Messaging/Channel.cs +++ b/src/DotNetOpenAuth/Messaging/Channel.cs @@ -182,6 +182,14 @@ namespace DotNetOpenAuth.Messaging { } /// <summary> + /// Gets a tool that can figure out what kind of message is being received + /// so it can be deserialized. + /// </summary> + internal IMessageFactory MessageFactoryTestHook { + get { return this.MessageFactory; } + } + + /// <summary> /// Gets the binding elements used by this channel, in no particular guaranteed order. /// </summary> protected internal ReadOnlyCollection<IChannelBindingElement> BindingElements { @@ -470,6 +478,66 @@ namespace DotNetOpenAuth.Messaging { #endregion /// <summary> + /// Verifies the integrity and applicability of an incoming message. + /// </summary> + /// <param name="message">The message just received.</param> + /// <exception cref="ProtocolException"> + /// Thrown when the message is somehow invalid. + /// This can be due to tampering, replay attack or expiration, among other things. + /// </exception> + internal void ProcessIncomingMessageTestHook(IProtocolMessage message) { + this.ProcessIncomingMessage(message); + } + + /// <summary> + /// Prepares an HTTP request that carries a given message. + /// </summary> + /// <param name="request">The message to send.</param> + /// <returns>The <see cref="HttpWebRequest"/> prepared to send the request.</returns> + /// <remarks> + /// This method must be overridden by a derived class, unless the <see cref="RequestCore"/> method + /// is overridden and does not require this method. + /// </remarks> + internal HttpWebRequest CreateHttpRequestTestHook(IDirectedProtocolMessage request) { + return this.CreateHttpRequest(request); + } + + /// <summary> + /// Queues a message for sending in the response stream where the fields + /// are sent in the response stream in querystring style. + /// </summary> + /// <param name="response">The message to send as a response.</param> + /// <returns>The pending user agent redirect based message to be sent as an HttpResponse.</returns> + /// <remarks> + /// This method implements spec OAuth V1.0 section 5.3. + /// </remarks> + internal OutgoingWebResponse PrepareDirectResponseTestHook(IProtocolMessage response) { + return this.PrepareDirectResponse(response); + } + + /// <summary> + /// Gets the protocol message that may be in the given HTTP response. + /// </summary> + /// <param name="response">The response that is anticipated to contain an protocol message.</param> + /// <returns>The deserialized message parts, if found. Null otherwise.</returns> + /// <exception cref="ProtocolException">Thrown when the response is not valid.</exception> + internal IDictionary<string, string> ReadFromResponseCoreTestHook(IncomingWebResponse response) { + return this.ReadFromResponseCore(response); + } + + /// <remarks> + /// This method should NOT be called by derived types + /// except when sending ONE WAY request messages. + /// </remarks> + /// <summary> + /// Prepares a message for transmit by applying signatures, nonces, etc. + /// </summary> + /// <param name="message">The message to prepare for sending.</param> + internal void ProcessOutgoingMessageTestHook(IProtocolMessage message) { + this.ProcessOutgoingMessage(message); + } + + /// <summary> /// Gets the current HTTP request being processed. /// </summary> /// <returns>The HttpRequestInfo for the current request.</returns> diff --git a/src/DotNetOpenAuth/Messaging/IChannelBindingElement.cs b/src/DotNetOpenAuth/Messaging/IChannelBindingElement.cs index db5dd24..f502f17 100644 --- a/src/DotNetOpenAuth/Messaging/IChannelBindingElement.cs +++ b/src/DotNetOpenAuth/Messaging/IChannelBindingElement.cs @@ -68,7 +68,13 @@ namespace DotNetOpenAuth.Messaging { /// Code Contract for the <see cref="IChannelBindingElement"/> interface. /// </summary> [ContractClassFor(typeof(IChannelBindingElement))] - internal class IChannelBindingElementContract : IChannelBindingElement { + internal abstract class IChannelBindingElementContract : IChannelBindingElement { + /// <summary> + /// Prevents a default instance of the <see cref="IChannelBindingElementContract"/> class from being created. + /// </summary> + private IChannelBindingElementContract() { + } + #region IChannelBindingElement Members /// <summary> diff --git a/src/DotNetOpenAuth/Messaging/IMessage.cs b/src/DotNetOpenAuth/Messaging/IMessage.cs index 031e908..e91a160 100644 --- a/src/DotNetOpenAuth/Messaging/IMessage.cs +++ b/src/DotNetOpenAuth/Messaging/IMessage.cs @@ -51,7 +51,13 @@ namespace DotNetOpenAuth.Messaging { /// Code contract for the <see cref="IMessage"/> interface. /// </summary> [ContractClassFor(typeof(IMessage))] - internal sealed class IMessageContract : IMessage { + internal abstract class IMessageContract : IMessage { + /// <summary> + /// Prevents a default instance of the <see cref="IMessageContract"/> class from being created. + /// </summary> + private IMessageContract() { + } + /// <summary> /// Gets the version of the protocol or extension this message is prepared to implement. /// </summary> diff --git a/src/DotNetOpenAuth/Messaging/IMessageFactory.cs b/src/DotNetOpenAuth/Messaging/IMessageFactory.cs index 3718545..f9ddf3d 100644 --- a/src/DotNetOpenAuth/Messaging/IMessageFactory.cs +++ b/src/DotNetOpenAuth/Messaging/IMessageFactory.cs @@ -46,7 +46,13 @@ namespace DotNetOpenAuth.Messaging { /// Code contract for the <see cref="IMessageFactory"/> interface. /// </summary> [ContractClassFor(typeof(IMessageFactory))] - internal class IMessageFactoryContract : IMessageFactory { + internal abstract class IMessageFactoryContract : IMessageFactory { + /// <summary> + /// Prevents a default instance of the <see cref="IMessageFactoryContract"/> class from being created. + /// </summary> + private IMessageFactoryContract() { + } + #region IMessageFactory Members /// <summary> diff --git a/src/DotNetOpenAuth/Messaging/IMessageWithBinaryData.cs b/src/DotNetOpenAuth/Messaging/IMessageWithBinaryData.cs index f411cf5..32ae227 100644 --- a/src/DotNetOpenAuth/Messaging/IMessageWithBinaryData.cs +++ b/src/DotNetOpenAuth/Messaging/IMessageWithBinaryData.cs @@ -33,7 +33,13 @@ namespace DotNetOpenAuth.Messaging { /// The contract class for the <see cref="IMessageWithBinaryData"/> interface. /// </summary> [ContractClassFor(typeof(IMessageWithBinaryData))] - internal sealed class IMessageWithBinaryDataContract : IMessageWithBinaryData { + internal abstract class IMessageWithBinaryDataContract : IMessageWithBinaryData { + /// <summary> + /// Prevents a default instance of the <see cref="IMessageWithBinaryDataContract"/> class from being created. + /// </summary> + private IMessageWithBinaryDataContract() { + } + #region IMessageWithBinaryData Members /// <summary> @@ -67,7 +73,6 @@ namespace DotNetOpenAuth.Messaging { /// </remarks> Version IMessage.Version { get { - Contract.Ensures(Contract.Result<Version>() != null); return default(Version); // dummy return } } @@ -81,7 +86,6 @@ namespace DotNetOpenAuth.Messaging { /// </remarks> IDictionary<string, string> IMessage.ExtraData { get { - Contract.Ensures(Contract.Result<IDictionary<string, string>>() != null); return default(IDictionary<string, string>); } } diff --git a/src/DotNetOpenAuth/Messaging/IProtocolMessageWithExtensions.cs b/src/DotNetOpenAuth/Messaging/IProtocolMessageWithExtensions.cs index 901e6ae..44c4cbb 100644 --- a/src/DotNetOpenAuth/Messaging/IProtocolMessageWithExtensions.cs +++ b/src/DotNetOpenAuth/Messaging/IProtocolMessageWithExtensions.cs @@ -27,7 +27,7 @@ namespace DotNetOpenAuth.Messaging { /// Code contract for the <see cref="IProtocolMessageWithExtensions"/> interface. /// </summary> [ContractClassFor(typeof(IProtocolMessageWithExtensions))] - internal class IProtocolMessageWithExtensionsContract : IProtocolMessageWithExtensions { + internal abstract class IProtocolMessageWithExtensionsContract : IProtocolMessageWithExtensions { /// <summary> /// Prevents a default instance of the <see cref="IProtocolMessageWithExtensionsContract"/> class from being created. /// </summary> @@ -79,7 +79,6 @@ namespace DotNetOpenAuth.Messaging { /// </remarks> Version IMessage.Version { get { - Contract.Ensures(Contract.Result<Version>() != null); throw new NotImplementedException(); } } @@ -92,7 +91,6 @@ namespace DotNetOpenAuth.Messaging { /// </remarks> IDictionary<string, string> IMessage.ExtraData { get { - Contract.Ensures(Contract.Result<IDictionary<string, string>>() != null); throw new NotImplementedException(); } } diff --git a/src/DotNetOpenAuth/Messaging/ITamperProtectionChannelBindingElement.cs b/src/DotNetOpenAuth/Messaging/ITamperProtectionChannelBindingElement.cs index 87ea553..e177dd9 100644 --- a/src/DotNetOpenAuth/Messaging/ITamperProtectionChannelBindingElement.cs +++ b/src/DotNetOpenAuth/Messaging/ITamperProtectionChannelBindingElement.cs @@ -82,8 +82,6 @@ namespace DotNetOpenAuth.Messaging { /// <see cref="MessagePartAttribute.RequiredProtection"/> properties where applicable. /// </remarks> MessageProtections? IChannelBindingElement.ProcessOutgoingMessage(IProtocolMessage message) { - Contract.Requires<ArgumentNullException>(message != null); - Contract.Requires<InvalidOperationException>(((IChannelBindingElement)this).Channel != null); throw new NotImplementedException(); } @@ -105,8 +103,6 @@ namespace DotNetOpenAuth.Messaging { /// <see cref="MessagePartAttribute.RequiredProtection"/> properties where applicable. /// </remarks> MessageProtections? IChannelBindingElement.ProcessIncomingMessage(IProtocolMessage message) { - Contract.Requires<ArgumentNullException>(message != null); - Contract.Requires<InvalidOperationException>(((IChannelBindingElement)this).Channel != null); throw new NotImplementedException(); } diff --git a/src/DotNetOpenAuth/OAuth/ChannelElements/IServiceProviderTokenManager.cs b/src/DotNetOpenAuth/OAuth/ChannelElements/IServiceProviderTokenManager.cs index ea0e90c..7df67ce 100644 --- a/src/DotNetOpenAuth/OAuth/ChannelElements/IServiceProviderTokenManager.cs +++ b/src/DotNetOpenAuth/OAuth/ChannelElements/IServiceProviderTokenManager.cs @@ -84,11 +84,11 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// Code contract class for the <see cref="IServiceProviderTokenManager"/> interface. /// </summary> [ContractClassFor(typeof(IServiceProviderTokenManager))] - internal class IServiceProviderTokenManagerContract : IServiceProviderTokenManager { + internal abstract class IServiceProviderTokenManagerContract : IServiceProviderTokenManager { /// <summary> - /// Initializes a new instance of the <see cref="IServiceProviderTokenManagerContract"/> class. + /// Prevents a default instance of the <see cref="IServiceProviderTokenManagerContract"/> class from being created. /// </summary> - internal IServiceProviderTokenManagerContract() { + private IServiceProviderTokenManagerContract() { } #region IServiceProviderTokenManager Members @@ -188,8 +188,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// </returns> /// <exception cref="ArgumentException">Thrown if the secret cannot be found for the given token.</exception> string ITokenManager.GetTokenSecret(string token) { - Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(token)); - Contract.Ensures(Contract.Result<string>() != null); throw new NotImplementedException(); } @@ -207,8 +205,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// method. /// </remarks> void ITokenManager.StoreNewRequestToken(DotNetOpenAuth.OAuth.Messages.UnauthorizedTokenRequest request, DotNetOpenAuth.OAuth.Messages.ITokenSecretContainingMessage response) { - Contract.Requires<ArgumentNullException>(request != null); - Contract.Requires<ArgumentNullException>(response != null); throw new NotImplementedException(); } @@ -236,10 +232,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// </para> /// </remarks> void ITokenManager.ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret) { - Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(consumerKey)); - Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(requestToken)); - Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(accessToken)); - Contract.Requires<ArgumentNullException>(accessTokenSecret != null); throw new NotImplementedException(); } @@ -251,7 +243,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// Request or Access token, or invalid if the token is not recognized. /// </returns> TokenType ITokenManager.GetTokenType(string token) { - Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(token)); throw new NotImplementedException(); } diff --git a/src/DotNetOpenAuth/OAuth/ChannelElements/ITokenManager.cs b/src/DotNetOpenAuth/OAuth/ChannelElements/ITokenManager.cs index 532e4b0..459cd28 100644 --- a/src/DotNetOpenAuth/OAuth/ChannelElements/ITokenManager.cs +++ b/src/DotNetOpenAuth/OAuth/ChannelElements/ITokenManager.cs @@ -79,11 +79,11 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// The code contract class for the <see cref="ITokenManager"/> interface. /// </summary> [ContractClassFor(typeof(ITokenManager))] - internal class ITokenManagerContract : ITokenManager { + internal abstract class ITokenManagerContract : ITokenManager { /// <summary> - /// Initializes a new instance of the <see cref="ITokenManagerContract"/> class. + /// Prevents a default instance of the <see cref="ITokenManagerContract"/> class from being created. /// </summary> - internal ITokenManagerContract() { + private ITokenManagerContract() { } #region ITokenManager Members diff --git a/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs b/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs index cf09036..fdf6e08 100644 --- a/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs +++ b/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs @@ -234,6 +234,18 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { } /// <summary> + /// Calculates a signature for a given message. + /// </summary> + /// <param name="message">The message to sign.</param> + /// <returns>The signature for the message.</returns> + /// <remarks> + /// This method signs the message per OAuth 1.0 section 9.2. + /// </remarks> + internal string GetSignatureTestHook(ITamperResistantOAuthMessage message) { + return this.GetSignature(message); + } + + /// <summary> /// Gets the "ConsumerSecret&TokenSecret" string, allowing either property to be empty or null. /// </summary> /// <param name="message">The message to extract the secrets from.</param> diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs index b25e819..bc613ed 100644 --- a/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs +++ b/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs @@ -35,7 +35,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { /// to the end of the direct response, corrupting the data. So we deviate /// from the spec a bit here to improve the story for free Providers. /// </remarks> - private const string KeyValueFormContentType = "application/x-openid-kvf"; + internal const string KeyValueFormContentType = "application/x-openid-kvf"; /// <summary> /// The encoder that understands how to read and write Key-Value Form. diff --git a/src/DotNetOpenAuth/OpenId/Extensions/ExtensionsInteropHelper.cs b/src/DotNetOpenAuth/OpenId/Extensions/ExtensionsInteropHelper.cs index 1b58c2f..5e1003a 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/ExtensionsInteropHelper.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/ExtensionsInteropHelper.cs @@ -234,6 +234,16 @@ namespace DotNetOpenAuth.OpenId.Extensions { } /// <summary> + /// Transforms an AX attribute type URI from the axschema.org format into a given format. + /// </summary> + /// <param name="axSchemaOrgFormatTypeUri">The ax schema org format type URI.</param> + /// <param name="targetFormat">The target format. Only one flag should be set.</param> + /// <returns>The AX attribute type URI in the target format.</returns> + internal static string TransformAXFormatTestHook(string axSchemaOrgFormatTypeUri, AXAttributeFormats targetFormat) { + return TransformAXFormat(axSchemaOrgFormatTypeUri, targetFormat); + } + + /// <summary> /// Adds the AX attribute value to the response if it is non-empty. /// </summary> /// <param name="ax">The AX Fetch response to add the attribute value to.</param> diff --git a/src/DotNetOpenAuth/OpenId/IIdentifierDiscoveryService.cs b/src/DotNetOpenAuth/OpenId/IIdentifierDiscoveryService.cs index eb2bf98..fcea327 100644 --- a/src/DotNetOpenAuth/OpenId/IIdentifierDiscoveryService.cs +++ b/src/DotNetOpenAuth/OpenId/IIdentifierDiscoveryService.cs @@ -37,7 +37,13 @@ namespace DotNetOpenAuth.OpenId { /// Code contract for the <see cref="IIdentifierDiscoveryService"/> interface. /// </summary> [ContractClassFor(typeof(IIdentifierDiscoveryService))] - internal class IIdentifierDiscoveryServiceContract : IIdentifierDiscoveryService { + internal abstract class IIdentifierDiscoveryServiceContract : IIdentifierDiscoveryService { + /// <summary> + /// Prevents a default instance of the <see cref="IIdentifierDiscoveryServiceContract"/> class from being created. + /// </summary> + private IIdentifierDiscoveryServiceContract() { + } + #region IDiscoveryService Members /// <summary> diff --git a/src/DotNetOpenAuth/OpenId/Messages/IOpenIdMessageExtension.cs b/src/DotNetOpenAuth/OpenId/Messages/IOpenIdMessageExtension.cs index 57233ac..08e02ba 100644 --- a/src/DotNetOpenAuth/OpenId/Messages/IOpenIdMessageExtension.cs +++ b/src/DotNetOpenAuth/OpenId/Messages/IOpenIdMessageExtension.cs @@ -58,7 +58,7 @@ namespace DotNetOpenAuth.OpenId.Messages { /// Code contract class for the IOpenIdMessageExtension interface. /// </summary> [ContractClassFor(typeof(IOpenIdMessageExtension))] - internal class IOpenIdMessageExtensionContract : IOpenIdMessageExtension { + internal abstract class IOpenIdMessageExtensionContract : IOpenIdMessageExtension { /// <summary> /// Prevents a default instance of the <see cref="IOpenIdMessageExtensionContract"/> class from being created. /// </summary> @@ -123,7 +123,6 @@ namespace DotNetOpenAuth.OpenId.Messages { /// </remarks> Version IMessage.Version { get { - Contract.Ensures(Contract.Result<Version>() != null); throw new NotImplementedException(); } } @@ -136,7 +135,6 @@ namespace DotNetOpenAuth.OpenId.Messages { /// </remarks> IDictionary<string, string> IMessage.ExtraData { get { - Contract.Ensures(Contract.Result<IDictionary<string, string>>() != null); throw new NotImplementedException(); } } diff --git a/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs b/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs index fff4cf6..776b28b 100644 --- a/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs +++ b/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs @@ -272,6 +272,29 @@ namespace DotNetOpenAuth.OpenId.Messages { /// </list> /// </value> /// <example>2005-05-15T17:11:51ZUNIQUE</example> + internal string ResponseNonceTestHook { + get { return this.ResponseNonce; } + set { this.ResponseNonce = value; } + } + + /// <summary> + /// Gets or sets the nonce that will protect the message from replay attacks. + /// </summary> + /// <value> + /// <para>A string 255 characters or less in length, that MUST be unique to + /// this particular successful authentication response. The nonce MUST start + /// with the current time on the server, and MAY contain additional ASCII + /// characters in the range 33-126 inclusive (printable non-whitespace characters), + /// as necessary to make each response unique. The date and time MUST be + /// formatted as specified in section 5.6 of [RFC3339] + /// (Klyne, G. and C. Newman, “Date and Time on the Internet: Timestamps,” .), + /// with the following restrictions:</para> + /// <list type="bullet"> + /// <item>All times must be in the UTC timezone, indicated with a "Z".</item> + /// <item>No fractional seconds are allowed</item> + /// </list> + /// </value> + /// <example>2005-05-15T17:11:51ZUNIQUE</example> [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Called by messaging framework via reflection.")] [MessagePart("openid.response_nonce", IsRequired = true, AllowEmpty = false, RequiredProtection = ProtectionLevel.Sign, MinVersion = "2.0")] [MessagePart("openid.response_nonce", IsRequired = false, AllowEmpty = false, RequiredProtection = ProtectionLevel.None, MaxVersion = "1.1")] diff --git a/src/DotNetOpenAuth/OpenId/Provider/AnonymousRequest.cs b/src/DotNetOpenAuth/OpenId/Provider/AnonymousRequest.cs index 24f84d6..ad73269 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/AnonymousRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/AnonymousRequest.cs @@ -31,7 +31,7 @@ namespace DotNetOpenAuth.OpenId.Provider { internal AnonymousRequest(OpenIdProvider provider, SignedResponseRequest request) : base(provider, request) { Contract.Requires<ArgumentNullException>(provider != null); - Contract.Requires<ArgumentException>(!(request is CheckIdRequest), "Instantiate " + typeof(AuthenticationRequest).Name + " to handle this kind of message."); + Contract.Requires<ArgumentException>(!(request is CheckIdRequest), "Instantiate AuthenticationRequest to handle this kind of message."); this.positiveResponse = new IndirectSignedResponse(request); } diff --git a/src/DotNetOpenAuth/OpenId/Provider/AutoResponsiveRequest.cs b/src/DotNetOpenAuth/OpenId/Provider/AutoResponsiveRequest.cs index e5988dd..41e082b 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/AutoResponsiveRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/AutoResponsiveRequest.cs @@ -64,6 +64,13 @@ namespace DotNetOpenAuth.OpenId.Provider { /// <summary> /// Gets the response message, once <see cref="IsResponseReady"/> is <c>true</c>. /// </summary> + internal IProtocolMessage ResponseMessageTestHook { + get { return this.ResponseMessage; } + } + + /// <summary> + /// Gets the response message, once <see cref="IsResponseReady"/> is <c>true</c>. + /// </summary> protected override IProtocolMessage ResponseMessage { get { return this.response; } } diff --git a/src/DotNetOpenAuth/OpenId/Provider/IAuthenticationRequest.cs b/src/DotNetOpenAuth/OpenId/Provider/IAuthenticationRequest.cs index 077dcf1..f59d436 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/IAuthenticationRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/IAuthenticationRequest.cs @@ -331,6 +331,16 @@ namespace DotNetOpenAuth.OpenId.Provider { } /// <summary> + /// Removes any response extensions previously added using <see cref="IRequest.AddResponseExtension"/>. + /// </summary> + /// <remarks> + /// This should be called before sending a negative response back to the relying party + /// if extensions were already added, since negative responses cannot carry extensions. + /// </remarks> + void IRequest.ClearResponseExtensions() { + } + + /// <summary> /// Gets an extension sent from the relying party. /// </summary> /// <typeparam name="T">The type of the extension.</typeparam> diff --git a/src/DotNetOpenAuth/OpenId/Provider/IHostProcessedRequest.cs b/src/DotNetOpenAuth/OpenId/Provider/IHostProcessedRequest.cs index be809bd..1c38d4b 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/IHostProcessedRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/IHostProcessedRequest.cs @@ -146,6 +146,16 @@ namespace DotNetOpenAuth.OpenId.Provider { } /// <summary> + /// Removes any response extensions previously added using <see cref="IRequest.AddResponseExtension"/>. + /// </summary> + /// <remarks> + /// This should be called before sending a negative response back to the relying party + /// if extensions were already added, since negative responses cannot carry extensions. + /// </remarks> + void IRequest.ClearResponseExtensions() { + } + + /// <summary> /// Gets an extension sent from the relying party. /// </summary> /// <typeparam name="T">The type of the extension.</typeparam> diff --git a/src/DotNetOpenAuth/OpenId/Provider/IRequest.cs b/src/DotNetOpenAuth/OpenId/Provider/IRequest.cs index 0fcdc28..c231fa3 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/IRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/IRequest.cs @@ -45,6 +45,15 @@ namespace DotNetOpenAuth.OpenId.Provider { void AddResponseExtension(IOpenIdMessageExtension extension); /// <summary> + /// Removes any response extensions previously added using <see cref="IRequest.AddResponseExtension"/>. + /// </summary> + /// <remarks> + /// This should be called before sending a negative response back to the relying party + /// if extensions were already added, since negative responses cannot carry extensions. + /// </remarks> + void ClearResponseExtensions(); + + /// <summary> /// Gets an extension sent from the relying party. /// </summary> /// <typeparam name="T">The type of the extension.</typeparam> @@ -105,6 +114,16 @@ namespace DotNetOpenAuth.OpenId.Provider { } /// <summary> + /// Removes any response extensions previously added using <see cref="IRequest.AddResponseExtension"/>. + /// </summary> + /// <remarks> + /// This should be called before sending a negative response back to the relying party + /// if extensions were already added, since negative responses cannot carry extensions. + /// </remarks> + void IRequest.ClearResponseExtensions() { + } + + /// <summary> /// Gets an extension sent from the relying party. /// </summary> /// <typeparam name="T">The type of the extension.</typeparam> diff --git a/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs b/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs index 10c69a3..3b4cb56 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs @@ -319,7 +319,7 @@ namespace DotNetOpenAuth.OpenId.Provider { public void SendResponse(IRequest request) { Contract.Requires<InvalidOperationException>(HttpContext.Current != null, MessagingStrings.CurrentHttpContextRequired); Contract.Requires<ArgumentNullException>(request != null); - Contract.Requires<ArgumentException>(((Request)request).IsResponseReady); + Contract.Requires<ArgumentException>(request.IsResponseReady); this.ApplyBehaviorsToResponse(request); Request requestInternal = (Request)request; @@ -335,7 +335,7 @@ namespace DotNetOpenAuth.OpenId.Provider { [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Justification = "Code Contract requires that we cast early.")] public OutgoingWebResponse PrepareResponse(IRequest request) { Contract.Requires<ArgumentNullException>(request != null); - Contract.Requires<ArgumentException>(((Request)request).IsResponseReady); + Contract.Requires<ArgumentException>(request.IsResponseReady); this.ApplyBehaviorsToResponse(request); Request requestInternal = (Request)request; diff --git a/src/DotNetOpenAuth/OpenId/Provider/Request.cs b/src/DotNetOpenAuth/OpenId/Provider/Request.cs index 1c3eb86..4e54ef9 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/Request.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/Request.cs @@ -76,7 +76,7 @@ namespace DotNetOpenAuth.OpenId.Provider { this.SecuritySettings = securitySettings; } - #region IRequest Members + #region IRequest Properties /// <summary> /// Gets a value indicating whether the response is ready to be sent to the user agent. @@ -165,6 +165,17 @@ namespace DotNetOpenAuth.OpenId.Provider { } /// <summary> + /// Removes any response extensions previously added using <see cref="AddResponseExtension"/>. + /// </summary> + /// <remarks> + /// This should be called before sending a negative response back to the relying party + /// if extensions were already added, since negative responses cannot carry extensions. + /// </remarks> + public void ClearResponseExtensions() { + this.responseExtensions.Clear(); + } + + /// <summary> /// Gets an extension sent from the relying party. /// </summary> /// <typeparam name="T">The type of the extension.</typeparam> diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/AssociationManager.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/AssociationManager.cs index ac70387..1ae2726 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/AssociationManager.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/AssociationManager.cs @@ -91,6 +91,13 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } /// <summary> + /// Gets the storage to use for saving and retrieving associations. May be null. + /// </summary> + internal IAssociationStore<Uri> AssociationStoreTestHook { + get { return this.associationStore; } + } + + /// <summary> /// Gets an association between this Relying Party and a given Provider /// if it already exists in the association store. /// </summary> diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs index 09383bb..c2472e0 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs @@ -398,6 +398,16 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } /// <summary> + /// Creates the request message to send to the Provider, + /// based on the properties in this instance. + /// </summary> + /// <returns>The message to send to the Provider.</returns> + internal SignedResponseRequest CreateRequestMessageTestHook() + { + return this.CreateRequestMessage(); + } + + /// <summary> /// Performs deferred request generation for the <see cref="Create"/> method. /// </summary> /// <param name="userSuppliedIdentifier">The user supplied identifier.</param> diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/IRelyingPartyBehavior.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/IRelyingPartyBehavior.cs index 300a15f..1bfa0db 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/IRelyingPartyBehavior.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/IRelyingPartyBehavior.cs @@ -45,11 +45,11 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// Contract class for the <see cref="IRelyingPartyBehavior"/> interface. /// </summary> [ContractClassFor(typeof(IRelyingPartyBehavior))] - internal class IRelyingPartyBehaviorContract : IRelyingPartyBehavior { + internal abstract class IRelyingPartyBehaviorContract : IRelyingPartyBehavior { /// <summary> - /// Initializes a new instance of the <see cref="IRelyingPartyBehaviorContract"/> class. + /// Prevents a default instance of the <see cref="IRelyingPartyBehaviorContract"/> class from being created. /// </summary> - protected IRelyingPartyBehaviorContract() { + private IRelyingPartyBehaviorContract() { } #region IRelyingPartyBehavior Members diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdLogin.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdLogin.cs index 4aa78a5..5128599 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdLogin.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdLogin.cs @@ -681,10 +681,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); - EnsureChildControls(); - EnsureID(); - this.requiredValidator.ControlToValidate = this.ID; - this.identifierFormatValidator.ControlToValidate = this.ID; + this.EnsureChildControls(); } /// <summary> @@ -726,7 +723,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { cell = new TableCell(); try { this.loginButton = new Button(); - this.loginButton.ID = "loginButton"; + this.loginButton.ID = this.ID + "_loginButton"; this.loginButton.Text = ButtonTextDefault; this.loginButton.ToolTip = ButtonToolTipDefault; this.loginButton.Click += this.LoginButton_Click; @@ -839,6 +836,16 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } /// <summary> + /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event. + /// </summary> + /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> + protected override void OnInit(EventArgs e) { + this.SetChildControlReferenceIds(); + + base.OnInit(e); + } + + /// <summary> /// Renders the child controls. /// </summary> /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter"/> object that receives the rendered content.</param> @@ -945,6 +952,19 @@ idselector_input_id = '" + this.ClientID + @"'; } /// <summary> + /// Sets child control properties that depend on this control's ID. + /// </summary> + private void SetChildControlReferenceIds() { + this.EnsureChildControls(); + this.EnsureID(); + ErrorUtilities.VerifyInternal(!string.IsNullOrEmpty(this.ID), "No control ID available yet!"); + this.requiredValidator.ControlToValidate = this.ID; + this.requiredValidator.ID = this.ID + "_requiredValidator"; + this.identifierFormatValidator.ControlToValidate = this.ID; + this.identifierFormatValidator.ID = this.ID + "_identifierFormatValidator"; + } + + /// <summary> /// A control that acts as a placeholder to indicate where /// the OpenIdLogin control should render its OpenIdTextBox parent. /// </summary> diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs index a416f3a..a5fdf9b 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs @@ -800,8 +800,13 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { // so we have to actually put the test for it ABOVE the call to objSrc.{0} so that it already // whether to call window.self.close() after the call. string htmlFormat = @" if (inPopup) {{ - objSrc.{0}; - window.self.close(); + try {{ + objSrc.{0}; + }} catch (ex) {{ + alert(ex); + }} finally {{ + window.self.close(); + }} }} else {{ objSrc.{0}; }}"; diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs index 5090ecd..380417f 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs @@ -914,16 +914,22 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { // Approximate the returnTo (either based on the customize property or the page URL) // so we can use it to help with Realm resolution. - Uri returnToApproximation = this.ReturnToUrl != null ? new Uri(this.RelyingParty.Channel.GetRequestFromContext().UrlBeforeRewriting, this.ReturnToUrl) : this.Page.Request.Url; + Uri returnToApproximation; + if (this.ReturnToUrl != null) { + string returnToResolvedPath = this.ResolveUrl(this.ReturnToUrl); + returnToApproximation = new Uri(this.RelyingParty.Channel.GetRequestFromContext().UrlBeforeRewriting, returnToResolvedPath); + } else { + returnToApproximation = this.Page.Request.Url; + } // Resolve the trust root, and swap out the scheme and port if necessary to match the - // return_to URL, since this match is required by OpenId, and the consumer app + // return_to URL, since this match is required by OpenID, and the consumer app // may be using HTTP at some times and HTTPS at others. UriBuilder realm = OpenIdUtilities.GetResolvedRealm(this.Page, this.RealmUrl, this.RelyingParty.Channel.GetRequestFromContext()); realm.Scheme = returnToApproximation.Scheme; realm.Port = returnToApproximation.Port; - // Initiate openid request + // Initiate OpenID request // We use TryParse here to avoid throwing an exception which // might slip through our validator control if it is disabled. Realm typedRealm = new Realm(realm); diff --git a/src/DotNetOpenAuth/OpenId/UriIdentifier.cs b/src/DotNetOpenAuth/OpenId/UriIdentifier.cs index 639ff57..48ed7f2 100644 --- a/src/DotNetOpenAuth/OpenId/UriIdentifier.cs +++ b/src/DotNetOpenAuth/OpenId/UriIdentifier.cs @@ -156,6 +156,16 @@ namespace DotNetOpenAuth.OpenId { } /// <summary> + /// Gets or sets a value indicating whether scheme substitution is being used to workaround + /// .NET path compression that invalidates some OpenIDs that have trailing periods + /// in one of their path segments. + /// </summary> + internal static bool SchemeSubstitutionTestHook { + get { return schemeSubstitution; } + set { schemeSubstitution = value; } + } + + /// <summary> /// Gets the URI this instance represents. /// </summary> internal Uri Uri { get; private set; } @@ -415,18 +425,9 @@ namespace DotNetOpenAuth.OpenId { private static bool TryCanonicalize(string uri, out Uri canonicalUri, bool forceHttpsDefaultScheme, out bool schemePrepended) { Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(uri)); - uri = uri.Trim(); canonicalUri = null; - schemePrepended = false; try { - // Assume http:// scheme if an allowed scheme isn't given, and strip - // fragments off. Consistent with spec section 7.2#3 - if (!IsAllowedScheme(uri)) { - uri = (forceHttpsDefaultScheme ? Uri.UriSchemeHttps : Uri.UriSchemeHttp) + - Uri.SchemeDelimiter + uri; - schemePrepended = true; - } - + uri = DoSimpleCanonicalize(uri, forceHttpsDefaultScheme, out schemePrepended); if (schemeSubstitution) { uri = NormalSchemeToSpecialRoundTrippingScheme(uri); } @@ -435,6 +436,7 @@ namespace DotNetOpenAuth.OpenId { return TryCanonicalize(uri, out canonicalUri); } catch (UriFormatException) { // We try not to land here with checks in the try block, but just in case. + schemePrepended = false; return false; } } @@ -442,7 +444,7 @@ namespace DotNetOpenAuth.OpenId { /// <summary> /// Fixes up the scheme if appropriate. /// </summary> - /// <param name="uri">The URI to canonicalize.</param> + /// <param name="uri">The URI, already in legal form (with http(s):// prepended if necessary).</param> /// <param name="canonicalUri">The resulting canonical URI.</param> /// <returns><c>true</c> if the canonicalization was successful; <c>false</c> otherwise.</returns> /// <remarks> @@ -494,6 +496,30 @@ namespace DotNetOpenAuth.OpenId { return delimiterIndex < 0 ? nonCompressingScheme : nonCompressingScheme + normal.Substring(delimiterIndex); } + /// <summary> + /// Performs the minimal URL normalization to allow a string to be passed to the <see cref="Uri"/> constructor. + /// </summary> + /// <param name="uri">The user-supplied identifier URI to normalize.</param> + /// <param name="forceHttpsDefaultScheme">if set to <c>true</c>, a missing scheme should result in HTTPS being prepended instead of HTTP.</param> + /// <param name="schemePrepended">if set to <c>true</c>, the scheme was prepended during normalization.</param> + /// <returns>The somewhat normalized URL.</returns> + private static string DoSimpleCanonicalize(string uri, bool forceHttpsDefaultScheme, out bool schemePrepended) { + Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(uri)); + + schemePrepended = false; + uri = uri.Trim(); + + // Assume http:// scheme if an allowed scheme isn't given, and strip + // fragments off. Consistent with spec section 7.2#3 + if (!IsAllowedScheme(uri)) { + uri = (forceHttpsDefaultScheme ? Uri.UriSchemeHttps : Uri.UriSchemeHttp) + + Uri.SchemeDelimiter + uri; + schemePrepended = true; + } + + return uri; + } + #if CONTRACTS_FULL /// <summary> /// Verifies conditions that should be true for any valid state of this object. @@ -523,6 +549,9 @@ namespace DotNetOpenAuth.OpenId { internal SimpleUri(string value) { Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(value)); + bool schemePrepended; + value = DoSimpleCanonicalize(value, false, out schemePrepended); + // Leverage the Uri class's parsing where we can. Uri uri = new Uri(value); this.Scheme = uri.Scheme; |