diff options
25 files changed, 639 insertions, 592 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionTestBase.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionTestBase.cs index 4da8dfe..95026d4 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionTestBase.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionTestBase.cs @@ -7,20 +7,19 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions {
using System;
using System.Collections.Generic;
+ using System.Collections.ObjectModel;
using System.Linq;
- using DotNetOpenId.Extensions;
+ using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
using DotNetOpenAuth.OpenId.Messages;
- using System.Collections.ObjectModel;
- using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Test.Messaging;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
public class ExtensionTestBase : OpenIdTestBase {
protected const ProtocolVersion Version = ProtocolVersion.V20;
[TestInitialize]
- public virtual void Setup() {
+ public override void SetUp() {
base.SetUp();
}
@@ -59,7 +58,7 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { response.Extensions.Add(extensionResponse);
}
- op.Channel.Send(response); + op.Channel.Send(response);
});
coordinator.Run();
}
diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/SimpleRegistrationTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/SimpleRegistrationTests.cs index 7f2592e..c41ccb8 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/SimpleRegistrationTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/SimpleRegistrationTests.cs @@ -1,20 +1,27 @@ -namespace DotNetOpenAuth.Test.OpenId.Extensions {
+//-----------------------------------------------------------------------
+// <copyright file="SimpleRegistrationTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Test.OpenId.Extensions {
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
+ using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
- using DotNetOpenAuth.OpenId;
[TestClass]
public class SimpleRegistrationTests : ExtensionTestBase {
[TestMethod]
public void Simple() {
- Roundtrip(Protocol.Default,
- new[] { new ClaimsRequest() { Nickname = DemandLevel.Request } },
- new[] { new ClaimsResponse() { Nickname = "Andrew" } });
+ ClaimsRequest request = new ClaimsRequest() { Nickname = DemandLevel.Request };
+ ClaimsResponse response = new ClaimsResponse(Constants.sreg_ns);
+ response.Nickname = "Andrew";
+ Roundtrip(Protocol.Default, new[] { request }, new[] { response });
}
////[TestMethod]
diff --git a/src/DotNetOpenAuth.sln b/src/DotNetOpenAuth.sln index 5466d83..73ec6eb 100644 --- a/src/DotNetOpenAuth.sln +++ b/src/DotNetOpenAuth.sln @@ -1,122 +1,122 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetOpenAuth", "DotNetOpenAuth\DotNetOpenAuth.csproj", "{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetOpenAuth.Test", "DotNetOpenAuth.Test\DotNetOpenAuth.Test.csproj", "{4376ECC9-C346-4A99-B13C-FA93C0FBD2C9}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{20B5E173-C3C4-49F8-BD25-E69044075B4D}" - ProjectSection(SolutionItems) = preProject - DotNetOpenAuth.vsmdi = DotNetOpenAuth.vsmdi - LocalTestRun.testrunconfig = LocalTestRun.testrunconfig - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Specs", "Specs", "{CD57219F-24F4-4136-8741-6063D0D7A031}" - ProjectSection(SolutionItems) = preProject - ..\doc\specs\OAuth Core 1.0.htm = ..\doc\specs\OAuth Core 1.0.htm - ..\doc\specs\openid-attribute-exchange-1_0.html = ..\doc\specs\openid-attribute-exchange-1_0.html - ..\doc\specs\openid-authentication-1_1.html = ..\doc\specs\openid-authentication-1_1.html - ..\doc\specs\openid-authentication-2_0.html = ..\doc\specs\openid-authentication-2_0.html - ..\doc\specs\openid-provider-authentication-policy-extension-1_0-02.html = ..\doc\specs\openid-provider-authentication-policy-extension-1_0-02.html - ..\doc\specs\openid-simple-registration-extension-1_0.html = ..\doc\specs\openid-simple-registration-extension-1_0.html - EndProjectSection -EndProject -Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Consumer", "..\samples\Consumer\", "{F9076F04-17AF-4205-93A2-1D3BEBFCDAEB}" - ProjectSection(WebsiteProperties) = preProject - TargetFramework = "3.5" - ProjectReferences = "{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}|DotNetOpenAuth.dll;{AA78D112-D889-414B-A7D4-467B34C7B663}|DotNetOpenAuth.ApplicationBlock.dll;" - Debug.AspNetCompiler.VirtualPath = "/Consumer" - Debug.AspNetCompiler.PhysicalPath = "..\samples\Consumer\" - Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\Consumer\" - Debug.AspNetCompiler.Updateable = "true" - Debug.AspNetCompiler.ForceOverwrite = "true" - Debug.AspNetCompiler.FixedNames = "false" - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.VirtualPath = "/Consumer" - Release.AspNetCompiler.PhysicalPath = "..\samples\Consumer\" - Release.AspNetCompiler.TargetPath = "PrecompiledWeb\Consumer\" - Release.AspNetCompiler.Updateable = "true" - Release.AspNetCompiler.ForceOverwrite = "true" - Release.AspNetCompiler.FixedNames = "false" - Release.AspNetCompiler.Debug = "False" - VWDPort = "48147" - DefaultWebSiteLanguage = "Visual C#" - EndProjectSection - ProjectSection(ProjectDependencies) = postProject - {EC910270-AAB6-4AC6-9B57-99118CFBE557} = {EC910270-AAB6-4AC6-9B57-99118CFBE557} - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{B4C6F647-C046-4B54-BE12-7701C4119EE7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumerWpf", "..\samples\ConsumerWpf\ConsumerWpf.csproj", "{6EC36418-DBC5-4AD1-A402-413604AA7A08}" -EndProject -Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "ServiceProvider", "..\samples\ServiceProvider\", "{EC910270-AAB6-4AC6-9B57-99118CFBE557}" - ProjectSection(WebsiteProperties) = preProject - TargetFramework = "3.5" - ProjectReferences = "{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}|DotNetOpenAuth.dll;" - Debug.AspNetCompiler.VirtualPath = "/ServiceProvider" - Debug.AspNetCompiler.PhysicalPath = "..\samples\ServiceProvider\" - Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\ServiceProvider\" - Debug.AspNetCompiler.Updateable = "true" - Debug.AspNetCompiler.ForceOverwrite = "true" - Debug.AspNetCompiler.FixedNames = "false" - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.VirtualPath = "/ServiceProvider" - Release.AspNetCompiler.PhysicalPath = "..\samples\ServiceProvider\" - Release.AspNetCompiler.TargetPath = "PrecompiledWeb\ServiceProvider\" - Release.AspNetCompiler.Updateable = "true" - Release.AspNetCompiler.ForceOverwrite = "true" - Release.AspNetCompiler.FixedNames = "false" - Release.AspNetCompiler.Debug = "False" - VWDPort = "65169" - VWDDynamicPort = "false" - DefaultWebSiteLanguage = "Visual C#" - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetOpenAuth.ApplicationBlock", "..\samples\DotNetOpenAuth.ApplicationBlock\DotNetOpenAuth.ApplicationBlock.csproj", "{AA78D112-D889-414B-A7D4-467B34C7B663}" -EndProject -Global - GlobalSection(TestCaseManagementSettings) = postSolution - CategoryFile = DotNetOpenAuth.vsmdi - EndGlobalSection - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {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 - {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 - {F9076F04-17AF-4205-93A2-1D3BEBFCDAEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F9076F04-17AF-4205-93A2-1D3BEBFCDAEB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F9076F04-17AF-4205-93A2-1D3BEBFCDAEB}.Release|Any CPU.ActiveCfg = Debug|Any CPU - {F9076F04-17AF-4205-93A2-1D3BEBFCDAEB}.Release|Any CPU.Build.0 = Debug|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 - {EC910270-AAB6-4AC6-9B57-99118CFBE557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EC910270-AAB6-4AC6-9B57-99118CFBE557}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EC910270-AAB6-4AC6-9B57-99118CFBE557}.Release|Any CPU.ActiveCfg = Debug|Any CPU - {EC910270-AAB6-4AC6-9B57-99118CFBE557}.Release|Any CPU.Build.0 = Debug|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 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {CD57219F-24F4-4136-8741-6063D0D7A031} = {20B5E173-C3C4-49F8-BD25-E69044075B4D} - {F9076F04-17AF-4205-93A2-1D3BEBFCDAEB} = {B4C6F647-C046-4B54-BE12-7701C4119EE7} - {6EC36418-DBC5-4AD1-A402-413604AA7A08} = {B4C6F647-C046-4B54-BE12-7701C4119EE7} - {EC910270-AAB6-4AC6-9B57-99118CFBE557} = {B4C6F647-C046-4B54-BE12-7701C4119EE7} - {AA78D112-D889-414B-A7D4-467B34C7B663} = {B4C6F647-C046-4B54-BE12-7701C4119EE7} - EndGlobalSection -EndGlobal +
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetOpenAuth", "DotNetOpenAuth\DotNetOpenAuth.csproj", "{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetOpenAuth.Test", "DotNetOpenAuth.Test\DotNetOpenAuth.Test.csproj", "{4376ECC9-C346-4A99-B13C-FA93C0FBD2C9}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{20B5E173-C3C4-49F8-BD25-E69044075B4D}"
+ ProjectSection(SolutionItems) = preProject
+ DotNetOpenAuth.vsmdi = DotNetOpenAuth.vsmdi
+ LocalTestRun.testrunconfig = LocalTestRun.testrunconfig
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Specs", "Specs", "{CD57219F-24F4-4136-8741-6063D0D7A031}"
+ ProjectSection(SolutionItems) = preProject
+ ..\doc\specs\OAuth Core 1.0.htm = ..\doc\specs\OAuth Core 1.0.htm
+ ..\doc\specs\openid-attribute-exchange-1_0.html = ..\doc\specs\openid-attribute-exchange-1_0.html
+ ..\doc\specs\openid-authentication-1_1.html = ..\doc\specs\openid-authentication-1_1.html
+ ..\doc\specs\openid-authentication-2_0.html = ..\doc\specs\openid-authentication-2_0.html
+ ..\doc\specs\openid-provider-authentication-policy-extension-1_0-02.html = ..\doc\specs\openid-provider-authentication-policy-extension-1_0-02.html
+ ..\doc\specs\openid-simple-registration-extension-1_0.html = ..\doc\specs\openid-simple-registration-extension-1_0.html
+ EndProjectSection
+EndProject
+Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Consumer", "..\samples\Consumer\", "{F9076F04-17AF-4205-93A2-1D3BEBFCDAEB}"
+ ProjectSection(WebsiteProperties) = preProject
+ TargetFramework = "3.5"
+ ProjectReferences = "{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}|DotNetOpenAuth.dll;{AA78D112-D889-414B-A7D4-467B34C7B663}|DotNetOpenAuth.ApplicationBlock.dll;"
+ Debug.AspNetCompiler.VirtualPath = "/Consumer"
+ Debug.AspNetCompiler.PhysicalPath = "..\samples\Consumer\"
+ Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\Consumer\"
+ Debug.AspNetCompiler.Updateable = "true"
+ Debug.AspNetCompiler.ForceOverwrite = "true"
+ Debug.AspNetCompiler.FixedNames = "false"
+ Debug.AspNetCompiler.Debug = "True"
+ Release.AspNetCompiler.VirtualPath = "/Consumer"
+ Release.AspNetCompiler.PhysicalPath = "..\samples\Consumer\"
+ Release.AspNetCompiler.TargetPath = "PrecompiledWeb\Consumer\"
+ Release.AspNetCompiler.Updateable = "true"
+ Release.AspNetCompiler.ForceOverwrite = "true"
+ Release.AspNetCompiler.FixedNames = "false"
+ Release.AspNetCompiler.Debug = "False"
+ VWDPort = "6319"
+ DefaultWebSiteLanguage = "Visual C#"
+ EndProjectSection
+ ProjectSection(ProjectDependencies) = postProject
+ {EC910270-AAB6-4AC6-9B57-99118CFBE557} = {EC910270-AAB6-4AC6-9B57-99118CFBE557}
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{B4C6F647-C046-4B54-BE12-7701C4119EE7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumerWpf", "..\samples\ConsumerWpf\ConsumerWpf.csproj", "{6EC36418-DBC5-4AD1-A402-413604AA7A08}"
+EndProject
+Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "ServiceProvider", "..\samples\ServiceProvider\", "{EC910270-AAB6-4AC6-9B57-99118CFBE557}"
+ ProjectSection(WebsiteProperties) = preProject
+ TargetFramework = "3.5"
+ ProjectReferences = "{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}|DotNetOpenAuth.dll;"
+ Debug.AspNetCompiler.VirtualPath = "/ServiceProvider"
+ Debug.AspNetCompiler.PhysicalPath = "..\samples\ServiceProvider\"
+ Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\ServiceProvider\"
+ Debug.AspNetCompiler.Updateable = "true"
+ Debug.AspNetCompiler.ForceOverwrite = "true"
+ Debug.AspNetCompiler.FixedNames = "false"
+ Debug.AspNetCompiler.Debug = "True"
+ Release.AspNetCompiler.VirtualPath = "/ServiceProvider"
+ Release.AspNetCompiler.PhysicalPath = "..\samples\ServiceProvider\"
+ Release.AspNetCompiler.TargetPath = "PrecompiledWeb\ServiceProvider\"
+ Release.AspNetCompiler.Updateable = "true"
+ Release.AspNetCompiler.ForceOverwrite = "true"
+ Release.AspNetCompiler.FixedNames = "false"
+ Release.AspNetCompiler.Debug = "False"
+ VWDPort = "65169"
+ VWDDynamicPort = "false"
+ DefaultWebSiteLanguage = "Visual C#"
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetOpenAuth.ApplicationBlock", "..\samples\DotNetOpenAuth.ApplicationBlock\DotNetOpenAuth.ApplicationBlock.csproj", "{AA78D112-D889-414B-A7D4-467B34C7B663}"
+EndProject
+Global
+ GlobalSection(TestCaseManagementSettings) = postSolution
+ CategoryFile = DotNetOpenAuth.vsmdi
+ EndGlobalSection
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {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
+ {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
+ {F9076F04-17AF-4205-93A2-1D3BEBFCDAEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F9076F04-17AF-4205-93A2-1D3BEBFCDAEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F9076F04-17AF-4205-93A2-1D3BEBFCDAEB}.Release|Any CPU.ActiveCfg = Debug|Any CPU
+ {F9076F04-17AF-4205-93A2-1D3BEBFCDAEB}.Release|Any CPU.Build.0 = Debug|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
+ {EC910270-AAB6-4AC6-9B57-99118CFBE557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EC910270-AAB6-4AC6-9B57-99118CFBE557}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EC910270-AAB6-4AC6-9B57-99118CFBE557}.Release|Any CPU.ActiveCfg = Debug|Any CPU
+ {EC910270-AAB6-4AC6-9B57-99118CFBE557}.Release|Any CPU.Build.0 = Debug|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
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {CD57219F-24F4-4136-8741-6063D0D7A031} = {20B5E173-C3C4-49F8-BD25-E69044075B4D}
+ {F9076F04-17AF-4205-93A2-1D3BEBFCDAEB} = {B4C6F647-C046-4B54-BE12-7701C4119EE7}
+ {6EC36418-DBC5-4AD1-A402-413604AA7A08} = {B4C6F647-C046-4B54-BE12-7701C4119EE7}
+ {EC910270-AAB6-4AC6-9B57-99118CFBE557} = {B4C6F647-C046-4B54-BE12-7701C4119EE7}
+ {AA78D112-D889-414B-A7D4-467B34C7B663} = {B4C6F647-C046-4B54-BE12-7701C4119EE7}
+ EndGlobalSection
+EndGlobal
diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj index a0c8e2e..fe63a50 100644 --- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj +++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj @@ -159,7 +159,6 @@ <Compile Include="Messaging\MessageTransport.cs" />
<Compile Include="OAuth\ChannelElements\OAuthServiceProviderMessageFactory.cs" />
<Compile Include="Messaging\ProtocolException.cs" />
- <Compile Include="OpenId\AliasManager.cs" />
<Compile Include="OpenId\Association.cs" />
<Compile Include="OpenId\AssociationMemoryStore.cs" />
<Compile Include="OpenId\Associations.cs" />
@@ -174,10 +173,8 @@ <Compile Include="OpenId\Configuration.cs" />
<Compile Include="OpenId\Extensions\AliasManager.cs" />
<Compile Include="OpenId\Extensions\ExtensionBase.cs" />
- <Compile Include="OpenId\Extensions\IOutgoingExtensions.cs" />
<Compile Include="OpenId\Extensions\ExtensionArgumentsManager.cs" />
<None Include="OpenId\Extensions\IExtension.cs" />
- <Compile Include="OpenId\Extensions\IIncomingExtensions.cs" />
<Compile Include="OpenId\Extensions\OpenIdExtensionFactory.cs" />
<Compile Include="OpenId\Extensions\SimpleRegistration\ClaimsRequest.cs" />
<Compile Include="OpenId\Extensions\SimpleRegistration\ClaimsResponse.cs" />
diff --git a/src/DotNetOpenAuth/Messaging/IMessage.cs b/src/DotNetOpenAuth/Messaging/IMessage.cs index 924daf7..cd42fce 100644 --- a/src/DotNetOpenAuth/Messaging/IMessage.cs +++ b/src/DotNetOpenAuth/Messaging/IMessage.cs @@ -1,5 +1,5 @@ //-----------------------------------------------------------------------
-// <copyright file="IProtocolMessage.cs" company="Andrew Arnott">
+// <copyright file="IMessage.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
diff --git a/src/DotNetOpenAuth/OAuth/Messages/MessageBase.cs b/src/DotNetOpenAuth/OAuth/Messages/MessageBase.cs index 3beb410..ac40efd 100644 --- a/src/DotNetOpenAuth/OAuth/Messages/MessageBase.cs +++ b/src/DotNetOpenAuth/OAuth/Messages/MessageBase.cs @@ -153,6 +153,13 @@ namespace DotNetOpenAuth.OAuth.Messages { internal static bool LowSecurityMode { get; set; }
/// <summary>
+ /// Gets a value indicating whether this message was deserialized as an incoming message.
+ /// </summary>
+ protected internal bool Incoming {
+ get { return this.incoming; }
+ }
+
+ /// <summary>
/// Gets the version of the protocol this message is prepared to implement.
/// </summary>
protected virtual Version Version {
@@ -181,13 +188,6 @@ namespace DotNetOpenAuth.OAuth.Messages { }
/// <summary>
- /// Gets a value indicating whether this message was deserialized as an incoming message.
- /// </summary>
- protected internal bool Incoming {
- get { return this.incoming; }
- }
-
- /// <summary>
/// Gets the preferred method of transport for the message.
/// </summary>
protected HttpDeliveryMethods HttpMethods {
diff --git a/src/DotNetOpenAuth/OpenId/AliasManager.cs b/src/DotNetOpenAuth/OpenId/AliasManager.cs deleted file mode 100644 index f4bbb04..0000000 --- a/src/DotNetOpenAuth/OpenId/AliasManager.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Diagnostics;
-using System.Globalization;
-
-namespace DotNetOpenId.Extensions {
- class AliasManager {
- readonly string aliasFormat = "alias{0}";
- /// <summary>
- /// Tracks extension Type URIs and aliases assigned to them.
- /// </summary>
- Dictionary<string, string> typeUriToAliasMap = new Dictionary<string, string>();
- /// <summary>
- /// Tracks extension aliases and Type URIs assigned to them.
- /// </summary>
- Dictionary<string, string> aliasToTypeUriMap = new Dictionary<string, string>();
-
- /// <summary>
- /// Gets an alias assigned for a given Type URI. A new alias is assigned if necessary.
- /// </summary>
- public string GetAlias(string typeUri) {
- if (string.IsNullOrEmpty(typeUri)) throw new ArgumentNullException("typeUri");
- string alias;
- if (typeUriToAliasMap.TryGetValue(typeUri, out alias))
- return alias;
- else
- return assignNewAlias(typeUri);
- }
-
- /// <summary>
- /// Sets an alias and the value that will be returned by <see cref="ResolveAlias"/>.
- /// </summary>
- public void SetAlias(string alias, string typeUri) {
- if (string.IsNullOrEmpty(alias)) throw new ArgumentNullException("alias");
- if (string.IsNullOrEmpty(typeUri)) throw new ArgumentNullException("typeUri");
- aliasToTypeUriMap.Add(alias, typeUri);
- typeUriToAliasMap.Add(typeUri, alias);
- }
- /// <summary>
- /// Takes a sequence of type URIs and assigns aliases for all of them.
- /// </summary>
- /// <param name="typeUris">The type URIs to create aliases for.</param>
- /// <param name="preferredTypeUriToAliases">An optional dictionary of URI/alias pairs that suggest preferred aliases to use if available for certain type URIs.</param>
- public void AssignAliases(IEnumerable<string> typeUris, IDictionary<string, string> preferredTypeUriToAliases) {
- // First go through the actually used type URIs and see which ones have matching preferred aliases.
- if (preferredTypeUriToAliases != null) {
- foreach (string typeUri in typeUris) {
- if (typeUriToAliasMap.ContainsKey(typeUri)) {
- // this Type URI is already mapped to an alias.
- continue;
- }
-
- string preferredAlias;
- if (preferredTypeUriToAliases.TryGetValue(typeUri, out preferredAlias) && !IsAliasUsed(preferredAlias)) {
- SetAlias(preferredAlias, typeUri);
- }
- }
- }
-
- // Now go through the whole list again and assign whatever is left now that the preferred ones
- // have gotten their picks where available.
- foreach (string typeUri in typeUris) {
- if (typeUriToAliasMap.ContainsKey(typeUri)) {
- // this Type URI is already mapped to an alias.
- continue;
- }
-
- assignNewAlias(typeUri);
- }
- }
- /// <summary>
- /// Sets up aliases for any Type URIs in a dictionary that do not yet have aliases defined,
- /// and where the given preferred alias is still available.
- /// </summary>
- /// <param name="preferredTypeUriToAliases">A dictionary of type URI keys and alias values.</param>
- public void SetPreferredAliasesWhereNotSet(IDictionary<string, string> preferredTypeUriToAliases) {
- if (preferredTypeUriToAliases == null) throw new ArgumentNullException("preferredTypeUriToAliases");
-
- foreach (var pair in preferredTypeUriToAliases) {
- if (typeUriToAliasMap.ContainsKey(pair.Key)) {
- // type URI is already mapped
- continue;
- }
-
- if (aliasToTypeUriMap.ContainsKey(pair.Value)) {
- // alias is already mapped
- continue;
- }
-
- // The type URI and alias are as yet unset, so go ahead and assign them.
- SetAlias(pair.Value, pair.Key);
- }
- }
-
- /// <summary>
- /// Gets the Type Uri encoded by a given alias.
- /// </summary>
- public string ResolveAlias(string alias) {
- string typeUri = TryResolveAlias(alias);
- if (typeUri == null)
- throw new ArgumentOutOfRangeException("alias");
- return typeUri;
- }
- public string TryResolveAlias(string alias) {
- if (string.IsNullOrEmpty(alias)) throw new ArgumentNullException("alias");
- string typeUri = null;
- aliasToTypeUriMap.TryGetValue(alias, out typeUri);
- return typeUri;
- }
-
- public IEnumerable<string> Aliases {
- get { return aliasToTypeUriMap.Keys; }
- }
- /// <summary>
- /// Returns a value indicating whether an alias has already been assigned to a type URI.
- /// </summary>
- /// <param name="alias">The alias in question.</param>
- /// <returns>True if the alias has already been assigned. False otherwise.</returns>
- public bool IsAliasUsed(string alias) {
- if (string.IsNullOrEmpty(alias)) throw new ArgumentNullException("alias");
- return aliasToTypeUriMap.ContainsKey(alias);
- }
- public bool IsAliasAssignedTo(string typeUri) {
- if (string.IsNullOrEmpty("typeUri")) throw new ArgumentNullException("typeUri");
- return typeUriToAliasMap.ContainsKey(typeUri);
- }
-
- string assignNewAlias(string typeUri) {
- Debug.Assert(!string.IsNullOrEmpty(typeUri));
- Debug.Assert(!typeUriToAliasMap.ContainsKey(typeUri));
- string alias = string.Format(CultureInfo.InvariantCulture, aliasFormat, typeUriToAliasMap.Count + 1);
- typeUriToAliasMap.Add(typeUri, alias);
- aliasToTypeUriMap.Add(alias, typeUri);
- return alias;
- }
- }
-}
diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs index abb7705..0ee03cf 100644 --- a/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs +++ b/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs @@ -14,9 +14,20 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { using DotNetOpenAuth.OpenId.Extensions;
using DotNetOpenAuth.OpenId.Messages;
+ /// <summary>
+ /// The binding element that serializes/deserializes OpenID extensions to/from
+ /// their carrying OpenID messages.
+ /// </summary>
internal class ExtensionsBindingElement : IChannelBindingElement {
+ /// <summary>
+ /// The extension factory.
+ /// </summary>
private readonly IOpenIdExtensionFactory extensionFactory;
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ExtensionsBindingElement"/> class.
+ /// </summary>
+ /// <param name="extensionFactory">The extension factory.</param>
internal ExtensionsBindingElement(IOpenIdExtensionFactory extensionFactory) {
ErrorUtilities.VerifyArgumentNotNull(extensionFactory, "extensionFactory");
this.extensionFactory = extensionFactory;
@@ -116,7 +127,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { var extensionData = extensionManager.GetExtensionArguments(typeUri);
// Initialize this particular extension.
- IOpenIdMessageExtension extension = extensionFactory.Create(typeUri, extensionData, extendableMessage);
+ IOpenIdMessageExtension extension = this.extensionFactory.Create(typeUri, extensionData, extendableMessage);
MessageDictionary extensionDictionary = new MessageDictionary(extension);
foreach (var pair in extensionData) {
extensionDictionary[pair.Key] = pair.Value;
diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs index 95ca6b1..1ed65cb 100644 --- a/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs +++ b/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs @@ -13,8 +13,8 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { using System.Text;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Bindings;
- using DotNetOpenAuth.OpenId.Messages;
using DotNetOpenAuth.OpenId.Extensions;
+ using DotNetOpenAuth.OpenId.Messages;
/// <summary>
/// A channel that knows how to send and receive OpenID messages.
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/AliasManager.cs b/src/DotNetOpenAuth/OpenId/Extensions/AliasManager.cs index ee9f288..ee26c3b 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/AliasManager.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/AliasManager.cs @@ -7,44 +7,60 @@ namespace DotNetOpenAuth.OpenId.Extensions {
using System;
using System.Collections.Generic;
- using System.Text;
using System.Diagnostics;
using System.Globalization;
+ using System.Text;
+ using DotNetOpenAuth.Messaging;
+ /// <summary>
+ /// Manages a fast, two-way mapping between type URIs and their aliases.
+ /// </summary>
internal class AliasManager {
+ /// <summary>
+ /// The format of auto-generated aliases.
+ /// </summary>
private readonly string aliasFormat = "alias{0}";
-
+
/// <summary>
/// Tracks extension Type URIs and aliases assigned to them.
/// </summary>
private Dictionary<string, string> typeUriToAliasMap = new Dictionary<string, string>();
-
+
/// <summary>
/// Tracks extension aliases and Type URIs assigned to them.
/// </summary>
private Dictionary<string, string> aliasToTypeUriMap = new Dictionary<string, string>();
/// <summary>
+ /// Gets the aliases that have been set.
+ /// </summary>
+ public IEnumerable<string> Aliases {
+ get { return this.aliasToTypeUriMap.Keys; }
+ }
+
+ /// <summary>
/// Gets an alias assigned for a given Type URI. A new alias is assigned if necessary.
/// </summary>
+ /// <param name="typeUri">The type URI.</param>
+ /// <returns>The alias assigned to this type URI. Never null.</returns>
public string GetAlias(string typeUri) {
- if (string.IsNullOrEmpty(typeUri)) throw new ArgumentNullException("typeUri");
+ ErrorUtilities.VerifyNonZeroLength(typeUri, "typeUri");
string alias;
- if (typeUriToAliasMap.TryGetValue(typeUri, out alias))
- return alias;
- else
- return assignNewAlias(typeUri);
+ return this.typeUriToAliasMap.TryGetValue(typeUri, out alias) ? alias : this.AssignNewAlias(typeUri);
}
/// <summary>
/// Sets an alias and the value that will be returned by <see cref="ResolveAlias"/>.
/// </summary>
+ /// <param name="alias">The alias.</param>
+ /// <param name="typeUri">The type URI.</param>
public void SetAlias(string alias, string typeUri) {
- if (string.IsNullOrEmpty(alias)) throw new ArgumentNullException("alias");
- if (string.IsNullOrEmpty(typeUri)) throw new ArgumentNullException("typeUri");
- aliasToTypeUriMap.Add(alias, typeUri);
- typeUriToAliasMap.Add(typeUri, alias);
+ ErrorUtilities.VerifyNonZeroLength(alias, "alias");
+ ErrorUtilities.VerifyNonZeroLength(typeUri, "typeUri");
+ this.aliasToTypeUriMap.Add(alias, typeUri);
+ this.typeUriToAliasMap.Add(typeUri, alias);
}
+
/// <summary>
/// Takes a sequence of type URIs and assigns aliases for all of them.
/// </summary>
@@ -54,14 +70,14 @@ namespace DotNetOpenAuth.OpenId.Extensions { // First go through the actually used type URIs and see which ones have matching preferred aliases.
if (preferredTypeUriToAliases != null) {
foreach (string typeUri in typeUris) {
- if (typeUriToAliasMap.ContainsKey(typeUri)) {
+ if (this.typeUriToAliasMap.ContainsKey(typeUri)) {
// this Type URI is already mapped to an alias.
continue;
}
string preferredAlias;
- if (preferredTypeUriToAliases.TryGetValue(typeUri, out preferredAlias) && !IsAliasUsed(preferredAlias)) {
- SetAlias(preferredAlias, typeUri);
+ if (preferredTypeUriToAliases.TryGetValue(typeUri, out preferredAlias) && !this.IsAliasUsed(preferredAlias)) {
+ this.SetAlias(preferredAlias, typeUri);
}
}
}
@@ -69,81 +85,98 @@ namespace DotNetOpenAuth.OpenId.Extensions { // Now go through the whole list again and assign whatever is left now that the preferred ones
// have gotten their picks where available.
foreach (string typeUri in typeUris) {
- if (typeUriToAliasMap.ContainsKey(typeUri)) {
+ if (this.typeUriToAliasMap.ContainsKey(typeUri)) {
// this Type URI is already mapped to an alias.
continue;
}
- assignNewAlias(typeUri);
+ this.AssignNewAlias(typeUri);
}
}
-
+
/// <summary>
/// Sets up aliases for any Type URIs in a dictionary that do not yet have aliases defined,
/// and where the given preferred alias is still available.
/// </summary>
/// <param name="preferredTypeUriToAliases">A dictionary of type URI keys and alias values.</param>
public void SetPreferredAliasesWhereNotSet(IDictionary<string, string> preferredTypeUriToAliases) {
- if (preferredTypeUriToAliases == null) throw new ArgumentNullException("preferredTypeUriToAliases");
+ ErrorUtilities.VerifyArgumentNotNull(preferredTypeUriToAliases, "preferredTypeUriToAliases");
foreach (var pair in preferredTypeUriToAliases) {
- if (typeUriToAliasMap.ContainsKey(pair.Key)) {
+ if (this.typeUriToAliasMap.ContainsKey(pair.Key)) {
// type URI is already mapped
continue;
}
- if (aliasToTypeUriMap.ContainsKey(pair.Value)) {
+ if (this.aliasToTypeUriMap.ContainsKey(pair.Value)) {
// alias is already mapped
continue;
}
// The type URI and alias are as yet unset, so go ahead and assign them.
- SetAlias(pair.Value, pair.Key);
+ this.SetAlias(pair.Value, pair.Key);
}
}
/// <summary>
/// Gets the Type Uri encoded by a given alias.
/// </summary>
+ /// <param name="alias">The alias.</param>
+ /// <returns>The Type URI.</returns>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown if the given alias does not have a matching TypeURI.</exception>
public string ResolveAlias(string alias) {
- string typeUri = TryResolveAlias(alias);
- if (typeUri == null)
+ string typeUri = this.TryResolveAlias(alias);
+ if (typeUri == null) {
throw new ArgumentOutOfRangeException("alias");
+ }
return typeUri;
}
-
+
+ /// <summary>
+ /// Gets the Type Uri encoded by a given alias.
+ /// </summary>
+ /// <param name="alias">The alias.</param>
+ /// <returns>The Type URI for the given alias, or null if none for that alias exist.</returns>
public string TryResolveAlias(string alias) {
- if (string.IsNullOrEmpty(alias)) throw new ArgumentNullException("alias");
+ ErrorUtilities.VerifyNonZeroLength(alias, "alias");
string typeUri = null;
- aliasToTypeUriMap.TryGetValue(alias, out typeUri);
+ this.aliasToTypeUriMap.TryGetValue(alias, out typeUri);
return typeUri;
}
- public IEnumerable<string> Aliases {
- get { return aliasToTypeUriMap.Keys; }
- }
-
/// <summary>
/// Returns a value indicating whether an alias has already been assigned to a type URI.
/// </summary>
/// <param name="alias">The alias in question.</param>
/// <returns>True if the alias has already been assigned. False otherwise.</returns>
public bool IsAliasUsed(string alias) {
- if (string.IsNullOrEmpty(alias)) throw new ArgumentNullException("alias");
- return aliasToTypeUriMap.ContainsKey(alias);
+ ErrorUtilities.VerifyNonZeroLength(alias, "alias");
+ return this.aliasToTypeUriMap.ContainsKey(alias);
}
-
+
+ /// <summary>
+ /// Determines whether a given TypeURI has an associated alias assigned to it.
+ /// </summary>
+ /// <param name="typeUri">The type URI.</param>
+ /// <returns>
+ /// <c>true</c> if the given type URI already has an alias assigned; <c>false</c> otherwise.
+ /// </returns>
public bool IsAliasAssignedTo(string typeUri) {
- if (string.IsNullOrEmpty("typeUri")) throw new ArgumentNullException("typeUri");
- return typeUriToAliasMap.ContainsKey(typeUri);
+ ErrorUtilities.VerifyArgumentNotNull(typeUri, "typeUri");
+ return this.typeUriToAliasMap.ContainsKey(typeUri);
}
- string assignNewAlias(string typeUri) {
- Debug.Assert(!string.IsNullOrEmpty(typeUri));
- Debug.Assert(!typeUriToAliasMap.ContainsKey(typeUri));
- string alias = string.Format(CultureInfo.InvariantCulture, aliasFormat, typeUriToAliasMap.Count + 1);
- typeUriToAliasMap.Add(typeUri, alias);
- aliasToTypeUriMap.Add(alias, typeUri);
+ /// <summary>
+ /// Assigns a new alias to a given Type URI.
+ /// </summary>
+ /// <param name="typeUri">The type URI to assign a new alias to.</param>
+ /// <returns>The newly generated alias.</returns>
+ private string AssignNewAlias(string typeUri) {
+ ErrorUtilities.VerifyNonZeroLength(typeUri, "typeUri");
+ ErrorUtilities.VerifyInternal(!this.typeUriToAliasMap.ContainsKey(typeUri), "Oops! This type URI already has an alias!");
+ string alias = string.Format(CultureInfo.InvariantCulture, this.aliasFormat, this.typeUriToAliasMap.Count + 1);
+ this.typeUriToAliasMap.Add(typeUri, alias);
+ this.aliasToTypeUriMap.Add(alias, typeUri);
return alias;
}
}
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/ExtensionArgumentsManager.cs b/src/DotNetOpenAuth/OpenId/Extensions/ExtensionArgumentsManager.cs index 3da1383..5c0151d 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/ExtensionArgumentsManager.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/ExtensionArgumentsManager.cs @@ -7,11 +7,27 @@ namespace DotNetOpenAuth.OpenId.Extensions {
using System;
using System.Collections.Generic;
- using System.Text;
using System.Globalization;
+ using System.Text;
using DotNetOpenAuth.Messaging;
- internal class ExtensionArgumentsManager : IIncomingExtensions, IOutgoingExtensions {
+ /// <summary>
+ /// Manages the processing and construction of OpenID extensions parts.
+ /// </summary>
+ internal class ExtensionArgumentsManager {
+ /// <summary>
+ /// This contains a set of aliases that we must be willing to implicitly
+ /// match to namespaces for backward compatibility with other OpenID libraries.
+ /// </summary>
+ private static readonly Dictionary<string, string> typeUriToAliasAffinity = new Dictionary<string, string> {
+ { Extensions.SimpleRegistration.Constants.sreg_ns, Extensions.SimpleRegistration.Constants.sreg_compatibility_alias },
+ // TODO: re-enable these lines.
+ ////{ Extensions.ProviderAuthenticationPolicy.Constants.TypeUri, Extensions.ProviderAuthenticationPolicy.Constants.pape_compatibility_alias },
+ };
+
+ /// <summary>
+ /// The version of OpenID that the message is using.
+ /// </summary>
private Protocol protocol;
/// <summary>
@@ -19,7 +35,10 @@ namespace DotNetOpenAuth.OpenId.Extensions { /// </summary>
private bool isReadMode;
- private Extensions.AliasManager aliasManager = new Extensions.AliasManager();
+ /// <summary>
+ /// The alias manager that will track Type URI to alias mappings.
+ /// </summary>
+ private AliasManager aliasManager = new AliasManager();
/// <summary>
/// A complex dictionary where the key is the Type URI of the extension,
@@ -28,29 +47,29 @@ namespace DotNetOpenAuth.OpenId.Extensions { private Dictionary<string, IDictionary<string, string>> extensions = new Dictionary<string, IDictionary<string, string>>();
/// <summary>
- /// This contains a set of aliases that we must be willing to implicitly
- /// match to namespaces for backward compatibility with other OpenID libraries.
+ /// Prevents a default instance of the <see cref="ExtensionArgumentsManager"/> class from being created.
/// </summary>
- private static readonly Dictionary<string, string> typeUriToAliasAffinity = new Dictionary<string, string> {
- // TODO: re-enable these lines.
- ////{ Extensions.SimpleRegistration.Constants.sreg_ns, Extensions.SimpleRegistration.Constants.sreg_compatibility_alias },
- ////{ Extensions.ProviderAuthenticationPolicy.Constants.TypeUri, Extensions.ProviderAuthenticationPolicy.Constants.pape_compatibility_alias },
- };
-
private ExtensionArgumentsManager() { }
+ /// <summary>
+ /// Creates a <see cref="ExtensionArgumentsManager"/> instance to process incoming extensions.
+ /// </summary>
+ /// <param name="query">The parameters in the OpenID message.</param>
+ /// <returns>The newly created instance of <see cref="ExtensionArgumentsManager"/>.</returns>
public static ExtensionArgumentsManager CreateIncomingExtensions(IDictionary<string, string> query) {
- if (query == null) throw new ArgumentNullException("query");
+ ErrorUtilities.VerifyArgumentNotNull(query, "query");
var mgr = new ExtensionArgumentsManager();
mgr.protocol = Protocol.Detect(query);
mgr.isReadMode = true;
string aliasPrefix = mgr.protocol.openid.ns + ".";
+
// First pass looks for namespace aliases
foreach (var pair in query) {
if (pair.Key.StartsWith(aliasPrefix, StringComparison.Ordinal)) {
mgr.aliasManager.SetAlias(pair.Key.Substring(aliasPrefix.Length), pair.Value);
}
}
+
// For backwards compatibility, add certain aliases if they aren't defined.
foreach (var pair in typeUriToAliasAffinity) {
if (!mgr.aliasManager.IsAliasAssignedTo(pair.Key) &&
@@ -58,16 +77,22 @@ namespace DotNetOpenAuth.OpenId.Extensions { mgr.aliasManager.SetAlias(pair.Value, pair.Key);
}
}
+
// Second pass looks for extensions using those aliases
foreach (var pair in query) {
- if (!pair.Key.StartsWith(mgr.protocol.openid.Prefix, StringComparison.Ordinal)) continue;
+ if (!pair.Key.StartsWith(mgr.protocol.openid.Prefix, StringComparison.Ordinal)) {
+ continue;
+ }
string possibleAlias = pair.Key.Substring(mgr.protocol.openid.Prefix.Length);
int periodIndex = possibleAlias.IndexOf(".", StringComparison.Ordinal);
- if (periodIndex >= 0) possibleAlias = possibleAlias.Substring(0, periodIndex);
+ if (periodIndex >= 0) {
+ possibleAlias = possibleAlias.Substring(0, periodIndex);
+ }
string typeUri;
if ((typeUri = mgr.aliasManager.TryResolveAlias(possibleAlias)) != null) {
- if (!mgr.extensions.ContainsKey(typeUri))
+ if (!mgr.extensions.ContainsKey(typeUri)) {
mgr.extensions[typeUri] = new Dictionary<string, string>();
+ }
string key = periodIndex >= 0 ? pair.Key.Substring(mgr.protocol.openid.Prefix.Length + possibleAlias.Length + 1) : string.Empty;
mgr.extensions[typeUri].Add(key, pair.Value);
}
@@ -75,9 +100,17 @@ namespace DotNetOpenAuth.OpenId.Extensions { return mgr;
}
+ /// <summary>
+ /// Creates a <see cref="ExtensionArgumentsManager"/> instance to prepare outgoing extensions.
+ /// </summary>
+ /// <param name="protocol">The protocol version used for the outgoing message.</param>
+ /// <returns>
+ /// The newly created instance of <see cref="ExtensionArgumentsManager"/>.
+ /// </returns>
public static ExtensionArgumentsManager CreateOutgoingExtensions(Protocol protocol) {
var mgr = new ExtensionArgumentsManager();
mgr.protocol = protocol;
+
// Affinity for certain alias for backwards compatibility
foreach (var pair in typeUriToAliasAffinity) {
mgr.aliasManager.SetAlias(pair.Value, pair.Key);
@@ -89,42 +122,58 @@ namespace DotNetOpenAuth.OpenId.Extensions { /// Gets the actual arguments to add to a querystring or other response,
/// where type URI, alias, and actual key/values are all defined.
/// </summary>
+ /// <param name="includeOpenIdPrefix">
+ /// <c>true</c> if the generated parameter names should include the 'openid.' prefix.
+ /// This should be <c>true</c> for all but direct response messages.
+ /// </param>
+ /// <returns>A dictionary of key=value pairs to add to the message to carry the extension.</returns>
public IDictionary<string, string> GetArgumentsToSend(bool includeOpenIdPrefix) {
- if (isReadMode) {
+ if (this.isReadMode) {
throw new InvalidOperationException();
}
Dictionary<string, string> args = new Dictionary<string, string>();
- foreach (var typeUriAndExtension in extensions) {
+ foreach (var typeUriAndExtension in this.extensions) {
string typeUri = typeUriAndExtension.Key;
var extensionArgs = typeUriAndExtension.Value;
if (extensionArgs.Count == 0) {
continue;
}
- string alias = aliasManager.GetAlias(typeUri);
+ string alias = this.aliasManager.GetAlias(typeUri);
+
// send out the alias declaration
- string openidPrefix = includeOpenIdPrefix ? protocol.openid.Prefix : string.Empty;
- args.Add(openidPrefix + protocol.openidnp.ns + "." + alias, typeUri);
+ string openidPrefix = includeOpenIdPrefix ? this.protocol.openid.Prefix : string.Empty;
+ args.Add(openidPrefix + this.protocol.openidnp.ns + "." + alias, typeUri);
string prefix = openidPrefix + alias;
foreach (var pair in extensionArgs) {
string key = prefix;
- if (pair.Key.Length > 0) key += "." + pair.Key;
+ if (pair.Key.Length > 0) {
+ key += "." + pair.Key;
+ }
args.Add(key, pair.Value);
}
}
return args;
}
+ /// <summary>
+ /// Adds query parameters for OpenID extensions to the request directed
+ /// at the OpenID provider.
+ /// </summary>
+ /// <param name="extensionTypeUri">The extension type URI.</param>
+ /// <param name="arguments">The arguments for this extension to add to the message.</param>
public void AddExtensionArguments(string extensionTypeUri, IDictionary<string, string> arguments) {
- if (isReadMode) {
+ if (this.isReadMode) {
throw new InvalidOperationException();
}
ErrorUtilities.VerifyNonZeroLength(extensionTypeUri, "extensionTypeUri");
ErrorUtilities.VerifyArgumentNotNull(arguments, "arguments");
- if (arguments.Count == 0) return;
+ if (arguments.Count == 0) {
+ return;
+ }
IDictionary<string, string> extensionArgs;
- if (!extensions.TryGetValue(extensionTypeUri, out extensionArgs)) {
- extensions.Add(extensionTypeUri, extensionArgs = new Dictionary<string, string>(arguments.Count));
+ if (!this.extensions.TryGetValue(extensionTypeUri, out extensionArgs)) {
+ this.extensions.Add(extensionTypeUri, extensionArgs = new Dictionary<string, string>(arguments.Count));
}
ErrorUtilities.VerifyProtocol(extensionArgs.Count == 0, OpenIdStrings.ExtensionAlreadyAddedWithSameTypeURI, extensionTypeUri);
@@ -136,23 +185,37 @@ namespace DotNetOpenAuth.OpenId.Extensions { /// <summary>
/// Gets the fields carried by a given OpenId extension.
/// </summary>
- /// <returns>The fields included in the given extension, or null if the extension is not present.</returns>
+ /// <param name="extensionTypeUri">The type URI of the extension whose fields are being queried for.</param>
+ /// <returns>
+ /// The fields included in the given extension, or null if the extension is not present.
+ /// </returns>
public IDictionary<string, string> GetExtensionArguments(string extensionTypeUri) {
ErrorUtilities.VerifyNonZeroLength(extensionTypeUri, "extensionTypeUri");
- if (!isReadMode) {
+ if (!this.isReadMode) {
throw new InvalidOperationException();
}
IDictionary<string, string> extensionArgs;
- extensions.TryGetValue(extensionTypeUri, out extensionArgs);
+ this.extensions.TryGetValue(extensionTypeUri, out extensionArgs);
return extensionArgs;
}
+ /// <summary>
+ /// Gets whether any arguments for a given extension are present.
+ /// </summary>
+ /// <param name="extensionTypeUri">The extension Type URI in question.</param>
+ /// <returns><c>true</c> if this extension is present; <c>false</c> otherwise.</returns>
public bool ContainsExtension(string extensionTypeUri) {
- if (!isReadMode) throw new InvalidOperationException();
- return extensions.ContainsKey(extensionTypeUri);
+ if (!this.isReadMode) {
+ throw new InvalidOperationException();
+ }
+ return this.extensions.ContainsKey(extensionTypeUri);
}
+ /// <summary>
+ /// Gets the type URIs of all discovered extensions in the message.
+ /// </summary>
+ /// <returns>A sequence of the type URIs.</returns>
public IEnumerable<string> GetExtensionTypeUris() {
return this.extensions.Keys;
}
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/ExtensionBase.cs b/src/DotNetOpenAuth/OpenId/Extensions/ExtensionBase.cs index 53b72c8..7899a54 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/ExtensionBase.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/ExtensionBase.cs @@ -9,22 +9,25 @@ namespace DotNetOpenAuth.OpenId.Extensions { using System.Collections.Generic;
using System.Linq;
using System.Text;
- using DotNetOpenAuth.OpenId.Messages;
using DotNetOpenAuth.Messaging;
+ using DotNetOpenAuth.OpenId.Messages;
+ /// <summary>
+ /// A hand base class for built-in extensions.
+ /// </summary>
public class ExtensionBase : IOpenIdMessageExtension {
/// <summary>
- /// Backing store for the <see cref="IOpenIdProtocolMessageExtension.TypeUri"/> property.
+ /// Backing store for the <see cref="IOpenIdMessageExtension.TypeUri"/> property.
/// </summary>
private string typeUri;
/// <summary>
- /// Backing store for the <see cref="IOpenIdProtocolMessageExtension.AdditionalSupportedTypeUris"/> property.
+ /// Backing store for the <see cref="IOpenIdMessageExtension.AdditionalSupportedTypeUris"/> property.
/// </summary>
private IEnumerable<string> additionalSupportedTypeUris;
/// <summary>
- /// Backing store for the <see cref="ExtraData"/> property.
+ /// Backing store for the <see cref="IMessage.ExtraData"/> property.
/// </summary>
private Dictionary<string, string> extraData = new Dictionary<string, string>();
@@ -46,18 +49,18 @@ namespace DotNetOpenAuth.OpenId.Extensions { /// Gets the TypeURI the extension uses in the OpenID protocol and in XRDS advertisements.
/// </summary>
string IOpenIdMessageExtension.TypeUri {
- get { return typeUri; }
+ get { return this.typeUri; }
}
/// <summary>
- /// Additional TypeURIs that are supported by this extension, in preferred order.
- /// May be empty if none other than <see cref="TypeUri"/> is supported, but
+ /// Gets the additional TypeURIs that are supported by this extension, in preferred order.
+ /// May be empty if none other than <see cref="IOpenIdMessageExtension.TypeUri"/> is supported, but
/// should not be null.
/// </summary>
/// <value></value>
/// <remarks>
/// Useful for reading in messages with an older version of an extension.
- /// The value in the <see cref="TypeUri"/> property is always checked before
+ /// The value in the <see cref="IOpenIdMessageExtension.TypeUri"/> property is always checked before
/// trying this list.
/// If you do support multiple versions of an extension using this method,
/// consider adding a CreateResponse method to your request extension class
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/IIncomingExtensions.cs b/src/DotNetOpenAuth/OpenId/Extensions/IIncomingExtensions.cs deleted file mode 100644 index 0b39c5d..0000000 --- a/src/DotNetOpenAuth/OpenId/Extensions/IIncomingExtensions.cs +++ /dev/null @@ -1,30 +0,0 @@ -//-----------------------------------------------------------------------
-// <copyright file="IIncomingExtensions.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOpenAuth.OpenId.Extensions {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
-
- internal interface IIncomingExtensions {
- /// <summary>
- /// Gets the key/value pairs of a provider's response for a given OpenID extension.
- /// </summary>
- /// <param name="extensionTypeUri">
- /// The Type URI of the OpenID extension whose arguments are being sought.
- /// </param>
- /// <returns>
- /// Returns key/value pairs for this extension.
- /// </returns>
- IDictionary<string, string> GetExtensionArguments(string extensionTypeUri);
-
- /// <summary>
- /// Gets whether any arguments for a given extension are present.
- /// </summary>
- bool ContainsExtension(string extensionTypeUri);
- }
-}
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/IOutgoingExtensions.cs b/src/DotNetOpenAuth/OpenId/Extensions/IOutgoingExtensions.cs deleted file mode 100644 index 12cfe0e..0000000 --- a/src/DotNetOpenAuth/OpenId/Extensions/IOutgoingExtensions.cs +++ /dev/null @@ -1,20 +0,0 @@ -//-----------------------------------------------------------------------
-// <copyright file="IOutgoingExtensions.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOpenAuth.OpenId.Extensions {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
-
- internal interface IOutgoingExtensions {
- /// <summary>
- /// Adds query parameters for OpenID extensions to the request directed
- /// at the OpenID provider.
- /// </summary>
- void AddExtensionArguments(string extensionTypeUri, IDictionary<string, string> arguments);
- }
-}
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/OpenIdExtensionFactory.cs b/src/DotNetOpenAuth/OpenId/Extensions/OpenIdExtensionFactory.cs index 88749d6..6248f4b 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/OpenIdExtensionFactory.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/OpenIdExtensionFactory.cs @@ -9,18 +9,17 @@ namespace DotNetOpenAuth.OpenId.Extensions { using System.Collections.Generic;
using System.Linq;
using System.Text;
- using DotNetOpenAuth.OpenId.ChannelElements;
- using DotNetOpenAuth.OpenId.Messages;
using DotNetOpenAuth.Messaging;
+ using DotNetOpenAuth.OpenId.ChannelElements;
using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration;
+ using DotNetOpenAuth.OpenId.Messages;
+ /// <summary>
+ /// An OpenID extension factory that supports registration so that third-party
+ /// extensions can add themselves to this library's supported extension list.
+ /// </summary>
internal class OpenIdExtensionFactory : IOpenIdExtensionFactory {
/// <summary>
- /// A delegate that individual extensions may register with this factory.
- /// </summary>
- internal delegate IOpenIdMessageExtension CreateDelegate(string typeUri, IDictionary<string, string> data, IProtocolMessageWithExtensions baseMessage);
-
- /// <summary>
/// A collection of the registered OpenID extensions.
/// </summary>
private List<CreateDelegate> registeredExtensions = new List<CreateDelegate>();
@@ -33,6 +32,18 @@ namespace DotNetOpenAuth.OpenId.Extensions { this.RegisterExtension(ClaimsResponse.Factory);
}
+ /// <summary>
+ /// A delegate that individual extensions may register with this factory.
+ /// </summary>
+ /// <param name="typeUri">The type URI of the extension.</param>
+ /// <param name="data">The parameters associated specifically with this extension.</param>
+ /// <param name="baseMessage">The OpenID message carrying this extension.</param>
+ /// <returns>
+ /// An instance of <see cref="IOpenIdMessageExtension"/> if the factory recognizes
+ /// the extension described in the input parameters; <c>null</c> otherwise.
+ /// </returns>
+ internal delegate IOpenIdMessageExtension CreateDelegate(string typeUri, IDictionary<string, string> data, IProtocolMessageWithExtensions baseMessage);
+
#region IOpenIdExtensionFactory Members
/// <summary>
@@ -50,7 +61,7 @@ namespace DotNetOpenAuth.OpenId.Extensions { /// that are not bound using <see cref="MessagePartAttribute"/>.
/// </remarks>
public IOpenIdMessageExtension Create(string typeUri, IDictionary<string, string> data, IProtocolMessageWithExtensions baseMessage) {
- foreach (var factoryMethod in registeredExtensions) {
+ foreach (var factoryMethod in this.registeredExtensions) {
IOpenIdMessageExtension result = factoryMethod(typeUri, data, baseMessage);
if (result != null) {
return result;
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs index afa72f6..0dabde8 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs @@ -7,24 +7,21 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
using System;
using System.Collections.Generic;
- using System.Text;
using System.Diagnostics;
- using System.Globalization;
- using DotNetOpenAuth.OpenId.Messages;
using System.Diagnostics.CodeAnalysis;
+ using System.Globalization;
+ using System.Text;
using DotNetOpenAuth.Messaging;
+ using DotNetOpenAuth.OpenId.Messages;
/// <summary>
/// Carries the request/require/none demand state of the simple registration fields.
/// </summary>
#pragma warning disable 0659, 0661
- [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals")]
public sealed class ClaimsRequest : ExtensionBase {
- private static readonly string[] additionalTypeUris = new string[] {
- Constants.sreg_ns10,
- Constants.sreg_ns11other,
- };
-
+ /// <summary>
+ /// The factory method that may be used in deserialization of this message.
+ /// </summary>
internal static readonly OpenIdExtensionFactory.CreateDelegate Factory = (typeUri, data, baseMessage) => {
if (typeUri == Constants.sreg_ns && baseMessage is SignedResponseRequest) {
return new ClaimsRequest();
@@ -34,6 +31,20 @@ 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>
+ private string typeUriDeserializedFrom;
+
+ /// <summary>
/// Initializes a new instance of the <see cref="ClaimsRequest"/> class.
/// </summary>
public ClaimsRequest()
@@ -45,111 +56,120 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { /// by deserializing from a message.
/// </summary>
/// <param name="typeUri">The type URI this extension was recognized by in the OpenID message.</param>
- internal ClaimsRequest(string typeUri) : this() {
+ internal ClaimsRequest(string typeUri)
+ : this() {
ErrorUtilities.VerifyNonZeroLength(typeUri, "typeUri");
this.typeUriDeserializedFrom = typeUri;
}
/// <summary>
- /// The URL the consumer site provides for the authenticating user to review
+ /// Gets or sets the URL the consumer site provides for the authenticating user to review
/// for how his claims will be used by the consumer web site.
/// </summary>
[MessagePart(Constants.policy_url, IsRequired = false)]
public Uri PolicyUrl { get; set; }
/// <summary>
- /// The level of interest a relying party has in the nickname of the user.
+ /// Gets or sets the level of interest a relying party has in the nickname of the user.
/// </summary>
public DemandLevel Nickname { get; set; }
/// <summary>
- /// The level of interest a relying party has in the email of the user.
+ /// Gets or sets the level of interest a relying party has in the email of the user.
/// </summary>
public DemandLevel Email { get; set; }
-
+
/// <summary>
- /// The level of interest a relying party has in the full name of the user.
+ /// Gets or sets the level of interest a relying party has in the full name of the user.
/// </summary>
public DemandLevel FullName { get; set; }
-
+
/// <summary>
- /// The level of interest a relying party has in the birthdate of the user.
+ /// Gets or sets the level of interest a relying party has in the birthdate of the user.
/// </summary>
public DemandLevel BirthDate { get; set; }
-
+
/// <summary>
- /// The level of interest a relying party has in the gender of the user.
+ /// Gets or sets the level of interest a relying party has in the gender of the user.
/// </summary>
public DemandLevel Gender { get; set; }
-
+
/// <summary>
- /// The level of interest a relying party has in the postal code of the user.
+ /// Gets or sets the level of interest a relying party has in the postal code of the user.
/// </summary>
public DemandLevel PostalCode { get; set; }
-
+
/// <summary>
- /// The level of interest a relying party has in the Country of the user.
+ /// Gets or sets the level of interest a relying party has in the Country of the user.
/// </summary>
public DemandLevel Country { get; set; }
-
+
/// <summary>
- /// The level of interest a relying party has in the language of the user.
+ /// Gets or sets the level of interest a relying party has in the language of the user.
/// </summary>
public DemandLevel Language { get; set; }
-
+
/// <summary>
- /// The level of interest a relying party has in the time zone of the user.
+ /// Gets or sets the level of interest a relying party has in the time zone of the user.
/// </summary>
public DemandLevel TimeZone { get; set; }
+ /// <summary>
+ /// Gets or sets the value of the sreg.required parameter.
+ /// </summary>
+ /// <value>A comma-delimited list of sreg fields.</value>
[MessagePart(Constants.required, AllowEmpty = true)]
private string RequiredList {
- get { return string.Join(",", assembleProfileFields(DemandLevel.Require)); }
+ get { return string.Join(",", this.AssembleProfileFields(DemandLevel.Require)); }
set { this.SetProfileRequestFromList(value.Split(','), DemandLevel.Require); }
}
+ /// <summary>
+ /// Gets or sets the value of the sreg.optional parameter.
+ /// </summary>
+ /// <value>A comma-delimited list of sreg fields.</value>
[MessagePart(Constants.optional, AllowEmpty = true)]
private string OptionalList {
- get { return string.Join(",", assembleProfileFields(DemandLevel.Request)); }
+ get { return string.Join(",", this.AssembleProfileFields(DemandLevel.Request)); }
set { this.SetProfileRequestFromList(value.Split(','), DemandLevel.Request); }
}
- private string typeUriDeserializedFrom;
-
- /// <summary>
- /// Prepares a Simple Registration response extension that is compatible with the
- /// version of Simple Registration used in the request message.
- /// </summary>
- public ClaimsResponse CreateResponse() {
- if (typeUriDeserializedFrom == null) {
- throw new InvalidOperationException(OpenIdStrings.CallDeserializeBeforeCreateResponse);
- }
- return new ClaimsResponse(typeUriDeserializedFrom);
- }
-
/// <summary>
/// Tests equality between two <see cref="ClaimsRequest"/> structs.
/// </summary>
+ /// <param name="one">One instance to compare.</param>
+ /// <param name="other">Another instance to compare.</param>
+ /// <returns>The result of the operator.</returns>
public static bool operator ==(ClaimsRequest one, ClaimsRequest other) {
- if ((object)one == null && (object)other == null) return true;
- if ((object)one == null ^ (object)other == null) return false;
- return one.Equals(other);
+ return one.EqualsNullSafe(other);
}
-
+
/// <summary>
/// Tests inequality between two <see cref="ClaimsRequest"/> structs.
/// </summary>
+ /// <param name="one">One instance to compare.</param>
+ /// <param name="other">Another instance to compare.</param>
+ /// <returns>The result of the operator.</returns>
public static bool operator !=(ClaimsRequest one, ClaimsRequest other) {
return !(one == other);
}
-
+
/// <summary>
/// Tests equality between two <see cref="ClaimsRequest"/> structs.
/// </summary>
+ /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
+ /// <returns>
+ /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
+ /// </returns>
+ /// <exception cref="T:System.NullReferenceException">
+ /// The <paramref name="obj"/> parameter is null.
+ /// </exception>
public override bool Equals(object obj) {
ClaimsRequest other = obj as ClaimsRequest;
- if (other == null) return false;
+ if (other == null) {
+ return false;
+ }
return
this.BirthDate.Equals(other.BirthDate) &&
@@ -165,10 +185,29 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { }
/// <summary>
+ /// Serves as a hash function for a particular type.
+ /// </summary>
+ /// <returns>
+ /// A hash code for the current <see cref="T:System.Object"/>.
+ /// </returns>
+ public override int GetHashCode() {
+ // It's important that if Equals returns true that the hash code also equals,
+ // so returning base.GetHashCode() is a BAD option.
+ // Return 1 is simple and poor for dictionary storage, but considering that every
+ // ClaimsRequest formulated at a single RP will likely have all the same fields,
+ // even a good hash code function will likely generate the same hash code. So
+ // we just cut to the chase and return a simple one.
+ return 1;
+ }
+
+ /// <summary>
/// Renders the requested information as a string.
/// </summary>
+ /// <returns>
+ /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
+ /// </returns>
public override string ToString() {
- return string.Format(CultureInfo.CurrentCulture, @"Nickname = '{0}'
+ string format = @"Nickname = '{0}'
Email = '{1}'
FullName = '{2}'
Birthdate = '{3}'
@@ -176,9 +215,23 @@ Gender = '{4}' PostalCode = '{5}'
Country = '{6}'
Language = '{7}'
-TimeZone = '{8}'", Nickname, Email, FullName, BirthDate, Gender, PostalCode, Country, Language, TimeZone);
+TimeZone = '{8}'";
+ return string.Format(CultureInfo.CurrentCulture, format, this.Nickname, this.Email, this.FullName, this.BirthDate, this.Gender, this.PostalCode, this.Country, this.Language, this.TimeZone);
+ }
+
+ /// <summary>
+ /// Prepares a Simple Registration response extension that is compatible with the
+ /// version of Simple Registration used in the request message.
+ /// </summary>
+ /// <returns>The newly created <see cref="ClaimsResponse"/> instance.</returns>
+ public ClaimsResponse CreateResponse() {
+ if (this.typeUriDeserializedFrom == null) {
+ throw new InvalidOperationException(OpenIdStrings.CallDeserializeBeforeCreateResponse);
+ }
+
+ return new ClaimsResponse(this.typeUriDeserializedFrom);
}
-
+
/// <summary>
/// Sets the profile request properties according to a list of
/// field names that might have been passed in the OpenId query dictionary.
@@ -193,31 +246,31 @@ TimeZone = '{8}'", Nickname, Email, FullName, BirthDate, Gender, PostalCode, Cou foreach (string field in fieldNames) {
switch (field) {
case Constants.nickname:
- Nickname = requestLevel;
+ this.Nickname = requestLevel;
break;
case Constants.email:
- Email = requestLevel;
+ this.Email = requestLevel;
break;
case Constants.fullname:
- FullName = requestLevel;
+ this.FullName = requestLevel;
break;
case Constants.dob:
- BirthDate = requestLevel;
+ this.BirthDate = requestLevel;
break;
case Constants.gender:
- Gender = requestLevel;
+ this.Gender = requestLevel;
break;
case Constants.postcode:
- PostalCode = requestLevel;
+ this.PostalCode = requestLevel;
break;
case Constants.country:
- Country = requestLevel;
+ this.Country = requestLevel;
break;
case Constants.language:
- Language = requestLevel;
+ this.Language = requestLevel;
break;
case Constants.timezone:
- TimeZone = requestLevel;
+ this.TimeZone = requestLevel;
break;
default:
Logger.WarnFormat("OpenIdProfileRequest.SetProfileRequestFromList: Unrecognized field name '{0}'.", field);
@@ -226,26 +279,32 @@ TimeZone = '{8}'", Nickname, Email, FullName, BirthDate, Gender, PostalCode, Cou }
}
- private string[] assembleProfileFields(DemandLevel level) {
+ /// <summary>
+ /// Assembles the profile parameter names that have a given <see cref="DemandLevel"/>.
+ /// </summary>
+ /// <param name="level">The demand level (request, require, none).</param>
+ /// <returns>An array of the profile parameter names that meet the criteria.</returns>
+ private string[] AssembleProfileFields(DemandLevel level) {
List<string> fields = new List<string>(10);
- if (Nickname == level)
+ if (this.Nickname == level) {
fields.Add(Constants.nickname);
- if (Email == level)
+ } if (this.Email == level) {
fields.Add(Constants.email);
- if (FullName == level)
+ } if (this.FullName == level) {
fields.Add(Constants.fullname);
- if (BirthDate == level)
+ } if (this.BirthDate == level) {
fields.Add(Constants.dob);
- if (Gender == level)
+ } if (this.Gender == level) {
fields.Add(Constants.gender);
- if (PostalCode == level)
+ } if (this.PostalCode == level) {
fields.Add(Constants.postcode);
- if (Country == level)
+ } if (this.Country == level) {
fields.Add(Constants.country);
- if (Language == level)
+ } if (this.Language == level) {
fields.Add(Constants.language);
- if (TimeZone == level)
+ } if (this.TimeZone == level) {
fields.Add(Constants.timezone);
+ }
return fields.ToArray();
}
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs index 01527a6..2111848 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs @@ -7,37 +7,46 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Net.Mail;
using System.Text;
+ using System.Text.RegularExpressions;
using System.Xml.Serialization;
- using DotNetOpenAuth.OpenId.Messages;
- using System.Diagnostics.CodeAnalysis;
using DotNetOpenAuth.Messaging;
- using System.Text.RegularExpressions;
+ using DotNetOpenAuth.OpenId.Messages;
#pragma warning disable 0659, 0661
/// <summary>
/// A struct storing Simple Registration field values describing an
/// authenticating user.
/// </summary>
- [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals"), Serializable()]
public sealed class ClaimsResponse : ExtensionBase {
+ /// <summary>
+ /// The factory method that may be used in deserialization of this message.
+ /// </summary>
internal static readonly OpenIdExtensionFactory.CreateDelegate Factory = (typeUri, data, baseMessage) => {
if (typeUri == Constants.sreg_ns && baseMessage is IndirectSignedResponse) {
- return new ClaimsResponse();
+ return new ClaimsResponse(typeUri);
}
return null;
};
/// <summary>
+ /// The allowed format for birthdates.
+ /// </summary>
+ private static readonly Regex birthDateValidator = new Regex(@"^\d\d\d\d-\d\d-\d\d$");
+
+ /// <summary>
/// Storage for the raw string birthdate value.
/// </summary>
private string birthDateRaw;
- private DateTime? birthDate;
- private static readonly Regex birthDateValidator = new Regex(@"^\d\d\d\d-\d\d-\d\d$");
+ /// <summary>
+ /// Backing field for the <see cref="BirthDate"/> property.
+ /// </summary>
+ private DateTime? birthDate;
/// <summary>
/// The TypeURI that must be used in the response, based on the one used in the request.
@@ -50,7 +59,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { private CultureInfo culture;
/// <summary>
- /// Creates an instance of the <see cref="ClaimsResponse"/> class.
+ /// Initializes a new instance of the <see cref="ClaimsResponse"/> class.
/// </summary>
[Obsolete("Use ClaimsRequest.CreateResponse() instead.")]
public ClaimsResponse()
@@ -71,25 +80,25 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { }
/// <summary>
- /// The nickname the user goes by.
+ /// Gets or sets the nickname the user goes by.
/// </summary>
[MessagePart(Constants.nickname)]
public string Nickname { get; set; }
/// <summary>
- /// The user's email address.
+ /// Gets or sets the user's email address.
/// </summary>
[MessagePart(Constants.email)]
public string Email { get; set; }
/// <summary>
- /// The full name of a user as a single string.
+ /// Gets or sets the full name of a user as a single string.
/// </summary>
[MessagePart(Constants.fullname)]
public string FullName { get; set; }
/// <summary>
- /// The user's birthdate.
+ /// Gets or sets the user's birthdate.
/// </summary>
public DateTime? BirthDate {
get {
@@ -98,6 +107,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { set {
this.birthDate = value;
+
// Don't use property accessor for peer property to avoid infinite loop between the two proeprty accessors.
if (value.HasValue) {
this.birthDateRaw = value.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
@@ -107,6 +117,10 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { }
}
+ /// <summary>
+ /// Gets or sets the raw birth date string given by the extension.
+ /// </summary>
+ /// <value>A string in the format yyyy-MM-dd.</value>
[MessagePart(Constants.dob)]
public string BirthDateRaw {
get {
@@ -118,6 +132,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { if (!birthDateValidator.IsMatch(value)) {
throw new ArgumentException(OpenIdStrings.SregInvalidBirthdate, "value");
}
+
// Update the BirthDate property, if possible.
// Don't use property accessor for peer property to avoid infinite loop between the two proeprty accessors.
// Some valid sreg dob values like "2000-00-00" will not work as a DateTime struct,
@@ -138,69 +153,73 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { }
/// <summary>
- /// The gender of the user.
+ /// Gets or sets the gender of the user.
/// </summary>
[MessagePart(Constants.gender, Encoder = typeof(GenderEncoder))]
public Gender? Gender { get; set; }
/// <summary>
- /// The zip code / postal code of the user.
+ /// Gets or sets the zip code / postal code of the user.
/// </summary>
[MessagePart(Constants.postcode)]
public string PostalCode { get; set; }
/// <summary>
- /// The country of the user.
+ /// Gets or sets the country of the user.
/// </summary>
[MessagePart(Constants.country)]
public string Country { get; set; }
/// <summary>
- /// The primary/preferred language of the user.
+ /// Gets or sets the primary/preferred language of the user.
/// </summary>
[MessagePart(Constants.language)]
public string Language { get; set; }
/// <summary>
- /// The user's timezone.
+ /// Gets or sets the user's timezone.
/// </summary>
[MessagePart(Constants.timezone)]
public string TimeZone { get; set; }
/// <summary>
- /// A combination of the user's full name and email address.
+ /// Gets a combination of the user's full name and email address.
/// </summary>
public MailAddress MailAddress {
get {
- if (string.IsNullOrEmpty(Email)) return null;
- if (string.IsNullOrEmpty(FullName))
- return new MailAddress(Email);
- else
- return new MailAddress(Email, FullName);
+ if (string.IsNullOrEmpty(this.Email)) {
+ return null;
+ } else if (string.IsNullOrEmpty(this.FullName)) {
+ return new MailAddress(this.Email);
+ } else {
+ return new MailAddress(this.Email, this.FullName);
+ }
}
}
/// <summary>
- /// A combination o the language and country of the user.
+ /// Gets or sets a combination o the language and country of the user.
/// </summary>
[XmlIgnore]
public CultureInfo Culture {
get {
- if (culture == null && !string.IsNullOrEmpty(Language)) {
- string cultureString = "";
- cultureString = Language;
- if (!string.IsNullOrEmpty(Country))
- cultureString += "-" + Country;
- culture = CultureInfo.GetCultureInfo(cultureString);
+ if (this.culture == null && !string.IsNullOrEmpty(this.Language)) {
+ string cultureString = string.Empty;
+ cultureString = this.Language;
+ if (!string.IsNullOrEmpty(this.Country)) {
+ cultureString += "-" + this.Country;
+ }
+ this.culture = CultureInfo.GetCultureInfo(cultureString);
}
- return culture;
+ return this.culture;
}
+
set {
- culture = value;
- Language = (value != null) ? value.TwoLetterISOLanguageName : null;
+ this.culture = value;
+ this.Language = (value != null) ? value.TwoLetterISOLanguageName : null;
int indexOfHyphen = (value != null) ? value.Name.IndexOf('-') : -1;
- Country = indexOfHyphen > 0 ? value.Name.Substring(indexOfHyphen + 1) : null;
+ this.Country = indexOfHyphen > 0 ? value.Name.Substring(indexOfHyphen + 1) : null;
}
}
@@ -249,6 +268,9 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { /// <summary>
/// Tests equality of two <see cref="ClaimsResponse"/> objects.
/// </summary>
+ /// <param name="one">One instance to compare.</param>
+ /// <param name="other">Another instance to compare.</param>
+ /// <returns>The result of the operator.</returns>
public static bool operator ==(ClaimsResponse one, ClaimsResponse other) {
return one.EqualsNullSafe(other);
}
@@ -256,6 +278,9 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { /// <summary>
/// Tests inequality of two <see cref="ClaimsResponse"/> objects.
/// </summary>
+ /// <param name="one">One instance to compare.</param>
+ /// <param name="other">Another instance to compare.</param>
+ /// <returns>The result of the operator.</returns>
public static bool operator !=(ClaimsResponse one, ClaimsResponse other) {
return !(one == other);
}
@@ -263,9 +288,18 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { /// <summary>
/// Tests equality of two <see cref="ClaimsResponse"/> objects.
/// </summary>
+ /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
+ /// <returns>
+ /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
+ /// </returns>
+ /// <exception cref="T:System.NullReferenceException">
+ /// The <paramref name="obj"/> parameter is null.
+ /// </exception>
public override bool Equals(object obj) {
ClaimsResponse other = obj as ClaimsResponse;
- if (other == null) return false;
+ if (other == null) {
+ return false;
+ }
return
this.BirthDateRaw.EqualsNullSafe(other.BirthDateRaw) &&
@@ -279,8 +313,14 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { this.TimeZone.EqualsNullSafe(other.TimeZone);
}
- private static string createAddFieldJS(string propertyName, string value) {
- return string.Format(CultureInfo.InvariantCulture, "{0}: {1},", propertyName, Util.GetSafeJavascriptValue(value));
+ /// <summary>
+ /// Serves as a hash function for a particular type.
+ /// </summary>
+ /// <returns>
+ /// A hash code for the current <see cref="T:System.Object"/>.
+ /// </returns>
+ public override int GetHashCode() {
+ return (this.Nickname != null) ? this.Nickname.GetHashCode() : base.GetHashCode();
}
}
}
\ No newline at end of file diff --git a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Constants.cs b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Constants.cs index 85f44de..2d8413f 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Constants.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Constants.cs @@ -1,8 +1,15 @@ -using System;
-using System.Collections.Generic;
-using System.Text;
+// <auto-generated/> // disable StyleCop on this file
+//-----------------------------------------------------------------------
+// <copyright file="Constants.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+
/// <summary>
/// Simple Registration constants
/// </summary>
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/DemandLevel.cs b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/DemandLevel.cs index 16fb57f..49e3a10 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/DemandLevel.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/DemandLevel.cs @@ -1,9 +1,8 @@ -/********************************************************
- * Copyright (C) 2007 Andrew Arnott
- * Released under the New BSD License
- * License available here: http://www.opensource.org/licenses/bsd-license.php
- * For news or support on this file: http://blog.nerdbank.net/
- ********************************************************/
+//-----------------------------------------------------------------------
+// <copyright file="DemandLevel.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
/// <summary>
@@ -15,11 +14,13 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { /// The relying party has no interest in obtaining this field.
/// </summary>
NoRequest,
+
/// <summary>
/// The relying party would like the value of this field, but wants
/// the Provider to display the field to the user as optionally provided.
/// </summary>
Request,
+
/// <summary>
/// The relying party considers this a required field as part of
/// authentication. The Provider and/or user agent MAY still choose to
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Gender.cs b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Gender.cs index a943179..0f7f586 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Gender.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/Gender.cs @@ -1,14 +1,14 @@ -/********************************************************
- * Copyright (C) 2007 Andrew Arnott
- * Released under the New BSD License
- * License available here: http://www.opensource.org/licenses/bsd-license.php
- * For news or support on this file: http://blog.nerdbank.net/
- ********************************************************/
+//-----------------------------------------------------------------------
+// <copyright file="Gender.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
-using DotNetOpenAuth.Messaging.Reflection;
-using DotNetOpenAuth.Messaging;
-using System;
namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
+ using System;
+ using DotNetOpenAuth.Messaging;
+ using DotNetOpenAuth.Messaging.Reflection;
+
/// <summary>
/// Indicates the gender of a user.
/// </summary>
@@ -17,6 +17,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { /// The user is male.
/// </summary>
Male,
+
/// <summary>
/// The user is female.
/// </summary>
diff --git a/src/DotNetOpenAuth/OpenId/Messages/DirectResponseBase.cs b/src/DotNetOpenAuth/OpenId/Messages/DirectResponseBase.cs index 850212c..503a1d8 100644 --- a/src/DotNetOpenAuth/OpenId/Messages/DirectResponseBase.cs +++ b/src/DotNetOpenAuth/OpenId/Messages/DirectResponseBase.cs @@ -99,6 +99,13 @@ namespace DotNetOpenAuth.OpenId.Messages { #endregion
/// <summary>
+ /// Gets a value indicating whether this message was deserialized as an incoming message.
+ /// </summary>
+ protected internal bool Incoming {
+ get { return this.incoming; }
+ }
+
+ /// <summary>
/// Gets the protocol used by this message.
/// </summary>
protected Protocol Protocol {
@@ -112,13 +119,6 @@ namespace DotNetOpenAuth.OpenId.Messages { get { return this.originatingRequest; }
}
- /// <summary>
- /// Gets a value indicating whether this message was deserialized as an incoming message.
- /// </summary>
- protected internal bool Incoming {
- get { return this.incoming; }
- }
-
#region IProtocolMessage methods
/// <summary>
diff --git a/src/DotNetOpenAuth/OpenId/Messages/IOpenIdMessageExtension.cs b/src/DotNetOpenAuth/OpenId/Messages/IOpenIdMessageExtension.cs index 8792e60..4fe066b 100644 --- a/src/DotNetOpenAuth/OpenId/Messages/IOpenIdMessageExtension.cs +++ b/src/DotNetOpenAuth/OpenId/Messages/IOpenIdMessageExtension.cs @@ -21,7 +21,7 @@ namespace DotNetOpenAuth.OpenId.Messages { string TypeUri { get; }
/// <summary>
- /// Additional TypeURIs that are supported by this extension, in preferred order.
+ /// Gets the additional TypeURIs that are supported by this extension, in preferred order.
/// May be empty if none other than <see cref="TypeUri"/> is supported, but
/// should not be null.
/// </summary>
@@ -33,7 +33,7 @@ namespace DotNetOpenAuth.OpenId.Messages { /// consider adding a CreateResponse method to your request extension class
/// so that the response can have the context it needs to remain compatible
/// given the version of the extension in the request message.
- /// The <see cref="SimpleRegistration.ClaimsRequest.CreateResponse"/> for an example.
+ /// The <see cref="Extensions.SimpleRegistration.ClaimsRequest.CreateResponse"/> for an example.
/// </remarks>
IEnumerable<string> AdditionalSupportedTypeUris { get; }
}
diff --git a/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs b/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs index 072cef5..373fc06 100644 --- a/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs +++ b/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs @@ -6,6 +6,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
using System;
+ using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Net.Security;
@@ -13,7 +14,6 @@ namespace DotNetOpenAuth.OpenId.Messages { using DotNetOpenAuth.Messaging.Bindings;
using DotNetOpenAuth.Messaging.Reflection;
using DotNetOpenAuth.OpenId.ChannelElements;
- using System.Collections.Generic;
/// <summary>
/// An indirect message from a Provider to a Relying Party where at least part of the
@@ -85,6 +85,21 @@ namespace DotNetOpenAuth.OpenId.Messages { : base(version, relyingPartyReturnTo, Protocol.Lookup(version).Args.Mode.id_res) {
}
+ #region IProtocolMessageWithExtensions Members
+
+ /// <summary>
+ /// Gets the list of extensions that are included with this message.
+ /// </summary>
+ /// <value></value>
+ /// <remarks>
+ /// Implementations of this interface should ensure that this property never returns null.
+ /// </remarks>
+ public IList<IExtensionMessage> Extensions {
+ get { return this.extensions; }
+ }
+
+ #endregion
+
/// <summary>
/// Gets the level of protection this message requires.
/// </summary>
@@ -199,20 +214,5 @@ namespace DotNetOpenAuth.OpenId.Messages { }
}
}
-
- #region IProtocolMessageWithExtensions Members
-
- /// <summary>
- /// Gets the list of extensions that are included with this message.
- /// </summary>
- /// <value></value>
- /// <remarks>
- /// Implementations of this interface should ensure that this property never returns null.
- /// </remarks>
- public IList<IExtensionMessage> Extensions {
- get { return this.extensions; }
- }
-
- #endregion
}
}
diff --git a/src/DotNetOpenAuth/OpenId/Messages/RequestBase.cs b/src/DotNetOpenAuth/OpenId/Messages/RequestBase.cs index 2003bd9..c8735ca 100644 --- a/src/DotNetOpenAuth/OpenId/Messages/RequestBase.cs +++ b/src/DotNetOpenAuth/OpenId/Messages/RequestBase.cs @@ -129,17 +129,17 @@ namespace DotNetOpenAuth.OpenId.Messages { #endregion
/// <summary>
- /// Gets the protocol used by this message.
+ /// Gets a value indicating whether this message was deserialized as an incoming message.
/// </summary>
- protected Protocol Protocol {
- get { return Protocol.Lookup(this.Version); }
+ protected internal bool Incoming {
+ get { return this.incoming; }
}
/// <summary>
- /// Gets a value indicating whether this message was deserialized as an incoming message.
+ /// Gets the protocol used by this message.
/// </summary>
- protected internal bool Incoming {
- get { return this.incoming; }
+ protected Protocol Protocol {
+ get { return Protocol.Lookup(this.Version); }
}
#region IProtocolMessage Methods
diff --git a/src/DotNetOpenAuth/Util.cs b/src/DotNetOpenAuth/Util.cs index d72c8f8..e2ad5f7 100644 --- a/src/DotNetOpenAuth/Util.cs +++ b/src/DotNetOpenAuth/Util.cs @@ -23,19 +23,19 @@ namespace DotNetOpenAuth { /// http://code.google.com/p/doctype/wiki/ArticleXSSInJavaScript
/// </remarks>
private static readonly Dictionary<string, string> javascriptStaticStringEscaping = new Dictionary<string, string> {
- {"\\", @"\\" }, // this WAS just above the & substitution but we moved it here to prevent double-escaping
- {"\t", @"\t" },
- {"\n", @"\n" },
- {"\r", @"\r" },
- {"\u0085", @"\u0085" },
- {"\u2028", @"\u2028" },
- {"\u2029", @"\u2029" },
- {"'", @"\x27" },
- {"\"", @"\x22" },
- {"&", @"\x26" },
- {"<", @"\x3c" },
- {">", @"\x3e" },
- {"=", @"\x3d" },
+ { "\\", @"\\" }, // this WAS just above the & substitution but we moved it here to prevent double-escaping
+ { "\t", @"\t" },
+ { "\n", @"\n" },
+ { "\r", @"\r" },
+ { "\u0085", @"\u0085" },
+ { "\u2028", @"\u2028" },
+ { "\u2029", @"\u2029" },
+ { "'", @"\x27" },
+ { "\"", @"\x22" },
+ { "&", @"\x26" },
+ { "<", @"\x3c" },
+ { ">", @"\x3e" },
+ { "=", @"\x3d" },
};
/// <summary>
@@ -81,7 +81,10 @@ namespace DotNetOpenAuth { /// <param name="value">The untrusted string value to be escaped to protected against XSS attacks.</param>
/// <returns>The escaped string.</returns>
internal static string GetSafeJavascriptValue(string value) {
- if (value == null) return "null";
+ if (value == null) {
+ return "null";
+ }
+
// We use a StringBuilder because we have potentially many replacements to do,
// and we don't want to create a new string for every intermediate replacement step.
StringBuilder builder = new StringBuilder(value);
|