summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-11-01 22:35:42 -0700
committerAndrew <andrewarnott@gmail.com>2008-11-01 22:35:42 -0700
commit0e2a186690a3f3e8b0d6e1701389fd9df88b8002 (patch)
tree5e23d2dda4a17a275b6f3cf9d6f03eb8ea2f9dc2
parent7bc257eacda8afd0226f3e9ab450a7a9e2c48bb2 (diff)
downloadDotNetOpenAuth-0e2a186690a3f3e8b0d6e1701389fd9df88b8002.zip
DotNetOpenAuth-0e2a186690a3f3e8b0d6e1701389fd9df88b8002.tar.gz
DotNetOpenAuth-0e2a186690a3f3e8b0d6e1701389fd9df88b8002.tar.bz2
StyleCop fixes.
-rw-r--r--src/DotNetOAuth/ChannelElements/OAuthChannel.cs4
-rw-r--r--src/DotNetOAuth/ConsumerBase.cs18
-rw-r--r--src/DotNetOAuth/Messages/GetAccessTokenMessage.cs3
-rw-r--r--src/DotNetOAuth/Messages/GrantRequestTokenMessage.cs19
-rw-r--r--src/DotNetOAuth/Messaging/Channel.cs86
-rw-r--r--src/DotNetOAuth/Messaging/ChannelEventArgs.cs25
-rw-r--r--src/DotNetOAuth/ServiceProvider.cs38
7 files changed, 113 insertions, 80 deletions
diff --git a/src/DotNetOAuth/ChannelElements/OAuthChannel.cs b/src/DotNetOAuth/ChannelElements/OAuthChannel.cs
index 7ac4527..46c227e 100644
--- a/src/DotNetOAuth/ChannelElements/OAuthChannel.cs
+++ b/src/DotNetOAuth/ChannelElements/OAuthChannel.cs
@@ -236,7 +236,9 @@ namespace DotNetOAuth.ChannelElements {
/// This method implements spec V1.0 section 5.3.
/// </remarks>
protected override Response SendDirectMessageResponse(IProtocolMessage response) {
- if (response == null) throw new ArgumentNullException("response");
+ if (response == null) {
+ throw new ArgumentNullException("response");
+ }
MessageSerializer serializer = MessageSerializer.Get(response.GetType());
var fields = serializer.Serialize(response);
diff --git a/src/DotNetOAuth/ConsumerBase.cs b/src/DotNetOAuth/ConsumerBase.cs
index 405df3a..475f9aa 100644
--- a/src/DotNetOAuth/ConsumerBase.cs
+++ b/src/DotNetOAuth/ConsumerBase.cs
@@ -56,15 +56,6 @@ namespace DotNetOAuth {
}
/// <summary>
- /// Gets or sets the object that processes <see cref="HttpWebRequest"/>s.
- /// </summary>
- /// <remarks>
- /// This defaults to a straightforward implementation, but can be set
- /// to a mock object for testing purposes.
- /// </remarks>
- internal IWebRequestHandler WebRequestHandler { get; set; }
-
- /// <summary>
/// Gets the channel to use for sending/receiving messages.
/// </summary>
public Channel Channel {
@@ -77,6 +68,15 @@ namespace DotNetOAuth {
internal OAuthChannel OAuthChannel { get; set; }
/// <summary>
+ /// Gets or sets the object that processes <see cref="HttpWebRequest"/>s.
+ /// </summary>
+ /// <remarks>
+ /// This defaults to a straightforward implementation, but can be set
+ /// to a mock object for testing purposes.
+ /// </remarks>
+ internal IWebRequestHandler WebRequestHandler { get; set; }
+
+ /// <summary>
/// Creates a web request prepared with OAuth authorization
/// that may be further tailored by adding parameters by the caller.
/// </summary>
diff --git a/src/DotNetOAuth/Messages/GetAccessTokenMessage.cs b/src/DotNetOAuth/Messages/GetAccessTokenMessage.cs
index 15c8ffd..caa83d3 100644
--- a/src/DotNetOAuth/Messages/GetAccessTokenMessage.cs
+++ b/src/DotNetOAuth/Messages/GetAccessTokenMessage.cs
@@ -5,9 +5,8 @@
//-----------------------------------------------------------------------
namespace DotNetOAuth.Messages {
- using System;
- using DotNetOAuth.Messaging;
using System.Globalization;
+ using DotNetOAuth.Messaging;
/// <summary>
/// A direct message sent by the Consumer to exchange an authorized Request Token
diff --git a/src/DotNetOAuth/Messages/GrantRequestTokenMessage.cs b/src/DotNetOAuth/Messages/GrantRequestTokenMessage.cs
index f52ac01..7cebda0 100644
--- a/src/DotNetOAuth/Messages/GrantRequestTokenMessage.cs
+++ b/src/DotNetOAuth/Messages/GrantRequestTokenMessage.cs
@@ -5,10 +5,10 @@
//-----------------------------------------------------------------------
namespace DotNetOAuth.Messages {
+ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using DotNetOAuth.Messaging;
- using System;
/// <summary>
/// A direct message sent from Service Provider to Consumer in response to
@@ -25,9 +25,15 @@ namespace DotNetOAuth.Messages {
/// This constructor is used by the Service Provider to send the message.
/// </remarks>
protected internal GrantRequestTokenMessage(GetRequestTokenMessage requestMessage, string requestToken, string tokenSecret) : this() {
- if (requestMessage == null) throw new ArgumentNullException("requestMessage");
- if (string.IsNullOrEmpty(requestToken)) throw new ArgumentNullException("requestToken");
- if (string.IsNullOrEmpty(tokenSecret)) throw new ArgumentNullException("tokenSecret");
+ if (requestMessage == null) {
+ throw new ArgumentNullException("requestMessage");
+ }
+ if (string.IsNullOrEmpty(requestToken)) {
+ throw new ArgumentNullException("requestToken");
+ }
+ if (string.IsNullOrEmpty(tokenSecret)) {
+ throw new ArgumentNullException("tokenSecret");
+ }
this.RequestMessage = requestMessage;
this.RequestToken = requestToken;
@@ -72,7 +78,10 @@ namespace DotNetOAuth.Messages {
[MessagePart("oauth_token", IsRequired = true)]
internal string RequestToken { get; set; }
- internal GetRequestTokenMessage RequestMessage { get; set; }
+ /// <summary>
+ /// Gets the original request for an unauthorized token.
+ /// </summary>
+ internal GetRequestTokenMessage RequestMessage { get; private set; }
/// <summary>
/// Gets or sets the Token Secret.
diff --git a/src/DotNetOAuth/Messaging/Channel.cs b/src/DotNetOAuth/Messaging/Channel.cs
index c283382..0f2fe04 100644
--- a/src/DotNetOAuth/Messaging/Channel.cs
+++ b/src/DotNetOAuth/Messaging/Channel.cs
@@ -81,6 +81,11 @@ namespace DotNetOAuth.Messaging {
}
/// <summary>
+ /// An event fired whenever a message is about to be encoded and sent.
+ /// </summary>
+ internal event EventHandler<ChannelEventArgs> Sending;
+
+ /// <summary>
/// Gets the binding elements used by this channel, in the order they are applied to outgoing messages.
/// </summary>
/// <remarks>
@@ -93,24 +98,6 @@ namespace DotNetOAuth.Messaging {
}
/// <summary>
- /// An event fired whenever a message is about to be encoded and sent.
- /// </summary>
- internal event EventHandler<ChannelEventArgs> Sending;
-
- /// <summary>
- /// Fires the <see cref="Sending"/> event.
- /// </summary>
- /// <param name="message">The message about to be encoded and sent.</param>
- protected virtual void OnSending(IProtocolMessage message) {
- if (message == null) throw new ArgumentNullException("message");
-
- var sending = this.Sending;
- if (sending != null) {
- sending(this, new ChannelEventArgs(message));
- }
- }
-
- /// <summary>
/// Gets a tool that can figure out what kind of message is being received
/// so it can be deserialized.
/// </summary>
@@ -325,18 +312,6 @@ namespace DotNetOAuth.Messaging {
}
/// <summary>
- /// Gets the protocol message that may be in the given HTTP response stream.
- /// </summary>
- /// <param name="responseStream">The response that is anticipated to contain an OAuth message.</param>
- /// <returns>The deserialized message, if one is found. Null otherwise.</returns>
- private IProtocolMessage ReadFromResponse(Stream responseStream) {
- IProtocolMessage message = this.ReadFromResponseInternal(responseStream);
- Logger.DebugFormat("Received message response: {0}", message);
- this.VerifyMessageAfterReceiving(message);
- return message;
- }
-
- /// <summary>
/// Gets the current HTTP request being processed.
/// </summary>
/// <returns>The HttpRequestInfo for the current request.</returns>
@@ -353,6 +328,21 @@ namespace DotNetOAuth.Messaging {
}
/// <summary>
+ /// Fires the <see cref="Sending"/> event.
+ /// </summary>
+ /// <param name="message">The message about to be encoded and sent.</param>
+ protected virtual void OnSending(IProtocolMessage message) {
+ if (message == null) {
+ throw new ArgumentNullException("message");
+ }
+
+ var sending = this.Sending;
+ if (sending != null) {
+ sending(this, new ChannelEventArgs(message));
+ }
+ }
+
+ /// <summary>
/// Gets the protocol message that may be embedded in the given HTTP request.
/// </summary>
/// <param name="request">The request to search for an embedded message.</param>
@@ -550,6 +540,22 @@ namespace DotNetOAuth.Messaging {
}
/// <summary>
+ /// Verifies that all required message parts are initialized to values
+ /// prior to sending the message to a remote party.
+ /// </summary>
+ /// <param name="message">The message to verify.</param>
+ /// <exception cref="ProtocolException">
+ /// Thrown when any required message part does not have a value.
+ /// </exception>
+ private static void EnsureValidMessageParts(IProtocolMessage message) {
+ Debug.Assert(message != null, "message == null");
+
+ MessageDictionary dictionary = new MessageDictionary(message);
+ MessageDescription description = MessageDescription.Get(message.GetType());
+ description.EnsureRequiredMessagePartsArePresent(dictionary.Keys);
+ }
+
+ /// <summary>
/// Calculates a fairly accurate estimation on the size of a message that contains
/// a given set of fields.
/// </summary>
@@ -644,19 +650,15 @@ namespace DotNetOAuth.Messaging {
}
/// <summary>
- /// Verifies that all required message parts are initialized to values
- /// prior to sending the message to a remote party.
+ /// Gets the protocol message that may be in the given HTTP response stream.
/// </summary>
- /// <param name="message">The message to verify.</param>
- /// <exception cref="ProtocolException">
- /// Thrown when any required message part does not have a value.
- /// </exception>
- private static void EnsureValidMessageParts(IProtocolMessage message) {
- Debug.Assert(message != null, "message == null");
-
- MessageDictionary dictionary = new MessageDictionary(message);
- MessageDescription description = MessageDescription.Get(message.GetType());
- description.EnsureRequiredMessagePartsArePresent(dictionary.Keys);
+ /// <param name="responseStream">The response that is anticipated to contain an OAuth message.</param>
+ /// <returns>The deserialized message, if one is found. Null otherwise.</returns>
+ private IProtocolMessage ReadFromResponse(Stream responseStream) {
+ IProtocolMessage message = this.ReadFromResponseInternal(responseStream);
+ Logger.DebugFormat("Received message response: {0}", message);
+ this.VerifyMessageAfterReceiving(message);
+ return message;
}
/// <summary>
diff --git a/src/DotNetOAuth/Messaging/ChannelEventArgs.cs b/src/DotNetOAuth/Messaging/ChannelEventArgs.cs
index 18c1d3a..82506c3 100644
--- a/src/DotNetOAuth/Messaging/ChannelEventArgs.cs
+++ b/src/DotNetOAuth/Messaging/ChannelEventArgs.cs
@@ -1,16 +1,31 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+//-----------------------------------------------------------------------
+// <copyright file="ChannelEventArgs.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOAuth.Messaging {
+ using System;
+
+ /// <summary>
+ /// The data packet sent with Channel events.
+ /// </summary>
public class ChannelEventArgs : EventArgs {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ChannelEventArgs"/> class.
+ /// </summary>
+ /// <param name="message">The message behind the fired event..</param>
internal ChannelEventArgs(IProtocolMessage message) {
- if (message == null) throw new ArgumentNullException("message");
+ if (message == null) {
+ throw new ArgumentNullException("message");
+ }
this.Message = message;
}
+ /// <summary>
+ /// Gets the message that caused the event to fire.
+ /// </summary>
public IProtocolMessage Message { get; private set; }
}
}
diff --git a/src/DotNetOAuth/ServiceProvider.cs b/src/DotNetOAuth/ServiceProvider.cs
index 4032a4a..99bdbca 100644
--- a/src/DotNetOAuth/ServiceProvider.cs
+++ b/src/DotNetOAuth/ServiceProvider.cs
@@ -27,6 +27,9 @@ namespace DotNetOAuth {
/// </list>
/// </remarks>
public class ServiceProvider {
+ /// <summary>
+ /// The field behind the <see cref="OAuthChannel"/> property.
+ /// </summary>
private OAuthChannel channel;
/// <summary>
@@ -63,19 +66,6 @@ namespace DotNetOAuth {
}
/// <summary>
- /// Hooks the channel in order to perform some operations on some outgoing messages.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="DotNetOAuth.Messaging.ChannelEventArgs"/> instance containing the event data.</param>
- private void OAuthChannel_Sending(object sender, ChannelEventArgs e) {
- // Hook to store the token and secret on its way down to the Consumer.
- var grantRequestTokenResponse = e.Message as GrantRequestTokenMessage;
- if (grantRequestTokenResponse != null) {
- this.TokenManager.StoreNewRequestToken(grantRequestTokenResponse.RequestMessage, grantRequestTokenResponse);
- }
- }
-
- /// <summary>
/// Gets the description of this Service Provider.
/// </summary>
public ServiceProviderDescription ServiceDescription { get; private set; }
@@ -106,15 +96,16 @@ namespace DotNetOAuth {
get {
return this.channel;
}
+
set {
if (this.channel != null) {
- this.channel.Sending -= OAuthChannel_Sending;
+ this.channel.Sending -= this.OAuthChannel_Sending;
}
this.channel = value;
if (this.channel != null) {
- this.channel.Sending += OAuthChannel_Sending;
+ this.channel.Sending += this.OAuthChannel_Sending;
}
}
}
@@ -180,7 +171,9 @@ namespace DotNetOAuth {
/// <param name="request">The token request message the Consumer sent that the Service Provider is now responding to.</param>
/// <returns>The response message to send using the <see cref="Channel"/>, after optionally adding extra data to it.</returns>
public GrantRequestTokenMessage PrepareUnauthorizedTokenMessage(GetRequestTokenMessage request) {
- if (request == null) throw new ArgumentNullException("request");
+ if (request == null) {
+ throw new ArgumentNullException("request");
+ }
string token = this.TokenGenerator.GenerateRequestToken(request.ConsumerKey);
string secret = this.TokenGenerator.GenerateSecret();
@@ -387,5 +380,18 @@ namespace DotNetOAuth {
return accessMessage;
}
+
+ /// <summary>
+ /// Hooks the channel in order to perform some operations on some outgoing messages.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="DotNetOAuth.Messaging.ChannelEventArgs"/> instance containing the event data.</param>
+ private void OAuthChannel_Sending(object sender, ChannelEventArgs e) {
+ // Hook to store the token and secret on its way down to the Consumer.
+ var grantRequestTokenResponse = e.Message as GrantRequestTokenMessage;
+ if (grantRequestTokenResponse != null) {
+ this.TokenManager.StoreNewRequestToken(grantRequestTokenResponse.RequestMessage, grantRequestTokenResponse);
+ }
+ }
}
}