diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-22 07:28:59 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-09-22 07:28:59 -0700 |
commit | 560913937eb6f1c0264eae08d45e2543b4713adb (patch) | |
tree | 4d4a8caff238dd0233f23b9ec8fa6ee26849dfb8 | |
parent | d4e2e55e9a48ffb397d1e095194c64ea726bfaeb (diff) | |
download | DotNetOpenAuth-560913937eb6f1c0264eae08d45e2543b4713adb.zip DotNetOpenAuth-560913937eb6f1c0264eae08d45e2543b4713adb.tar.gz DotNetOpenAuth-560913937eb6f1c0264eae08d45e2543b4713adb.tar.bz2 |
Fixed up the timestamp to be OAuth compliant.
-rw-r--r-- | src/DotNetOAuth/Messages/SignedMessageBase.cs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/DotNetOAuth/Messages/SignedMessageBase.cs b/src/DotNetOAuth/Messages/SignedMessageBase.cs index 7361adf..52f03ab 100644 --- a/src/DotNetOAuth/Messages/SignedMessageBase.cs +++ b/src/DotNetOAuth/Messages/SignedMessageBase.cs @@ -15,6 +15,17 @@ namespace DotNetOAuth.Messages { /// </summary>
internal class SignedMessageBase : MessageBase, ITamperResistantOAuthMessage, IExpiringProtocolMessage, IReplayProtectedProtocolMessage {
/// <summary>
+ /// The reference date and time for calculating time stamps.
+ /// </summary>
+ private static readonly DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+
+ /// <summary>
+ /// The number of seconds since 1/1/1970, consistent with the OAuth timestamp requirement.
+ /// </summary>
+ [MessagePart("oauth_timestamp")]
+ private long timestamp;
+
+ /// <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>
@@ -52,8 +63,10 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets or sets the OAuth timestamp of the message.
/// </summary>
- [MessagePart("oauth_timestamp")]
- DateTime IExpiringProtocolMessage.UtcCreationDate { get; set; }
+ DateTime IExpiringProtocolMessage.UtcCreationDate {
+ get { return epoch + TimeSpan.FromSeconds(this.timestamp); }
+ set { this.timestamp = (long)(value - epoch).TotalSeconds; }
+ }
#endregion
|