diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-28 22:27:59 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-09-28 22:32:54 -0700 |
commit | aff8bdb3b5b67fbb9f5879843d657b120b2128a7 (patch) | |
tree | abf9782fd7acbb32e7313a625f76bd031eadcb13 | |
parent | 667def8345605f97429898712f0ff13e263d13df (diff) | |
download | DotNetOpenAuth-aff8bdb3b5b67fbb9f5879843d657b120b2128a7.zip DotNetOpenAuth-aff8bdb3b5b67fbb9f5879843d657b120b2128a7.tar.gz DotNetOpenAuth-aff8bdb3b5b67fbb9f5879843d657b120b2128a7.tar.bz2 |
Fixed OAuth channel bug that would not set HTTP Method in time for HMAC-SHA1 signing.
-rw-r--r-- | src/DotNetOAuth/ChannelElements/OAuthChannel.cs | 2 | ||||
-rw-r--r-- | src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs | 49 | ||||
-rw-r--r-- | src/DotNetOAuth/DotNetOAuth.csproj | 1 |
3 files changed, 51 insertions, 1 deletions
diff --git a/src/DotNetOAuth/ChannelElements/OAuthChannel.cs b/src/DotNetOAuth/ChannelElements/OAuthChannel.cs index 5bb05b6..38e6434 100644 --- a/src/DotNetOAuth/ChannelElements/OAuthChannel.cs +++ b/src/DotNetOAuth/ChannelElements/OAuthChannel.cs @@ -53,7 +53,7 @@ namespace DotNetOAuth.ChannelElements { /// This overload for testing purposes only.
/// </remarks>
internal OAuthChannel(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, IMessageTypeProvider messageTypeProvider, IWebRequestHandler webRequestHandler)
- : base(messageTypeProvider, signingBindingElement, new StandardExpirationBindingElement(), new StandardReplayProtectionBindingElement(store)) {
+ : base(messageTypeProvider, new OAuthHttpMethodBindingElement(), signingBindingElement, new StandardExpirationBindingElement(), new StandardReplayProtectionBindingElement(store)) {
if (webRequestHandler == null) {
throw new ArgumentNullException("webRequestHandler");
}
diff --git a/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs b/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs new file mode 100644 index 0000000..9a157b5 --- /dev/null +++ b/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs @@ -0,0 +1,49 @@ +//-----------------------------------------------------------------------
+// <copyright file="OAuthHttpMethodBindingElement.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.ChannelElements {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using DotNetOAuth.Messaging;
+
+ internal class OAuthHttpMethodBindingElement : IChannelBindingElement {
+
+ #region IChannelBindingElement Members
+
+ public MessageProtection Protection {
+ get { return MessageProtection.None; }
+ }
+
+ public bool PrepareMessageForSending(IProtocolMessage message) {
+ var oauthMessage = message as ITamperResistantOAuthMessage;
+
+ if (oauthMessage != null) {
+ HttpDeliveryMethod transmissionMethod = oauthMessage.HttpMethods;
+ if ((transmissionMethod & HttpDeliveryMethod.AuthorizationHeaderRequest) != 0) {
+ oauthMessage.HttpMethod = "GET";
+ } else if ((transmissionMethod & HttpDeliveryMethod.PostRequest) != 0) {
+ oauthMessage.HttpMethod = "POST";
+ } else if ((transmissionMethod & HttpDeliveryMethod.GetRequest) != 0) {
+ oauthMessage.HttpMethod = "GET";
+ } else {
+ return false;
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public bool PrepareMessageForReceiving(IProtocolMessage message) {
+ return false;
+ }
+
+ #endregion
+ }
+}
diff --git a/src/DotNetOAuth/DotNetOAuth.csproj b/src/DotNetOAuth/DotNetOAuth.csproj index 4645a41..9eb36d0 100644 --- a/src/DotNetOAuth/DotNetOAuth.csproj +++ b/src/DotNetOAuth/DotNetOAuth.csproj @@ -59,6 +59,7 @@ <ItemGroup>
<Compile Include="ChannelElements\ITokenGenerator.cs" />
<Compile Include="ChannelElements\ITokenManager.cs" />
+ <Compile Include="ChannelElements\OAuthHttpMethodBindingElement.cs" />
<Compile Include="ChannelElements\PlainTextSigningBindingElement.cs" />
<Compile Include="ChannelElements\HmacSha1SigningBindingElement.cs" />
<Compile Include="ChannelElements\SigningBindingElementChain.cs" />
|