diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-12-03 16:16:52 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-12-03 16:16:52 -0800 |
commit | 4ebb33b6c0ca65e31d489c8c14c8c74a48734d8c (patch) | |
tree | 56554ba986a7624803a62a3e3b94d807a6cc526c /src | |
parent | 7c1d657f7a81bf628298d37246dcb4165473738f (diff) | |
parent | b5572b44cd369b3a0ed825251f44f7e54a1714d4 (diff) | |
download | DotNetOpenAuth-4ebb33b6c0ca65e31d489c8c14c8c74a48734d8c.zip DotNetOpenAuth-4ebb33b6c0ca65e31d489c8c14c8c74a48734d8c.tar.gz DotNetOpenAuth-4ebb33b6c0ca65e31d489c8c14c8c74a48734d8c.tar.bz2 |
Merge branch 'v3.1' into v3.2
Diffstat (limited to 'src')
3 files changed, 30 insertions, 9 deletions
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); + } } } |