diff options
Diffstat (limited to 'src')
32 files changed, 246 insertions, 157 deletions
diff --git a/src/DotNetOAuth.Test/ChannelElements/PlainTextSigningBindingElementTest.cs b/src/DotNetOAuth.Test/ChannelElements/PlainTextSigningBindingElementTest.cs index de2c45f..2c26df8 100644 --- a/src/DotNetOAuth.Test/ChannelElements/PlainTextSigningBindingElementTest.cs +++ b/src/DotNetOAuth.Test/ChannelElements/PlainTextSigningBindingElementTest.cs @@ -16,7 +16,7 @@ namespace DotNetOAuth.Test.ChannelElements [TestMethod]
public void HttpsSignatureGeneration() {
SigningBindingElementBase target = new PlainTextSigningBindingElement();
- ServiceProviderEndpoint endpoint = new ServiceProviderEndpoint("https://localtest", HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://localtest", HttpDeliveryMethod.GetRequest);
ITamperResistantOAuthMessage message = new RequestTokenMessage(endpoint);
message.ConsumerSecret = "cs";
message.TokenSecret = "ts";
@@ -27,7 +27,7 @@ namespace DotNetOAuth.Test.ChannelElements [TestMethod]
public void HttpsSignatureVerification() {
- ServiceProviderEndpoint endpoint = new ServiceProviderEndpoint("https://localtest", HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://localtest", HttpDeliveryMethod.GetRequest);
ITamperProtectionChannelBindingElement target = new PlainTextSigningBindingElement();
ITamperResistantOAuthMessage message = new RequestTokenMessage(endpoint);
message.ConsumerSecret = "cs";
@@ -40,7 +40,7 @@ namespace DotNetOAuth.Test.ChannelElements [TestMethod]
public void HttpsSignatureVerificationNotApplicable() {
SigningBindingElementBase target = new PlainTextSigningBindingElement();
- ServiceProviderEndpoint endpoint = new ServiceProviderEndpoint("https://localtest", HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://localtest", HttpDeliveryMethod.GetRequest);
ITamperResistantOAuthMessage message = new RequestTokenMessage(endpoint);
message.ConsumerSecret = "cs";
message.TokenSecret = "ts";
@@ -52,7 +52,7 @@ namespace DotNetOAuth.Test.ChannelElements [TestMethod]
public void HttpSignatureGeneration() {
SigningBindingElementBase target = new PlainTextSigningBindingElement();
- ServiceProviderEndpoint endpoint = new ServiceProviderEndpoint("http://localtest", HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("http://localtest", HttpDeliveryMethod.GetRequest);
ITamperResistantOAuthMessage message = new RequestTokenMessage(endpoint);
message.ConsumerSecret = "cs";
message.TokenSecret = "ts";
@@ -66,7 +66,7 @@ namespace DotNetOAuth.Test.ChannelElements [TestMethod]
public void HttpSignatureVerification() {
SigningBindingElementBase target = new PlainTextSigningBindingElement();
- ServiceProviderEndpoint endpoint = new ServiceProviderEndpoint("http://localtest", HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("http://localtest", HttpDeliveryMethod.GetRequest);
ITamperResistantOAuthMessage message = new RequestTokenMessage(endpoint);
message.ConsumerSecret = "cs";
message.TokenSecret = "ts";
diff --git a/src/DotNetOAuth.Test/Logging.config b/src/DotNetOAuth.Test/Logging.config index 66e595f..be6b69e 100644 --- a/src/DotNetOAuth.Test/Logging.config +++ b/src/DotNetOAuth.Test/Logging.config @@ -25,9 +25,9 @@ </root>
<!-- Specify the level for some specific categories -->
<logger name="DotNetOAuth">
- <level value="Warn" />
+ <level value="Debug" />
</logger>
<logger name="DotNetOAuth.Test">
- <level value="Info" />
+ <level value="Debug" />
</logger>
</log4net>
diff --git a/src/DotNetOAuth.Test/Messaging/ChannelTests.cs b/src/DotNetOAuth.Test/Messaging/ChannelTests.cs index 8aeaa5b..40bf7ac 100644 --- a/src/DotNetOAuth.Test/Messaging/ChannelTests.cs +++ b/src/DotNetOAuth.Test/Messaging/ChannelTests.cs @@ -188,13 +188,13 @@ namespace DotNetOAuth.Test.Messaging { [TestMethod, ExpectedException(typeof(ArgumentNullException))]
public void ReceiveNull() {
TestBadChannel badChannel = new TestBadChannel(false);
- badChannel.Receive(null);
+ badChannel.Receive(null, null);
}
[TestMethod]
public void ReceiveUnrecognizedMessage() {
TestBadChannel badChannel = new TestBadChannel(false);
- Assert.IsNull(badChannel.Receive(new Dictionary<string, string>()));
+ Assert.IsNull(badChannel.Receive(new Dictionary<string, string>(), null));
}
[TestMethod]
diff --git a/src/DotNetOAuth.Test/Messaging/MessageSerializerTests.cs b/src/DotNetOAuth.Test/Messaging/MessageSerializerTests.cs index 1d36b83..d2d87e1 100644 --- a/src/DotNetOAuth.Test/Messaging/MessageSerializerTests.cs +++ b/src/DotNetOAuth.Test/Messaging/MessageSerializerTests.cs @@ -55,7 +55,7 @@ namespace DotNetOAuth.Test.Messaging { [TestMethod, ExpectedException(typeof(ArgumentNullException))]
public void DeserializeNull() {
var serializer = MessageSerializer.Get(typeof(Mocks.TestMessage));
- serializer.Deserialize(null);
+ serializer.Deserialize(null, null);
}
[TestMethod]
@@ -65,7 +65,7 @@ namespace DotNetOAuth.Test.Messaging { fields["Name"] = "Andrew";
fields["age"] = "15";
fields["Timestamp"] = "1990-01-01T00:00:00";
- var actual = (Mocks.TestMessage)serializer.Deserialize(fields);
+ var actual = (Mocks.TestMessage)serializer.Deserialize(fields, null);
Assert.AreEqual(15, actual.Age);
Assert.AreEqual("Andrew", actual.Name);
Assert.AreEqual(DateTime.Parse("1/1/1990"), actual.Timestamp);
@@ -94,7 +94,7 @@ namespace DotNetOAuth.Test.Messaging { fields["SecondDerivedElement"] = "second";
fields["explicit"] = "explicitValue";
fields["private"] = "privateValue";
- var actual = (Mocks.TestDerivedMessage)serializer.Deserialize(fields);
+ var actual = (Mocks.TestDerivedMessage)serializer.Deserialize(fields, null);
Assert.AreEqual(15, actual.Age);
Assert.AreEqual("Andrew", actual.Name);
Assert.AreEqual("first", actual.TheFirstDerivedElement);
@@ -113,7 +113,7 @@ namespace DotNetOAuth.Test.Messaging { // Add some field that is not recognized by the class. This simulates a querystring with
// more parameters than are actually interesting to the protocol message.
fields["someExtraField"] = "asdf";
- var actual = (Mocks.TestMessage)serializer.Deserialize(fields);
+ var actual = (Mocks.TestMessage)serializer.Deserialize(fields, null);
Assert.AreEqual(15, actual.Age);
Assert.AreEqual("Andrew", actual.Name);
Assert.IsNull(actual.EmptyMember);
@@ -124,7 +124,7 @@ namespace DotNetOAuth.Test.Messaging { var serializer = MessageSerializer.Get(typeof(Mocks.TestMessage));
var fields = GetStandardTestFields(FieldFill.AllRequired);
fields["age"] = "-1"; // Set an disallowed value.
- serializer.Deserialize(fields);
+ serializer.Deserialize(fields, null);
}
}
}
diff --git a/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs b/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs index 1002cbc..5b59ba1 100644 --- a/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs +++ b/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs @@ -35,8 +35,8 @@ namespace DotNetOAuth.Test.Mocks { base.SendIndirectMessage(message);
}
- internal new IProtocolMessage Receive(Dictionary<string, string> fields) {
- return base.Receive(fields);
+ internal new IProtocolMessage Receive(Dictionary<string, string> fields, MessageReceivingEndpoint recipient) {
+ return base.Receive(fields, recipient);
}
internal new IProtocolMessage ReadFromRequest(HttpRequestInfo request) {
diff --git a/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs b/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs index 719a4a9..8906151 100644 --- a/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs @@ -18,7 +18,7 @@ namespace DotNetOAuth.Test.Mocks { #region IDirectedProtocolMessage Members
- public Uri Recipient { get; internal set; }
+ public Uri Recipient { get; set; }
#endregion
diff --git a/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs b/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs index 3181841..370f2d3 100644 --- a/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs +++ b/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs @@ -20,11 +20,11 @@ namespace DotNetOAuth.Test { [TestMethod]
public void SpecAppendixAExample() {
ServiceProviderEndpoints endpoints = new ServiceProviderEndpoints() {
- RequestTokenEndpoint = new ServiceProviderEndpoint("https://photos.example.net/request_token", HttpDeliveryMethod.PostRequest),
- UserAuthorizationEndpoint = new ServiceProviderEndpoint("http://photos.example.net/authorize", HttpDeliveryMethod.GetRequest),
- AccessTokenEndpoint = new ServiceProviderEndpoint("https://photos.example.net/access_token", HttpDeliveryMethod.PostRequest),
+ RequestTokenEndpoint = new MessageReceivingEndpoint("https://photos.example.net/request_token", HttpDeliveryMethod.PostRequest),
+ UserAuthorizationEndpoint = new MessageReceivingEndpoint("http://photos.example.net/authorize", HttpDeliveryMethod.GetRequest),
+ AccessTokenEndpoint = new MessageReceivingEndpoint("https://photos.example.net/access_token", HttpDeliveryMethod.PostRequest),
};
- ServiceProviderEndpoint accessPhotoEndpoint = new ServiceProviderEndpoint("http://photos.example.net/photos?file=vacation.jpg&size=original", HttpDeliveryMethod.AuthorizationHeaderRequest);
+ MessageReceivingEndpoint accessPhotoEndpoint = new MessageReceivingEndpoint("http://photos.example.net/photos?file=vacation.jpg&size=original", HttpDeliveryMethod.AuthorizationHeaderRequest);
var tokenManager = new InMemoryTokenManager();
var sp = new ServiceProvider(endpoints, tokenManager);
Consumer consumer = new Consumer(endpoints, new InMemoryTokenManager()) {
diff --git a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs index 8846aad..08a9ac8 100644 --- a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs +++ b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs @@ -43,10 +43,12 @@ namespace DotNetOAuth.Test.Scenarios { internal CoordinatingOAuthChannel RemoteChannel { get; set; }
internal Response RequestProtectedResource(AccessProtectedResourcesMessage request) {
- TestBase.TestLogger.InfoFormat("Sending protected resource request: {0}", request);
- PrepareMessageForSending(request);
+ ((ITamperResistantOAuthMessage)request).HttpMethod = this.GetHttpMethod(((ITamperResistantOAuthMessage)request).HttpMethods);
+ this.PrepareMessageForSending(request);
+ HttpRequestInfo requestInfo = this.SpoofHttpMethod(request);
+ TestBase.TestLogger.InfoFormat("Sending protected resource request: {0}", requestInfo.Message);
// Drop the outgoing message in the other channel's in-slot and let them know it's there.
- this.RemoteChannel.incomingMessage = request;
+ this.RemoteChannel.incomingMessage = requestInfo.Message;
this.RemoteChannel.incomingMessageSignal.Set();
return this.AwaitIncomingRawResponse();
}
@@ -57,9 +59,10 @@ namespace DotNetOAuth.Test.Scenarios { }
protected override IProtocolMessage RequestInternal(IDirectedProtocolMessage request) {
- TestBase.TestLogger.InfoFormat("Sending request: {0}", request);
+ HttpRequestInfo requestInfo = this.SpoofHttpMethod(request);
+ TestBase.TestLogger.InfoFormat("Sending request: {0}", requestInfo.Message);
// Drop the outgoing message in the other channel's in-slot and let them know it's there.
- this.RemoteChannel.incomingMessage = CloneSerializedParts(request);
+ this.RemoteChannel.incomingMessage = requestInfo.Message;
this.RemoteChannel.incomingMessageSignal.Set();
// Now wait for a response...
return this.AwaitIncomingMessage();
@@ -67,7 +70,8 @@ namespace DotNetOAuth.Test.Scenarios { protected override void SendDirectMessageResponse(IProtocolMessage response) {
TestBase.TestLogger.InfoFormat("Sending response: {0}", response);
- this.RemoteChannel.incomingMessage = CloneSerializedParts(response);
+ this.RemoteChannel.incomingMessage = CloneSerializedParts(response, null);
+ this.CopyDirectionalParts(response, this.RemoteChannel.incomingMessage);
this.RemoteChannel.incomingMessageSignal.Set();
}
@@ -82,7 +86,29 @@ namespace DotNetOAuth.Test.Scenarios { }
protected override IProtocolMessage ReadFromRequestInternal(HttpRequestInfo request) {
- return request.Message ?? base.ReadFromRequestInternal(request);
+ return request.Message ?? base.ReadFromRequestInternal(request); // TODO: trim off ?? and after?
+ }
+
+ /// <summary>
+ /// Spoof HTTP request information for signing/verification purposes.
+ /// </summary>
+ /// <param name="message">The message to add a pretend HTTP method to.</param>
+ /// <returns>A spoofed HttpRequestInfo that wraps the new message.</returns>
+ private HttpRequestInfo SpoofHttpMethod(IDirectedProtocolMessage message) {
+ HttpRequestInfo requestInfo = new HttpRequestInfo(message);
+
+ var signedMessage = message as ITamperResistantOAuthMessage;
+ if (signedMessage != null) {
+ string httpMethod = this.GetHttpMethod(signedMessage.HttpMethods);
+ requestInfo.HttpMethod = httpMethod;
+ requestInfo.Url = message.Recipient;
+ signedMessage.HttpMethod = httpMethod;
+ }
+
+ requestInfo.Message = this.CloneSerializedParts(message, requestInfo);
+ this.CopyDirectionalParts(message, requestInfo.Message); // Remove since its body is empty.
+
+ return requestInfo;
}
private IProtocolMessage AwaitIncomingMessage() {
@@ -99,40 +125,31 @@ namespace DotNetOAuth.Test.Scenarios { return response;
}
- private T CloneSerializedParts<T>(T message) where T : class, IProtocolMessage {
+ private T CloneSerializedParts<T>(T message, HttpRequestInfo requestInfo) where T : class, IProtocolMessage {
if (message == null) {
throw new ArgumentNullException("message");
}
- T cloned;
- var directedMessage = message as IOAuthDirectedMessage;
- if (directedMessage != null) {
- // Some OAuth messages take just the recipient, while others take the whole endpoint
- ConstructorInfo ctor;
- if ((ctor = message.GetType().GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Uri) }, null)) != null) {
- cloned = (T)ctor.Invoke(new object[] { directedMessage.Recipient });
- } else if ((ctor = message.GetType().GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(ServiceProviderEndpoint) }, null)) != null) {
- ServiceProviderEndpoint endpoint = new ServiceProviderEndpoint(
- directedMessage.Recipient,
- directedMessage.HttpMethods);
- cloned = (T)ctor.Invoke(new object[] { endpoint });
- } else if ((ctor = message.GetType().GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[0], null)) != null) {
- cloned = (T)ctor.Invoke(new object[0]);
- } else {
- throw new InvalidOperationException("Unrecognized constructor signature on type " + message.GetType());
- }
- } else {
- cloned = (T)Activator.CreateInstance(message.GetType(), true);
+ MessageReceivingEndpoint recipient = null;
+ IOAuthDirectedMessage directedMessage = message as IOAuthDirectedMessage;
+ if (directedMessage != null && directedMessage.Recipient != null) {
+ recipient = new MessageReceivingEndpoint(directedMessage.Recipient, directedMessage.HttpMethods);
}
- var messageDictionary = new MessageDictionary(message);
- var clonedDictionary = new MessageDictionary(cloned);
+ MessageSerializer serializer = MessageSerializer.Get(message.GetType());
+ return (T)serializer.Deserialize(serializer.Serialize(message), recipient);
+ }
- foreach (var pair in messageDictionary) {
- clonedDictionary[pair.Key] = pair.Value;
+ 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;
}
+ }
- return cloned;
+ private string GetHttpMethod(HttpDeliveryMethod methods) {
+ return (methods & HttpDeliveryMethod.PostRequest) != 0 ? "POST" : "GET";
}
}
}
diff --git a/src/DotNetOAuth.Test/ServiceProviderEndpointsTests.cs b/src/DotNetOAuth.Test/ServiceProviderEndpointsTests.cs index 513f880..843df09 100644 --- a/src/DotNetOAuth.Test/ServiceProviderEndpointsTests.cs +++ b/src/DotNetOAuth.Test/ServiceProviderEndpointsTests.cs @@ -20,8 +20,8 @@ namespace DotNetOAuth.Test { [TestMethod]
public void UserAuthorizationUriTest() {
ServiceProviderEndpoints target = new ServiceProviderEndpoints();
- ServiceProviderEndpoint expected = new ServiceProviderEndpoint("http://localhost/authorization", HttpDeliveryMethod.GetRequest);
- ServiceProviderEndpoint actual;
+ MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/authorization", HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint actual;
target.UserAuthorizationEndpoint = expected;
actual = target.UserAuthorizationEndpoint;
Assert.AreEqual(expected, actual);
@@ -36,8 +36,8 @@ namespace DotNetOAuth.Test { [TestMethod]
public void RequestTokenUriTest() {
var target = new ServiceProviderEndpoints();
- ServiceProviderEndpoint expected = new ServiceProviderEndpoint("http://localhost/requesttoken", HttpDeliveryMethod.GetRequest);
- ServiceProviderEndpoint actual;
+ MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/requesttoken", HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint actual;
target.RequestTokenEndpoint = expected;
actual = target.RequestTokenEndpoint;
Assert.AreEqual(expected, actual);
@@ -53,7 +53,7 @@ namespace DotNetOAuth.Test { [TestMethod, ExpectedException(typeof(ArgumentException))]
public void RequestTokenUriWithOAuthParametersTest() {
var target = new ServiceProviderEndpoints();
- target.RequestTokenEndpoint = new ServiceProviderEndpoint("http://localhost/requesttoken?oauth_token=something", HttpDeliveryMethod.GetRequest);
+ target.RequestTokenEndpoint = new MessageReceivingEndpoint("http://localhost/requesttoken?oauth_token=something", HttpDeliveryMethod.GetRequest);
}
/// <summary>
@@ -62,8 +62,8 @@ namespace DotNetOAuth.Test { [TestMethod]
public void AccessTokenUriTest() {
var target = new ServiceProviderEndpoints();
- ServiceProviderEndpoint expected = new ServiceProviderEndpoint("http://localhost/accesstoken", HttpDeliveryMethod.GetRequest);
- ServiceProviderEndpoint actual;
+ MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/accesstoken", HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint actual;
target.AccessTokenEndpoint = expected;
actual = target.AccessTokenEndpoint;
Assert.AreEqual(expected, actual);
diff --git a/src/DotNetOAuth/ChannelElements/HmacSha1SigningBindingElement.cs b/src/DotNetOAuth/ChannelElements/HmacSha1SigningBindingElement.cs index f6c7b03..5dbffed 100644 --- a/src/DotNetOAuth/ChannelElements/HmacSha1SigningBindingElement.cs +++ b/src/DotNetOAuth/ChannelElements/HmacSha1SigningBindingElement.cs @@ -31,7 +31,9 @@ namespace DotNetOAuth.ChannelElements { protected override string GetSignature(ITamperResistantOAuthMessage message) {
string key = GetConsumerAndTokenSecretString(message);
HashAlgorithm hasher = new HMACSHA1(Encoding.ASCII.GetBytes(key));
- byte[] digest = hasher.ComputeHash(Encoding.ASCII.GetBytes(ConstructSignatureBaseString(message)));
+ string baseString = ConstructSignatureBaseString(message);
+ Logger.DebugFormat("Signing message with signature base string: {0}", baseString);
+ byte[] digest = hasher.ComputeHash(Encoding.ASCII.GetBytes(baseString));
return Uri.EscapeDataString(Convert.ToBase64String(digest));
}
}
diff --git a/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs b/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs index 9483005..caeeb7c 100644 --- a/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs +++ b/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs @@ -5,6 +5,7 @@ //-----------------------------------------------------------------------
namespace DotNetOAuth.ChannelElements {
+ using System;
using DotNetOAuth.Messaging;
/// <summary>
@@ -15,5 +16,10 @@ namespace DotNetOAuth.ChannelElements { /// Gets the preferred method of transport for the message.
/// </summary>
HttpDeliveryMethod HttpMethods { get; }
+
+ /// <summary>
+ /// Gets or sets the URL of the intended receiver of this message.
+ /// </summary>
+ new Uri Recipient { get; set; }
}
}
diff --git a/src/DotNetOAuth/ChannelElements/ITamperResistantOAuthMessage.cs b/src/DotNetOAuth/ChannelElements/ITamperResistantOAuthMessage.cs index a7f9892..926dcfb 100644 --- a/src/DotNetOAuth/ChannelElements/ITamperResistantOAuthMessage.cs +++ b/src/DotNetOAuth/ChannelElements/ITamperResistantOAuthMessage.cs @@ -12,7 +12,7 @@ namespace DotNetOAuth.ChannelElements { /// <summary>
/// An interface that OAuth messages implement to support signing.
/// </summary>
- internal interface ITamperResistantOAuthMessage : IDirectedProtocolMessage, ITamperResistantProtocolMessage {
+ internal interface ITamperResistantOAuthMessage : IOAuthDirectedMessage, ITamperResistantProtocolMessage {
/// <summary>
/// Gets or sets the method used to sign the message.
/// </summary>
@@ -40,7 +40,7 @@ namespace DotNetOAuth.ChannelElements { /// <summary>
/// Gets or sets the extra, non-OAuth parameters that will be included in the request.
- /// Only applicable to Consumer.
+ /// Only applicable to Consumer (SPs will receive these extra parameters via the ExtraData dictionary).
/// </summary>
IDictionary<string, string> AdditionalParametersInHttpRequest { get; set; }
}
diff --git a/src/DotNetOAuth/ChannelElements/OAuthChannel.cs b/src/DotNetOAuth/ChannelElements/OAuthChannel.cs index 197acc4..5bb05b6 100644 --- a/src/DotNetOAuth/ChannelElements/OAuthChannel.cs +++ b/src/DotNetOAuth/ChannelElements/OAuthChannel.cs @@ -145,13 +145,22 @@ namespace DotNetOAuth.ChannelElements { fields.Add(key, value);
}
- return this.Receive(fields);
+ return this.Receive(fields, request.GetRecipient());
}
}
}
// We didn't find an OAuth authorization header. Revert to other payload methods.
- return base.ReadFromRequestInternal(request);
+ IProtocolMessage message = base.ReadFromRequestInternal(request);
+
+ // Add receiving HTTP transport information required for signature generation.
+ var signedMessage = message as ITamperResistantOAuthMessage;
+ if (signedMessage != null) {
+ signedMessage.Recipient = request.Url;
+ signedMessage.HttpMethod = request.HttpMethod;
+ }
+
+ return message;
}
/// <summary>
@@ -167,7 +176,7 @@ namespace DotNetOAuth.ChannelElements { using (StreamReader reader = new StreamReader(responseStream)) {
string response = reader.ReadToEnd();
var fields = HttpUtility.ParseQueryString(response).ToDictionary();
- return Receive(fields);
+ return Receive(fields, null);
}
}
@@ -189,7 +198,7 @@ namespace DotNetOAuth.ChannelElements { return null;
}
var responseSerialize = MessageSerializer.Get(messageType);
- var responseMessage = responseSerialize.Deserialize(responseFields);
+ var responseMessage = responseSerialize.Deserialize(responseFields, null);
return responseMessage;
}
diff --git a/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs b/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs index 6c18703..14c4fd1 100644 --- a/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs +++ b/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs @@ -127,7 +127,9 @@ namespace DotNetOAuth.ChannelElements { signatureBaseStringElements.Add(endpoint.Uri.AbsoluteUri);
var encodedDictionary = OAuthChannel.GetEncodedParameters(message);
- OAuthChannel.EncodeParameters(message.AdditionalParametersInHttpRequest, encodedDictionary);
+ if (message.AdditionalParametersInHttpRequest != null) {
+ OAuthChannel.EncodeParameters(message.AdditionalParametersInHttpRequest, encodedDictionary);
+ }
encodedDictionary.Remove("oauth_signature");
var sortedKeyValueList = new List<KeyValuePair<string, string>>(encodedDictionary);
sortedKeyValueList.Sort(SignatureBaseStringParameterComparer);
diff --git a/src/DotNetOAuth/Consumer.cs b/src/DotNetOAuth/Consumer.cs index e45e7f4..c3b34f3 100644 --- a/src/DotNetOAuth/Consumer.cs +++ b/src/DotNetOAuth/Consumer.cs @@ -132,7 +132,7 @@ namespace DotNetOAuth { /// <param name="endpoint">The URL and method on the Service Provider to send the request to.</param>
/// <param name="accessToken">The access token that permits access to the protected resource.</param>
/// <returns>The initialized WebRequest object.</returns>
- public WebRequest CreateAuthorizedRequest(ServiceProviderEndpoint endpoint, string accessToken) {
+ public WebRequest CreateAuthorizedRequest(MessageReceivingEndpoint endpoint, string accessToken) {
IDirectedProtocolMessage message = this.CreateAuthorizedRequestInternal(endpoint, accessToken);
WebRequest wr = this.Channel.InitializeRequest(message);
return wr;
@@ -146,7 +146,7 @@ namespace DotNetOAuth { /// <param name="accessToken">The access token that permits access to the protected resource.</param>
/// <returns>The initialized WebRequest object.</returns>
/// <exception cref="WebException">Thrown if the request fails for any reason after it is sent to the Service Provider.</exception>
- public Response SendAuthorizedRequest(ServiceProviderEndpoint endpoint, string accessToken) {
+ public Response SendAuthorizedRequest(MessageReceivingEndpoint endpoint, string accessToken) {
IDirectedProtocolMessage message = this.CreateAuthorizedRequestInternal(endpoint, accessToken);
HttpWebRequest wr = this.Channel.InitializeRequest(message);
return this.WebRequestHandler.GetResponse(wr);
@@ -159,7 +159,7 @@ namespace DotNetOAuth { /// <param name="endpoint">The URL and method on the Service Provider to send the request to.</param>
/// <param name="accessToken">The access token that permits access to the protected resource.</param>
/// <returns>The initialized WebRequest object.</returns>
- internal AccessProtectedResourcesMessage CreateAuthorizedRequestInternal(ServiceProviderEndpoint endpoint, string accessToken) {
+ internal AccessProtectedResourcesMessage CreateAuthorizedRequestInternal(MessageReceivingEndpoint endpoint, string accessToken) {
if (endpoint == null) {
throw new ArgumentNullException("endpoint");
}
diff --git a/src/DotNetOAuth/DotNetOAuth.csproj b/src/DotNetOAuth/DotNetOAuth.csproj index db751b4..6cecde1 100644 --- a/src/DotNetOAuth/DotNetOAuth.csproj +++ b/src/DotNetOAuth/DotNetOAuth.csproj @@ -125,7 +125,7 @@ <Compile Include="Messages\RequestTokenMessage.cs" />
<Compile Include="ChannelElements\RsaSha1SigningBindingElement.cs" />
<Compile Include="ChannelElements\StandardWebRequestHandler.cs" />
- <Compile Include="ServiceProviderEndpoint.cs" />
+ <Compile Include="Messaging\MessageReceivingEndpoint.cs" />
<Compile Include="Util.cs" />
<Compile Include="Protocol.cs" />
<Compile Include="ServiceProvider.cs" />
diff --git a/src/DotNetOAuth/Messages/AccessProtectedResourcesMessage.cs b/src/DotNetOAuth/Messages/AccessProtectedResourcesMessage.cs index 85db448..34a1c9e 100644 --- a/src/DotNetOAuth/Messages/AccessProtectedResourcesMessage.cs +++ b/src/DotNetOAuth/Messages/AccessProtectedResourcesMessage.cs @@ -17,7 +17,7 @@ namespace DotNetOAuth.Messages { /// Initializes a new instance of the <see cref="AccessProtectedResourcesMessage"/> class.
/// </summary>
/// <param name="serviceProvider">The URI of the Service Provider endpoint to send this message to.</param>
- internal AccessProtectedResourcesMessage(ServiceProviderEndpoint serviceProvider)
+ internal AccessProtectedResourcesMessage(MessageReceivingEndpoint serviceProvider)
: base(MessageTransport.Direct, serviceProvider) {
}
diff --git a/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs b/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs index 6b8251a..d525f6e 100644 --- a/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs +++ b/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs @@ -17,7 +17,7 @@ namespace DotNetOAuth.Messages { /// </summary>
/// <param name="consumer">The URI of the Consumer endpoint to send this message to.</param>
internal DirectUserToConsumerMessage(Uri consumer)
- : base(MessageProtection.None, MessageTransport.Indirect, new ServiceProviderEndpoint(consumer, HttpDeliveryMethod.GetRequest)) {
+ : base(MessageProtection.None, MessageTransport.Indirect, new MessageReceivingEndpoint(consumer, HttpDeliveryMethod.GetRequest)) {
}
/// <summary>
diff --git a/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs b/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs index a222c0d..0bf1948 100644 --- a/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs +++ b/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs @@ -16,7 +16,7 @@ namespace DotNetOAuth.Messages { /// Initializes a new instance of the <see cref="DirectUserToServiceProviderMessage"/> class.
/// </summary>
/// <param name="serviceProvider">The URI of the Service Provider endpoint to send this message to.</param>
- internal DirectUserToServiceProviderMessage(ServiceProviderEndpoint serviceProvider)
+ internal DirectUserToServiceProviderMessage(MessageReceivingEndpoint serviceProvider)
: base(MessageProtection.None, MessageTransport.Indirect, serviceProvider) {
}
diff --git a/src/DotNetOAuth/Messages/MessageBase.cs b/src/DotNetOAuth/Messages/MessageBase.cs index 91530be..e213346 100644 --- a/src/DotNetOAuth/Messages/MessageBase.cs +++ b/src/DotNetOAuth/Messages/MessageBase.cs @@ -35,7 +35,7 @@ namespace DotNetOAuth.Messages { /// <summary>
/// The URI to the remote endpoint to send this message to.
/// </summary>
- private ServiceProviderEndpoint recipient;
+ private MessageReceivingEndpoint recipient;
/// <summary>
/// Initializes a new instance of the <see cref="MessageBase"/> class.
@@ -53,7 +53,7 @@ namespace DotNetOAuth.Messages { /// <param name="protectionRequired">The level of protection the message requires.</param>
/// <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>
- protected MessageBase(MessageProtection protectionRequired, MessageTransport transport, ServiceProviderEndpoint recipient) {
+ protected MessageBase(MessageProtection protectionRequired, MessageTransport transport, MessageReceivingEndpoint recipient) {
if (recipient == null) {
throw new ArgumentNullException("recipient");
}
@@ -112,7 +112,24 @@ namespace DotNetOAuth.Messages { /// Gets the preferred method of transport for the message.
/// </summary>
HttpDeliveryMethod IOAuthDirectedMessage.HttpMethods {
- get { return this.recipient.AllowedMethods; }
+ get { return this.recipient != null ? this.recipient.AllowedMethods : HttpDeliveryMethod.None; }
+ }
+
+ /// <summary>
+ /// Gets or sets the URI to the Service Provider endpoint to send this message to.
+ /// </summary>
+ Uri IOAuthDirectedMessage.Recipient {
+ get {
+ return this.recipient != null ? this.recipient.Location : null;
+ }
+
+ set {
+ if (this.recipient != null) {
+ this.recipient = new MessageReceivingEndpoint(value, this.recipient.AllowedMethods);
+ } else if (value != null) {
+ throw new InvalidOperationException();
+ }
+ }
}
#endregion
diff --git a/src/DotNetOAuth/Messages/RequestAccessTokenMessage.cs b/src/DotNetOAuth/Messages/RequestAccessTokenMessage.cs index 8b7adee..62e413a 100644 --- a/src/DotNetOAuth/Messages/RequestAccessTokenMessage.cs +++ b/src/DotNetOAuth/Messages/RequestAccessTokenMessage.cs @@ -17,7 +17,7 @@ namespace DotNetOAuth.Messages { /// Initializes a new instance of the <see cref="RequestAccessTokenMessage"/> class.
/// </summary>
/// <param name="serviceProvider">The URI of the Service Provider endpoint to send this message to.</param>
- internal RequestAccessTokenMessage(ServiceProviderEndpoint serviceProvider)
+ internal RequestAccessTokenMessage(MessageReceivingEndpoint serviceProvider)
: base(MessageTransport.Direct, serviceProvider) {
}
diff --git a/src/DotNetOAuth/Messages/RequestTokenMessage.cs b/src/DotNetOAuth/Messages/RequestTokenMessage.cs index cab178a..5d77693 100644 --- a/src/DotNetOAuth/Messages/RequestTokenMessage.cs +++ b/src/DotNetOAuth/Messages/RequestTokenMessage.cs @@ -15,7 +15,7 @@ namespace DotNetOAuth.Messages { /// Initializes a new instance of the <see cref="RequestTokenMessage"/> class.
/// </summary>
/// <param name="serviceProvider">The URI of the Service Provider endpoint to send this message to.</param>
- internal RequestTokenMessage(ServiceProviderEndpoint serviceProvider)
+ internal RequestTokenMessage(MessageReceivingEndpoint serviceProvider)
: base(MessageTransport.Direct, serviceProvider) {
}
}
diff --git a/src/DotNetOAuth/Messages/SignedMessageBase.cs b/src/DotNetOAuth/Messages/SignedMessageBase.cs index 28026e6..c1c2d1c 100644 --- a/src/DotNetOAuth/Messages/SignedMessageBase.cs +++ b/src/DotNetOAuth/Messages/SignedMessageBase.cs @@ -39,7 +39,7 @@ namespace DotNetOAuth.Messages { /// </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, ServiceProviderEndpoint recipient)
+ internal SignedMessageBase(MessageTransport transport, MessageReceivingEndpoint recipient)
: base(MessageProtection.All, transport, recipient) {
}
diff --git a/src/DotNetOAuth/Messaging/Channel.cs b/src/DotNetOAuth/Messaging/Channel.cs index fdca618..63ee1cc 100644 --- a/src/DotNetOAuth/Messaging/Channel.cs +++ b/src/DotNetOAuth/Messaging/Channel.cs @@ -327,15 +327,16 @@ namespace DotNetOAuth.Messaging { fields = request.QueryString.ToDictionary();
}
- return this.Receive(fields);
+ return this.Receive(fields, request.GetRecipient());
}
/// <summary>
/// Deserializes a dictionary of values into a message.
/// </summary>
/// <param name="fields">The dictionary of values that were read from an HTTP request or response.</param>
+ /// <param name="recipient">Information about where the message was been directed. Null for direct response messages.</param>
/// <returns>The deserialized message, or null if no message could be recognized in the provided data.</returns>
- protected virtual IProtocolMessage Receive(Dictionary<string, string> fields) {
+ protected virtual IProtocolMessage Receive(Dictionary<string, string> fields, MessageReceivingEndpoint recipient) {
if (fields == null) {
throw new ArgumentNullException("fields");
}
@@ -349,7 +350,7 @@ namespace DotNetOAuth.Messaging { // We have a message! Assemble it.
var serializer = MessageSerializer.Get(messageType);
- IProtocolMessage message = serializer.Deserialize(fields);
+ IProtocolMessage message = serializer.Deserialize(fields, recipient);
return message;
}
diff --git a/src/DotNetOAuth/Messaging/HttpRequestInfo.cs b/src/DotNetOAuth/Messaging/HttpRequestInfo.cs index d9d0c72..f095a6f 100644 --- a/src/DotNetOAuth/Messaging/HttpRequestInfo.cs +++ b/src/DotNetOAuth/Messaging/HttpRequestInfo.cs @@ -75,9 +75,9 @@ namespace DotNetOAuth.Messaging { }
/// <summary>
- /// Gets the message that is being sent over a mock transport (for testing).
+ /// Gets or sets the message that is being sent over a mock transport (for testing).
/// </summary>
- internal IProtocolMessage Message { get; private set; }
+ internal IProtocolMessage Message { get; set; }
/// <summary>
/// Gets or sets the verb in the request (i.e. GET, POST, etc.)
diff --git a/src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs b/src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs new file mode 100644 index 0000000..9ad749b --- /dev/null +++ b/src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs @@ -0,0 +1,49 @@ +//-----------------------------------------------------------------------
+// <copyright file="MessageReceivingEndpoint.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.Messaging {
+ using System;
+
+ /// <summary>
+ /// An immutable description of a URL that receives messages.
+ /// </summary>
+ public class MessageReceivingEndpoint {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MessageReceivingEndpoint"/> class.
+ /// </summary>
+ /// <param name="locationUri">The URL of this endpoint.</param>
+ /// <param name="method">The HTTP method(s) allowed.</param>
+ public MessageReceivingEndpoint(string locationUri, HttpDeliveryMethod method)
+ : this(new Uri(locationUri), method) { }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MessageReceivingEndpoint"/> class.
+ /// </summary>
+ /// <param name="location">The URL of this endpoint.</param>
+ /// <param name="method">The HTTP method(s) allowed.</param>
+ public MessageReceivingEndpoint(Uri location, HttpDeliveryMethod method) {
+ if (location == null) {
+ throw new ArgumentNullException("location");
+ }
+ if (method == HttpDeliveryMethod.None) {
+ throw new ArgumentOutOfRangeException("method");
+ }
+
+ this.Location = location;
+ this.AllowedMethods = method;
+ }
+
+ /// <summary>
+ /// Gets the URL of this endpoint.
+ /// </summary>
+ public Uri Location { get; private set; }
+
+ /// <summary>
+ /// Gets the HTTP method(s) allowed.
+ /// </summary>
+ public HttpDeliveryMethod AllowedMethods { get; private set; }
+ }
+}
diff --git a/src/DotNetOAuth/Messaging/MessageSerializer.cs b/src/DotNetOAuth/Messaging/MessageSerializer.cs index 0e1e491..fd42108 100644 --- a/src/DotNetOAuth/Messaging/MessageSerializer.cs +++ b/src/DotNetOAuth/Messaging/MessageSerializer.cs @@ -9,6 +9,8 @@ namespace DotNetOAuth.Messaging { using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
+ using System.Reflection;
+ using DotNetOAuth.ChannelElements;
using DotNetOAuth.Messaging.Reflection;
/// <summary>
@@ -75,8 +77,9 @@ namespace DotNetOAuth.Messaging { /// Reads name=value pairs into an OAuth message.
/// </summary>
/// <param name="fields">The name=value pairs that were read in from the transport.</param>
+ /// <param name="recipient">The recipient of the message.</param>
/// <returns>The instantiated and initialized <see cref="IProtocolMessage"/> instance.</returns>
- internal IProtocolMessage Deserialize(IDictionary<string, string> fields) {
+ internal IProtocolMessage Deserialize(IDictionary<string, string> fields, MessageReceivingEndpoint recipient) {
if (fields == null) {
throw new ArgumentNullException("fields");
}
@@ -84,18 +87,49 @@ namespace DotNetOAuth.Messaging { // Before we deserialize the message, make sure all the required parts are present.
MessageDescription.Get(this.messageType).EnsureRequiredMessagePartsArePresent(fields.Keys);
- IProtocolMessage result;
- try {
- result = (IProtocolMessage)Activator.CreateInstance(this.messageType, true);
- } catch (MissingMethodException ex) {
- throw new ProtocolException("Failed to instantiate type " + this.messageType.FullName, ex);
- }
+ IProtocolMessage result = this.CreateMessage(recipient);
foreach (var pair in fields) {
IDictionary<string, string> dictionary = new MessageDictionary(result);
- dictionary.Add(pair);
+ dictionary[pair.Key] = pair.Value;
}
result.EnsureValidMessage();
return result;
}
+
+ /// <summary>
+ /// Instantiates a new message to deserialize data into.
+ /// </summary>
+ /// <param name="recipient">The recipient this message is directed to, if any.</param>
+ /// <returns>The newly created message object.</returns>
+ private IProtocolMessage CreateMessage(MessageReceivingEndpoint recipient) {
+ IProtocolMessage result;
+ if (typeof(IOAuthDirectedMessage).IsAssignableFrom(this.messageType)) {
+ // Some OAuth messages take just the recipient, while others take the whole endpoint
+ ConstructorInfo ctor;
+ if ((ctor = this.messageType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Uri) }, null)) != null) {
+ if (recipient == null) {
+ // We need a recipient to deserialize directed messages.
+ throw new ArgumentNullException("recipient");
+ }
+
+ result = (IProtocolMessage)ctor.Invoke(new object[] { recipient.Location });
+ } else if ((ctor = this.messageType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(MessageReceivingEndpoint) }, null)) != null) {
+ if (recipient == null) {
+ // We need a recipient to deserialize directed messages.
+ throw new ArgumentNullException("recipient");
+ }
+
+ result = (IProtocolMessage)ctor.Invoke(new object[] { recipient });
+ } else if ((ctor = this.messageType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[0], null)) != null) {
+ result = (IProtocolMessage)ctor.Invoke(new object[0]);
+ } else {
+ throw new InvalidOperationException("Unrecognized constructor signature on type " + this.messageType);
+ }
+ } else {
+ result = (IProtocolMessage)Activator.CreateInstance(this.messageType, true);
+ }
+
+ return result;
+ }
}
}
diff --git a/src/DotNetOAuth/Messaging/MessagingUtilities.cs b/src/DotNetOAuth/Messaging/MessagingUtilities.cs index 88aea0c..7793276 100644 --- a/src/DotNetOAuth/Messaging/MessagingUtilities.cs +++ b/src/DotNetOAuth/Messaging/MessagingUtilities.cs @@ -131,6 +131,15 @@ namespace DotNetOAuth.Messaging { }
/// <summary>
+ /// Extracts the recipient from an HttpRequestInfo.
+ /// </summary>
+ /// <param name="request">The request to get recipient information from.</param>
+ /// <returns>The recipient.</returns>
+ internal static MessageReceivingEndpoint GetRecipient(this HttpRequestInfo request) {
+ return new MessageReceivingEndpoint(request.Url, request.HttpMethod == "GET" ? HttpDeliveryMethod.GetRequest : HttpDeliveryMethod.PostRequest);
+ }
+
+ /// <summary>
/// Converts a <see cref="NameValueCollection"/> to an IDictionary<string, string>.
/// </summary>
/// <param name="nvc">The NameValueCollection to convert. May be null.</param>
diff --git a/src/DotNetOAuth/ServiceProvider.cs b/src/DotNetOAuth/ServiceProvider.cs index 9201628..6f5c2c4 100644 --- a/src/DotNetOAuth/ServiceProvider.cs +++ b/src/DotNetOAuth/ServiceProvider.cs @@ -171,11 +171,6 @@ namespace DotNetOAuth { if (tokenMessage != null) {
message.TokenSecret = this.TokenManager.GetTokenSecret(tokenMessage.Token);
}
-
- // TODO: more complete filling of message properties.
- ////message.Recipient =
- ////message.AdditionalParametersInHttpRequest =
- ////message.HttpMethod =
}
}
}
diff --git a/src/DotNetOAuth/ServiceProviderEndpoint.cs b/src/DotNetOAuth/ServiceProviderEndpoint.cs deleted file mode 100644 index 89f5e61..0000000 --- a/src/DotNetOAuth/ServiceProviderEndpoint.cs +++ /dev/null @@ -1,53 +0,0 @@ -//-----------------------------------------------------------------------
-// <copyright file="ServiceProviderEndpoint.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DotNetOAuth.Messaging;
-
- /// <summary>
- /// A description of an individual endpoint on a Service Provider.
- /// </summary>
- public class ServiceProviderEndpoint {
- /// <summary>
- /// Initializes a new instance of the <see cref="ServiceProviderEndpoint"/> class.
- /// </summary>
- /// <param name="locationUri">The URL of this Service Provider endpoint.</param>
- /// <param name="method">The HTTP method(s) allowed.</param>
- public ServiceProviderEndpoint(string locationUri, HttpDeliveryMethod method)
- : this(new Uri(locationUri), method) { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ServiceProviderEndpoint"/> class.
- /// </summary>
- /// <param name="location">The URL of this Service Provider endpoint.</param>
- /// <param name="method">The HTTP method(s) allowed.</param>
- public ServiceProviderEndpoint(Uri location, HttpDeliveryMethod method) {
- if (location == null) {
- throw new ArgumentNullException("location");
- }
- if (method == HttpDeliveryMethod.None) {
- throw new ArgumentOutOfRangeException("method");
- }
-
- this.Location = location;
- this.AllowedMethods = method;
- }
-
- /// <summary>
- /// Gets or sets the URL of this Service Provider endpoint.
- /// </summary>
- public Uri Location { get; set; }
-
- /// <summary>
- /// Gets or sets the HTTP method(s) allowed.
- /// </summary>
- public HttpDeliveryMethod AllowedMethods { get; set; }
- }
-}
diff --git a/src/DotNetOAuth/ServiceProviderEndpoints.cs b/src/DotNetOAuth/ServiceProviderEndpoints.cs index e635ad2..82bdf28 100644 --- a/src/DotNetOAuth/ServiceProviderEndpoints.cs +++ b/src/DotNetOAuth/ServiceProviderEndpoints.cs @@ -18,7 +18,7 @@ namespace DotNetOAuth { /// <summary>
/// The field used to store the value of the <see cref="RequestTokenEndpoint"/> property.
/// </summary>
- private ServiceProviderEndpoint requestTokenEndpoint;
+ private MessageReceivingEndpoint requestTokenEndpoint;
/// <summary>
/// Initializes a new instance of the <see cref="ServiceProviderEndpoints"/> class.
@@ -35,7 +35,7 @@ namespace DotNetOAuth { /// This is the URL that <see cref="Messages.RequestTokenMessage"/> messages are directed to.
/// </remarks>
/// <exception cref="ArgumentException">Thrown if this property is set to a URI with OAuth protocol parameters.</exception>
- public ServiceProviderEndpoint RequestTokenEndpoint {
+ public MessageReceivingEndpoint RequestTokenEndpoint {
get {
return this.requestTokenEndpoint;
}
@@ -57,7 +57,7 @@ namespace DotNetOAuth { /// This is the URL that <see cref="Messages.DirectUserToServiceProviderMessage"/> messages are
/// indirectly (via the user agent) sent to.
/// </remarks>
- public ServiceProviderEndpoint UserAuthorizationEndpoint { get; set; }
+ public MessageReceivingEndpoint UserAuthorizationEndpoint { get; set; }
/// <summary>
/// Gets or sets the URL used to exchange the User-authorized Request Token
@@ -66,6 +66,6 @@ namespace DotNetOAuth { /// <remarks>
/// This is the URL that <see cref="Messages.RequestAccessTokenMessage"/> messages are directed to.
/// </remarks>
- public ServiceProviderEndpoint AccessTokenEndpoint { get; set; }
+ public MessageReceivingEndpoint AccessTokenEndpoint { get; set; }
}
}
diff --git a/src/DotNetOAuth/Util.cs b/src/DotNetOAuth/Util.cs index e3af5f1..1bf76b1 100644 --- a/src/DotNetOAuth/Util.cs +++ b/src/DotNetOAuth/Util.cs @@ -6,11 +6,12 @@ namespace DotNetOAuth {
using System.Globalization;
using System.Reflection;
+ using DotNetOAuth.Messaging;
/// <summary>
/// A grab-bag utility class.
/// </summary>
- internal class Util {
+ internal static class Util {
/// <summary>
/// Gets a human-readable description of the library name and version, including
/// whether the build is an official or private one.
|