summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-12-23 13:09:32 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2010-12-23 13:09:32 -0800
commit45775797c5f50dc56370c75c3244ea0e83ab4832 (patch)
tree92b067e463370751e7c35ad626062b9d641842fc /src
parent5c38b4c0564f75a845678005c474df2073113ce7 (diff)
parent1b87e9b8d74afe71b70d842ee435523e7f1aad46 (diff)
downloadDotNetOpenAuth-45775797c5f50dc56370c75c3244ea0e83ab4832.zip
DotNetOpenAuth-45775797c5f50dc56370c75c3244ea0e83ab4832.tar.gz
DotNetOpenAuth-45775797c5f50dc56370c75c3244ea0e83ab4832.tar.bz2
Merge branch 'v3.4' into oauth2
Conflicts: samples/OAuthServiceProvider/Code/DatabaseTokenManager.cs samples/OAuthServiceProvider/Code/OAuthToken.cs src/DotNetOpenAuth/Messaging/MessagingStrings.resx
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth.BuildTasks/AddFilesTo7Zip.cs105
-rw-r--r--src/DotNetOpenAuth.BuildTasks/ChangeProjectReferenceToAssemblyReference.cs2
-rw-r--r--src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj13
-rw-r--r--src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln17
-rw-r--r--src/DotNetOpenAuth.BuildTasks/NuGetPack.cs108
-rw-r--r--src/DotNetOpenAuth.BuildTasks/ReSignDelaySignedAssemblies.cs2
-rw-r--r--src/DotNetOpenAuth.BuildTasks/TaskStrings.Designer.cs4
-rw-r--r--src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj1
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs2
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs2
-rw-r--r--src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs2
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/Extensions/SimpleRegistration/ClaimsResponseTests.cs12
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshotTests.cs6
-rw-r--r--src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd19
-rw-r--r--src/DotNetOpenAuth/Configuration/DotNetOpenAuthSection.cs14
-rw-r--r--src/DotNetOpenAuth/DotNetOpenAuth.csproj1
-rw-r--r--src/DotNetOpenAuth/IEmbeddedResourceRetrieval.cs22
-rw-r--r--src/DotNetOpenAuth/Messaging/Channel.cs27
-rw-r--r--src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs9
-rw-r--r--src/DotNetOpenAuth/Messaging/MessagingStrings.resx5
-rw-r--r--src/DotNetOpenAuth/Messaging/MessagingUtilities.cs6
-rw-r--r--src/DotNetOpenAuth/Mvc/OpenIdHelper.cs79
-rw-r--r--src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs10
-rw-r--r--src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs4
-rw-r--r--src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Constants.cs8
-rw-r--r--src/DotNetOpenAuth/OpenId/Interop/AuthenticationResponseShim.cs7
-rw-r--r--src/DotNetOpenAuth/Reporting.cs9
-rw-r--r--src/DotNetOpenAuth/Strings.Designer.cs11
-rw-r--r--src/DotNetOpenAuth/Strings.resx5
-rw-r--r--src/DotNetOpenAuth/Util.cs35
-rw-r--r--src/DotNetOpenAuth/Yadis/Yadis.cs19
31 files changed, 479 insertions, 87 deletions
diff --git a/src/DotNetOpenAuth.BuildTasks/AddFilesTo7Zip.cs b/src/DotNetOpenAuth.BuildTasks/AddFilesTo7Zip.cs
new file mode 100644
index 0000000..8bf3e16
--- /dev/null
+++ b/src/DotNetOpenAuth.BuildTasks/AddFilesTo7Zip.cs
@@ -0,0 +1,105 @@
+//-----------------------------------------------------------------------
+// <copyright file="AddFilesTo7Zip.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.BuildTasks {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using Microsoft.Build.Utilities;
+ using Microsoft.Build.Framework;
+
+ public class AddFilesTo7Zip : ToolTask {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AddFilesTo7Zip"/> class.
+ /// </summary>
+ public AddFilesTo7Zip() {
+ this.YieldDuringToolExecution = true;
+ }
+
+ [Required]
+ public ITaskItem ZipFileName { get; set; }
+
+ [Required]
+ public ITaskItem[] Files { get; set; }
+
+ public string WorkingDirectory { get; set; }
+
+ /// <summary>
+ /// Gets the name of the tool.
+ /// </summary>
+ /// <value>
+ /// The name of the tool.
+ /// </value>
+ protected override string ToolName {
+ get { return "7za.exe"; }
+ }
+
+ /// <summary>
+ /// Generates the full path to tool.
+ /// </summary>
+ protected override string GenerateFullPathToTool() {
+ return this.ToolPath;
+ }
+
+ protected override string GenerateCommandLineCommands() {
+ var args = new CommandLineBuilder();
+
+ args.AppendSwitch("a");
+ args.AppendSwitch("--");
+
+ args.AppendFileNameIfNotNull(this.ZipFileName);
+
+ return args.ToString();
+ }
+
+ /// <summary>
+ /// Gets the response file switch.
+ /// </summary>
+ /// <param name="responseFilePath">The response file path.</param>
+ protected override string GetResponseFileSwitch(string responseFilePath) {
+ return "@" + responseFilePath;
+ }
+
+ /// <summary>
+ /// Gets the response file encoding.
+ /// </summary>
+ /// <value>
+ /// The response file encoding.
+ /// </value>
+ protected override Encoding ResponseFileEncoding {
+ get { return Encoding.UTF8; }
+ }
+
+ /// <summary>
+ /// Generates the response file commands.
+ /// </summary>
+ protected override string GenerateResponseFileCommands() {
+ var args = new CommandLineBuilder();
+ args.AppendFileNamesIfNotNull(this.Files.Select(GetWorkingDirectoryRelativePath).ToArray(), Environment.NewLine);
+ return args.ToString();
+ }
+
+ /// <summary>
+ /// Gets the working directory.
+ /// </summary>
+ protected override string GetWorkingDirectory() {
+ if (!String.IsNullOrEmpty(this.WorkingDirectory)) {
+ return this.WorkingDirectory;
+ } else {
+ return base.GetWorkingDirectory();
+ }
+ }
+
+ private string GetWorkingDirectoryRelativePath(ITaskItem taskItem) {
+ if (taskItem.ItemSpec.StartsWith(this.WorkingDirectory, StringComparison.OrdinalIgnoreCase)) {
+ return taskItem.ItemSpec.Substring(this.WorkingDirectory.Length);
+ } else {
+ return taskItem.ItemSpec;
+ }
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth.BuildTasks/ChangeProjectReferenceToAssemblyReference.cs b/src/DotNetOpenAuth.BuildTasks/ChangeProjectReferenceToAssemblyReference.cs
index 503e168..fb42ade 100644
--- a/src/DotNetOpenAuth.BuildTasks/ChangeProjectReferenceToAssemblyReference.cs
+++ b/src/DotNetOpenAuth.BuildTasks/ChangeProjectReferenceToAssemblyReference.cs
@@ -38,7 +38,7 @@
foreach (var project in Projects) {
Project doc = new Project();
- doc.Load(project.ItemSpec);
+ doc.Load(project.ItemSpec, ProjectLoadSettings.IgnoreMissingImports);
var projectReferences = doc.EvaluatedItems.OfType<BuildItem>().Where(item => item.Name == "ProjectReference");
var matchingReferences = from reference in projectReferences
diff --git a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
index 179c825..310ee9d 100644
--- a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
+++ b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
@@ -11,7 +11,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DotNetOpenAuth.BuildTasks</RootNamespace>
<AssemblyName>DotNetOpenAuth.BuildTasks</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
@@ -29,6 +29,7 @@
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<CodeContractsAssemblyMode>1</CodeContractsAssemblyMode>
+ <TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -78,14 +79,10 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="Microsoft.Build" />
<Reference Include="Microsoft.Build.Engine" />
<Reference Include="Microsoft.Build.Framework" />
- <Reference Include="Microsoft.Build.Utilities.v3.5">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="Microsoft.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=736440c9b414ea16, processorArchitecture=MSIL">
- <Private>False</Private>
- </Reference>
+ <Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SystemRoot)\System32\inetsrv\Microsoft.Web.Administration.dll</HintPath>
@@ -101,6 +98,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="AddFilesTo7Zip.cs" />
<Compile Include="AddProjectItems.cs" />
<Compile Include="ChangeProjectReferenceToAssemblyReference.cs" />
<Compile Include="CompareFiles.cs" />
@@ -120,6 +118,7 @@
<Compile Include="CheckAdminRights.cs" />
<Compile Include="JsPack.cs" />
<Compile Include="NativeMethods.cs" />
+ <Compile Include="NuGetPack.cs" />
<Compile Include="ParseMaster.cs" />
<Compile Include="PathSegment.cs" />
<Compile Include="PrepareOhlohRelease.cs" />
diff --git a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
index a144f1c..5c2ffbb 100644
--- a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
+++ b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
@@ -9,12 +9,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\..\tools\DotNetOpenAuth.automated.targets = ..\..\tools\DotNetOpenAuth.automated.targets
..\..\lib\DotNetOpenAuth.BuildTasks.targets = ..\..\lib\DotNetOpenAuth.BuildTasks.targets
..\..\tools\DotNetOpenAuth.Common.Settings.targets = ..\..\tools\DotNetOpenAuth.Common.Settings.targets
+ ..\..\nuget\DotNetOpenAuth.nuspec = ..\..\nuget\DotNetOpenAuth.nuspec
..\..\tools\DotNetOpenAuth.props = ..\..\tools\DotNetOpenAuth.props
..\..\tools\DotNetOpenAuth.targets = ..\..\tools\DotNetOpenAuth.targets
..\..\tools\DotNetOpenAuth.Versioning.targets = ..\..\tools\DotNetOpenAuth.Versioning.targets
..\..\tools\drop.proj = ..\..\tools\drop.proj
..\..\EnlistmentInfo.props = ..\..\EnlistmentInfo.props
..\..\EnlistmentInfo.targets = ..\..\EnlistmentInfo.targets
+ ..\..\nuget\nuget.proj = ..\..\nuget\nuget.proj
..\..\tools\ohloh.proj = ..\..\tools\ohloh.proj
..\..\projecttemplates\projecttemplates.proj = ..\..\projecttemplates\projecttemplates.proj
..\..\samples\Samples.proj = ..\..\samples\Samples.proj
@@ -25,6 +27,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetOpenAuth.BuildTasks", "DotNetOpenAuth.BuildTasks.csproj", "{AC231A51-EF60-437C-A33F-AF8ADEB8EB74}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{D49E2011-0E1C-4AB5-9887-BD1D42266503}"
+ ProjectSection(SolutionItems) = preProject
+ ..\..\nuget\DotNetOpenAuth.nuspec = ..\..\nuget\DotNetOpenAuth.nuspec
+ ..\..\nuget\nuget.proj = ..\..\nuget\nuget.proj
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{BF3868D6-3BBA-4E40-B180-213370C15494}"
+ ProjectSection(SolutionItems) = preProject
+ ..\..\nuget\content\web.config.transform = ..\..\nuget\content\web.config.transform
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,4 +52,8 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {D49E2011-0E1C-4AB5-9887-BD1D42266503} = {ABBE14A3-0404-4123-9093-E598C3DD3E9B}
+ {BF3868D6-3BBA-4E40-B180-213370C15494} = {D49E2011-0E1C-4AB5-9887-BD1D42266503}
+ EndGlobalSection
EndGlobal
diff --git a/src/DotNetOpenAuth.BuildTasks/NuGetPack.cs b/src/DotNetOpenAuth.BuildTasks/NuGetPack.cs
new file mode 100644
index 0000000..356c51f
--- /dev/null
+++ b/src/DotNetOpenAuth.BuildTasks/NuGetPack.cs
@@ -0,0 +1,108 @@
+//-----------------------------------------------------------------------
+// <copyright file="NuGetPack.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.BuildTasks {
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Text;
+ using System.Xml.Linq;
+ using Microsoft.Build.Framework;
+ using Microsoft.Build.Utilities;
+
+ /// <summary>
+ /// Creates a .nupkg archive from a .nuspec file and content files.
+ /// </summary>
+ public class NuGetPack : ToolTask {
+ /// <summary>
+ /// Gets or sets the path to the .nuspec file.
+ /// </summary>
+ [Required]
+ public ITaskItem NuSpec { get; set; }
+
+ /// <summary>
+ /// Gets or sets the base directory, the contents of which gets included in the .nupkg archive.
+ /// </summary>
+ public ITaskItem BaseDirectory { get; set; }
+
+ /// <summary>
+ /// Gets or sets the path to the directory that will contain the generated .nupkg archive.
+ /// </summary>
+ public ITaskItem OutputPackageDirectory { get; set; }
+
+ /// <summary>
+ /// Returns the fully qualified path to the executable file.
+ /// </summary>
+ /// <returns>
+ /// The fully qualified path to the executable file.
+ /// </returns>
+ protected override string GenerateFullPathToTool() {
+ return this.ToolPath;
+ }
+
+ /// <summary>
+ /// Gets the name of the executable file to run.
+ /// </summary>
+ /// <returns>The name of the executable file to run.</returns>
+ protected override string ToolName {
+ get { return "NuGet.exe"; }
+ }
+
+ /// <summary>
+ /// Runs the exectuable file with the specified task parameters.
+ /// </summary>
+ /// <returns>
+ /// true if the task runs successfully; otherwise, false.
+ /// </returns>
+ public override bool Execute() {
+ if (this.OutputPackageDirectory != null && Path.GetDirectoryName(this.OutputPackageDirectory.ItemSpec).Length > 0) {
+ Directory.CreateDirectory(Path.GetDirectoryName(this.OutputPackageDirectory.ItemSpec));
+ }
+
+ string fullPackagePath = this.DeriveFullPackagePath();
+ this.Log.LogMessage("Creating NuGet package '{0}'.", fullPackagePath);
+
+ bool result = base.Execute();
+
+ if (result) {
+ this.Log.LogMessage(MessageImportance.High, "Successfully created package '{0}'.", fullPackagePath);
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// Returns a string value containing the command line arguments to pass directly to the executable file.
+ /// </summary>
+ /// <returns>
+ /// A string value containing the command line arguments to pass directly to the executable file.
+ /// </returns>
+ protected override string GenerateCommandLineCommands() {
+ var args = new CommandLineBuilder();
+
+ args.AppendSwitch("pack");
+ args.AppendFileNameIfNotNull(this.NuSpec);
+ args.AppendSwitchIfNotNull("-b ", this.BaseDirectory);
+ args.AppendSwitchIfNotNull("-o ", this.OutputPackageDirectory);
+
+ return args.ToString();
+ }
+
+ /// <summary>
+ /// Derives the path to the generated .nupkg file.
+ /// </summary>
+ /// <returns>A relative path.</returns>
+ private string DeriveFullPackagePath() {
+ var spec = XDocument.Load(this.NuSpec.ItemSpec);
+ var metadata = spec.Element("package").Element("metadata");
+ string id = metadata.Element("id").Value;
+ string version = metadata.Element("version").Value;
+ string baseDirectory = this.OutputPackageDirectory != null ? this.OutputPackageDirectory.ItemSpec : String.Empty;
+ return Path.Combine(baseDirectory, String.Format("{0}.{1}.nupkg", id, version));
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth.BuildTasks/ReSignDelaySignedAssemblies.cs b/src/DotNetOpenAuth.BuildTasks/ReSignDelaySignedAssemblies.cs
index a0ba386..2bcc160 100644
--- a/src/DotNetOpenAuth.BuildTasks/ReSignDelaySignedAssemblies.cs
+++ b/src/DotNetOpenAuth.BuildTasks/ReSignDelaySignedAssemblies.cs
@@ -32,7 +32,7 @@ namespace DotNetOpenAuth.BuildTasks {
////if (this.Assemblies.Length != 1) {
//// throw new NotSupportedException("Exactly 1 assembly for signing is supported.");
////}
- CommandLineBuilder args = new CommandLineBuilder();
+ var args = new CommandLineBuilder();
args.AppendSwitch("-q");
if (this.KeyFile != null) {
diff --git a/src/DotNetOpenAuth.BuildTasks/TaskStrings.Designer.cs b/src/DotNetOpenAuth.BuildTasks/TaskStrings.Designer.cs
index 17647fd..d5a80a4 100644
--- a/src/DotNetOpenAuth.BuildTasks/TaskStrings.Designer.cs
+++ b/src/DotNetOpenAuth.BuildTasks/TaskStrings.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.4927
+// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -19,7 +19,7 @@ namespace DotNetOpenAuth.BuildTasks {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class TaskStrings {
diff --git a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj
index f4d0bb3..c463e19 100644
--- a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj
+++ b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj
@@ -153,7 +153,6 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net" />
- <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
<Reference Include="Moq" />
<Reference Include="NUnit.Framework" />
<Reference Include="System" />
diff --git a/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs b/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs
index 5d31d40..acb200f 100644
--- a/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs
@@ -77,6 +77,8 @@ namespace DotNetOpenAuth.Test.Messaging {
OutgoingWebResponse response = this.Channel.PrepareResponse(message);
Assert.AreEqual(HttpStatusCode.Redirect, response.Status);
+ Assert.AreEqual("text/html; charset=utf-8", response.Headers[HttpResponseHeader.ContentType]);
+ Assert.IsTrue(response.Body != null && response.Body.Length > 0); // a non-empty body helps get passed filters like WebSense
StringAssert.StartsWith("http://provider/path", response.Headers[HttpResponseHeader.Location]);
foreach (var pair in expected) {
string key = MessagingUtilities.EscapeUriDataStringRfc3986(pair.Key);
diff --git a/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs b/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
index 2c2da64..79751ae 100644
--- a/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
@@ -270,7 +270,7 @@ namespace DotNetOpenAuth.Test.Messaging {
}
almostMatchTimer.Stop();
- const double ToleranceFactor = 0.06;
+ const double ToleranceFactor = 0.12;
long averageTimeTicks = (totalMismatchTimer.ElapsedTicks + almostMatchTimer.ElapsedTicks) / 2;
var tolerableDifference = TimeSpan.FromTicks((long)(averageTimeTicks * ToleranceFactor));
var absoluteDifference = TimeSpan.FromTicks(Math.Abs(totalMismatchTimer.ElapsedTicks - almostMatchTimer.ElapsedTicks));
diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs
index 54ed37e..479375a 100644
--- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs
+++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs
@@ -125,7 +125,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements {
OutgoingWebResponse response = this.channel.PrepareResponse(message);
Assert.AreSame(message, response.OriginalMessage);
Assert.AreEqual(HttpStatusCode.OK, response.Status);
- Assert.AreEqual(0, response.Headers.Count);
+ Assert.AreEqual(2, response.Headers.Count);
NameValueCollection body = HttpUtility.ParseQueryString(response.Body);
Assert.AreEqual("15", body["age"]);
diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/SimpleRegistration/ClaimsResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/SimpleRegistration/ClaimsResponseTests.cs
index 0bdc36e..69bb935 100644
--- a/src/DotNetOpenAuth.Test/OpenId/Extensions/SimpleRegistration/ClaimsResponseTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/SimpleRegistration/ClaimsResponseTests.cs
@@ -11,6 +11,7 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions {
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Xml.Serialization;
+ using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration;
using NUnit.Framework;
@@ -130,6 +131,17 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions {
response.BirthDateRaw = "2008";
}
+ [TestCase]
+ public void ResponseAlternateTypeUriTests() {
+ var request = new ClaimsRequest(Constants.sreg_ns10);
+ request.Email = DemandLevel.Require;
+
+ var response = new ClaimsResponse(Constants.sreg_ns10);
+ response.Email = "a@b.com";
+
+ ExtensionTestUtilities.Roundtrip(Protocol.Default, new[] { request }, new[] { response });
+ }
+
private ClaimsResponse GetFilledData() {
return new ClaimsResponse(Constants.sreg_ns) {
BirthDate = new DateTime(2005, 2, 3),
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshotTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshotTests.cs
index e069c44..0bb994c 100644
--- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshotTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshotTests.cs
@@ -12,16 +12,16 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.Messages;
using DotNetOpenAuth.OpenId.RelyingParty;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
+ using NUnit.Framework;
- [TestClass]
+ [TestFixture]
public class PositiveAuthenticationResponseSnapshotTests : OpenIdTestBase {
/// <summary>
/// Verifies that the PositiveAuthenticationResponseSnapshot is serializable,
/// as required by the <see cref="OpenIdRelyingPartyAjaxControlBase"/> class.
/// </summary>
- [TestMethod]
+ [Test]
public void Serializable() {
var response = new Mock<IAuthenticationResponse>(MockBehavior.Strict);
response.Setup(o => o.ClaimedIdentifier).Returns(VanityUri);
diff --git a/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd b/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd
index 1e20747..626fed3 100644
--- a/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd
+++ b/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd
@@ -886,6 +886,25 @@
</xs:attribute>
</xs:complexType>
</xs:element>
+ <xs:element name="webResourceUrlProvider">
+ <xs:annotation>
+ <xs:documentation>
+ The type that implements the DotNetOpenAuth.IEmbeddedResourceRetrieval interface
+ to instantiate for obtaining URLs that fetch embedded resource streams.
+ Primarily useful when the System.Web.UI.Page class is not used in the ASP.NET pipeline.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attribute name="type" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ The fully-qualified name of the type that implements the IEmbeddedResourceRetrieval interface.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="xaml" type="xs:string" use="optional" />
+ </xs:complexType>
+ </xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
diff --git a/src/DotNetOpenAuth/Configuration/DotNetOpenAuthSection.cs b/src/DotNetOpenAuth/Configuration/DotNetOpenAuthSection.cs
index 117a542..409fca9 100644
--- a/src/DotNetOpenAuth/Configuration/DotNetOpenAuthSection.cs
+++ b/src/DotNetOpenAuth/Configuration/DotNetOpenAuthSection.cs
@@ -40,6 +40,11 @@ namespace DotNetOpenAuth.Configuration {
private const string ReportingElementName = "reporting";
/// <summary>
+ /// The name of the &lt;webResourceUrlProvider&gt; sub-element.
+ /// </summary>
+ private const string WebResourceUrlProviderName = "webResourceUrlProvider";
+
+ /// <summary>
/// Initializes a new instance of the <see cref="DotNetOpenAuthSection"/> class.
/// </summary>
internal DotNetOpenAuthSection() {
@@ -116,5 +121,14 @@ namespace DotNetOpenAuth.Configuration {
this[ReportingElementName] = value;
}
}
+
+ /// <summary>
+ /// Gets or sets the type to use for obtaining URLs that fetch embedded resource streams.
+ /// </summary>
+ [ConfigurationProperty(WebResourceUrlProviderName)]
+ internal TypeConfigurationElement<IEmbeddedResourceRetrieval> EmbeddedResourceRetrievalProvider {
+ get { return (TypeConfigurationElement<IEmbeddedResourceRetrieval>)this[WebResourceUrlProviderName] ?? new TypeConfigurationElement<IEmbeddedResourceRetrieval>(); }
+ set { this[WebResourceUrlProviderName] = value; }
+ }
}
}
diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
index 09623f4..aa90551 100644
--- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj
+++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
@@ -302,6 +302,7 @@ http://opensource.org/licenses/ms-pl.html
<Compile Include="Configuration\HostNameOrRegexCollection.cs" />
<Compile Include="Configuration\HostNameElement.cs" />
<Compile Include="Configuration\XriResolverElement.cs" />
+ <Compile Include="IEmbeddedResourceRetrieval.cs" />
<Compile Include="InfoCard\ClaimType.cs" />
<Compile Include="InfoCard\InfoCardImage.cs" />
<Compile Include="InfoCard\InfoCardStrings.Designer.cs">
diff --git a/src/DotNetOpenAuth/IEmbeddedResourceRetrieval.cs b/src/DotNetOpenAuth/IEmbeddedResourceRetrieval.cs
new file mode 100644
index 0000000..b9a6fd0
--- /dev/null
+++ b/src/DotNetOpenAuth/IEmbeddedResourceRetrieval.cs
@@ -0,0 +1,22 @@
+//-----------------------------------------------------------------------
+// <copyright file="IEmbeddedResourceRetrieval.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth {
+ using System;
+
+ /// <summary>
+ /// An interface that provides URLs from which embedded resources can be obtained.
+ /// </summary>
+ public interface IEmbeddedResourceRetrieval {
+ /// <summary>
+ /// Gets the URL from which the given manifest resource may be downloaded by the user agent.
+ /// </summary>
+ /// <param name="someTypeInResourceAssembly">Some type in the assembly containing the desired resource.</param>
+ /// <param name="manifestResourceName">Manifest name of the desired resource.</param>
+ /// <returns>An absolute URL.</returns>
+ Uri GetWebResourceUrl(Type someTypeInResourceAssembly, string manifestResourceName);
+ }
+}
diff --git a/src/DotNetOpenAuth/Messaging/Channel.cs b/src/DotNetOpenAuth/Messaging/Channel.cs
index f168f6f..800d49d 100644
--- a/src/DotNetOpenAuth/Messaging/Channel.cs
+++ b/src/DotNetOpenAuth/Messaging/Channel.cs
@@ -67,6 +67,14 @@ namespace DotNetOpenAuth.Messaging {
private const int IndirectMessageGetToPostThreshold = 2 * 1024; // 2KB, recommended by OpenID group
/// <summary>
+ /// The HTML that should be returned to the user agent as part of a 301 Redirect.
+ /// </summary>
+ /// <value>A string that should be used as the first argument to String.Format, where the {0} should be replaced with the URL to redirect to.</value>
+ private const string RedirectResponseBodyFormat = @"<html><head><title>Object moved</title></head><body>
+<h2>Object moved to <a href=""{0}"">here</a>.</h2>
+</body></html>";
+
+ /// <summary>
/// A list of binding elements in the order they must be applied to outgoing messages.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
@@ -286,10 +294,12 @@ namespace DotNetOpenAuth.Messaging {
this.ProcessOutgoingMessage(message);
Logger.Channel.DebugFormat("Sending message: {0}", message.GetType().Name);
+ OutgoingWebResponse result;
switch (message.Transport) {
case MessageTransport.Direct:
// This is a response to a direct message.
- return this.PrepareDirectResponse(message);
+ result = this.PrepareDirectResponse(message);
+ break;
case MessageTransport.Indirect:
var directedMessage = message as IDirectedProtocolMessage;
ErrorUtilities.VerifyArgumentNamed(
@@ -301,7 +311,8 @@ namespace DotNetOpenAuth.Messaging {
directedMessage.Recipient != null,
"message",
MessagingStrings.DirectedMessageMissingRecipient);
- return this.PrepareIndirectResponse(directedMessage);
+ result = this.PrepareIndirectResponse(directedMessage);
+ break;
default:
throw ErrorUtilities.ThrowArgumentNamed(
"message",
@@ -309,6 +320,13 @@ namespace DotNetOpenAuth.Messaging {
"Transport",
message.Transport);
}
+
+ // Apply caching policy to any response. We want to disable all caching because in auth* protocols,
+ // caching can be utilized in identity spoofing attacks.
+ result.Headers[HttpResponseHeader.CacheControl] = "no-cache, no-store, max-age=0, must-revalidate";
+ result.Headers[HttpResponseHeader.Pragma] = "no-cache";
+
+ return result;
}
/// <summary>
@@ -782,6 +800,8 @@ namespace DotNetOpenAuth.Messaging {
Contract.Requires<ArgumentNullException>(fields != null);
Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
+ // As part of this redirect, we include an HTML body in order to get passed some proxy filters
+ // such as WebSense.
WebHeaderCollection headers = new WebHeaderCollection();
UriBuilder builder = new UriBuilder(message.Recipient);
if (payloadInFragment) {
@@ -791,11 +811,12 @@ namespace DotNetOpenAuth.Messaging {
}
headers.Add(HttpResponseHeader.Location, builder.Uri.AbsoluteUri);
+ headers.Add(HttpResponseHeader.ContentType, "text/html; charset=utf-8");
Logger.Http.DebugFormat("Redirecting to {0}", builder.Uri.AbsoluteUri);
OutgoingWebResponse response = new OutgoingWebResponse {
Status = HttpStatusCode.Redirect,
Headers = headers,
- Body = null,
+ Body = string.Format(CultureInfo.InvariantCulture, RedirectResponseBodyFormat, builder.Uri.AbsoluteUri),
OriginalMessage = message
};
diff --git a/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs b/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs
index 235e558..11bd751 100644
--- a/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs
+++ b/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs
@@ -196,6 +196,15 @@ namespace DotNetOpenAuth.Messaging {
}
/// <summary>
+ /// Looks up a localized string similar to Failed to add extra parameter &apos;{0}&apos; with value &apos;{1}&apos;..
+ /// </summary>
+ internal static string ExtraParameterAddFailure {
+ get {
+ return ResourceManager.GetString("ExtraParameterAddFailure", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to At least one of GET or POST flags must be present..
/// </summary>
internal static string GetOrPostFlagsRequired {
diff --git a/src/DotNetOpenAuth/Messaging/MessagingStrings.resx b/src/DotNetOpenAuth/Messaging/MessagingStrings.resx
index fdeb756..bd10b76 100644
--- a/src/DotNetOpenAuth/Messaging/MessagingStrings.resx
+++ b/src/DotNetOpenAuth/Messaging/MessagingStrings.resx
@@ -318,4 +318,7 @@
<data name="UnsupportedEncryptionAlgorithm" xml:space="preserve">
<value>This blob is not a recognized encryption format.</value>
</data>
-</root> \ No newline at end of file
+ <data name="ExtraParameterAddFailure" xml:space="preserve">
+ <value>Failed to add extra parameter '{0}' with value '{1}'.</value>
+ </data>
+</root>
diff --git a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
index 6c0fb3a..6518971 100644
--- a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
@@ -1213,7 +1213,11 @@ namespace DotNetOpenAuth.Messaging {
if (extraParameters != null) {
foreach (var pair in extraParameters) {
- messageDictionary.Add(pair);
+ try {
+ messageDictionary.Add(pair);
+ } catch (ArgumentException ex) {
+ throw ErrorUtilities.Wrap(ex, MessagingStrings.ExtraParameterAddFailure, pair.Key, pair.Value);
+ }
}
}
}
diff --git a/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs b/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs
index 193e445..ffde271 100644
--- a/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs
+++ b/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs
@@ -30,16 +30,14 @@ namespace DotNetOpenAuth.Mvc {
/// Emits a series of stylesheet import tags to support the AJAX OpenID Selector.
/// </summary>
/// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
- /// <param name="page">The page being rendered.</param>
/// <returns>HTML that should be sent directly to the browser.</returns>
- public static string OpenIdSelectorStyles(this HtmlHelper html, Page page) {
+ public static string OpenIdSelectorStyles(this HtmlHelper html) {
Contract.Requires<ArgumentNullException>(html != null);
- Contract.Requires<ArgumentNullException>(page != null);
Contract.Ensures(Contract.Result<string>() != null);
StringWriter result = new StringWriter();
- result.WriteStylesheetLink(page, OpenId.RelyingParty.OpenIdSelector.EmbeddedStylesheetResourceName);
- result.WriteStylesheetLink(page, OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedStylesheetResourceName);
+ result.WriteStylesheetLink(OpenId.RelyingParty.OpenIdSelector.EmbeddedStylesheetResourceName);
+ result.WriteStylesheetLink(OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedStylesheetResourceName);
return result.ToString();
}
@@ -47,25 +45,22 @@ namespace DotNetOpenAuth.Mvc {
/// Emits a series of script import tags and some inline script to support the AJAX OpenID Selector.
/// </summary>
/// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
- /// <param name="page">The page being rendered.</param>
/// <returns>HTML that should be sent directly to the browser.</returns>
- public static string OpenIdSelectorScripts(this HtmlHelper html, Page page) {
- return OpenIdSelectorScripts(html, page, null, null);
+ public static string OpenIdSelectorScripts(this HtmlHelper html) {
+ return OpenIdSelectorScripts(html, null, null);
}
/// <summary>
/// Emits a series of script import tags and some inline script to support the AJAX OpenID Selector.
/// </summary>
/// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
- /// <param name="page">The page being rendered.</param>
/// <param name="selectorOptions">An optional instance of an <see cref="OpenIdSelector"/> control, whose properties have been customized to express how this MVC control should be rendered.</param>
/// <param name="additionalOptions">An optional set of additional script customizations.</param>
/// <returns>
/// HTML that should be sent directly to the browser.
/// </returns>
- public static string OpenIdSelectorScripts(this HtmlHelper html, Page page, OpenIdSelector selectorOptions, OpenIdAjaxOptions additionalOptions) {
+ public static string OpenIdSelectorScripts(this HtmlHelper html, OpenIdSelector selectorOptions, OpenIdAjaxOptions additionalOptions) {
Contract.Requires<ArgumentNullException>(html != null);
- Contract.Requires<ArgumentNullException>(page != null);
Contract.Ensures(Contract.Result<string>() != null);
if (selectorOptions == null) {
@@ -92,10 +87,10 @@ window.openid_trace = {1}; // causes lots of messages";
OpenIdRelyingPartyAjaxControlBase.EmbeddedAjaxJavascriptResource,
OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedScriptResourceName,
};
- result.WriteScriptTags(page, scriptResources);
+ result.WriteScriptTags(scriptResources);
if (selectorOptions.DownloadYahooUILibrary) {
- result.WriteScriptTags(new[] { "https://ajax.googleapis.com/ajax/libs/yui/2.8.0r4/build/yuiloader/yuiloader-min.js" });
+ result.WriteScriptTagsUrls(new[] { "https://ajax.googleapis.com/ajax/libs/yui/2.8.0r4/build/yuiloader/yuiloader-min.js" });
}
var blockBuilder = new StringWriter();
@@ -163,10 +158,10 @@ window.openid_trace = {1}; // causes lots of messages";
}});";
blockBuilder.WriteLine(
blockFormat,
- MessagingUtilities.GetSafeJavascriptValue(page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenIdTextBox.EmbeddedLogoResourceName)),
- MessagingUtilities.GetSafeJavascriptValue(page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedSpinnerResourceName)),
- MessagingUtilities.GetSafeJavascriptValue(page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedLoginSuccessResourceName)),
- MessagingUtilities.GetSafeJavascriptValue(page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedLoginFailureResourceName)),
+ MessagingUtilities.GetSafeJavascriptValue(Util.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenIdTextBox.EmbeddedLogoResourceName)),
+ MessagingUtilities.GetSafeJavascriptValue(Util.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedSpinnerResourceName)),
+ MessagingUtilities.GetSafeJavascriptValue(Util.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedLoginSuccessResourceName)),
+ MessagingUtilities.GetSafeJavascriptValue(Util.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedLoginFailureResourceName)),
selectorOptions.Throttle,
selectorOptions.Timeout.TotalMilliseconds,
MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.LogOnText),
@@ -183,7 +178,7 @@ window.openid_trace = {1}; // causes lots of messages";
MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.AuthenticationFailedToolTip));
result.WriteScriptBlock(blockBuilder.ToString());
- result.WriteScriptTags(page, OpenId.RelyingParty.OpenIdSelector.EmbeddedScriptResourceName);
+ result.WriteScriptTags(OpenId.RelyingParty.OpenIdSelector.EmbeddedScriptResourceName);
Reporting.RecordFeatureUse("MVC " + typeof(OpenIdSelector).Name);
return result.ToString();
@@ -193,20 +188,18 @@ window.openid_trace = {1}; // causes lots of messages";
/// Emits the HTML to render an OpenID Provider button as a part of the overall OpenID Selector UI.
/// </summary>
/// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
- /// <param name="page">The page being rendered.</param>
/// <param name="providerIdentifier">The OP Identifier.</param>
/// <param name="imageUrl">The URL of the image to display on the button.</param>
/// <returns>
/// HTML that should be sent directly to the browser.
/// </returns>
- public static string OpenIdSelectorOPButton(this HtmlHelper html, Page page, Identifier providerIdentifier, string imageUrl) {
+ public static string OpenIdSelectorOPButton(this HtmlHelper html, Identifier providerIdentifier, string imageUrl) {
Contract.Requires<ArgumentNullException>(html != null);
- Contract.Requires<ArgumentNullException>(page != null);
Contract.Requires<ArgumentNullException>(providerIdentifier != null);
Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(imageUrl));
Contract.Ensures(Contract.Result<string>() != null);
- return OpenIdSelectorButton(html, page, providerIdentifier, "OPButton", imageUrl);
+ return OpenIdSelectorButton(html, providerIdentifier, "OPButton", imageUrl);
}
/// <summary>
@@ -214,32 +207,28 @@ window.openid_trace = {1}; // causes lots of messages";
/// allowing the user to enter their own OpenID.
/// </summary>
/// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
- /// <param name="page">The page being rendered.</param>
/// <param name="imageUrl">The URL of the image to display on the button.</param>
/// <returns>
/// HTML that should be sent directly to the browser.
/// </returns>
- public static string OpenIdSelectorOpenIdButton(this HtmlHelper html, Page page, string imageUrl) {
+ public static string OpenIdSelectorOpenIdButton(this HtmlHelper html, string imageUrl) {
Contract.Requires<ArgumentNullException>(html != null);
- Contract.Requires<ArgumentNullException>(page != null);
Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(imageUrl));
Contract.Ensures(Contract.Result<string>() != null);
- return OpenIdSelectorButton(html, page, "OpenIDButton", "OpenIDButton", imageUrl);
+ return OpenIdSelectorButton(html, "OpenIDButton", "OpenIDButton", imageUrl);
}
/// <summary>
/// Emits the HTML to render the entire OpenID Selector UI.
/// </summary>
/// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
- /// <param name="page">The page being rendered.</param>
/// <param name="buttons">The buttons to include on the selector.</param>
/// <returns>
/// HTML that should be sent directly to the browser.
/// </returns>
- public static string OpenIdSelector(this HtmlHelper html, Page page, params SelectorButton[] buttons) {
+ public static string OpenIdSelector(this HtmlHelper html, params SelectorButton[] buttons) {
Contract.Requires<ArgumentNullException>(html != null);
- Contract.Requires<ArgumentNullException>(page != null);
Contract.Requires<ArgumentNullException>(buttons != null);
Contract.Ensures(Contract.Result<string>() != null);
@@ -252,13 +241,13 @@ window.openid_trace = {1}; // causes lots of messages";
foreach (SelectorButton button in buttons) {
var op = button as SelectorProviderButton;
if (op != null) {
- h.Write(OpenIdSelectorOPButton(html, page, op.OPIdentifier, op.Image));
+ h.Write(OpenIdSelectorOPButton(html, op.OPIdentifier, op.Image));
continue;
}
var openid = button as SelectorOpenIdButton;
if (openid != null) {
- h.Write(OpenIdSelectorOpenIdButton(html, page, openid.Image));
+ h.Write(OpenIdSelectorOpenIdButton(html, openid.Image));
continue;
}
@@ -294,16 +283,14 @@ window.openid_trace = {1}; // causes lots of messages";
/// Emits the HTML to render a button as a part of the overall OpenID Selector UI.
/// </summary>
/// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
- /// <param name="page">The page being rendered.</param>
/// <param name="id">The value to assign to the HTML id attribute.</param>
/// <param name="cssClass">The value to assign to the HTML class attribute.</param>
/// <param name="imageUrl">The URL of the image to draw on the button.</param>
/// <returns>
/// HTML that should be sent directly to the browser.
/// </returns>
- private static string OpenIdSelectorButton(this HtmlHelper html, Page page, string id, string cssClass, string imageUrl) {
+ private static string OpenIdSelectorButton(this HtmlHelper html, string id, string cssClass, string imageUrl) {
Contract.Requires<ArgumentNullException>(html != null);
- Contract.Requires<ArgumentNullException>(page != null);
Contract.Requires<ArgumentNullException>(id != null);
Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(imageUrl));
Contract.Ensures(Contract.Result<string>() != null);
@@ -327,7 +314,7 @@ window.openid_trace = {1}; // causes lots of messages";
h.RenderBeginTag(HtmlTextWriterTag.Img);
h.RenderEndTag();
- h.AddAttribute(HtmlTextWriterAttribute.Src, page.ClientScript.GetWebResourceUrl(typeof(OpenIdSelector), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedLoginSuccessResourceName));
+ h.AddAttribute(HtmlTextWriterAttribute.Src, Util.GetWebResourceUrl(typeof(OpenIdSelector), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedLoginSuccessResourceName));
h.AddAttribute(HtmlTextWriterAttribute.Class, "loginSuccess");
h.AddAttribute(HtmlTextWriterAttribute.Title, "Authenticated as {0}");
h.RenderBeginTag(HtmlTextWriterTag.Img);
@@ -351,7 +338,7 @@ window.openid_trace = {1}; // causes lots of messages";
/// </summary>
/// <param name="writer">The writer to emit the tags to.</param>
/// <param name="scriptUrls">The locations of the scripts to import.</param>
- private static void WriteScriptTags(this TextWriter writer, IEnumerable<string> scriptUrls) {
+ private static void WriteScriptTagsUrls(this TextWriter writer, IEnumerable<string> scriptUrls) {
Contract.Requires<ArgumentNullException>(writer != null);
Contract.Requires<ArgumentNullException>(scriptUrls != null);
@@ -364,28 +351,24 @@ window.openid_trace = {1}; // causes lots of messages";
/// Writes out script tags that import a script from resources embedded in this assembly.
/// </summary>
/// <param name="writer">The writer to emit the tags to.</param>
- /// <param name="page">The page being rendered.</param>
/// <param name="resourceName">Name of the resource.</param>
- private static void WriteScriptTags(this TextWriter writer, Page page, string resourceName) {
+ private static void WriteScriptTags(this TextWriter writer, string resourceName) {
Contract.Requires<ArgumentNullException>(writer != null);
- Contract.Requires<ArgumentNullException>(page != null);
Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(resourceName));
- WriteScriptTags(writer, page, new[] { resourceName });
+ WriteScriptTags(writer, new[] { resourceName });
}
/// <summary>
/// Writes out script tags that import scripts from resources embedded in this assembly.
/// </summary>
/// <param name="writer">The writer to emit the tags to.</param>
- /// <param name="page">The page being rendered.</param>
/// <param name="resourceNames">The resource names.</param>
- private static void WriteScriptTags(this TextWriter writer, Page page, IEnumerable<string> resourceNames) {
+ private static void WriteScriptTags(this TextWriter writer, IEnumerable<string> resourceNames) {
Contract.Requires<ArgumentNullException>(writer != null);
- Contract.Requires<ArgumentNullException>(page != null);
Contract.Requires<ArgumentNullException>(resourceNames != null);
- writer.WriteScriptTags(resourceNames.Select(r => page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), r)));
+ writer.WriteScriptTagsUrls(resourceNames.Select(r => Util.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), r)));
}
/// <summary>
@@ -407,14 +390,12 @@ window.openid_trace = {1}; // causes lots of messages";
/// Writes a given CSS link.
/// </summary>
/// <param name="writer">The writer to emit the tags to.</param>
- /// <param name="page">The page being rendered.</param>
/// <param name="resourceName">Name of the resource containing the CSS content.</param>
- private static void WriteStylesheetLink(this TextWriter writer, Page page, string resourceName) {
+ private static void WriteStylesheetLink(this TextWriter writer, string resourceName) {
Contract.Requires<ArgumentNullException>(writer != null);
- Contract.Requires<ArgumentNullException>(page != null);
Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(resourceName));
- WriteStylesheetLink(writer, page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyAjaxControlBase), resourceName));
+ WriteStylesheetLinkUrl(writer, Util.GetWebResourceUrl(typeof(OpenIdRelyingPartyAjaxControlBase), resourceName));
}
/// <summary>
@@ -422,7 +403,7 @@ window.openid_trace = {1}; // causes lots of messages";
/// </summary>
/// <param name="writer">The writer to emit the tags to.</param>
/// <param name="stylesheet">The stylesheet to link in.</param>
- private static void WriteStylesheetLink(this TextWriter writer, string stylesheet) {
+ private static void WriteStylesheetLinkUrl(this TextWriter writer, string stylesheet) {
Contract.Requires<ArgumentNullException>(writer != null);
Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(stylesheet));
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs
index f775492..cec8042 100644
--- a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs
+++ b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs
@@ -32,14 +32,6 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
};
/// <summary>
- /// Additional type URIs that this extension is sometimes known by remote parties.
- /// </summary>
- private static readonly string[] additionalTypeUris = new string[] {
- Constants.sreg_ns10,
- Constants.sreg_ns11other,
- };
-
- /// <summary>
/// The type URI that this particular (deserialized) extension was read in using,
/// allowing a response to alter be crafted using the same type URI.
/// </summary>
@@ -49,7 +41,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
/// Initializes a new instance of the <see cref="ClaimsRequest"/> class.
/// </summary>
public ClaimsRequest()
- : base(new Version(1, 0), Constants.sreg_ns, additionalTypeUris) {
+ : base(new Version(1, 0), Constants.sreg_ns, Constants.AdditionalTypeUris) {
}
/// <summary>
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
index 7db6d45..d4df028 100644
--- a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
+++ b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
@@ -27,7 +27,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
/// The factory method that may be used in deserialization of this message.
/// </summary>
internal static readonly StandardOpenIdExtensionFactory.CreateDelegate Factory = (typeUri, data, baseMessage, isProviderRole) => {
- if (typeUri == Constants.sreg_ns && !isProviderRole) {
+ if ((typeUri == Constants.sreg_ns || Array.IndexOf(Constants.AdditionalTypeUris, typeUri) >= 0) && !isProviderRole) {
return new ClaimsResponse(typeUri);
}
@@ -69,7 +69,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
/// This value should be the same one the relying party used to send the extension request.
/// </param>
internal ClaimsResponse(string typeUriToUse)
- : base(new Version(1, 0), typeUriToUse, EmptyList<string>.Instance) {
+ : base(new Version(1, 0), typeUriToUse, Constants.AdditionalTypeUris) {
Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(typeUriToUse));
}
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Constants.cs b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Constants.cs
index 544ba77..9e00137 100644
--- a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Constants.cs
+++ b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Constants.cs
@@ -34,5 +34,13 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
internal const string Male = "M";
internal const string Female = "F";
}
+
+ /// <summary>
+ /// Additional type URIs that this extension is sometimes known by remote parties.
+ /// </summary>
+ internal static readonly string[] AdditionalTypeUris = new string[] {
+ Constants.sreg_ns10,
+ Constants.sreg_ns11other,
+ };
}
}
diff --git a/src/DotNetOpenAuth/OpenId/Interop/AuthenticationResponseShim.cs b/src/DotNetOpenAuth/OpenId/Interop/AuthenticationResponseShim.cs
index 6319c02..c0354ac 100644
--- a/src/DotNetOpenAuth/OpenId/Interop/AuthenticationResponseShim.cs
+++ b/src/DotNetOpenAuth/OpenId/Interop/AuthenticationResponseShim.cs
@@ -92,6 +92,13 @@ namespace DotNetOpenAuth.OpenId.Interop {
}
/// <summary>
+ /// Gets the provider endpoint that sent the assertion.
+ /// </summary>
+ public string ProviderEndpoint {
+ get { return this.response.Provider != null ? this.response.Provider.Uri.AbsoluteUri : null; }
+ }
+
+ /// <summary>
/// Gets a value indicating whether the authentication attempt succeeded.
/// </summary>
public bool Successful {
diff --git a/src/DotNetOpenAuth/Reporting.cs b/src/DotNetOpenAuth/Reporting.cs
index 612845f..2f93416 100644
--- a/src/DotNetOpenAuth/Reporting.cs
+++ b/src/DotNetOpenAuth/Reporting.cs
@@ -32,6 +32,11 @@ namespace DotNetOpenAuth {
/// </summary>
public static class Reporting {
/// <summary>
+ /// A UTF8 encoder that doesn't emit the preamble. Used for mid-stream writers.
+ /// </summary>
+ private static readonly Encoding Utf8NoPreamble = new UTF8Encoding(false);
+
+ /// <summary>
/// A value indicating whether reporting is desirable or not. Must be logical-AND'd with !<see cref="broken"/>.
/// </summary>
private static bool enabled;
@@ -665,7 +670,7 @@ namespace DotNetOpenAuth {
this.memorySet.Add(this.reader.ReadLine());
}
- this.writer = new StreamWriter(this.fileStream, Encoding.UTF8);
+ this.writer = new StreamWriter(this.fileStream, Utf8NoPreamble);
this.lastFlushed = DateTime.Now;
}
@@ -818,7 +823,7 @@ namespace DotNetOpenAuth {
}
}
- this.writer = new StreamWriter(this.fileStream, Encoding.UTF8);
+ this.writer = new StreamWriter(this.fileStream, Utf8NoPreamble);
this.lastFlushed = DateTime.Now;
}
diff --git a/src/DotNetOpenAuth/Strings.Designer.cs b/src/DotNetOpenAuth/Strings.Designer.cs
index 70b9fb2..1461f83 100644
--- a/src/DotNetOpenAuth/Strings.Designer.cs
+++ b/src/DotNetOpenAuth/Strings.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:4.0.30104.0
+// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -79,6 +79,15 @@ namespace DotNetOpenAuth {
}
/// <summary>
+ /// Looks up a localized string similar to The current IHttpHandler is not one of types: {0}. An embedded resource URL provider must be set in your .config file..
+ /// </summary>
+ internal static string EmbeddedResourceUrlProviderRequired {
+ get {
+ return ResourceManager.GetString("EmbeddedResourceUrlProviderRequired", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to No current HttpContext was detected, so an {0} instance must be explicitly provided or specified in the .config file. Call the constructor overload that takes an {0}..
/// </summary>
internal static string StoreRequiredWhenNoHttpContextAvailable {
diff --git a/src/DotNetOpenAuth/Strings.resx b/src/DotNetOpenAuth/Strings.resx
index a7f080d..4b78664 100644
--- a/src/DotNetOpenAuth/Strings.resx
+++ b/src/DotNetOpenAuth/Strings.resx
@@ -126,4 +126,7 @@
<data name="ConfigurationXamlReferenceRequiresHttpContext" xml:space="preserve">
<value>The configuration XAML reference to {0} requires a current HttpContext to resolve.</value>
</data>
-</root>
+ <data name="EmbeddedResourceUrlProviderRequired" xml:space="preserve">
+ <value>The current IHttpHandler is not one of types: {0}. An embedded resource URL provider must be set in your .config file.</value>
+ </data>
+</root> \ No newline at end of file
diff --git a/src/DotNetOpenAuth/Util.cs b/src/DotNetOpenAuth/Util.cs
index 8a18ef8..0317c4d 100644
--- a/src/DotNetOpenAuth/Util.cs
+++ b/src/DotNetOpenAuth/Util.cs
@@ -11,6 +11,10 @@ namespace DotNetOpenAuth {
using System.Net;
using System.Reflection;
using System.Text;
+ using System.Web;
+ using System.Web.UI;
+
+ using DotNetOpenAuth.Configuration;
using DotNetOpenAuth.Messaging;
/// <summary>
@@ -24,6 +28,11 @@ namespace DotNetOpenAuth {
internal const string DefaultNamespace = "DotNetOpenAuth";
/// <summary>
+ /// The web.config file-specified provider of web resource URLs.
+ /// </summary>
+ private static IEmbeddedResourceRetrieval embeddedResourceRetrieval = DotNetOpenAuthSection.Configuration.EmbeddedResourceRetrievalProvider.CreateInstance(null, false);
+
+ /// <summary>
/// Gets a human-readable description of the library name and version, including
/// whether the build is an official or private one.
/// </summary>
@@ -154,6 +163,32 @@ namespace DotNetOpenAuth {
}
/// <summary>
+ /// Gets the web resource URL from a Page or <see cref="IEmbeddedResourceRetrieval"/> object.
+ /// </summary>
+ /// <param name="someTypeInResourceAssembly">Some type in resource assembly.</param>
+ /// <param name="manifestResourceName">Name of the manifest resource.</param>
+ /// <returns>An absolute URL</returns>
+ internal static string GetWebResourceUrl(Type someTypeInResourceAssembly, string manifestResourceName) {
+ Page page;
+ IEmbeddedResourceRetrieval retrieval;
+
+ if (embeddedResourceRetrieval != null) {
+ Uri url = embeddedResourceRetrieval.GetWebResourceUrl(someTypeInResourceAssembly, manifestResourceName);
+ return url != null ? url.AbsoluteUri : null;
+ } else if ((page = HttpContext.Current.CurrentHandler as Page) != null) {
+ return page.ClientScript.GetWebResourceUrl(someTypeInResourceAssembly, manifestResourceName);
+ } else if ((retrieval = HttpContext.Current.CurrentHandler as IEmbeddedResourceRetrieval) != null) {
+ return retrieval.GetWebResourceUrl(someTypeInResourceAssembly, manifestResourceName).AbsoluteUri;
+ } else {
+ throw new InvalidOperationException(
+ string.Format(
+ CultureInfo.CurrentCulture,
+ Strings.EmbeddedResourceUrlProviderRequired,
+ string.Join(", ", new string[] { typeof(Page).FullName, typeof(IEmbeddedResourceRetrieval).FullName })));
+ }
+ }
+
+ /// <summary>
/// Manages an individual deferred ToString call.
/// </summary>
/// <typeparam name="T">The type of object to be serialized as a string.</typeparam>
diff --git a/src/DotNetOpenAuth/Yadis/Yadis.cs b/src/DotNetOpenAuth/Yadis/Yadis.cs
index 8b8c20f..357dd8d 100644
--- a/src/DotNetOpenAuth/Yadis/Yadis.cs
+++ b/src/DotNetOpenAuth/Yadis/Yadis.cs
@@ -151,7 +151,24 @@ namespace DotNetOpenAuth.Yadis {
options |= DirectWebRequestOptions.RequireSsl;
}
- return requestHandler.GetResponse(request, options);
+ try {
+ return requestHandler.GetResponse(request, options);
+ } catch (ProtocolException ex) {
+ var webException = ex.InnerException as WebException;
+ if (webException != null) {
+ var response = webException.Response as HttpWebResponse;
+ if (response != null && response.IsFromCache) {
+ // We don't want to report error responses from the cache, since the server may have fixed
+ // whatever was causing the problem. So try again with cache disabled.
+ Logger.Messaging.Error("An HTTP error response was obtained from the cache. Retrying with cache disabled.", ex);
+ var nonCachingRequest = request.Clone();
+ nonCachingRequest.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Reload);
+ return requestHandler.GetResponse(nonCachingRequest, options);
+ }
+ }
+
+ throw;
+ }
}
/// <summary>