summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-09-28 22:27:59 -0700
committerAndrew <andrewarnott@gmail.com>2008-09-28 22:32:54 -0700
commitaff8bdb3b5b67fbb9f5879843d657b120b2128a7 (patch)
treeabf9782fd7acbb32e7313a625f76bd031eadcb13 /src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs
parent667def8345605f97429898712f0ff13e263d13df (diff)
downloadDotNetOpenAuth-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.
Diffstat (limited to 'src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs')
-rw-r--r--src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs49
1 files changed, 49 insertions, 0 deletions
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
+ }
+}