diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/DotNetOAuth/DotNetOAuth.csproj | 2 | ||||
-rw-r--r-- | src/DotNetOAuth/Messages/AccessProtectedResourcesMessage.cs | 58 | ||||
-rw-r--r-- | src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs | 37 | ||||
-rw-r--r-- | src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs | 48 | ||||
-rw-r--r-- | src/DotNetOAuth/Messages/GrantAccessTokenMessage.cs | 25 | ||||
-rw-r--r-- | src/DotNetOAuth/Messages/ITamperResistantOAuthMessage.cs | 19 | ||||
-rw-r--r-- | src/DotNetOAuth/Messages/MessageBase.cs | 157 | ||||
-rw-r--r-- | src/DotNetOAuth/Messages/OAuth Messages.cd | 98 | ||||
-rw-r--r-- | src/DotNetOAuth/Messages/RequestAccessTokenMessage.cs | 58 | ||||
-rw-r--r-- | src/DotNetOAuth/Messages/RequestTokenMessage.cs | 53 | ||||
-rw-r--r-- | src/DotNetOAuth/Messages/UnauthorizedRequestTokenMessage.cs | 25 | ||||
-rw-r--r-- | src/DotNetOAuth/Messaging/IProtocolMessage.cs | 2 | ||||
-rw-r--r-- | src/DotNetOAuth/OAuthMessageTypeProvider.cs | 2 |
13 files changed, 408 insertions, 176 deletions
diff --git a/src/DotNetOAuth/DotNetOAuth.csproj b/src/DotNetOAuth/DotNetOAuth.csproj index 7d7c1a6..71cc127 100644 --- a/src/DotNetOAuth/DotNetOAuth.csproj +++ b/src/DotNetOAuth/DotNetOAuth.csproj @@ -68,6 +68,7 @@ <ItemGroup>
<Compile Include="Consumer.cs" />
<Compile Include="IWebRequestHandler.cs" />
+ <Compile Include="Messages\ITamperResistantOAuthMessage.cs" />
<Compile Include="Messages\MessageBase.cs" />
<Compile Include="Messages\RequestAccessTokenMessage.cs" />
<Compile Include="Messaging\MessagePartAttribute.cs" />
@@ -129,6 +130,7 @@ </ItemGroup>
<ItemGroup>
<None Include="ClassDiagram.cd" />
+ <None Include="Messages\OAuth Messages.cd" />
<None Include="Messaging\Bindings\Bindings.cd" />
<None Include="Messaging\Exceptions.cd" />
<None Include="Messaging\Messaging.cd" />
diff --git a/src/DotNetOAuth/Messages/AccessProtectedResourcesMessage.cs b/src/DotNetOAuth/Messages/AccessProtectedResourcesMessage.cs index 7c0d2e3..1b145a9 100644 --- a/src/DotNetOAuth/Messages/AccessProtectedResourcesMessage.cs +++ b/src/DotNetOAuth/Messages/AccessProtectedResourcesMessage.cs @@ -9,46 +9,38 @@ namespace DotNetOAuth.Messages { using System.Runtime.Serialization;
using DotNetOAuth.Messaging;
- internal class AccessProtectedResourcesMessage : MessageBase, IDirectedProtocolMessage {
- private Uri serviceProvider;
-
- internal AccessProtectedResourcesMessage(Uri serviceProvider) {
- if (serviceProvider == null) {
- throw new ArgumentNullException("serviceProvider");
- }
-
- this.serviceProvider = serviceProvider;
+ /// <summary>
+ /// A message attached to a request for protected resources that provides the necessary
+ /// credentials to be granted access to those resources.
+ /// </summary>
+ internal class AccessProtectedResourcesMessage : MessageBase {
+ /// <summary>
+ /// 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(Uri serviceProvider)
+ : base(MessageProtection.All, MessageTransport.Direct, serviceProvider) {
}
+ /// <summary>
+ /// Gets or sets the Consumer key.
+ /// </summary>
[MessagePart(Name = "oauth_consumer_key", IsRequired = true)]
public string ConsumerKey { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Access Token.
+ /// </summary>
[MessagePart(Name = "oauth_token", IsRequired = true)]
public string AccessToken { get; set; }
- [MessagePart(Name = "oauth_signature_method", IsRequired = true)]
- public string SignatureMethod { get; set; }
- [MessagePart(Name = "oauth_signature", IsRequired = true)]
- public string Signature { get; set; }
- [MessagePart(Name = "oauth_timestamp", IsRequired = true)]
- public Uri Timestamp { get; set; }
- [MessagePart(Name = "oauth_nonce", IsRequired = true)]
- public Uri Nonce { get; set; }
- [MessagePart(Name = "oauth_version", IsRequired = false)]
- public Uri Version { get; set; }
-
- protected override MessageTransport Transport {
- get { return MessageTransport.Direct; }
- }
-
- protected override MessageProtection RequiredProtection {
- get { return MessageProtection.All; }
- }
-
- #region IDirectedProtocolMessage Members
- Uri IDirectedProtocolMessage.Recipient {
- get { return this.serviceProvider; }
+ /// <summary>
+ /// Gets or sets the protocol version used in the construction of this message.
+ /// </summary>
+ [MessagePart(Name = "oauth_version", IsRequired = false)]
+ public string Version {
+ get { return this.VersionString; }
+ set { this.VersionString = value; }
}
-
- #endregion
}
}
diff --git a/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs b/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs index 1f4cdcd..6f75609 100644 --- a/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs +++ b/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs @@ -9,31 +9,22 @@ namespace DotNetOAuth.Messages { using System.Runtime.Serialization;
using DotNetOAuth.Messaging;
- internal class DirectUserToConsumerMessage : MessageBase, IDirectedProtocolMessage {
- private Uri consumer;
-
- internal DirectUserToConsumerMessage(Uri consumer) {
- this.consumer = consumer;
+ /// <summary>
+ /// A message used to redirect the user from a Service Provider to a Consumer's web site.
+ /// </summary>
+ internal class DirectUserToConsumerMessage : MessageBase {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DirectUserToConsumerMessage"/> class.
+ /// </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, consumer) {
}
- // TODO: graph in spec says this is optional, but in text is suggests it is required.
- [MessagePart(Name = "oauth_token", IsRequired = true)]
+ /// <summary>
+ /// Gets or sets the Request Token.
+ /// </summary>
+ [MessagePart(Name = "oauth_token", IsRequired = true)] // TODO: graph in spec says this is optional, but in text is suggests it is required.
public string RequestToken { get; set; }
-
- protected override MessageTransport Transport {
- get { return MessageTransport.Indirect; }
- }
-
- protected override MessageProtection RequiredProtection {
- get { return MessageProtection.None; }
- }
-
- #region IDirectedProtocolMessage Members
-
- Uri IDirectedProtocolMessage.Recipient {
- get { return this.consumer; }
- }
-
- #endregion
}
}
diff --git a/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs b/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs index 24d3fa4..1c591cf 100644 --- a/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs +++ b/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs @@ -9,36 +9,34 @@ namespace DotNetOAuth.Messages { using System.Runtime.Serialization;
using DotNetOAuth.Messaging;
- internal class DirectUserToServiceProviderMessage : MessageBase, IDirectedProtocolMessage {
- private Uri serviceProvider;
-
- internal DirectUserToServiceProviderMessage(Uri serviceProvider) {
- if (serviceProvider == null) {
- throw new ArgumentNullException("serviceProvider");
- }
-
- this.serviceProvider = serviceProvider;
+ /// <summary>
+ /// A message used to redirect the user from a Consumer to a Service Provider's web site.
+ /// </summary>
+ internal class DirectUserToServiceProviderMessage : MessageBase {
+ /// <summary>
+ /// 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(Uri serviceProvider)
+ : base(MessageProtection.None, MessageTransport.Indirect, serviceProvider) {
}
+ /// <summary>
+ /// Gets or sets the Request Token obtained in the previous step.
+ /// </summary>
+ /// <remarks>
+ /// The Service Provider MAY declare this parameter as REQUIRED, or
+ /// accept requests to the User Authorization URL without it, in which
+ /// case it will prompt the User to enter it manually.
+ /// </remarks>
[MessagePart(Name = "oauth_token", IsRequired = false)]
public string RequestToken { get; set; }
+
+ /// <summary>
+ /// Gets or sets a URL the Service Provider will use to redirect the User back
+ /// to the Consumer when Obtaining User Authorization is complete. Optional.
+ /// </summary>
[MessagePart(Name = "oauth_callback", IsRequired = false)]
public string Callback { get; set; }
-
- protected override MessageTransport Transport {
- get { return MessageTransport.Indirect; }
- }
-
- protected override MessageProtection RequiredProtection {
- get { return MessageProtection.None; }
- }
-
- #region IDirectedProtocolMessage Members
-
- Uri IDirectedProtocolMessage.Recipient {
- get { return this.serviceProvider; }
- }
-
- #endregion
}
}
diff --git a/src/DotNetOAuth/Messages/GrantAccessTokenMessage.cs b/src/DotNetOAuth/Messages/GrantAccessTokenMessage.cs index e9a8be4..42022a9 100644 --- a/src/DotNetOAuth/Messages/GrantAccessTokenMessage.cs +++ b/src/DotNetOAuth/Messages/GrantAccessTokenMessage.cs @@ -9,21 +9,28 @@ namespace DotNetOAuth.Messages { using System.Runtime.Serialization;
using DotNetOAuth.Messaging;
+ /// <summary>
+ /// A direct message sent from Service Provider to Consumer in response to
+ /// a Consumer's <see cref="RequestAccessTokenMessage"/> request.
+ /// </summary>
internal class GrantAccessTokenMessage : MessageBase {
- internal GrantAccessTokenMessage() {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="GrantAccessTokenMessage"/> class.
+ /// </summary>
+ internal GrantAccessTokenMessage()
+ : base(MessageProtection.None, MessageTransport.Direct) {
}
+ /// <summary>
+ /// Gets or sets the Access Token assigned by the Service Provider.
+ /// </summary>
[MessagePart(Name = "oauth_token", IsRequired = true)]
public string AccessToken { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Token Secret.
+ /// </summary>
[MessagePart(Name = "oauth_token_secret", IsRequired = true)]
public string TokenSecret { get; set; }
-
- protected override MessageTransport Transport {
- get { return MessageTransport.Direct; }
- }
-
- protected override MessageProtection RequiredProtection {
- get { return MessageProtection.None; }
- }
}
}
diff --git a/src/DotNetOAuth/Messages/ITamperResistantOAuthMessage.cs b/src/DotNetOAuth/Messages/ITamperResistantOAuthMessage.cs new file mode 100644 index 0000000..3d4f8c0 --- /dev/null +++ b/src/DotNetOAuth/Messages/ITamperResistantOAuthMessage.cs @@ -0,0 +1,19 @@ +//-----------------------------------------------------------------------
+// <copyright file="ITamperResistantOAuthMessage.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.Messages {
+ using DotNetOAuth.Messaging.Bindings;
+
+ /// <summary>
+ /// An interface that OAuth messages implement to support signing.
+ /// </summary>
+ internal interface ITamperResistantOAuthMessage : ITamperResistantProtocolMessage {
+ /// <summary>
+ /// Gets or sets the method used to sign the message.
+ /// </summary>
+ string SignatureMethod { get; set; }
+ }
+}
diff --git a/src/DotNetOAuth/Messages/MessageBase.cs b/src/DotNetOAuth/Messages/MessageBase.cs index b31d6ee..e689f26 100644 --- a/src/DotNetOAuth/Messages/MessageBase.cs +++ b/src/DotNetOAuth/Messages/MessageBase.cs @@ -1,41 +1,180 @@ -namespace DotNetOAuth.Messages {
+//-----------------------------------------------------------------------
+// <copyright file="MessageBase.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.Messages {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
- internal abstract class MessageBase : IProtocolMessage {
+ /// <summary>
+ /// A base class for all OAuth messages.
+ /// </summary>
+ internal abstract class MessageBase : IDirectedProtocolMessage, ITamperResistantOAuthMessage, IExpiringProtocolMessage, IReplayProtectedProtocolMessage {
+ /// <summary>
+ /// A store for extra name/value data pairs that are attached to this message.
+ /// </summary>
private Dictionary<string, string> extraData = new Dictionary<string, string>();
- #region IProtocolMessage Members
+ /// <summary>
+ /// Gets a value indicating whether signing this message is required.
+ /// </summary>
+ private MessageProtection protectionRequired;
+
+ /// <summary>
+ /// Gets a value indicating whether this is a direct or indirect message.
+ /// </summary>
+ private MessageTransport transport;
+
+ /// <summary>
+ /// The URI to the remote endpoint to send this message to.
+ /// </summary>
+ private Uri recipient;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MessageBase"/> class.
+ /// </summary>
+ /// <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>
+ protected MessageBase(MessageProtection protectionRequired, MessageTransport transport) {
+ this.protectionRequired = protectionRequired;
+ this.transport = transport;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MessageBase"/> class.
+ /// </summary>
+ /// <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, Uri recipient) {
+ if (recipient == null) {
+ throw new ArgumentNullException("recipient");
+ }
+
+ this.protectionRequired = protectionRequired;
+ this.transport = transport;
+ this.recipient = recipient;
+ }
+
+ #region IProtocolMessage Properties
+ /// <summary>
+ /// Gets the version of the protocol this message is prepared to implement.
+ /// </summary>
Version IProtocolMessage.ProtocolVersion {
get { return new Version(1, 0); }
}
+ /// <summary>
+ /// Gets the level of protection this message requires.
+ /// </summary>
MessageProtection IProtocolMessage.RequiredProtection {
- get { return this.RequiredProtection; }
+ get { return this.protectionRequired; }
}
+ /// <summary>
+ /// Gets a value indicating whether this is a direct or indirect message.
+ /// </summary>
MessageTransport IProtocolMessage.Transport {
- get { return this.Transport; }
+ get { return this.transport; }
}
+ /// <summary>
+ /// Gets the dictionary of additional name/value fields tacked on to this message.
+ /// </summary>
IDictionary<string, string> IProtocolMessage.ExtraData {
get { return this.extraData; }
}
- void IProtocolMessage.EnsureValidMessage() {
- this.EnsureValidMessage();
+ #endregion
+
+ #region IDirectedProtocolMessage Members
+
+ /// <summary>
+ /// Gets the URI to the Service Provider endpoint to send this message to.
+ /// </summary>
+ Uri IDirectedProtocolMessage.Recipient {
+ get { return this.recipient; }
}
#endregion
- protected abstract MessageTransport Transport { get; }
+ #region ITamperResistantOAuthMessage Members
+
+ /// <summary>
+ /// Gets or sets the message signature.
+ /// </summary>
+ [MessagePart("oauth_signature")]
+ string ITamperResistantProtocolMessage.Signature { get; set; }
+
+ /// <summary>
+ /// Gets or sets the signature method used to sign the request.
+ /// </summary>
+ [MessagePart("oauth_signature_method")]
+ string ITamperResistantOAuthMessage.SignatureMethod { get; set; }
+
+ #endregion
- protected abstract MessageProtection RequiredProtection { get; }
+ #region IExpiringProtocolMessage Members
+
+ /// <summary>
+ /// Gets or sets the OAuth timestamp of the message.
+ /// </summary>
+ [MessagePart("oauth_timestamp")]
+ DateTime IExpiringProtocolMessage.UtcCreationDate { get; set; }
+
+ #endregion
+
+ #region IReplayProtectedProtocolMessage Members
+
+ /// <summary>
+ /// Gets or sets the message nonce used for replay detection.
+ /// </summary>
+ [MessagePart("oauth_nonce")]
+ string IReplayProtectedProtocolMessage.Nonce { get; set; }
+
+ #endregion
+
+ /// <summary>
+ /// Gets or sets the version of the protocol this message was created with.
+ /// </summary>
+ /// <remarks>
+ /// This property is useful for handling the oauth_version message part.
+ /// </remarks>
+ protected string VersionString {
+ get {
+ return ((IProtocolMessage)this).ProtocolVersion.ToString();
+ }
+
+ set {
+ if (value != this.VersionString) {
+ throw new ArgumentOutOfRangeException("value");
+ }
+ }
+ }
+
+ #region IProtocolMessage Methods
+
+ /// <summary>
+ /// Checks the message state for conformity to the protocol specification
+ /// and throws an exception if the message is invalid.
+ /// </summary>
+ void IProtocolMessage.EnsureValidMessage() {
+ this.EnsureValidMessage();
+ }
+
+ #endregion
+ /// <summary>
+ /// Checks the message state for conformity to the protocol specification
+ /// and throws an exception if the message is invalid.
+ /// </summary>
protected virtual void EnsureValidMessage() { }
}
}
diff --git a/src/DotNetOAuth/Messages/OAuth Messages.cd b/src/DotNetOAuth/Messages/OAuth Messages.cd new file mode 100644 index 0000000..1045864 --- /dev/null +++ b/src/DotNetOAuth/Messages/OAuth Messages.cd @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="utf-8"?>
+<ClassDiagram MajorVersion="1" MinorVersion="1">
+ <Class Name="DotNetOAuth.Messages.AccessProtectedResourcesMessage">
+ <Position X="5" Y="5" Width="3.5" />
+ <TypeIdentifier>
+ <HashCode>IAAAAAAAAAAAAAAAAAAAAgAAEAAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messages\AccessProtectedResourcesMessage.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Class Name="DotNetOAuth.Messages.UnauthorizedRequestTokenMessage">
+ <Position X="9" Y="0.75" Width="3" />
+ <Compartments>
+ <Compartment Name="Methods" Collapsed="true" />
+ </Compartments>
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAIAAIAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messages\UnauthorizedRequestTokenMessage.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Class Name="DotNetOAuth.Messages.DirectUserToConsumerMessage">
+ <Position X="9" Y="2.75" Width="2.5" />
+ <Compartments>
+ <Compartment Name="Methods" Collapsed="true" />
+ </Compartments>
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messages\DirectUserToConsumerMessage.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Class Name="DotNetOAuth.Messages.DirectUserToServiceProviderMessage">
+ <Position X="1.5" Y="2.75" Width="3" />
+ <Compartments>
+ <Compartment Name="Methods" Collapsed="true" />
+ </Compartments>
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAQAA=</HashCode>
+ <FileName>Messages\DirectUserToServiceProviderMessage.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Class Name="DotNetOAuth.Messages.GrantAccessTokenMessage">
+ <Position X="9" Y="4.5" Width="2.5" />
+ <Compartments>
+ <Compartment Name="Methods" Collapsed="true" />
+ </Compartments>
+ <InheritanceLine Type="DotNetOAuth.Messages.MessageBase" FixedFromPoint="true">
+ <Path>
+ <Point X="8.5" Y="4.5" />
+ <Point X="8.74" Y="4.5" />
+ <Point X="8.74" Y="5.342" />
+ <Point X="9" Y="5.342" />
+ </Path>
+ </InheritanceLine>
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAEAAAIAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messages\GrantAccessTokenMessage.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Class Name="DotNetOAuth.Messages.MessageBase">
+ <Position X="5" Y="1" Width="3.5" />
+ <Compartments>
+ <Compartment Name="Fields" Collapsed="true" />
+ </Compartments>
+ <TypeIdentifier>
+ <HashCode>AAAKFAAAYIAAAAAAAICAAAAAAAQEIAAAQgCAACAAAAA=</HashCode>
+ <FileName>Messages\MessageBase.cs</FileName>
+ </TypeIdentifier>
+ <Lollipop Position="0.2" />
+ </Class>
+ <Class Name="DotNetOAuth.Messages.RequestAccessTokenMessage">
+ <Position X="1.5" Y="4.75" Width="2.5" />
+ <Compartments>
+ <Compartment Name="Methods" Collapsed="true" />
+ </Compartments>
+ <InheritanceLine Type="DotNetOAuth.Messages.MessageBase" FixedFromPoint="true">
+ <Path>
+ <Point X="5" Y="4.312" />
+ <Point X="4.76" Y="4.312" />
+ <Point X="4.76" Y="5.688" />
+ <Point X="4" Y="5.688" />
+ </Path>
+ </InheritanceLine>
+ <TypeIdentifier>
+ <HashCode>IAAAAAAAAAAAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messages\RequestAccessTokenMessage.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Class Name="DotNetOAuth.Messages.RequestTokenMessage">
+ <Position X="1.5" Y="0.75" Width="2" />
+ <Compartments>
+ <Compartment Name="Methods" Collapsed="true" />
+ </Compartments>
+ <TypeIdentifier>
+ <HashCode>IAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messages\RequestTokenMessage.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Font Name="Segoe UI" Size="9" />
+</ClassDiagram>
\ No newline at end of file diff --git a/src/DotNetOAuth/Messages/RequestAccessTokenMessage.cs b/src/DotNetOAuth/Messages/RequestAccessTokenMessage.cs index 5d01a90..3cb5ca9 100644 --- a/src/DotNetOAuth/Messages/RequestAccessTokenMessage.cs +++ b/src/DotNetOAuth/Messages/RequestAccessTokenMessage.cs @@ -8,46 +8,38 @@ namespace DotNetOAuth.Messages { using System;
using DotNetOAuth.Messaging;
- internal class RequestAccessTokenMessage : MessageBase, IDirectedProtocolMessage {
- private Uri serviceProvider;
-
- internal RequestAccessTokenMessage(Uri serviceProvider) {
- if (serviceProvider == null) {
- throw new ArgumentNullException("serviceProvider");
- }
-
- this.serviceProvider = serviceProvider;
+ /// <summary>
+ /// A direct message sent by the Consumer to exchange a Request Token for an Access Token
+ /// and Token Secret.
+ /// </summary>
+ internal class RequestAccessTokenMessage : MessageBase {
+ /// <summary>
+ /// 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(Uri serviceProvider)
+ : base(MessageProtection.All, MessageTransport.Direct, serviceProvider) {
}
+ /// <summary>
+ /// Gets or sets the Consumer Key.
+ /// </summary>
[MessagePart(Name = "oauth_consumer_key", IsRequired = true)]
public string ConsumerKey { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Request Token.
+ /// </summary>
[MessagePart(Name = "oauth_token", IsRequired = true)]
public string RequestToken { get; set; }
- [MessagePart(Name = "oauth_signature_method", IsRequired = true)]
- public string SignatureMethod { get; set; }
- [MessagePart(Name = "oauth_signature", IsRequired = true)]
- public string Signature { get; set; }
- [MessagePart(Name = "oauth_timestamp", IsRequired = true)]
- public Uri Timestamp { get; set; }
- [MessagePart(Name = "oauth_nonce", IsRequired = true)]
- public Uri Nonce { get; set; }
- [MessagePart(Name = "oauth_version", IsRequired = false)]
- public Uri Version { get; set; }
-
- protected override DotNetOAuth.Messaging.MessageTransport Transport {
- get { return MessageTransport.Direct; }
- }
- protected override DotNetOAuth.Messaging.MessageProtection RequiredProtection {
- get { return MessageProtection.All; }
- }
-
- #region IDirectedProtocolMessage Members
-
- Uri IDirectedProtocolMessage.Recipient {
- get { return this.serviceProvider; }
+ /// <summary>
+ /// Gets or sets the protocol version used in the construction of this message.
+ /// </summary>
+ [MessagePart(Name = "oauth_version", IsRequired = false)]
+ public string Version {
+ get { return this.VersionString; }
+ set { this.VersionString = value; }
}
-
- #endregion
}
}
diff --git a/src/DotNetOAuth/Messages/RequestTokenMessage.cs b/src/DotNetOAuth/Messages/RequestTokenMessage.cs index e327e72..4d47db0 100644 --- a/src/DotNetOAuth/Messages/RequestTokenMessage.cs +++ b/src/DotNetOAuth/Messages/RequestTokenMessage.cs @@ -9,44 +9,31 @@ namespace DotNetOAuth.Messages { using System.Runtime.Serialization;
using DotNetOAuth.Messaging;
- internal class RequestTokenMessage : MessageBase, IDirectedProtocolMessage {
- private Uri serviceProvider;
-
- internal RequestTokenMessage(Uri serviceProvider) {
- if (serviceProvider == null) {
- throw new ArgumentNullException("serviceProvider");
- }
-
- this.serviceProvider = serviceProvider;
+ /// <summary>
+ /// A direct message sent from Consumer to Service Provider to request a token.
+ /// </summary>
+ internal class RequestTokenMessage : MessageBase {
+ /// <summary>
+ /// 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(Uri serviceProvider)
+ : base(MessageProtection.All, MessageTransport.Direct, serviceProvider) {
}
+ /// <summary>
+ /// Gets or sets the consumer key.
+ /// </summary>
[MessagePart(Name = "oauth_consumer_key", IsRequired = true)]
public string ConsumerKey { get; set; }
- [MessagePart(Name = "oauth_signature_method", IsRequired = true)]
- public string SignatureMethod { get; set; }
- [MessagePart(Name = "oauth_signature", IsRequired = true)]
- public string Signature { get; set; }
- [MessagePart(Name = "oauth_timestamp", IsRequired = true)]
- public Uri Timestamp { get; set; }
- [MessagePart(Name = "oauth_nonce", IsRequired = true)]
- public Uri Nonce { get; set; }
- [MessagePart(Name = "oauth_version", IsRequired = false)]
- public Uri Version { get; set; }
-
- protected override MessageTransport Transport {
- get { return MessageTransport.Direct; }
- }
- protected override MessageProtection RequiredProtection {
- get { return MessageProtection.All; }
- }
-
- #region IDirectedProtocolMessage Members
-
- Uri IDirectedProtocolMessage.Recipient {
- get { return this.serviceProvider; }
+ /// <summary>
+ /// Gets or sets the protocol version used in the construction of this message.
+ /// </summary>
+ [MessagePart(Name = "oauth_version", IsRequired = false)]
+ public string Version {
+ get { return this.VersionString; }
+ set { this.VersionString = value; }
}
-
- #endregion
}
}
diff --git a/src/DotNetOAuth/Messages/UnauthorizedRequestTokenMessage.cs b/src/DotNetOAuth/Messages/UnauthorizedRequestTokenMessage.cs index e7a170f..593e691 100644 --- a/src/DotNetOAuth/Messages/UnauthorizedRequestTokenMessage.cs +++ b/src/DotNetOAuth/Messages/UnauthorizedRequestTokenMessage.cs @@ -9,21 +9,28 @@ namespace DotNetOAuth.Messages { using System.Runtime.Serialization;
using DotNetOAuth.Messaging;
+ /// <summary>
+ /// A direct message sent from Service Provider to Consumer in response to
+ /// a Consumer's <see cref="RequestTokenMessage"/> request.
+ /// </summary>
internal class UnauthorizedRequestTokenMessage : MessageBase {
- internal UnauthorizedRequestTokenMessage() {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="UnauthorizedRequestTokenMessage"/> class.
+ /// </summary>
+ internal UnauthorizedRequestTokenMessage()
+ : base(MessageProtection.None, MessageTransport.Direct) {
}
+ /// <summary>
+ /// Gets or sets the Request Token.
+ /// </summary>
[MessagePart(Name = "oauth_token", IsRequired = true)]
public string RequestToken { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Token Secret.
+ /// </summary>
[MessagePart(Name = "oauth_token_secret", IsRequired = true)]
public string TokenSecret { get; set; }
-
- protected override MessageTransport Transport {
- get { return MessageTransport.Direct; }
- }
-
- protected override MessageProtection RequiredProtection {
- get { return MessageProtection.None; }
- }
}
}
diff --git a/src/DotNetOAuth/Messaging/IProtocolMessage.cs b/src/DotNetOAuth/Messaging/IProtocolMessage.cs index a95822c..c353c71 100644 --- a/src/DotNetOAuth/Messaging/IProtocolMessage.cs +++ b/src/DotNetOAuth/Messaging/IProtocolMessage.cs @@ -25,7 +25,7 @@ namespace DotNetOAuth.Messaging { MessageProtection RequiredProtection { get; }
/// <summary>
- /// Gets whether this is a direct or indirect message.
+ /// Gets a value indicating whether this is a direct or indirect message.
/// </summary>
MessageTransport Transport { get; }
diff --git a/src/DotNetOAuth/OAuthMessageTypeProvider.cs b/src/DotNetOAuth/OAuthMessageTypeProvider.cs index 6f6d8b6..8e572d2 100644 --- a/src/DotNetOAuth/OAuthMessageTypeProvider.cs +++ b/src/DotNetOAuth/OAuthMessageTypeProvider.cs @@ -49,7 +49,7 @@ namespace DotNetOAuth { // which have all the same parameters, by figuring out what type of token
// is in the token parameter.
bool tokenTypeIsAccessToken = false; // TODO
-
+
return tokenTypeIsAccessToken ? typeof(AccessProtectedResourcesMessage) :
typeof(RequestAccessTokenMessage);
}
|