diff options
Diffstat (limited to 'src')
-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" />
|