summaryrefslogtreecommitdiffstats
path: root/samples/OAuthServiceProvider/App_Code
diff options
context:
space:
mode:
Diffstat (limited to 'samples/OAuthServiceProvider/App_Code')
-rw-r--r--samples/OAuthServiceProvider/App_Code/Constants.cs2
-rw-r--r--samples/OAuthServiceProvider/App_Code/DataClasses.dbml10
-rw-r--r--samples/OAuthServiceProvider/App_Code/DataClasses.dbml.layout10
-rw-r--r--samples/OAuthServiceProvider/App_Code/DataClasses.designer.cs195
-rw-r--r--samples/OAuthServiceProvider/App_Code/DatabaseNonceStore.cs53
-rw-r--r--samples/OAuthServiceProvider/App_Code/Global.cs6
6 files changed, 232 insertions, 44 deletions
diff --git a/samples/OAuthServiceProvider/App_Code/Constants.cs b/samples/OAuthServiceProvider/App_Code/Constants.cs
index 7780e96..168b952 100644
--- a/samples/OAuthServiceProvider/App_Code/Constants.cs
+++ b/samples/OAuthServiceProvider/App_Code/Constants.cs
@@ -25,6 +25,6 @@ public static class Constants {
}
public static ServiceProvider CreateServiceProvider() {
- return new ServiceProvider(SelfDescription, Global.TokenManager);
+ return new ServiceProvider(SelfDescription, Global.TokenManager, Global.NonceStore);
}
}
diff --git a/samples/OAuthServiceProvider/App_Code/DataClasses.dbml b/samples/OAuthServiceProvider/App_Code/DataClasses.dbml
index 651de9f..393420e 100644
--- a/samples/OAuthServiceProvider/App_Code/DataClasses.dbml
+++ b/samples/OAuthServiceProvider/App_Code/DataClasses.dbml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Database Name="Database" Class="DataClassesDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
+<?xml version="1.0" encoding="utf-8"?><Database Name="Database" Class="DataClassesDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
<Connection Mode="WebSettings" ConnectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" SettingsObjectName="System.Configuration.ConfigurationManager.ConnectionStrings" SettingsPropertyName="DatabaseConnectionString" Provider="System.Data.SqlClient" />
<Table Name="dbo.[User]" Member="Users">
<Type Name="User">
@@ -48,4 +47,11 @@
<Association Name="User_OAuthToken" Member="User" ThisKey="UserId" OtherKey="UserId" Type="User" IsForeignKey="true" DeleteRule="CASCADE" />
</Type>
</Table>
+ <Table Name="" Member="Nonces">
+ <Type Name="Nonce">
+ <Column Member="Context" Type="System.String" IsPrimaryKey="true" CanBeNull="false" />
+ <Column Member="Code" Type="System.String" IsPrimaryKey="true" CanBeNull="false" />
+ <Column Member="Timestamp" Type="System.DateTime" IsPrimaryKey="true" CanBeNull="false" />
+ </Type>
+ </Table>
</Database> \ No newline at end of file
diff --git a/samples/OAuthServiceProvider/App_Code/DataClasses.dbml.layout b/samples/OAuthServiceProvider/App_Code/DataClasses.dbml.layout
index 71bd4aa..44ce026 100644
--- a/samples/OAuthServiceProvider/App_Code/DataClasses.dbml.layout
+++ b/samples/OAuthServiceProvider/App_Code/DataClasses.dbml.layout
@@ -26,14 +26,14 @@
<elementListCompartment Id="403126d0-3d2a-4af4-b0b8-c489a830bbd4" absoluteBounds="3.515, 3.585, 1.9700000000000002, 2.364705403645833" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
</nestedChildShapes>
</classShape>
- <associationConnector edgePoints="[(2.625 : 1.31814697265625); (3.5 : 1.31814697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
+ <associationConnector edgePoints="[(2.625 : 1.31814697265625); (3.5 : 1.31814697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm">
<AssociationMoniker Name="/DataClassesDataContext/User/User_FavoriteSite" />
<nodes>
<classShapeMoniker Id="696d2c69-040e-411d-9257-bb664b743834" />
<classShapeMoniker Id="8a79b099-7f87-4766-907a-db2c3e1b5716" />
</nodes>
</associationConnector>
- <associationConnector edgePoints="[(2.625 : 4.23159912109375); (3.5 : 4.23159912109375)]" fixedFrom="Algorithm" fixedTo="Algorithm">
+ <associationConnector edgePoints="[(2.625 : 4.23159912109375); (3.5 : 4.23159912109375)]" fixedFrom="NotFixed" fixedTo="NotFixed">
<AssociationMoniker Name="/DataClassesDataContext/OAuthConsumer/OAuthConsumer_OAuthToken" />
<nodes>
<classShapeMoniker Id="f909becb-85b1-4fe6-bb16-3feb3e4fe3ee" />
@@ -47,5 +47,11 @@
<classShapeMoniker Id="895ebbc8-8352-4c04-9e53-b8e6c8302d36" />
</nodes>
</associationConnector>
+ <classShape Id="a63562a7-acf2-4ed9-9686-52a1ad85633e" absoluteBounds="1.375, 6.375, 2, 1.3862939453124996">
+ <DataClassMoniker Name="/DataClassesDataContext/Nonce" />
+ <nestedChildShapes>
+ <elementListCompartment Id="9e4514ef-bc7b-4179-88e6-05363bf6ee5e" absoluteBounds="1.39, 6.835, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
+ </nestedChildShapes>
+ </classShape>
</nestedChildShapes>
</ordesignerObjectsDiagram> \ No newline at end of file
diff --git a/samples/OAuthServiceProvider/App_Code/DataClasses.designer.cs b/samples/OAuthServiceProvider/App_Code/DataClasses.designer.cs
index b66e75f..89757e5 100644
--- a/samples/OAuthServiceProvider/App_Code/DataClasses.designer.cs
+++ b/samples/OAuthServiceProvider/App_Code/DataClasses.designer.cs
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.4918
+// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -21,7 +21,7 @@ using System.Reflection;
-[System.Data.Linq.Mapping.DatabaseAttribute(Name="Database")]
+[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="Database")]
public partial class DataClassesDataContext : System.Data.Linq.DataContext
{
@@ -41,6 +41,9 @@ public partial class DataClassesDataContext : System.Data.Linq.DataContext
partial void InsertOAuthToken(OAuthToken instance);
partial void UpdateOAuthToken(OAuthToken instance);
partial void DeleteOAuthToken(OAuthToken instance);
+ partial void InsertNonce(Nonce instance);
+ partial void UpdateNonce(Nonce instance);
+ partial void DeleteNonce(Nonce instance);
#endregion
public DataClassesDataContext() :
@@ -104,9 +107,17 @@ public partial class DataClassesDataContext : System.Data.Linq.DataContext
return this.GetTable<OAuthToken>();
}
}
+
+ public System.Data.Linq.Table<Nonce> Nonces
+ {
+ get
+ {
+ return this.GetTable<Nonce>();
+ }
+ }
}
-[Table(Name="dbo.[User]")]
+[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.[User]")]
public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
{
@@ -149,7 +160,7 @@ public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
OnCreated();
}
- [Column(Storage="_UserId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
public int UserId
{
get
@@ -169,7 +180,7 @@ public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
}
}
- [Column(Storage="_OpenIDClaimedIdentifier", DbType="NVarChar(150) NOT NULL", CanBeNull=false)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_OpenIDClaimedIdentifier", DbType="NVarChar(150) NOT NULL", CanBeNull=false)]
public string OpenIDClaimedIdentifier
{
get
@@ -189,7 +200,7 @@ public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
}
}
- [Column(Storage="_OpenIDFriendlyIdentifier", DbType="NVarChar(150)")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_OpenIDFriendlyIdentifier", DbType="NVarChar(150)")]
public string OpenIDFriendlyIdentifier
{
get
@@ -209,7 +220,7 @@ public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
}
}
- [Column(Storage="_FullName", DbType="NVarChar(150)", CanBeNull=false)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FullName", DbType="NVarChar(150)", CanBeNull=false)]
public string FullName
{
get
@@ -229,7 +240,7 @@ public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
}
}
- [Column(Storage="_Age", DbType="int")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Age", DbType="int")]
public System.Nullable<int> Age
{
get
@@ -249,7 +260,7 @@ public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
}
}
- [Association(Name="User_FavoriteSite", Storage="_FavoriteSites", ThisKey="UserId", OtherKey="UserId")]
+ [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_FavoriteSite", Storage="_FavoriteSites", ThisKey="UserId", OtherKey="UserId")]
public EntitySet<FavoriteSite> FavoriteSites
{
get
@@ -262,7 +273,7 @@ public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
}
}
- [Association(Name="User_OAuthToken", Storage="_OAuthTokens", ThisKey="UserId", OtherKey="UserId")]
+ [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_OAuthToken", Storage="_OAuthTokens", ThisKey="UserId", OtherKey="UserId")]
public EntitySet<OAuthToken> OAuthTokens
{
get
@@ -320,7 +331,7 @@ public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
}
}
-[Table(Name="dbo.FavoriteSite")]
+[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.FavoriteSite")]
public partial class FavoriteSite : INotifyPropertyChanging, INotifyPropertyChanged
{
@@ -352,7 +363,7 @@ public partial class FavoriteSite : INotifyPropertyChanging, INotifyPropertyChan
OnCreated();
}
- [Column(Storage="_FavoriteSiteId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FavoriteSiteId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
public int FavoriteSiteId
{
get
@@ -372,7 +383,7 @@ public partial class FavoriteSite : INotifyPropertyChanging, INotifyPropertyChan
}
}
- [Column(Storage="_UserId", DbType="Int NOT NULL")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="Int NOT NULL")]
public int UserId
{
get
@@ -396,7 +407,7 @@ public partial class FavoriteSite : INotifyPropertyChanging, INotifyPropertyChan
}
}
- [Column(Storage="_SiteUrl", DbType="NVarChar(255) NOT NULL", CanBeNull=false)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_SiteUrl", DbType="NVarChar(255) NOT NULL", CanBeNull=false)]
public string SiteUrl
{
get
@@ -416,7 +427,7 @@ public partial class FavoriteSite : INotifyPropertyChanging, INotifyPropertyChan
}
}
- [Association(Name="User_FavoriteSite", Storage="_User", ThisKey="UserId", OtherKey="UserId", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")]
+ [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_FavoriteSite", Storage="_User", ThisKey="UserId", OtherKey="UserId", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")]
public User User
{
get
@@ -471,7 +482,7 @@ public partial class FavoriteSite : INotifyPropertyChanging, INotifyPropertyChan
}
}
-[Table(Name="dbo.OAuthConsumer")]
+[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.OAuthConsumer")]
public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyChanged
{
@@ -515,7 +526,7 @@ public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyCha
OnCreated();
}
- [Column(Storage="_ConsumerId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
public int ConsumerId
{
get
@@ -535,7 +546,7 @@ public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyCha
}
}
- [Column(Storage="_ConsumerKey", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerKey", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
public string ConsumerKey
{
get
@@ -555,7 +566,7 @@ public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyCha
}
}
- [Column(Storage="_ConsumerSecret", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerSecret", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
public string ConsumerSecret
{
get
@@ -575,7 +586,7 @@ public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyCha
}
}
- [Column(Storage="_Callback")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Callback")]
public string Callback
{
get
@@ -595,7 +606,7 @@ public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyCha
}
}
- [Column(Storage="_VerificationCodeFormat")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_VerificationCodeFormat", CanBeNull=false)]
public DotNetOpenAuth.OAuth.VerificationCodeFormat VerificationCodeFormat
{
get
@@ -615,7 +626,7 @@ public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyCha
}
}
- [Column(Storage="_VerificationCodeLength")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_VerificationCodeLength")]
public int VerificationCodeLength
{
get
@@ -635,7 +646,7 @@ public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyCha
}
}
- [Association(Name="OAuthConsumer_OAuthToken", Storage="_OAuthTokens", ThisKey="ConsumerId", OtherKey="ConsumerId")]
+ [global::System.Data.Linq.Mapping.AssociationAttribute(Name="OAuthConsumer_OAuthToken", Storage="_OAuthTokens", ThisKey="ConsumerId", OtherKey="ConsumerId")]
public EntitySet<OAuthToken> OAuthTokens
{
get
@@ -681,7 +692,7 @@ public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyCha
}
}
-[Table(Name="dbo.OAuthToken")]
+[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.OAuthToken")]
public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChanged
{
@@ -748,7 +759,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
OnCreated();
}
- [Column(Storage="_TokenId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TokenId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
public int TokenId
{
get
@@ -768,7 +779,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Column(Storage="_Token", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Token", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
public string Token
{
get
@@ -788,7 +799,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Column(Storage="_TokenSecret", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TokenSecret", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
public string TokenSecret
{
get
@@ -808,7 +819,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Column(Storage="_State", DbType="INT NOT NULL", CanBeNull=false)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_State", DbType="INT NOT NULL", CanBeNull=false)]
public TokenAuthorizationState State
{
get
@@ -828,7 +839,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Column(Storage="_IssueDate", DbType="DateTime NOT NULL")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IssueDate", DbType="DateTime NOT NULL")]
public System.DateTime IssueDate
{
get
@@ -848,7 +859,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Column(Storage="_ConsumerId", DbType="Int NOT NULL")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerId", DbType="Int NOT NULL")]
public int ConsumerId
{
get
@@ -872,7 +883,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Column(Storage="_UserId", DbType="Int")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="Int")]
public System.Nullable<int> UserId
{
get
@@ -896,7 +907,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Column(Storage="_Scope", DbType="nvarchar(MAX)", CanBeNull=false)]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Scope", DbType="nvarchar(MAX)", CanBeNull=false)]
public string Scope
{
get
@@ -916,7 +927,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Column(Storage="_RequestTokenVerifier")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_RequestTokenVerifier")]
public string RequestTokenVerifier
{
get
@@ -936,7 +947,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Column(Storage="_RequestTokenCallback")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_RequestTokenCallback")]
public string RequestTokenCallback
{
get
@@ -956,7 +967,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Column(Storage="_ConsumerVersion")]
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerVersion")]
public string ConsumerVersion
{
get
@@ -976,7 +987,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Association(Name="OAuthConsumer_OAuthToken", Storage="_OAuthConsumer", ThisKey="ConsumerId", OtherKey="ConsumerId", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")]
+ [global::System.Data.Linq.Mapping.AssociationAttribute(Name="OAuthConsumer_OAuthToken", Storage="_OAuthConsumer", ThisKey="ConsumerId", OtherKey="ConsumerId", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")]
public OAuthConsumer OAuthConsumer
{
get
@@ -1010,7 +1021,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
- [Association(Name="User_OAuthToken", Storage="_User", ThisKey="UserId", OtherKey="UserId", IsForeignKey=true, DeleteRule="CASCADE")]
+ [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_OAuthToken", Storage="_User", ThisKey="UserId", OtherKey="UserId", IsForeignKey=true, DeleteRule="CASCADE")]
public User User
{
get
@@ -1064,4 +1075,114 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange
}
}
}
+
+[global::System.Data.Linq.Mapping.TableAttribute(Name="")]
+public partial class Nonce : INotifyPropertyChanging, INotifyPropertyChanged
+{
+
+ private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
+
+ private string _Context;
+
+ private string _Code;
+
+ private System.DateTime _Timestamp;
+
+ #region Extensibility Method Definitions
+ partial void OnLoaded();
+ partial void OnValidate(System.Data.Linq.ChangeAction action);
+ partial void OnCreated();
+ partial void OnContextChanging(string value);
+ partial void OnContextChanged();
+ partial void OnCodeChanging(string value);
+ partial void OnCodeChanged();
+ partial void OnTimestampChanging(System.DateTime value);
+ partial void OnTimestampChanged();
+ #endregion
+
+ public Nonce()
+ {
+ OnCreated();
+ }
+
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Context", CanBeNull=false, IsPrimaryKey=true)]
+ public string Context
+ {
+ get
+ {
+ return this._Context;
+ }
+ set
+ {
+ if ((this._Context != value))
+ {
+ this.OnContextChanging(value);
+ this.SendPropertyChanging();
+ this._Context = value;
+ this.SendPropertyChanged("Context");
+ this.OnContextChanged();
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Code", CanBeNull=false, IsPrimaryKey=true)]
+ public string Code
+ {
+ get
+ {
+ return this._Code;
+ }
+ set
+ {
+ if ((this._Code != value))
+ {
+ this.OnCodeChanging(value);
+ this.SendPropertyChanging();
+ this._Code = value;
+ this.SendPropertyChanged("Code");
+ this.OnCodeChanged();
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Timestamp", IsPrimaryKey=true)]
+ public System.DateTime Timestamp
+ {
+ get
+ {
+ return this._Timestamp;
+ }
+ set
+ {
+ if ((this._Timestamp != value))
+ {
+ this.OnTimestampChanging(value);
+ this.SendPropertyChanging();
+ this._Timestamp = value;
+ this.SendPropertyChanged("Timestamp");
+ this.OnTimestampChanged();
+ }
+ }
+ }
+
+ public event PropertyChangingEventHandler PropertyChanging;
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void SendPropertyChanging()
+ {
+ if ((this.PropertyChanging != null))
+ {
+ this.PropertyChanging(this, emptyChangingEventArgs);
+ }
+ }
+
+ protected virtual void SendPropertyChanged(String propertyName)
+ {
+ if ((this.PropertyChanged != null))
+ {
+ this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+}
#pragma warning restore 1591
diff --git a/samples/OAuthServiceProvider/App_Code/DatabaseNonceStore.cs b/samples/OAuthServiceProvider/App_Code/DatabaseNonceStore.cs
new file mode 100644
index 0000000..c535fca
--- /dev/null
+++ b/samples/OAuthServiceProvider/App_Code/DatabaseNonceStore.cs
@@ -0,0 +1,53 @@
+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.
+ /// </summary>
+ public DatabaseNonceStore() {
+ }
+
+ #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;
+ }
+ }
+
+ #endregion
+} \ No newline at end of file
diff --git a/samples/OAuthServiceProvider/App_Code/Global.cs b/samples/OAuthServiceProvider/App_Code/Global.cs
index 10b3cba..6a7ccc9 100644
--- a/samples/OAuthServiceProvider/App_Code/Global.cs
+++ b/samples/OAuthServiceProvider/App_Code/Global.cs
@@ -38,6 +38,8 @@ public class Global : HttpApplication {
public static DatabaseTokenManager TokenManager { get; set; }
+ public static DatabaseNonceStore NonceStore { get; set; }
+
public static User LoggedInUser {
get { return Global.DataContext.Users.SingleOrDefault(user => user.OpenIDClaimedIdentifier == HttpContext.Current.User.Identity.Name); }
}
@@ -101,8 +103,8 @@ public class Global : HttpApplication {
// start before the first incoming request context is available.
// TODO: fix this.
Constants.WebRootUrl = new Uri(HttpContext.Current.Request.Url, appPath);
- var tokenManager = new DatabaseTokenManager();
- Global.TokenManager = tokenManager;
+ Global.TokenManager = new DatabaseTokenManager();
+ Global.NonceStore = new DatabaseNonceStore();
}
private void Application_End(object sender, EventArgs e) {