summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-12-09 23:55:42 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2009-12-09 23:55:42 -0800
commit89538d518854daddd108affe7688fbd7a03a9949 (patch)
tree328a2d97c340ba91805a116923aaeddb586dc990 /src
parent0a1042ae9ff54c5b3523e1cf4210c1fade4a9144 (diff)
parent4ebb33b6c0ca65e31d489c8c14c8c74a48734d8c (diff)
downloadDotNetOpenAuth-89538d518854daddd108affe7688fbd7a03a9949.zip
DotNetOpenAuth-89538d518854daddd108affe7688fbd7a03a9949.tar.gz
DotNetOpenAuth-89538d518854daddd108affe7688fbd7a03a9949.tar.bz2
Merge branch 'v3.2' into mono2
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/DiffieHellmanTests.cs4
-rw-r--r--src/DotNetOpenAuth/Messaging/Reflection/MessageDescription.cs15
-rw-r--r--src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs14
-rw-r--r--src/DotNetOpenAuth/OpenId/Extensions/ExtensionArgumentsManager.cs10
4 files changed, 33 insertions, 10 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/DiffieHellmanTests.cs b/src/DotNetOpenAuth.Test/OpenId/DiffieHellmanTests.cs
index fbbea71..426e19a 100644
--- a/src/DotNetOpenAuth.Test/OpenId/DiffieHellmanTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/DiffieHellmanTests.cs
@@ -13,7 +13,7 @@ namespace DotNetOpenAuth.Test.OpenId {
using Org.Mentalis.Security.Cryptography;
[TestClass]
- public class DiffieHellmanTests {
+ public class DiffieHellmanTests : OpenIdTestBase {
[TestMethod]
public void Test() {
string s1 = Test1();
@@ -28,7 +28,9 @@ namespace DotNetOpenAuth.Test.OpenId {
try {
string line;
+ int lineNumber = 0;
while ((line = reader.ReadLine()) != null) {
+ TestContext.WriteLine("\tLine {0}", ++lineNumber);
string[] parts = line.Trim().Split(' ');
byte[] x = Convert.FromBase64String(parts[0]);
DiffieHellmanManaged dh = new DiffieHellmanManaged(AssociateDiffieHellmanRequest.DefaultMod, AssociateDiffieHellmanRequest.DefaultGen, x);
diff --git a/src/DotNetOpenAuth/Messaging/Reflection/MessageDescription.cs b/src/DotNetOpenAuth/Messaging/Reflection/MessageDescription.cs
index 5cb7877..cadce44 100644
--- a/src/DotNetOpenAuth/Messaging/Reflection/MessageDescription.cs
+++ b/src/DotNetOpenAuth/Messaging/Reflection/MessageDescription.cs
@@ -114,10 +114,19 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// <summary>
/// Ensures the message parts pass basic validation.
/// </summary>
- /// <param name="parts">The key/value pairs of the serialzied message.</param>
+ /// <param name="parts">The key/value pairs of the serialized message.</param>
internal void EnsureMessagePartsPassBasicValidation(IDictionary<string, string> parts) {
- this.EnsureRequiredMessagePartsArePresent(parts.Keys);
- this.EnsureRequiredProtocolMessagePartsAreNotEmpty(parts);
+ try {
+ this.EnsureRequiredMessagePartsArePresent(parts.Keys);
+ this.EnsureRequiredProtocolMessagePartsAreNotEmpty(parts);
+ } catch (ProtocolException) {
+ Logger.Messaging.ErrorFormat(
+ "Error while performing basic validation of {0} with these message parts:{1}{2}",
+ this.messageType.Name,
+ Environment.NewLine,
+ parts.ToStringDeferred());
+ throw;
+ }
}
/// <summary>
diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs
index fa6bfa4..6f9c79a 100644
--- a/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs
+++ b/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs
@@ -100,7 +100,12 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
// OpenID 2.0 Section 12 forbids two extensions with the same TypeURI in the same message.
ErrorUtilities.VerifyProtocol(!extensionManager.ContainsExtension(extension.TypeUri), OpenIdStrings.ExtensionAlreadyAddedWithSameTypeURI, extension.TypeUri);
- var extensionDictionary = this.Channel.MessageDescriptions.GetAccessor(extension).Serialize();
+ // Ensure that we're sending out a valid extension.
+ var extensionDescription = this.Channel.MessageDescriptions.Get(extension);
+ var extensionDictionary = extensionDescription.GetDictionary(extension).Serialize();
+ extensionDescription.EnsureMessagePartsPassBasicValidation(extensionDictionary);
+
+ // Add the extension to the outgoing message payload.
extensionManager.AddExtensionArguments(extension.TypeUri, extensionDictionary);
} else {
Logger.OpenId.WarnFormat("Unexpected extension type {0} did not implement {1}.", protocolExtension.GetType(), typeof(IOpenIdMessageExtension).Name);
@@ -193,7 +198,12 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
IOpenIdMessageExtension extension = this.ExtensionFactory.Create(typeUri, extensionData, message, isAtProvider);
if (extension != null) {
try {
- MessageDictionary extensionDictionary = this.Channel.MessageDescriptions.GetAccessor(extension);
+ // Make sure the extension fulfills spec requirements before deserializing it.
+ MessageDescription messageDescription = this.Channel.MessageDescriptions.Get(extension);
+ messageDescription.EnsureMessagePartsPassBasicValidation(extensionData);
+
+ // Deserialize the extension.
+ MessageDictionary extensionDictionary = messageDescription.GetDictionary(extension);
foreach (var pair in extensionData) {
extensionDictionary[pair.Key] = pair.Value;
}
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/ExtensionArgumentsManager.cs b/src/DotNetOpenAuth/OpenId/Extensions/ExtensionArgumentsManager.cs
index 5c4e978..e33be0f 100644
--- a/src/DotNetOpenAuth/OpenId/Extensions/ExtensionArgumentsManager.cs
+++ b/src/DotNetOpenAuth/OpenId/Extensions/ExtensionArgumentsManager.cs
@@ -70,10 +70,12 @@ namespace DotNetOpenAuth.OpenId.Extensions {
}
// For backwards compatibility, add certain aliases if they aren't defined.
- foreach (var pair in typeUriToAliasAffinity) {
- if (!mgr.aliasManager.IsAliasAssignedTo(pair.Key) &&
- !mgr.aliasManager.IsAliasUsed(pair.Value)) {
- mgr.aliasManager.SetAlias(pair.Value, pair.Key);
+ if (mgr.protocol.Version.Major < 2) {
+ foreach (var pair in typeUriToAliasAffinity) {
+ if (!mgr.aliasManager.IsAliasAssignedTo(pair.Key) &&
+ !mgr.aliasManager.IsAliasUsed(pair.Value)) {
+ mgr.aliasManager.SetAlias(pair.Value, pair.Key);
+ }
}
}