diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-22 07:17:22 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-09-22 07:17:22 -0700 |
commit | d4e2e55e9a48ffb397d1e095194c64ea726bfaeb (patch) | |
tree | c7ec31e3a6a31f1f1513d39c1515b2aa3d5341b8 /src/DotNetOAuth/Messages/SignedMessageBase.cs | |
parent | f80ac82be5e9432806ce35b7025b007246d74147 (diff) | |
download | DotNetOpenAuth-d4e2e55e9a48ffb397d1e095194c64ea726bfaeb.zip DotNetOpenAuth-d4e2e55e9a48ffb397d1e095194c64ea726bfaeb.tar.gz DotNetOpenAuth-d4e2e55e9a48ffb397d1e095194c64ea726bfaeb.tar.bz2 |
Refactored OAuth signing functionality into a SignedMessageBase class.
Diffstat (limited to 'src/DotNetOAuth/Messages/SignedMessageBase.cs')
-rw-r--r-- | src/DotNetOAuth/Messages/SignedMessageBase.cs | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/DotNetOAuth/Messages/SignedMessageBase.cs b/src/DotNetOAuth/Messages/SignedMessageBase.cs new file mode 100644 index 0000000..7361adf --- /dev/null +++ b/src/DotNetOAuth/Messages/SignedMessageBase.cs @@ -0,0 +1,86 @@ +//-----------------------------------------------------------------------
+// <copyright file="SignedMessageBase.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.Messages {
+ using System;
+ using DotNetOAuth.ChannelElements;
+ using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
+
+ /// <summary>
+ /// A base class for all signed OAuth messages.
+ /// </summary>
+ internal class SignedMessageBase : MessageBase, ITamperResistantOAuthMessage, IExpiringProtocolMessage, IReplayProtectedProtocolMessage {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SignedMessageBase"/> class.
+ /// </summary>
+ /// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param>
+ internal SignedMessageBase(MessageTransport transport)
+ : base(MessageProtection.All, transport) {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SignedMessageBase"/> class.
+ /// </summary>
+ /// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param>
+ /// <param name="recipient">The URI that a directed message will be delivered to.</param>
+ internal SignedMessageBase(MessageTransport transport, Uri recipient)
+ : base(MessageProtection.All, transport, recipient) {
+ }
+
+ #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
+
+ #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>
+ [MessagePart(Name = "oauth_version", IsRequired = false)]
+ private string Version {
+ get {
+ return ((IProtocolMessage)this).ProtocolVersion.ToString();
+ }
+
+ set {
+ if (value != this.Version) {
+ throw new ArgumentOutOfRangeException("value");
+ }
+ }
+ }
+ }
+}
|