summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-10-04 16:44:16 -0700
committerAndrew <andrewarnott@gmail.com>2008-10-04 16:44:16 -0700
commit3273432532a1d3ba03d19663cbbbd748b3ea5094 (patch)
tree76d2a6c2ed9fb3457909b9669fc03952da16b8dc /src
parentd89b47ef7d65ec863e8858e4cc52024c77092915 (diff)
downloadDotNetOpenAuth-3273432532a1d3ba03d19663cbbbd748b3ea5094.zip
DotNetOpenAuth-3273432532a1d3ba03d19663cbbbd748b3ea5094.tar.gz
DotNetOpenAuth-3273432532a1d3ba03d19663cbbbd748b3ea5094.tar.bz2
Changed the way HttpMethod is derived for signing verification.
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs10
-rw-r--r--src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs4
-rw-r--r--src/DotNetOAuth/Messages/SignedMessageBase.cs14
-rw-r--r--src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs5
-rw-r--r--src/DotNetOAuth/Messaging/MessagingStrings.Designer.cs9
-rw-r--r--src/DotNetOAuth/Messaging/MessagingStrings.resx3
-rw-r--r--src/DotNetOAuth/ServiceProviderDescription.cs2
7 files changed, 23 insertions, 24 deletions
diff --git a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs
index 4e9ce0f..c49d341 100644
--- a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs
+++ b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs
@@ -76,7 +76,6 @@ namespace DotNetOAuth.Test.Scenarios {
protected override Response SendDirectMessageResponse(IProtocolMessage response) {
TestBase.TestLogger.InfoFormat("Sending response: {0}", response);
this.RemoteChannel.incomingMessage = CloneSerializedParts(response, null);
- this.CopyDirectionalParts(response, this.RemoteChannel.incomingMessage);
this.RemoteChannel.incomingMessageSignal.Set();
return null;
}
@@ -108,7 +107,6 @@ namespace DotNetOAuth.Test.Scenarios {
}
requestInfo.Message = this.CloneSerializedParts(message, requestInfo);
- this.CopyDirectionalParts(message, requestInfo.Message); // Remove since its body is empty.
return requestInfo;
}
@@ -142,14 +140,6 @@ namespace DotNetOAuth.Test.Scenarios {
return (T)serializer.Deserialize(serializer.Serialize(message), recipient);
}
- private void CopyDirectionalParts(IProtocolMessage original, IProtocolMessage copy) {
- var signedOriginal = original as ITamperResistantOAuthMessage;
- var signedCopy = copy as ITamperResistantOAuthMessage;
- if (signedOriginal != null && signedCopy != null) {
- signedCopy.HttpMethod = signedOriginal.HttpMethod;
- }
- }
-
private string GetHttpMethod(HttpDeliveryMethod methods) {
return (methods & HttpDeliveryMethod.PostRequest) != 0 ? "POST" : "GET";
}
diff --git a/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs b/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs
index f247fbc..4a5a912 100644
--- a/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs
+++ b/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs
@@ -37,9 +37,7 @@ namespace DotNetOAuth.ChannelElements {
if (oauthMessage != null) {
HttpDeliveryMethod transmissionMethod = oauthMessage.HttpMethods;
- if ((transmissionMethod & HttpDeliveryMethod.AuthorizationHeaderRequest) != 0) {
- oauthMessage.HttpMethod = "GET";
- } else if ((transmissionMethod & HttpDeliveryMethod.PostRequest) != 0) {
+ if ((transmissionMethod & HttpDeliveryMethod.PostRequest) != 0) {
oauthMessage.HttpMethod = "POST";
} else if ((transmissionMethod & HttpDeliveryMethod.GetRequest) != 0) {
oauthMessage.HttpMethod = "GET";
diff --git a/src/DotNetOAuth/Messages/SignedMessageBase.cs b/src/DotNetOAuth/Messages/SignedMessageBase.cs
index 88e6239..75fa8ca 100644
--- a/src/DotNetOAuth/Messages/SignedMessageBase.cs
+++ b/src/DotNetOAuth/Messages/SignedMessageBase.cs
@@ -30,17 +30,12 @@ namespace DotNetOAuth.Messages {
/// Initializes a new instance of the <see cref="SignedMessageBase"/> class.
/// </summary>
/// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param>
- internal SignedMessageBase(MessageTransport transport)
- : base(MessageProtection.All, transport) {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="SignedMessageBase"/> class.
- /// </summary>
- /// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param>
/// <param name="recipient">The URI that a directed message will be delivered to.</param>
internal SignedMessageBase(MessageTransport transport, MessageReceivingEndpoint recipient)
: base(MessageProtection.All, transport, recipient) {
+ ITamperResistantOAuthMessage self = (ITamperResistantOAuthMessage)this;
+ HttpDeliveryMethod methods = ((IOAuthDirectedMessage)this).HttpMethods;
+ self.HttpMethod = (methods & HttpDeliveryMethod.PostRequest) != 0 ? "POST" : "GET";
}
#region ITamperResistantOAuthMessage Members
@@ -53,7 +48,6 @@ namespace DotNetOAuth.Messages {
/// <summary>
/// Gets or sets the Token Secret used to sign the message.
- /// Only applicable to Consumer.
/// </summary>
public string TokenSecret { get; set; }
@@ -65,13 +59,11 @@ namespace DotNetOAuth.Messages {
/// <summary>
/// Gets or sets the Consumer Secret used to sign the message.
- /// Only applicable to Consumer.
/// </summary>
public string ConsumerSecret { get; set; }
/// <summary>
/// Gets or sets the HTTP method that will be used to transmit the message.
- /// Only applicable to Consumer.
/// </summary>
string ITamperResistantOAuthMessage.HttpMethod { get; set; }
diff --git a/src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs b/src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs
index 9ad749b..31c79ca 100644
--- a/src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs
+++ b/src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs
@@ -6,10 +6,12 @@
namespace DotNetOAuth.Messaging {
using System;
+ using System.Diagnostics;
/// <summary>
/// An immutable description of a URL that receives messages.
/// </summary>
+ [DebuggerDisplay("{AllowedMethods} {Location}")]
public class MessageReceivingEndpoint {
/// <summary>
/// Initializes a new instance of the <see cref="MessageReceivingEndpoint"/> class.
@@ -31,6 +33,9 @@ namespace DotNetOAuth.Messaging {
if (method == HttpDeliveryMethod.None) {
throw new ArgumentOutOfRangeException("method");
}
+ if ((method & (HttpDeliveryMethod.PostRequest | HttpDeliveryMethod.GetRequest)) == 0) {
+ throw new ArgumentOutOfRangeException("method", MessagingStrings.GetOrPostFlagsRequired);
+ }
this.Location = location;
this.AllowedMethods = method;
diff --git a/src/DotNetOAuth/Messaging/MessagingStrings.Designer.cs b/src/DotNetOAuth/Messaging/MessagingStrings.Designer.cs
index 5fd839a..c002ecd 100644
--- a/src/DotNetOAuth/Messaging/MessagingStrings.Designer.cs
+++ b/src/DotNetOAuth/Messaging/MessagingStrings.Designer.cs
@@ -151,6 +151,15 @@ namespace DotNetOAuth.Messaging {
}
/// <summary>
+ /// Looks up a localized string similar to At least one of GET or POST flags must be present..
+ /// </summary>
+ internal static string GetOrPostFlagsRequired {
+ get {
+ return ResourceManager.GetString("GetOrPostFlagsRequired", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to This method requires a current HttpContext. Alternatively, use an overload of this method that allows you to pass in information without an HttpContext..
/// </summary>
internal static string HttpContextRequired {
diff --git a/src/DotNetOAuth/Messaging/MessagingStrings.resx b/src/DotNetOAuth/Messaging/MessagingStrings.resx
index 66db7f4..255938c 100644
--- a/src/DotNetOAuth/Messaging/MessagingStrings.resx
+++ b/src/DotNetOAuth/Messaging/MessagingStrings.resx
@@ -147,6 +147,9 @@
<data name="ExpiredMessage" xml:space="preserve">
<value>The message expired at {0} and it is now {1}.</value>
</data>
+ <data name="GetOrPostFlagsRequired" xml:space="preserve">
+ <value>At least one of GET or POST flags must be present.</value>
+ </data>
<data name="HttpContextRequired" xml:space="preserve">
<value>This method requires a current HttpContext. Alternatively, use an overload of this method that allows you to pass in information without an HttpContext.</value>
</data>
diff --git a/src/DotNetOAuth/ServiceProviderDescription.cs b/src/DotNetOAuth/ServiceProviderDescription.cs
index 2148a8a..0ade8d4 100644
--- a/src/DotNetOAuth/ServiceProviderDescription.cs
+++ b/src/DotNetOAuth/ServiceProviderDescription.cs
@@ -6,6 +6,7 @@
namespace DotNetOAuth {
using System;
+ using System.Diagnostics;
using DotNetOAuth.ChannelElements;
using DotNetOAuth.Messaging;
@@ -16,6 +17,7 @@ namespace DotNetOAuth {
/// <summary>
/// The field used to store the value of the <see cref="RequestTokenEndpoint"/> property.
/// </summary>
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
private MessageReceivingEndpoint requestTokenEndpoint;
/// <summary>