diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-06-23 08:10:15 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-06-24 17:08:56 -0700 |
commit | 6dd05a3312483393bb3c27b3c7e7b1d945d583a2 (patch) | |
tree | 5c5ccc38a767bff0479d13e86a41c29d7f89804e | |
parent | 97b1531f9fb1516a79f05172365ded01e5177419 (diff) | |
download | DotNetOpenAuth-6dd05a3312483393bb3c27b3c7e7b1d945d583a2.zip DotNetOpenAuth-6dd05a3312483393bb3c27b3c7e7b1d945d583a2.tar.gz DotNetOpenAuth-6dd05a3312483393bb3c27b3c7e7b1d945d583a2.tar.bz2 |
None of the databag derived types need to customize encode/decode behavior any more.
-rw-r--r-- | src/DotNetOpenAuth/OAuthWrap/ChannelElements/AccessToken.cs | 19 | ||||
-rw-r--r-- | src/DotNetOpenAuth/OAuthWrap/ChannelElements/DataBag.cs | 6 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/DotNetOpenAuth/OAuthWrap/ChannelElements/AccessToken.cs b/src/DotNetOpenAuth/OAuthWrap/ChannelElements/AccessToken.cs index 0fba167..6181b60 100644 --- a/src/DotNetOpenAuth/OAuthWrap/ChannelElements/AccessToken.cs +++ b/src/DotNetOpenAuth/OAuthWrap/ChannelElements/AccessToken.cs @@ -71,18 +71,25 @@ namespace DotNetOpenAuth.OAuthWrap.ChannelElements { } /// <summary> - /// Populates this instance with data from a given string. + /// Checks the message state for conformity to the protocol specification + /// and throws an exception if the message is invalid. /// </summary> - /// <param name="value">The value to deserialize from.</param> - /// <param name="containingMessage">The message that contained this token.</param> - protected override void Decode(string value, IProtocolMessage containingMessage) { - base.Decode(value, containingMessage); + /// <remarks> + /// <para>Some messages have required fields, or combinations of fields that must relate to each other + /// in specialized ways. After deserializing a message, this method checks the state of the + /// message to see if it conforms to the protocol.</para> + /// <para>Note that this property should <i>not</i> check signatures or perform any state checks + /// outside this scope of this particular message.</para> + /// </remarks> + /// <exception cref="ProtocolException">Thrown if the message is invalid.</exception> + protected override void EnsureValidMessage() { + base.EnsureValidMessage(); // Has this token expired? if (this.Lifetime.HasValue) { DateTime expirationDate = this.UtcCreationDate + this.Lifetime.Value; if (expirationDate < DateTime.UtcNow) { - throw new ExpiredMessageException(expirationDate, containingMessage); + throw new ExpiredMessageException(expirationDate, this.ContainingMessage); } } } diff --git a/src/DotNetOpenAuth/OAuthWrap/ChannelElements/DataBag.cs b/src/DotNetOpenAuth/OAuthWrap/ChannelElements/DataBag.cs index d9e4ab6..6f6d5b6 100644 --- a/src/DotNetOpenAuth/OAuthWrap/ChannelElements/DataBag.cs +++ b/src/DotNetOpenAuth/OAuthWrap/ChannelElements/DataBag.cs @@ -161,6 +161,11 @@ namespace DotNetOpenAuth.OAuthWrap.ChannelElements { internal DateTime UtcCreationDate { get; set; } /// <summary> + /// Gets or sets the message that delivered this DataBag instance to this host. + /// </summary> + protected IProtocolMessage ContainingMessage { get; set; } + + /// <summary> /// Gets the type of this instance. /// </summary> /// <value>The type of the bag.</value> @@ -221,6 +226,7 @@ namespace DotNetOpenAuth.OAuthWrap.ChannelElements { Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(value)); Contract.Requires<ArgumentNullException>(containingMessage != null, "containingMessage"); + this.ContainingMessage = containingMessage; byte[] encoded = Convert.FromBase64String(value); if (this.encrypted) { |