blob: 9a157b53ae5de01ac167b4e3544635eac7ff8668 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
}
}
|