summaryrefslogtreecommitdiffstats
path: root/samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-04-19 07:09:32 -0400
committerAndrew Arnott <andrewarnott@gmail.com>2010-04-19 07:09:32 -0400
commit668c50fd19dc633bd367ac8ace37df8b5f9a5881 (patch)
tree8ab71b553fa22e12aae6817b3c6fab93acdd31df /samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs
parentfef932af78eac2b775452c4a851e84a813027548 (diff)
downloadDotNetOpenAuth-668c50fd19dc633bd367ac8ace37df8b5f9a5881.zip
DotNetOpenAuth-668c50fd19dc633bd367ac8ace37df8b5f9a5881.tar.gz
DotNetOpenAuth-668c50fd19dc633bd367ac8ace37df8b5f9a5881.tar.bz2
Updated OAuth C and SP samples to use standard WAP namespaces.
Diffstat (limited to 'samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs')
-rw-r--r--samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs92
1 files changed, 47 insertions, 45 deletions
diff --git a/samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs b/samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs
index c535fca..1f8f56e 100644
--- a/samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs
+++ b/samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs
@@ -1,53 +1,55 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web;
-using DotNetOpenAuth.Messaging.Bindings;
+namespace OAuthServiceProvider.Code {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Web;
+ using DotNetOpenAuth.Messaging.Bindings;
-/// <summary>
-/// A database-persisted nonce store.
-/// </summary>
-public class DatabaseNonceStore : INonceStore {
/// <summary>
- /// Initializes a new instance of the <see cref="DatabaseNonceStore"/> class.
+ /// A database-persisted nonce store.
/// </summary>
- public DatabaseNonceStore() {
- }
+ public class DatabaseNonceStore : INonceStore {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DatabaseNonceStore"/> class.
+ /// </summary>
+ public DatabaseNonceStore() {
+ }
- #region INonceStore Members
+ #region INonceStore Members
- /// <summary>
- /// Stores a given nonce and timestamp.
- /// </summary>
- /// <param name="context">The context, or namespace, within which the
- /// <paramref name="nonce"/> must be unique.
- /// The context SHOULD be treated as case-sensitive.
- /// The value will never be <c>null</c> but may be the empty string.</param>
- /// <param name="nonce">A series of random characters.</param>
- /// <param name="timestampUtc">The UTC timestamp that together with the nonce string make it unique
- /// within the given <paramref name="context"/>.
- /// The timestamp may also be used by the data store to clear out old nonces.</param>
- /// <returns>
- /// True if the context+nonce+timestamp (combination) was not previously in the database.
- /// False if the nonce was stored previously with the same timestamp and context.
- /// </returns>
- /// <remarks>
- /// The nonce must be stored for no less than the maximum time window a message may
- /// be processed within before being discarded as an expired message.
- /// This maximum message age can be looked up via the
- /// <see cref="DotNetOpenAuth.Configuration.MessagingElement.MaximumMessageLifetime"/>
- /// property, accessible via the <see cref="DotNetOpenAuth.Configuration.DotNetOpenAuthSection.Configuration"/>
- /// property.
- /// </remarks>
- public bool StoreNonce(string context, string nonce, DateTime timestampUtc) {
- Global.DataContext.Nonces.InsertOnSubmit(new Nonce { Context = context, Code = nonce, Timestamp = timestampUtc });
- try {
- Global.DataContext.SubmitChanges();
- return true;
- } catch (System.Data.Linq.DuplicateKeyException) {
- return false;
+ /// <summary>
+ /// Stores a given nonce and timestamp.
+ /// </summary>
+ /// <param name="context">The context, or namespace, within which the
+ /// <paramref name="nonce"/> must be unique.
+ /// The context SHOULD be treated as case-sensitive.
+ /// The value will never be <c>null</c> but may be the empty string.</param>
+ /// <param name="nonce">A series of random characters.</param>
+ /// <param name="timestampUtc">The UTC timestamp that together with the nonce string make it unique
+ /// within the given <paramref name="context"/>.
+ /// The timestamp may also be used by the data store to clear out old nonces.</param>
+ /// <returns>
+ /// True if the context+nonce+timestamp (combination) was not previously in the database.
+ /// False if the nonce was stored previously with the same timestamp and context.
+ /// </returns>
+ /// <remarks>
+ /// The nonce must be stored for no less than the maximum time window a message may
+ /// be processed within before being discarded as an expired message.
+ /// This maximum message age can be looked up via the
+ /// <see cref="DotNetOpenAuth.Configuration.MessagingElement.MaximumMessageLifetime"/>
+ /// property, accessible via the <see cref="DotNetOpenAuth.Configuration.DotNetOpenAuthSection.Configuration"/>
+ /// property.
+ /// </remarks>
+ public bool StoreNonce(string context, string nonce, DateTime timestampUtc) {
+ Global.DataContext.Nonces.InsertOnSubmit(new Nonce { Context = context, Code = nonce, Timestamp = timestampUtc });
+ try {
+ Global.DataContext.SubmitChanges();
+ return true;
+ } catch (System.Data.Linq.DuplicateKeyException) {
+ return false;
+ }
}
- }
- #endregion
+ #endregion
+ }
} \ No newline at end of file