diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-11 22:32:59 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-09-11 22:33:39 -0700 |
commit | 8fd37aa11f6da68ed6366a3f98a89feac7501f1e (patch) | |
tree | 108dd73bb3ad7509c1cd73fef75aa6a7c9814bbb /src | |
parent | f6d28fb14c91c97f6cc8b85c442987082997866a (diff) | |
download | DotNetOpenAuth-8fd37aa11f6da68ed6366a3f98a89feac7501f1e.zip DotNetOpenAuth-8fd37aa11f6da68ed6366a3f98a89feac7501f1e.tar.gz DotNetOpenAuth-8fd37aa11f6da68ed6366a3f98a89feac7501f1e.tar.bz2 |
Refactored Channel's virtual and abstract methods to NOT be "internal" (or public).
This will be useful when we add message signing and verification to the Channel base class.
It's also consistent with design guidelines to never have public (or internal in this case) methods be virtual or abstract so the base class has control over its operations.
Diffstat (limited to 'src')
-rw-r--r-- | src/DotNetOAuth.Test/Mocks/TestBadChannel.cs | 4 | ||||
-rw-r--r-- | src/DotNetOAuth.Test/Mocks/TestChannel.cs | 4 | ||||
-rw-r--r-- | src/DotNetOAuth/Messaging/Channel.cs | 89 | ||||
-rw-r--r-- | src/DotNetOAuth/OAuthChannel.cs | 8 |
4 files changed, 66 insertions, 39 deletions
diff --git a/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs b/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs index 5d6802f..1002cbc 100644 --- a/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs +++ b/src/DotNetOAuth.Test/Mocks/TestBadChannel.cs @@ -43,11 +43,11 @@ namespace DotNetOAuth.Test.Mocks { return base.ReadFromRequest(request);
}
- protected internal override IProtocolMessage Request(IDirectedProtocolMessage request) {
+ protected override IProtocolMessage RequestInternal(IDirectedProtocolMessage request) {
throw new NotImplementedException();
}
- protected internal override IProtocolMessage ReadFromResponse(System.IO.Stream responseStream) {
+ protected override IProtocolMessage ReadFromResponseInternal(System.IO.Stream responseStream) {
throw new NotImplementedException();
}
diff --git a/src/DotNetOAuth.Test/Mocks/TestChannel.cs b/src/DotNetOAuth.Test/Mocks/TestChannel.cs index 359019f..5663ec2 100644 --- a/src/DotNetOAuth.Test/Mocks/TestChannel.cs +++ b/src/DotNetOAuth.Test/Mocks/TestChannel.cs @@ -16,11 +16,11 @@ namespace DotNetOAuth.Test.Mocks { : base(new TestMessageTypeProvider()) {
}
- protected internal override IProtocolMessage Request(IDirectedProtocolMessage request) {
+ protected override IProtocolMessage RequestInternal(IDirectedProtocolMessage request) {
throw new NotImplementedException("Request");
}
- protected internal override IProtocolMessage ReadFromResponse(System.IO.Stream responseStream) {
+ protected override IProtocolMessage ReadFromResponseInternal(System.IO.Stream responseStream) {
throw new NotImplementedException("ReadFromResponse");
}
diff --git a/src/DotNetOAuth/Messaging/Channel.cs b/src/DotNetOAuth/Messaging/Channel.cs index dc4209a..d294816 100644 --- a/src/DotNetOAuth/Messaging/Channel.cs +++ b/src/DotNetOAuth/Messaging/Channel.cs @@ -151,7 +151,34 @@ namespace DotNetOAuth.Messaging { /// </summary>
/// <param name="request">The request to search for an embedded message.</param>
/// <returns>The deserialized message, if one is found. Null otherwise.</returns>
- protected internal virtual IProtocolMessage ReadFromRequest(HttpRequestInfo request) {
+ protected internal IProtocolMessage ReadFromRequest(HttpRequestInfo request) {
+ return this.ReadFromRequestInternal(request);
+ }
+
+ /// <summary>
+ /// Sends a direct message to a remote party and waits for the response.
+ /// </summary>
+ /// <param name="request">The message to send.</param>
+ /// <returns>The remote party's response.</returns>
+ protected internal IProtocolMessage Request(IDirectedProtocolMessage request) {
+ return this.RequestInternal(request);
+ }
+
+ /// <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>
+ protected internal IProtocolMessage ReadFromResponse(Stream responseStream) {
+ return this.ReadFromResponseInternal(responseStream);
+ }
+
+ /// <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>
+ /// <returns>The deserialized message, if one is found. Null otherwise.</returns>
+ protected virtual IProtocolMessage ReadFromRequestInternal(HttpRequestInfo request) {
if (request == null) {
throw new ArgumentNullException("request");
}
@@ -166,20 +193,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>
- protected internal abstract IProtocolMessage ReadFromResponse(Stream responseStream);
-
- /// <summary>
- /// Sends a direct message to a remote party and waits for the response.
- /// </summary>
- /// <param name="request">The message to send.</param>
- /// <returns>The remote party's response.</returns>
- protected internal abstract IProtocolMessage Request(IDirectedProtocolMessage request);
-
- /// <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>
@@ -204,22 +217,6 @@ namespace DotNetOAuth.Messaging { }
/// <summary>
- /// Takes a message and temporarily stores it for sending as the hosting site's
- /// HTTP response to the current request.
- /// </summary>
- /// <param name="response">The message to store for sending.</param>
- protected void QueueIndirectOrResponseMessage(Response response) {
- if (response == null) {
- throw new ArgumentNullException("response");
- }
- if (this.queuedIndirectOrResponseMessage != null) {
- throw new InvalidOperationException(MessagingStrings.QueuedMessageResponseAlreadyExists);
- }
-
- this.queuedIndirectOrResponseMessage = response;
- }
-
- /// <summary>
/// Queues an indirect message for transmittal via the user agent.
/// </summary>
/// <param name="message">The message to send.</param>
@@ -316,6 +313,20 @@ 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>
+ protected abstract IProtocolMessage ReadFromResponseInternal(Stream responseStream);
+
+ /// <summary>
+ /// Sends a direct message to a remote party and waits for the response.
+ /// </summary>
+ /// <param name="request">The message to send.</param>
+ /// <returns>The remote party's response.</returns>
+ protected abstract IProtocolMessage RequestInternal(IDirectedProtocolMessage request);
+
+ /// <summary>
/// Queues a message for sending in the response stream where the fields
/// are sent in the response stream in querystring style.
/// </summary>
@@ -326,6 +337,22 @@ namespace DotNetOAuth.Messaging { protected abstract void SendDirectMessageResponse(IProtocolMessage response);
/// <summary>
+ /// Takes a message and temporarily stores it for sending as the hosting site's
+ /// HTTP response to the current request.
+ /// </summary>
+ /// <param name="response">The message to store for sending.</param>
+ protected void QueueIndirectOrResponseMessage(Response response) {
+ if (response == null) {
+ throw new ArgumentNullException("response");
+ }
+ if (this.queuedIndirectOrResponseMessage != null) {
+ throw new InvalidOperationException(MessagingStrings.QueuedMessageResponseAlreadyExists);
+ }
+
+ this.queuedIndirectOrResponseMessage = response;
+ }
+
+ /// <summary>
/// Calculates a fairly accurate estimation on the size of a message that contains
/// a given set of fields.
/// </summary>
diff --git a/src/DotNetOAuth/OAuthChannel.cs b/src/DotNetOAuth/OAuthChannel.cs index ff789b2..5ca973e 100644 --- a/src/DotNetOAuth/OAuthChannel.cs +++ b/src/DotNetOAuth/OAuthChannel.cs @@ -65,7 +65,7 @@ namespace DotNetOAuth { /// </summary>
/// <param name="request">The HTTP request to search.</param>
/// <returns>A dictionary of data in the request. Should never be null, but may be empty.</returns>
- protected internal override IProtocolMessage ReadFromRequest(HttpRequestInfo request) {
+ protected override IProtocolMessage ReadFromRequestInternal(HttpRequestInfo request) {
if (request == null) {
throw new ArgumentNullException("request");
}
@@ -97,7 +97,7 @@ namespace DotNetOAuth { }
// We didn't find an OAuth authorization header. Revert to other payload methods.
- return base.ReadFromRequest(request);
+ return base.ReadFromRequestInternal(request);
}
/// <summary>
@@ -105,7 +105,7 @@ namespace DotNetOAuth { /// </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>
- protected internal override IProtocolMessage ReadFromResponse(Stream responseStream) {
+ protected override IProtocolMessage ReadFromResponseInternal(Stream responseStream) {
if (responseStream == null) {
throw new ArgumentNullException("responseStream");
}
@@ -122,7 +122,7 @@ namespace DotNetOAuth { /// </summary>
/// <param name="request">The message to send.</param>
/// <returns>The remote party's response.</returns>
- protected internal override IProtocolMessage Request(IDirectedProtocolMessage request) {
+ protected override IProtocolMessage RequestInternal(IDirectedProtocolMessage request) {
if (request == null) {
throw new ArgumentNullException("request");
}
|