summaryrefslogtreecommitdiffstats
path: root/projecttemplates/RelyingPartyLogic
diff options
context:
space:
mode:
Diffstat (limited to 'projecttemplates/RelyingPartyLogic')
-rw-r--r--projecttemplates/RelyingPartyLogic/CreateDatabase.sql112
-rw-r--r--projecttemplates/RelyingPartyLogic/Model.Client.cs29
-rw-r--r--projecttemplates/RelyingPartyLogic/Model.ClientAuthorization.cs (renamed from projecttemplates/RelyingPartyLogic/Model.IssuedToken.cs)6
-rw-r--r--projecttemplates/RelyingPartyLogic/Model.Consumer.cs40
-rw-r--r--projecttemplates/RelyingPartyLogic/Model.Designer.cs1061
-rw-r--r--projecttemplates/RelyingPartyLogic/Model.IssuedAccessToken.cs74
-rw-r--r--projecttemplates/RelyingPartyLogic/Model.IssuedRequestToken.cs63
-rw-r--r--projecttemplates/RelyingPartyLogic/Model.edmx292
-rw-r--r--projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs17
-rw-r--r--projecttemplates/RelyingPartyLogic/OAuthAuthorizationManager.cs21
-rw-r--r--projecttemplates/RelyingPartyLogic/OAuthAuthorizationServer.cs176
-rw-r--r--projecttemplates/RelyingPartyLogic/OAuthConsumerTokenManager.cs48
-rw-r--r--projecttemplates/RelyingPartyLogic/OAuthPrincipalAuthorizationPolicy.cs5
-rw-r--r--projecttemplates/RelyingPartyLogic/OAuthServiceProvider.cs99
-rw-r--r--projecttemplates/RelyingPartyLogic/OAuthServiceProviderTokenManager.cs112
-rw-r--r--projecttemplates/RelyingPartyLogic/OAuthTokenManager.cs141
-rw-r--r--projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj23
-rw-r--r--projecttemplates/RelyingPartyLogic/SpecialAccessTokenAnalyzer.cs36
18 files changed, 862 insertions, 1493 deletions
diff --git a/projecttemplates/RelyingPartyLogic/CreateDatabase.sql b/projecttemplates/RelyingPartyLogic/CreateDatabase.sql
index 0fa1b43..5c82398 100644
--- a/projecttemplates/RelyingPartyLogic/CreateDatabase.sql
+++ b/projecttemplates/RelyingPartyLogic/CreateDatabase.sql
@@ -8,10 +8,10 @@ SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL
GO
/*
-:setvar Path1 "WEBROOT\App_Data\"
+:setvar Path1 "WEBROOT"
:setvar DatabaseName "RelyingPartyDatabase"
-:setvar DefaultDataPath ""
-:setvar DefaultLogPath ""
+:setvar DefaultDataPath "c:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\"
+:setvar DefaultLogPath "c:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\"
*/
GO
@@ -128,24 +128,6 @@ ELSE
GO
-IF IS_SRVROLEMEMBER(N'sysadmin') = 1
- BEGIN
- IF EXISTS (SELECT 1
- FROM [master].[dbo].[sysdatabases]
- WHERE [name] = N'$(DatabaseName)')
- BEGIN
- EXECUTE sp_executesql N'ALTER DATABASE [$(DatabaseName)]
- SET HONOR_BROKER_PRIORITY OFF
- WITH ROLLBACK IMMEDIATE';
- END
- END
-ELSE
- BEGIN
- PRINT N'The database settings cannot be modified. You must be a SysAdmin to apply these settings.';
- END
-
-
-GO
USE [$(DatabaseName)]
GO
@@ -200,7 +182,7 @@ ALTER TABLE [dbo].[AuthenticationToken]
GO
-PRINT N'Creating [dbo].[Consumer]...';
+PRINT N'Creating [dbo].[Client]...';
GO
@@ -208,15 +190,12 @@ SET ANSI_NULLS, QUOTED_IDENTIFIER ON;
GO
-CREATE TABLE [dbo].[Consumer] (
- [ConsumerId] INT IDENTITY (1, 1) NOT NULL,
- [ConsumerKey] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL,
- [ConsumerSecret] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL,
- [X509Certificate] IMAGE NULL,
- [Callback] NVARCHAR (2048) NULL,
- [VerificationCodeFormat] INT NOT NULL,
- [VerificationCodeLength] INT NOT NULL,
- [Name] NVARCHAR (50) NULL
+CREATE TABLE [dbo].[Client] (
+ [ClientId] INT IDENTITY (1, 1) NOT NULL,
+ [ClientIdentifier] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL,
+ [ClientSecret] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL,
+ [Callback] VARCHAR (2048) NULL,
+ [Name] NVARCHAR (50) NOT NULL
);
@@ -229,21 +208,22 @@ PRINT N'Creating PK_Consumer...';
GO
-ALTER TABLE [dbo].[Consumer]
- ADD CONSTRAINT [PK_Consumer] PRIMARY KEY CLUSTERED ([ConsumerId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF);
+ALTER TABLE [dbo].[Client]
+ ADD CONSTRAINT [PK_Consumer] PRIMARY KEY CLUSTERED ([ClientId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF);
GO
-PRINT N'Creating [dbo].[Consumer].[IX_Consumer]...';
+PRINT N'Creating [dbo].[Client].[IX_Consumer]...';
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Consumer]
- ON [dbo].[Consumer]([ConsumerKey] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0);
+ ON [dbo].[Client]([ClientIdentifier] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0)
+ ON [PRIMARY];
GO
-PRINT N'Creating [dbo].[IssuedToken]...';
+PRINT N'Creating [dbo].[ClientAuthorization]...';
GO
@@ -251,19 +231,13 @@ SET ANSI_NULLS, QUOTED_IDENTIFIER ON;
GO
-CREATE TABLE [dbo].[IssuedToken] (
- [IssuedTokenId] INT IDENTITY (1, 1) NOT NULL,
- [ConsumerId] INT NOT NULL,
- [UserId] INT NULL,
- [Token] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL,
- [TokenSecret] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL,
- [CreatedOn] DATETIME NOT NULL,
- [Callback] NVARCHAR (2048) NULL,
- [VerificationCode] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL,
- [ConsumerVersion] VARCHAR (10) NULL,
- [ExpirationDate] DATETIME NULL,
- [IsAccessToken] BIT NOT NULL,
- [Scope] NVARCHAR (255) NULL
+CREATE TABLE [dbo].[ClientAuthorization] (
+ [AuthorizationId] INT IDENTITY (1, 1) NOT NULL,
+ [ClientId] INT NOT NULL,
+ [UserId] INT NOT NULL,
+ [CreatedOn] DATETIME NOT NULL,
+ [ExpirationDate] DATETIME NULL,
+ [Scope] VARCHAR (2048) NULL
);
@@ -276,17 +250,8 @@ PRINT N'Creating PK_IssuedToken...';
GO
-ALTER TABLE [dbo].[IssuedToken]
- ADD CONSTRAINT [PK_IssuedToken] PRIMARY KEY CLUSTERED ([IssuedTokenId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF);
-
-
-GO
-PRINT N'Creating [dbo].[IssuedToken].[IX_IssuedToken]...';
-
-
-GO
-CREATE UNIQUE NONCLUSTERED INDEX [IX_IssuedToken]
- ON [dbo].[IssuedToken]([Token] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0);
+ALTER TABLE [dbo].[ClientAuthorization]
+ ADD CONSTRAINT [PK_IssuedToken] PRIMARY KEY CLUSTERED ([AuthorizationId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF);
GO
@@ -515,20 +480,11 @@ PRINT N'Creating DF_IssuedToken_CreatedOn...';
GO
-ALTER TABLE [dbo].[IssuedToken]
+ALTER TABLE [dbo].[ClientAuthorization]
ADD CONSTRAINT [DF_IssuedToken_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn];
GO
-PRINT N'Creating DF_IssuedToken_IsAccessToken...';
-
-
-GO
-ALTER TABLE [dbo].[IssuedToken]
- ADD CONSTRAINT [DF_IssuedToken_IsAccessToken] DEFAULT ((0)) FOR [IsAccessToken];
-
-
-GO
PRINT N'Creating DF_Nonce_Issued...';
@@ -569,8 +525,8 @@ PRINT N'Creating FK_IssuedToken_Consumer...';
GO
-ALTER TABLE [dbo].[IssuedToken] WITH NOCHECK
- ADD CONSTRAINT [FK_IssuedToken_Consumer] FOREIGN KEY ([ConsumerId]) REFERENCES [dbo].[Consumer] ([ConsumerId]) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE [dbo].[ClientAuthorization] WITH NOCHECK
+ ADD CONSTRAINT [FK_IssuedToken_Consumer] FOREIGN KEY ([ClientId]) REFERENCES [dbo].[Client] ([ClientId]) ON DELETE CASCADE ON UPDATE CASCADE;
GO
@@ -578,7 +534,7 @@ PRINT N'Creating FK_IssuedToken_User...';
GO
-ALTER TABLE [dbo].[IssuedToken] WITH NOCHECK
+ALTER TABLE [dbo].[ClientAuthorization] WITH NOCHECK
ADD CONSTRAINT [FK_IssuedToken_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]) ON DELETE CASCADE ON UPDATE CASCADE;
@@ -717,9 +673,9 @@ USE [$(DatabaseName)];
GO
ALTER TABLE [dbo].[AuthenticationToken] WITH CHECK CHECK CONSTRAINT [FK_AuthenticationToken_User];
-ALTER TABLE [dbo].[IssuedToken] WITH CHECK CHECK CONSTRAINT [FK_IssuedToken_Consumer];
+ALTER TABLE [dbo].[ClientAuthorization] WITH CHECK CHECK CONSTRAINT [FK_IssuedToken_Consumer];
-ALTER TABLE [dbo].[IssuedToken] WITH CHECK CHECK CONSTRAINT [FK_IssuedToken_User];
+ALTER TABLE [dbo].[ClientAuthorization] WITH CHECK CHECK CONSTRAINT [FK_IssuedToken_User];
ALTER TABLE [dbo].[UserRole] WITH CHECK CHECK CONSTRAINT [FK_UserRole_Role];
@@ -727,9 +683,3 @@ ALTER TABLE [dbo].[UserRole] WITH CHECK CHECK CONSTRAINT [FK_UserRole_User];
GO
-ALTER DATABASE [$(DatabaseName)]
- SET MULTI_USER
- WITH ROLLBACK IMMEDIATE;
-
-
-GO
diff --git a/projecttemplates/RelyingPartyLogic/Model.Client.cs b/projecttemplates/RelyingPartyLogic/Model.Client.cs
new file mode 100644
index 0000000..9426408
--- /dev/null
+++ b/projecttemplates/RelyingPartyLogic/Model.Client.cs
@@ -0,0 +1,29 @@
+//-----------------------------------------------------------------------
+// <copyright file="Model.Client.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace RelyingPartyLogic {
+ using System;
+
+ using DotNetOpenAuth.OAuth2;
+
+ public partial class Client : IConsumerDescription {
+ public Uri Callback {
+ get { return this.CallbackAsString != null ? new Uri(this.CallbackAsString) : null; }
+ set { this.CallbackAsString = value != null ? value.AbsoluteUri : null; }
+ }
+
+ #region IConsumerDescription Members
+
+ /// <summary>
+ /// Gets the client secret.
+ /// </summary>
+ string IConsumerDescription.Secret {
+ get { return this.ClientSecret; }
+ }
+
+ #endregion
+ }
+}
diff --git a/projecttemplates/RelyingPartyLogic/Model.IssuedToken.cs b/projecttemplates/RelyingPartyLogic/Model.ClientAuthorization.cs
index 5e10178..3d7646a 100644
--- a/projecttemplates/RelyingPartyLogic/Model.IssuedToken.cs
+++ b/projecttemplates/RelyingPartyLogic/Model.ClientAuthorization.cs
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
-// <copyright file="Model.IssuedToken.cs" company="Andrew Arnott">
+// <copyright file="Model.ClientAuthorization.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
@@ -11,11 +11,11 @@ namespace RelyingPartyLogic {
using System.Web;
using DotNetOpenAuth.OAuth.ChannelElements;
- public partial class IssuedToken {
+ public partial class ClientAuthorization {
/// <summary>
/// Initializes a new instance of the <see cref="IssuedToken"/> class.
/// </summary>
- public IssuedToken() {
+ public ClientAuthorization() {
this.CreatedOnUtc = DateTime.UtcNow;
}
diff --git a/projecttemplates/RelyingPartyLogic/Model.Consumer.cs b/projecttemplates/RelyingPartyLogic/Model.Consumer.cs
deleted file mode 100644
index a09029a..0000000
--- a/projecttemplates/RelyingPartyLogic/Model.Consumer.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="Model.Consumer.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace RelyingPartyLogic {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography.X509Certificates;
- using System.Web;
- using DotNetOpenAuth.OAuth;
- using DotNetOpenAuth.OAuth.ChannelElements;
-
- public partial class Consumer : IConsumerDescription {
- public VerificationCodeFormat VerificationCodeFormat {
- get { return (VerificationCodeFormat)this.VerificationCodeFormatAsInt; }
- set { this.VerificationCodeFormatAsInt = (int)value; }
- }
-
- public X509Certificate2 Certificate {
- get { return this.X509CertificateAsBinary != null ? new X509Certificate2(this.X509CertificateAsBinary) : null; }
- set { this.X509CertificateAsBinary = value != null ? value.RawData : null; }
- }
-
- public Uri Callback {
- get { return this.CallbackAsString != null ? new Uri(this.CallbackAsString) : null; }
- set { this.CallbackAsString = value != null ? value.AbsoluteUri : null; }
- }
-
- string IConsumerDescription.Secret {
- get { return this.ConsumerSecret; }
- }
-
- string IConsumerDescription.Key {
- get { return this.ConsumerKey; }
- }
- }
-}
diff --git a/projecttemplates/RelyingPartyLogic/Model.Designer.cs b/projecttemplates/RelyingPartyLogic/Model.Designer.cs
index a1a5348..8884760 100644
--- a/projecttemplates/RelyingPartyLogic/Model.Designer.cs
+++ b/projecttemplates/RelyingPartyLogic/Model.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:4.0.30104.0
+// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -11,11 +11,11 @@
[assembly: global::System.Data.Objects.DataClasses.EdmSchemaAttribute()]
[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "UserRole", "Role", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.Role), "User", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.User))]
[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "FK_AuthenticationToken_User", "User", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RelyingPartyLogic.User), "AuthenticationToken", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.AuthenticationToken))]
-[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "FK_IssuedToken_Consumer1", "Consumer", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RelyingPartyLogic.Consumer), "IssuedToken", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.IssuedToken))]
-[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "FK_IssuedToken_User1", "User", global::System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(RelyingPartyLogic.User), "IssuedToken", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.IssuedToken))]
+[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "FK_IssuedToken_Consumer", "Client", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RelyingPartyLogic.Client), "ClientAuthorization", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.ClientAuthorization))]
+[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "FK_IssuedToken_User", "User", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RelyingPartyLogic.User), "ClientAuthorization", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.ClientAuthorization))]
// Original file name:
-// Generation date: 1/7/2010 8:42:18 PM
+// Generation date: 7/14/2010 9:35:17 PM
namespace RelyingPartyLogic
{
@@ -101,73 +101,73 @@ namespace RelyingPartyLogic
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
private global::System.Data.Objects.ObjectQuery<AuthenticationToken> _AuthenticationTokens;
/// <summary>
- /// There are no comments for Consumers in the schema.
+ /// There are no comments for Nonces in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public global::System.Data.Objects.ObjectQuery<Consumer> Consumers
+ public global::System.Data.Objects.ObjectQuery<Nonce> Nonces
{
get
{
- if ((this._Consumers == null))
+ if ((this._Nonces == null))
{
- this._Consumers = base.CreateQuery<Consumer>("[Consumers]");
+ this._Nonces = base.CreateQuery<Nonce>("[Nonces]");
}
- return this._Consumers;
+ return this._Nonces;
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private global::System.Data.Objects.ObjectQuery<Consumer> _Consumers;
+ private global::System.Data.Objects.ObjectQuery<Nonce> _Nonces;
/// <summary>
- /// There are no comments for IssuedTokens in the schema.
+ /// There are no comments for OpenIdAssociations in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public global::System.Data.Objects.ObjectQuery<IssuedToken> IssuedTokens
+ public global::System.Data.Objects.ObjectQuery<OpenIdAssociation> OpenIdAssociations
{
get
{
- if ((this._IssuedTokens == null))
+ if ((this._OpenIdAssociations == null))
{
- this._IssuedTokens = base.CreateQuery<IssuedToken>("[IssuedTokens]");
+ this._OpenIdAssociations = base.CreateQuery<OpenIdAssociation>("[OpenIdAssociations]");
}
- return this._IssuedTokens;
+ return this._OpenIdAssociations;
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private global::System.Data.Objects.ObjectQuery<IssuedToken> _IssuedTokens;
+ private global::System.Data.Objects.ObjectQuery<OpenIdAssociation> _OpenIdAssociations;
/// <summary>
- /// There are no comments for Nonces in the schema.
+ /// There are no comments for Clients in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public global::System.Data.Objects.ObjectQuery<Nonce> Nonces
+ public global::System.Data.Objects.ObjectQuery<Client> Clients
{
get
{
- if ((this._Nonces == null))
+ if ((this._Clients == null))
{
- this._Nonces = base.CreateQuery<Nonce>("[Nonces]");
+ this._Clients = base.CreateQuery<Client>("[Clients]");
}
- return this._Nonces;
+ return this._Clients;
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private global::System.Data.Objects.ObjectQuery<Nonce> _Nonces;
+ private global::System.Data.Objects.ObjectQuery<Client> _Clients;
/// <summary>
- /// There are no comments for OpenIdAssociations in the schema.
+ /// There are no comments for ClientAuthorizations in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public global::System.Data.Objects.ObjectQuery<OpenIdAssociation> OpenIdAssociations
+ public global::System.Data.Objects.ObjectQuery<ClientAuthorization> ClientAuthorizations
{
get
{
- if ((this._OpenIdAssociations == null))
+ if ((this._ClientAuthorizations == null))
{
- this._OpenIdAssociations = base.CreateQuery<OpenIdAssociation>("[OpenIdAssociations]");
+ this._ClientAuthorizations = base.CreateQuery<ClientAuthorization>("[ClientAuthorizations]");
}
- return this._OpenIdAssociations;
+ return this._ClientAuthorizations;
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private global::System.Data.Objects.ObjectQuery<OpenIdAssociation> _OpenIdAssociations;
+ private global::System.Data.Objects.ObjectQuery<ClientAuthorization> _ClientAuthorizations;
/// <summary>
/// There are no comments for Roles in the schema.
/// </summary>
@@ -193,36 +193,36 @@ namespace RelyingPartyLogic
base.AddObject("AuthenticationTokens", authenticationToken);
}
/// <summary>
- /// There are no comments for Consumers in the schema.
+ /// There are no comments for Nonces in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public void AddToConsumers(Consumer consumer)
+ public void AddToNonces(Nonce nonce)
{
- base.AddObject("Consumers", consumer);
+ base.AddObject("Nonces", nonce);
}
/// <summary>
- /// There are no comments for IssuedTokens in the schema.
+ /// There are no comments for OpenIdAssociations in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public void AddToIssuedTokens(IssuedToken issuedToken)
+ public void AddToOpenIdAssociations(OpenIdAssociation openIdAssociation)
{
- base.AddObject("IssuedTokens", issuedToken);
+ base.AddObject("OpenIdAssociations", openIdAssociation);
}
/// <summary>
- /// There are no comments for Nonces in the schema.
+ /// There are no comments for Clients in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public void AddToNonces(Nonce nonce)
+ public void AddToClients(Client client)
{
- base.AddObject("Nonces", nonce);
+ base.AddObject("Clients", client);
}
/// <summary>
- /// There are no comments for OpenIdAssociations in the schema.
+ /// There are no comments for ClientAuthorizations in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public void AddToOpenIdAssociations(OpenIdAssociation openIdAssociation)
+ public void AddToClientAuthorizations(ClientAuthorization clientAuthorization)
{
- base.AddObject("OpenIdAssociations", openIdAssociation);
+ base.AddObject("ClientAuthorizations", clientAuthorization);
}
}
/// <summary>
@@ -791,609 +791,503 @@ namespace RelyingPartyLogic
}
}
/// <summary>
- /// There are no comments for IssuedTokens in the schema.
+ /// There are no comments for ClientAuthorizations in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_User1", "IssuedToken")]
+ [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_User", "ClientAuthorization")]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
[global::System.Xml.Serialization.XmlIgnoreAttribute()]
[global::System.Xml.Serialization.SoapIgnoreAttribute()]
[global::System.Runtime.Serialization.DataMemberAttribute()]
- public global::System.Data.Objects.DataClasses.EntityCollection<IssuedToken> IssuedTokens
+ public global::System.Data.Objects.DataClasses.EntityCollection<ClientAuthorization> ClientAuthorizations
{
get
{
- return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<IssuedToken>("DatabaseModel.FK_IssuedToken_User1", "IssuedToken");
+ return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<ClientAuthorization>("DatabaseModel.FK_IssuedToken_User", "ClientAuthorization");
}
set
{
if ((value != null))
{
- ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<IssuedToken>("DatabaseModel.FK_IssuedToken_User1", "IssuedToken", value);
+ ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<ClientAuthorization>("DatabaseModel.FK_IssuedToken_User", "ClientAuthorization", value);
}
}
}
}
/// <summary>
- /// There are no comments for DatabaseModel.Consumer in the schema.
+ /// There are no comments for DatabaseModel.Nonce in the schema.
/// </summary>
/// <KeyProperties>
- /// ConsumerId
+ /// NonceId
/// </KeyProperties>
- [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="Consumer")]
+ [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="Nonce")]
[global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
[global::System.Serializable()]
- public partial class Consumer : global::System.Data.Objects.DataClasses.EntityObject
+ public partial class Nonce : global::System.Data.Objects.DataClasses.EntityObject
{
/// <summary>
- /// Create a new Consumer object.
+ /// Create a new Nonce object.
/// </summary>
- /// <param name="consumerKey">Initial value of ConsumerKey.</param>
- /// <param name="verificationCodeLength">Initial value of VerificationCodeLength.</param>
- /// <param name="consumerId">Initial value of ConsumerId.</param>
+ /// <param name="nonceId">Initial value of NonceId.</param>
+ /// <param name="context">Initial value of Context.</param>
+ /// <param name="code">Initial value of Code.</param>
+ /// <param name="issuedUtc">Initial value of IssuedUtc.</param>
+ /// <param name="expiresUtc">Initial value of ExpiresUtc.</param>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public static Consumer CreateConsumer(string consumerKey, int verificationCodeLength, int consumerId)
+ public static Nonce CreateNonce(int nonceId, string context, string code, global::System.DateTime issuedUtc, global::System.DateTime expiresUtc)
{
- Consumer consumer = new Consumer();
- consumer.ConsumerKey = consumerKey;
- consumer.VerificationCodeLength = verificationCodeLength;
- consumer.ConsumerId = consumerId;
- return consumer;
+ Nonce nonce = new Nonce();
+ nonce.NonceId = nonceId;
+ nonce.Context = context;
+ nonce.Code = code;
+ nonce.IssuedUtc = issuedUtc;
+ nonce.ExpiresUtc = expiresUtc;
+ return nonce;
}
/// <summary>
- /// There are no comments for property ConsumerKey in the schema.
+ /// There are no comments for property NonceId in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
+ [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string ConsumerKey
+ public int NonceId
{
get
{
- return this._ConsumerKey;
+ return this._NonceId;
}
set
{
- this.OnConsumerKeyChanging(value);
- this.ReportPropertyChanging("ConsumerKey");
- this._ConsumerKey = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
- this.ReportPropertyChanged("ConsumerKey");
- this.OnConsumerKeyChanged();
+ this.OnNonceIdChanging(value);
+ this.ReportPropertyChanging("NonceId");
+ this._NonceId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
+ this.ReportPropertyChanged("NonceId");
+ this.OnNonceIdChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _ConsumerKey;
+ private int _NonceId;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnConsumerKeyChanging(string value);
+ partial void OnNonceIdChanging(int value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnConsumerKeyChanged();
+ partial void OnNonceIdChanged();
/// <summary>
- /// There are no comments for property ConsumerSecret in the schema.
+ /// Gets or sets the Provider Endpoint URL the nonce came from.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
+ [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string ConsumerSecret
+ public string Context
{
get
{
- return this._ConsumerSecret;
+ return this._Context;
}
set
{
- this.OnConsumerSecretChanging(value);
- this.ReportPropertyChanging("ConsumerSecret");
- this._ConsumerSecret = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
- this.ReportPropertyChanged("ConsumerSecret");
- this.OnConsumerSecretChanged();
+ this.OnContextChanging(value);
+ this.ReportPropertyChanging("Context");
+ this._Context = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
+ this.ReportPropertyChanged("Context");
+ this.OnContextChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _ConsumerSecret;
+ private string _Context;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnConsumerSecretChanging(string value);
+ partial void OnContextChanging(string value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnConsumerSecretChanged();
+ partial void OnContextChanged();
/// <summary>
- /// There are no comments for property X509CertificateAsBinary in the schema.
+ /// There are no comments for property Code in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
+ [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private byte[] X509CertificateAsBinary
+ public string Code
{
get
{
- return global::System.Data.Objects.DataClasses.StructuralObject.GetValidValue(this._X509CertificateAsBinary);
+ return this._Code;
}
set
{
- this.OnX509CertificateAsBinaryChanging(value);
- this.ReportPropertyChanging("X509CertificateAsBinary");
- this._X509CertificateAsBinary = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
- this.ReportPropertyChanged("X509CertificateAsBinary");
- this.OnX509CertificateAsBinaryChanged();
+ this.OnCodeChanging(value);
+ this.ReportPropertyChanging("Code");
+ this._Code = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
+ this.ReportPropertyChanged("Code");
+ this.OnCodeChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private byte[] _X509CertificateAsBinary;
+ private string _Code;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnX509CertificateAsBinaryChanging(byte[] value);
+ partial void OnCodeChanging(string value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnX509CertificateAsBinaryChanged();
+ partial void OnCodeChanged();
/// <summary>
- /// There are no comments for property CallbackAsString in the schema.
+ /// There are no comments for property IssuedUtc in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
+ [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string CallbackAsString
+ public global::System.DateTime IssuedUtc
{
get
{
- return this._CallbackAsString;
+ return this._IssuedUtc;
}
set
{
- this.OnCallbackAsStringChanging(value);
- this.ReportPropertyChanging("CallbackAsString");
- this._CallbackAsString = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
- this.ReportPropertyChanged("CallbackAsString");
- this.OnCallbackAsStringChanged();
+ this.OnIssuedUtcChanging(value);
+ this.ReportPropertyChanging("IssuedUtc");
+ this._IssuedUtc = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
+ this.ReportPropertyChanged("IssuedUtc");
+ this.OnIssuedUtcChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _CallbackAsString;
+ private global::System.DateTime _IssuedUtc;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnCallbackAsStringChanging(string value);
+ partial void OnIssuedUtcChanging(global::System.DateTime value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnCallbackAsStringChanged();
+ partial void OnIssuedUtcChanged();
/// <summary>
- /// There are no comments for property VerificationCodeFormatAsInt in the schema.
+ /// There are no comments for property ExpiresUtc in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private int VerificationCodeFormatAsInt
+ public global::System.DateTime ExpiresUtc
{
get
{
- return this._VerificationCodeFormatAsInt;
+ return this._ExpiresUtc;
}
set
{
- this.OnVerificationCodeFormatAsIntChanging(value);
- this.ReportPropertyChanging("VerificationCodeFormatAsInt");
- this._VerificationCodeFormatAsInt = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("VerificationCodeFormatAsInt");
- this.OnVerificationCodeFormatAsIntChanged();
+ this.OnExpiresUtcChanging(value);
+ this.ReportPropertyChanging("ExpiresUtc");
+ this._ExpiresUtc = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
+ this.ReportPropertyChanged("ExpiresUtc");
+ this.OnExpiresUtcChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private int _VerificationCodeFormatAsInt;
+ private global::System.DateTime _ExpiresUtc;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnVerificationCodeFormatAsIntChanging(int value);
+ partial void OnExpiresUtcChanging(global::System.DateTime value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnVerificationCodeFormatAsIntChanged();
+ partial void OnExpiresUtcChanged();
+ }
+ /// <summary>
+ /// There are no comments for DatabaseModel.OpenIdAssociation in the schema.
+ /// </summary>
+ /// <KeyProperties>
+ /// AssociationId
+ /// </KeyProperties>
+ [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="OpenIdAssociation")]
+ [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
+ [global::System.Serializable()]
+ public partial class OpenIdAssociation : global::System.Data.Objects.DataClasses.EntityObject
+ {
/// <summary>
- /// There are no comments for property VerificationCodeLength in the schema.
+ /// Create a new OpenIdAssociation object.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
- [global::System.Runtime.Serialization.DataMemberAttribute()]
+ /// <param name="associationId">Initial value of AssociationId.</param>
+ /// <param name="distinguishingFactor">Initial value of DistinguishingFactor.</param>
+ /// <param name="associationHandle">Initial value of AssociationHandle.</param>
+ /// <param name="expirationUtc">Initial value of ExpirationUtc.</param>
+ /// <param name="privateData">Initial value of PrivateData.</param>
+ /// <param name="privateDataLength">Initial value of PrivateDataLength.</param>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public int VerificationCodeLength
+ public static OpenIdAssociation CreateOpenIdAssociation(int associationId, string distinguishingFactor, string associationHandle, global::System.DateTime expirationUtc, byte[] privateData, int privateDataLength)
{
- get
- {
- return this._VerificationCodeLength;
- }
- set
- {
- this.OnVerificationCodeLengthChanging(value);
- this.ReportPropertyChanging("VerificationCodeLength");
- this._VerificationCodeLength = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("VerificationCodeLength");
- this.OnVerificationCodeLengthChanged();
- }
+ OpenIdAssociation openIdAssociation = new OpenIdAssociation();
+ openIdAssociation.AssociationId = associationId;
+ openIdAssociation.DistinguishingFactor = distinguishingFactor;
+ openIdAssociation.AssociationHandle = associationHandle;
+ openIdAssociation.ExpirationUtc = expirationUtc;
+ openIdAssociation.PrivateData = privateData;
+ openIdAssociation.PrivateDataLength = privateDataLength;
+ return openIdAssociation;
}
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private int _VerificationCodeLength;
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnVerificationCodeLengthChanging(int value);
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnVerificationCodeLengthChanged();
/// <summary>
- /// There are no comments for property ConsumerId in the schema.
+ /// There are no comments for property AssociationId in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public int ConsumerId
+ public int AssociationId
{
get
{
- return this._ConsumerId;
+ return this._AssociationId;
}
- private set
+ set
{
- this.OnConsumerIdChanging(value);
- this.ReportPropertyChanging("ConsumerId");
- this._ConsumerId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("ConsumerId");
- this.OnConsumerIdChanged();
+ this.OnAssociationIdChanging(value);
+ this.ReportPropertyChanging("AssociationId");
+ this._AssociationId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
+ this.ReportPropertyChanged("AssociationId");
+ this.OnAssociationIdChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private int _ConsumerId;
+ private int _AssociationId;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnConsumerIdChanging(int value);
+ partial void OnAssociationIdChanging(int value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnConsumerIdChanged();
+ partial void OnAssociationIdChanged();
/// <summary>
- /// There are no comments for property Name in the schema.
+ /// Gets or sets the Provider Endpoint URL the association is with.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
+ [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string Name
+ public string DistinguishingFactor
{
get
{
- return this._Name;
+ return this._DistinguishingFactor;
}
set
{
- this.OnNameChanging(value);
- this.ReportPropertyChanging("Name");
- this._Name = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
- this.ReportPropertyChanged("Name");
- this.OnNameChanged();
+ this.OnDistinguishingFactorChanging(value);
+ this.ReportPropertyChanging("DistinguishingFactor");
+ this._DistinguishingFactor = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
+ this.ReportPropertyChanged("DistinguishingFactor");
+ this.OnDistinguishingFactorChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _Name;
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnNameChanging(string value);
+ private string _DistinguishingFactor;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnNameChanged();
- /// <summary>
- /// There are no comments for IssuedTokens in the schema.
- /// </summary>
- [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_Consumer1", "IssuedToken")]
+ partial void OnDistinguishingFactorChanging(string value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- [global::System.Xml.Serialization.XmlIgnoreAttribute()]
- [global::System.Xml.Serialization.SoapIgnoreAttribute()]
- [global::System.Runtime.Serialization.DataMemberAttribute()]
- public global::System.Data.Objects.DataClasses.EntityCollection<IssuedToken> IssuedTokens
- {
- get
- {
- return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<IssuedToken>("DatabaseModel.FK_IssuedToken_Consumer1", "IssuedToken");
- }
- set
- {
- if ((value != null))
- {
- ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<IssuedToken>("DatabaseModel.FK_IssuedToken_Consumer1", "IssuedToken", value);
- }
- }
- }
- }
- /// <summary>
- /// There are no comments for DatabaseModel.IssuedToken in the schema.
- /// </summary>
- /// <KeyProperties>
- /// IssuedTokenId
- /// </KeyProperties>
- [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="IssuedToken")]
- [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
- [global::System.Serializable()]
- [global::System.Runtime.Serialization.KnownTypeAttribute(typeof(global::RelyingPartyLogic.IssuedRequestToken))]
- [global::System.Runtime.Serialization.KnownTypeAttribute(typeof(global::RelyingPartyLogic.IssuedAccessToken))]
- public abstract partial class IssuedToken : global::System.Data.Objects.DataClasses.EntityObject
- {
+ partial void OnDistinguishingFactorChanged();
/// <summary>
- /// There are no comments for property Token in the schema.
+ /// There are no comments for property AssociationHandle in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string Token
+ public string AssociationHandle
{
get
{
- return this._Token;
+ return this._AssociationHandle;
}
set
{
- this.OnTokenChanging(value);
- this.ReportPropertyChanging("Token");
- this._Token = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
- this.ReportPropertyChanged("Token");
- this.OnTokenChanged();
+ this.OnAssociationHandleChanging(value);
+ this.ReportPropertyChanging("AssociationHandle");
+ this._AssociationHandle = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
+ this.ReportPropertyChanged("AssociationHandle");
+ this.OnAssociationHandleChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _Token;
+ private string _AssociationHandle;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnTokenChanging(string value);
+ partial void OnAssociationHandleChanging(string value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnTokenChanged();
+ partial void OnAssociationHandleChanged();
/// <summary>
- /// There are no comments for property TokenSecret in the schema.
+ /// There are no comments for property ExpirationUtc in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string TokenSecret
+ public global::System.DateTime ExpirationUtc
{
get
{
- return this._TokenSecret;
+ return this._ExpirationUtc;
}
set
{
- this.OnTokenSecretChanging(value);
- this.ReportPropertyChanging("TokenSecret");
- this._TokenSecret = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
- this.ReportPropertyChanged("TokenSecret");
- this.OnTokenSecretChanged();
+ this.OnExpirationUtcChanging(value);
+ this.ReportPropertyChanging("ExpirationUtc");
+ this._ExpirationUtc = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
+ this.ReportPropertyChanged("ExpirationUtc");
+ this.OnExpirationUtcChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _TokenSecret;
+ private global::System.DateTime _ExpirationUtc;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnTokenSecretChanging(string value);
+ partial void OnExpirationUtcChanging(global::System.DateTime value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnTokenSecretChanged();
+ partial void OnExpirationUtcChanged();
/// <summary>
- /// There are no comments for property CreatedOnUtc in the schema.
+ /// There are no comments for property PrivateData in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public global::System.DateTime CreatedOnUtc
+ public byte[] PrivateData
{
get
{
- return this._CreatedOnUtc;
+ return global::System.Data.Objects.DataClasses.StructuralObject.GetValidValue(this._PrivateData);
}
- internal set
+ set
{
- this.OnCreatedOnUtcChanging(value);
- this.ReportPropertyChanging("CreatedOnUtc");
- this._CreatedOnUtc = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("CreatedOnUtc");
- this.OnCreatedOnUtcChanged();
+ this.OnPrivateDataChanging(value);
+ this.ReportPropertyChanging("PrivateData");
+ this._PrivateData = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
+ this.ReportPropertyChanged("PrivateData");
+ this.OnPrivateDataChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private global::System.DateTime _CreatedOnUtc;
+ private byte[] _PrivateData;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnCreatedOnUtcChanging(global::System.DateTime value);
+ partial void OnPrivateDataChanging(byte[] value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnCreatedOnUtcChanged();
+ partial void OnPrivateDataChanged();
/// <summary>
- /// There are no comments for property Scope in the schema.
+ /// There are no comments for property PrivateDataLength in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
+ [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string Scope
+ public int PrivateDataLength
{
get
{
- return this._Scope;
+ return this._PrivateDataLength;
}
set
{
- this.OnScopeChanging(value);
- this.ReportPropertyChanging("Scope");
- this._Scope = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
- this.ReportPropertyChanged("Scope");
- this.OnScopeChanged();
+ this.OnPrivateDataLengthChanging(value);
+ this.ReportPropertyChanging("PrivateDataLength");
+ this._PrivateDataLength = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
+ this.ReportPropertyChanged("PrivateDataLength");
+ this.OnPrivateDataLengthChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _Scope;
+ private int _PrivateDataLength;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnScopeChanging(string value);
+ partial void OnPrivateDataLengthChanging(int value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnScopeChanged();
+ partial void OnPrivateDataLengthChanged();
+ }
+ /// <summary>
+ /// There are no comments for DatabaseModel.Client in the schema.
+ /// </summary>
+ /// <KeyProperties>
+ /// ClientId
+ /// </KeyProperties>
+ [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="Client")]
+ [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
+ [global::System.Serializable()]
+ public partial class Client : global::System.Data.Objects.DataClasses.EntityObject
+ {
/// <summary>
- /// There are no comments for property IssuedTokenId in the schema.
+ /// Create a new Client object.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
- [global::System.Runtime.Serialization.DataMemberAttribute()]
+ /// <param name="clientId">Initial value of ClientId.</param>
+ /// <param name="clientIdentifier">Initial value of ClientIdentifier.</param>
+ /// <param name="name">Initial value of Name.</param>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public int IssuedTokenId
+ public static Client CreateClient(int clientId, string clientIdentifier, string name)
{
- get
- {
- return this._IssuedTokenId;
- }
- internal set
- {
- this.OnIssuedTokenIdChanging(value);
- this.ReportPropertyChanging("IssuedTokenId");
- this._IssuedTokenId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("IssuedTokenId");
- this.OnIssuedTokenIdChanged();
- }
+ Client client = new Client();
+ client.ClientId = clientId;
+ client.ClientIdentifier = clientIdentifier;
+ client.Name = name;
+ return client;
}
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private int _IssuedTokenId;
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnIssuedTokenIdChanging(int value);
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnIssuedTokenIdChanged();
/// <summary>
- /// There are no comments for Consumer in the schema.
+ /// There are no comments for property ClientId in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_Consumer1", "Consumer")]
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- [global::System.Xml.Serialization.XmlIgnoreAttribute()]
- [global::System.Xml.Serialization.SoapIgnoreAttribute()]
+ [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
- public Consumer Consumer
- {
- get
- {
- return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer1", "Consumer").Value;
- }
- set
- {
- ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer1", "Consumer").Value = value;
- }
- }
- /// <summary>
- /// There are no comments for Consumer in the schema.
- /// </summary>
- [global::System.ComponentModel.BrowsableAttribute(false)]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- [global::System.Runtime.Serialization.DataMemberAttribute()]
- public global::System.Data.Objects.DataClasses.EntityReference<Consumer> ConsumerReference
+ public int ClientId
{
get
{
- return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer1", "Consumer");
+ return this._ClientId;
}
set
{
- if ((value != null))
- {
- ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer1", "Consumer", value);
- }
+ this.OnClientIdChanging(value);
+ this.ReportPropertyChanging("ClientId");
+ this._ClientId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
+ this.ReportPropertyChanged("ClientId");
+ this.OnClientIdChanged();
}
}
- /// <summary>
- /// There are no comments for User in the schema.
- /// </summary>
- [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_User1", "User")]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- [global::System.Xml.Serialization.XmlIgnoreAttribute()]
- [global::System.Xml.Serialization.SoapIgnoreAttribute()]
- [global::System.Runtime.Serialization.DataMemberAttribute()]
- public User User
- {
- get
- {
- return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User1", "User").Value;
- }
- set
- {
- ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User1", "User").Value = value;
- }
- }
- /// <summary>
- /// There are no comments for User in the schema.
- /// </summary>
- [global::System.ComponentModel.BrowsableAttribute(false)]
+ private int _ClientId;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- [global::System.Runtime.Serialization.DataMemberAttribute()]
- public global::System.Data.Objects.DataClasses.EntityReference<User> UserReference
- {
- get
- {
- return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User1", "User");
- }
- set
- {
- if ((value != null))
- {
- ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<User>("DatabaseModel.FK_IssuedToken_User1", "User", value);
- }
- }
- }
- }
- /// <summary>
- /// There are no comments for DatabaseModel.IssuedRequestToken in the schema.
- /// </summary>
- /// <KeyProperties>
- /// IssuedTokenId
- /// </KeyProperties>
- [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="IssuedRequestToken")]
- [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
- [global::System.Serializable()]
- public partial class IssuedRequestToken : IssuedToken
- {
- /// <summary>
- /// Create a new IssuedRequestToken object.
- /// </summary>
- /// <param name="token">Initial value of Token.</param>
- /// <param name="tokenSecret">Initial value of TokenSecret.</param>
- /// <param name="createdOnUtc">Initial value of CreatedOnUtc.</param>
- /// <param name="issuedTokenId">Initial value of IssuedTokenId.</param>
+ partial void OnClientIdChanging(int value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public static IssuedRequestToken CreateIssuedRequestToken(string token, string tokenSecret, global::System.DateTime createdOnUtc, int issuedTokenId)
- {
- IssuedRequestToken issuedRequestToken = new IssuedRequestToken();
- issuedRequestToken.Token = token;
- issuedRequestToken.TokenSecret = tokenSecret;
- issuedRequestToken.CreatedOnUtc = createdOnUtc;
- issuedRequestToken.IssuedTokenId = issuedTokenId;
- return issuedRequestToken;
- }
+ partial void OnClientIdChanged();
/// <summary>
- /// There are no comments for property ConsumerVersionAsString in the schema.
+ /// There are no comments for property ClientIdentifier in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string ConsumerVersionAsString
+ public string ClientIdentifier
{
get
{
- return this._ConsumerVersionAsString;
+ return this._ClientIdentifier;
}
set
{
- this.OnConsumerVersionAsStringChanging(value);
- this.ReportPropertyChanging("ConsumerVersionAsString");
- this._ConsumerVersionAsString = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
- this.ReportPropertyChanged("ConsumerVersionAsString");
- this.OnConsumerVersionAsStringChanged();
+ this.OnClientIdentifierChanging(value);
+ this.ReportPropertyChanging("ClientIdentifier");
+ this._ClientIdentifier = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
+ this.ReportPropertyChanged("ClientIdentifier");
+ this.OnClientIdentifierChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _ConsumerVersionAsString;
+ private string _ClientIdentifier;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnConsumerVersionAsStringChanging(string value);
+ partial void OnClientIdentifierChanging(string value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnConsumerVersionAsStringChanged();
+ partial void OnClientIdentifierChanged();
/// <summary>
- /// There are no comments for property VerificationCode in the schema.
+ /// There are no comments for property ClientSecret in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string VerificationCode
+ public string ClientSecret
{
get
{
- return this._VerificationCode;
+ return this._ClientSecret;
}
set
{
- this.OnVerificationCodeChanging(value);
- this.ReportPropertyChanging("VerificationCode");
- this._VerificationCode = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
- this.ReportPropertyChanged("VerificationCode");
- this.OnVerificationCodeChanged();
+ this.OnClientSecretChanging(value);
+ this.ReportPropertyChanging("ClientSecret");
+ this._ClientSecret = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
+ this.ReportPropertyChanged("ClientSecret");
+ this.OnClientSecretChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _VerificationCode;
+ private string _ClientSecret;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnVerificationCodeChanging(string value);
+ partial void OnClientSecretChanging(string value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnVerificationCodeChanged();
+ partial void OnClientSecretChanged();
/// <summary>
/// There are no comments for property CallbackAsString in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string CallbackAsString
+ public string CallbackAsString
{
get
{
@@ -1414,422 +1308,265 @@ namespace RelyingPartyLogic
partial void OnCallbackAsStringChanging(string value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
partial void OnCallbackAsStringChanged();
- }
- /// <summary>
- /// There are no comments for DatabaseModel.IssuedAccessToken in the schema.
- /// </summary>
- /// <KeyProperties>
- /// IssuedTokenId
- /// </KeyProperties>
- [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="IssuedAccessToken")]
- [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
- [global::System.Serializable()]
- public partial class IssuedAccessToken : IssuedToken
- {
/// <summary>
- /// Create a new IssuedAccessToken object.
- /// </summary>
- /// <param name="token">Initial value of Token.</param>
- /// <param name="tokenSecret">Initial value of TokenSecret.</param>
- /// <param name="createdOnUtc">Initial value of CreatedOnUtc.</param>
- /// <param name="issuedTokenId">Initial value of IssuedTokenId.</param>
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public static IssuedAccessToken CreateIssuedAccessToken(string token, string tokenSecret, global::System.DateTime createdOnUtc, int issuedTokenId)
- {
- IssuedAccessToken issuedAccessToken = new IssuedAccessToken();
- issuedAccessToken.Token = token;
- issuedAccessToken.TokenSecret = tokenSecret;
- issuedAccessToken.CreatedOnUtc = createdOnUtc;
- issuedAccessToken.IssuedTokenId = issuedTokenId;
- return issuedAccessToken;
- }
- /// <summary>
- /// There are no comments for property ExpirationDateUtc in the schema.
+ /// There are no comments for property Name in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
+ [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public global::System.Nullable<global::System.DateTime> ExpirationDateUtc
+ public string Name
{
get
{
- return this._ExpirationDateUtc;
+ return this._Name;
}
set
{
- this.OnExpirationDateUtcChanging(value);
- this.ReportPropertyChanging("ExpirationDateUtc");
- this._ExpirationDateUtc = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("ExpirationDateUtc");
- this.OnExpirationDateUtcChanged();
+ this.OnNameChanging(value);
+ this.ReportPropertyChanging("Name");
+ this._Name = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
+ this.ReportPropertyChanged("Name");
+ this.OnNameChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private global::System.Nullable<global::System.DateTime> _ExpirationDateUtc;
+ private string _Name;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnExpirationDateUtcChanging(global::System.Nullable<global::System.DateTime> value);
+ partial void OnNameChanging(string value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnExpirationDateUtcChanged();
- }
- /// <summary>
- /// There are no comments for DatabaseModel.Nonce in the schema.
- /// </summary>
- /// <KeyProperties>
- /// NonceId
- /// </KeyProperties>
- [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="Nonce")]
- [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
- [global::System.Serializable()]
- public partial class Nonce : global::System.Data.Objects.DataClasses.EntityObject
- {
+ partial void OnNameChanged();
/// <summary>
- /// Create a new Nonce object.
+ /// There are no comments for ClientAuthorizations in the schema.
/// </summary>
- /// <param name="nonceId">Initial value of NonceId.</param>
- /// <param name="context">Initial value of Context.</param>
- /// <param name="code">Initial value of Code.</param>
- /// <param name="issuedUtc">Initial value of IssuedUtc.</param>
- /// <param name="expiresUtc">Initial value of ExpiresUtc.</param>
+ [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_Consumer", "ClientAuthorization")]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public static Nonce CreateNonce(int nonceId, string context, string code, global::System.DateTime issuedUtc, global::System.DateTime expiresUtc)
- {
- Nonce nonce = new Nonce();
- nonce.NonceId = nonceId;
- nonce.Context = context;
- nonce.Code = code;
- nonce.IssuedUtc = issuedUtc;
- nonce.ExpiresUtc = expiresUtc;
- return nonce;
- }
- /// <summary>
- /// There are no comments for property NonceId in the schema.
- /// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
+ [global::System.Xml.Serialization.XmlIgnoreAttribute()]
+ [global::System.Xml.Serialization.SoapIgnoreAttribute()]
[global::System.Runtime.Serialization.DataMemberAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public int NonceId
+ public global::System.Data.Objects.DataClasses.EntityCollection<ClientAuthorization> ClientAuthorizations
{
get
{
- return this._NonceId;
+ return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<ClientAuthorization>("DatabaseModel.FK_IssuedToken_Consumer", "ClientAuthorization");
}
set
{
- this.OnNonceIdChanging(value);
- this.ReportPropertyChanging("NonceId");
- this._NonceId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("NonceId");
- this.OnNonceIdChanged();
+ if ((value != null))
+ {
+ ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<ClientAuthorization>("DatabaseModel.FK_IssuedToken_Consumer", "ClientAuthorization", value);
+ }
}
}
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private int _NonceId;
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnNonceIdChanging(int value);
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnNonceIdChanged();
+ }
+ /// <summary>
+ /// There are no comments for DatabaseModel.ClientAuthorization in the schema.
+ /// </summary>
+ /// <KeyProperties>
+ /// AuthorizationId
+ /// </KeyProperties>
+ [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="ClientAuthorization")]
+ [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
+ [global::System.Serializable()]
+ public partial class ClientAuthorization : global::System.Data.Objects.DataClasses.EntityObject
+ {
/// <summary>
- /// Gets or sets the Provider Endpoint URL the nonce came from.
+ /// Create a new ClientAuthorization object.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
- [global::System.Runtime.Serialization.DataMemberAttribute()]
+ /// <param name="authorizationId">Initial value of AuthorizationId.</param>
+ /// <param name="createdOnUtc">Initial value of CreatedOnUtc.</param>
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string Context
+ public static ClientAuthorization CreateClientAuthorization(int authorizationId, global::System.DateTime createdOnUtc)
{
- get
- {
- return this._Context;
- }
- set
- {
- this.OnContextChanging(value);
- this.ReportPropertyChanging("Context");
- this._Context = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
- this.ReportPropertyChanged("Context");
- this.OnContextChanged();
- }
+ ClientAuthorization clientAuthorization = new ClientAuthorization();
+ clientAuthorization.AuthorizationId = authorizationId;
+ clientAuthorization.CreatedOnUtc = createdOnUtc;
+ return clientAuthorization;
}
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _Context;
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnContextChanging(string value);
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnContextChanged();
/// <summary>
- /// There are no comments for property Code in the schema.
+ /// There are no comments for property AuthorizationId in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
+ [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string Code
+ public int AuthorizationId
{
get
{
- return this._Code;
+ return this._AuthorizationId;
}
set
{
- this.OnCodeChanging(value);
- this.ReportPropertyChanging("Code");
- this._Code = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
- this.ReportPropertyChanged("Code");
- this.OnCodeChanged();
+ this.OnAuthorizationIdChanging(value);
+ this.ReportPropertyChanging("AuthorizationId");
+ this._AuthorizationId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
+ this.ReportPropertyChanged("AuthorizationId");
+ this.OnAuthorizationIdChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _Code;
+ private int _AuthorizationId;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnCodeChanging(string value);
+ partial void OnAuthorizationIdChanging(int value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnCodeChanged();
+ partial void OnAuthorizationIdChanged();
/// <summary>
- /// There are no comments for property IssuedUtc in the schema.
+ /// There are no comments for property CreatedOnUtc in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public global::System.DateTime IssuedUtc
+ public global::System.DateTime CreatedOnUtc
{
get
{
- return this._IssuedUtc;
+ return this._CreatedOnUtc;
}
set
{
- this.OnIssuedUtcChanging(value);
- this.ReportPropertyChanging("IssuedUtc");
- this._IssuedUtc = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("IssuedUtc");
- this.OnIssuedUtcChanged();
+ this.OnCreatedOnUtcChanging(value);
+ this.ReportPropertyChanging("CreatedOnUtc");
+ this._CreatedOnUtc = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
+ this.ReportPropertyChanged("CreatedOnUtc");
+ this.OnCreatedOnUtcChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private global::System.DateTime _IssuedUtc;
+ private global::System.DateTime _CreatedOnUtc;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnIssuedUtcChanging(global::System.DateTime value);
+ partial void OnCreatedOnUtcChanging(global::System.DateTime value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnIssuedUtcChanged();
+ partial void OnCreatedOnUtcChanged();
/// <summary>
- /// There are no comments for property ExpiresUtc in the schema.
+ /// There are no comments for property ExpirationDate in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
+ [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public global::System.DateTime ExpiresUtc
+ public global::System.Nullable<global::System.DateTime> ExpirationDate
{
get
{
- return this._ExpiresUtc;
+ return this._ExpirationDate;
}
set
{
- this.OnExpiresUtcChanging(value);
- this.ReportPropertyChanging("ExpiresUtc");
- this._ExpiresUtc = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("ExpiresUtc");
- this.OnExpiresUtcChanged();
+ this.OnExpirationDateChanging(value);
+ this.ReportPropertyChanging("ExpirationDate");
+ this._ExpirationDate = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
+ this.ReportPropertyChanged("ExpirationDate");
+ this.OnExpirationDateChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private global::System.DateTime _ExpiresUtc;
+ private global::System.Nullable<global::System.DateTime> _ExpirationDate;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnExpiresUtcChanging(global::System.DateTime value);
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnExpiresUtcChanged();
- }
- /// <summary>
- /// There are no comments for DatabaseModel.OpenIdAssociation in the schema.
- /// </summary>
- /// <KeyProperties>
- /// AssociationId
- /// </KeyProperties>
- [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="OpenIdAssociation")]
- [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
- [global::System.Serializable()]
- public partial class OpenIdAssociation : global::System.Data.Objects.DataClasses.EntityObject
- {
- /// <summary>
- /// Create a new OpenIdAssociation object.
- /// </summary>
- /// <param name="associationId">Initial value of AssociationId.</param>
- /// <param name="distinguishingFactor">Initial value of DistinguishingFactor.</param>
- /// <param name="associationHandle">Initial value of AssociationHandle.</param>
- /// <param name="expirationUtc">Initial value of ExpirationUtc.</param>
- /// <param name="privateData">Initial value of PrivateData.</param>
- /// <param name="privateDataLength">Initial value of PrivateDataLength.</param>
+ partial void OnExpirationDateChanging(global::System.Nullable<global::System.DateTime> value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public static OpenIdAssociation CreateOpenIdAssociation(int associationId, string distinguishingFactor, string associationHandle, global::System.DateTime expirationUtc, byte[] privateData, int privateDataLength)
- {
- OpenIdAssociation openIdAssociation = new OpenIdAssociation();
- openIdAssociation.AssociationId = associationId;
- openIdAssociation.DistinguishingFactor = distinguishingFactor;
- openIdAssociation.AssociationHandle = associationHandle;
- openIdAssociation.ExpirationUtc = expirationUtc;
- openIdAssociation.PrivateData = privateData;
- openIdAssociation.PrivateDataLength = privateDataLength;
- return openIdAssociation;
- }
+ partial void OnExpirationDateChanged();
/// <summary>
- /// There are no comments for property AssociationId in the schema.
+ /// There are no comments for property Scope in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
+ [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
[global::System.Runtime.Serialization.DataMemberAttribute()]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public int AssociationId
+ public string Scope
{
get
{
- return this._AssociationId;
+ return this._Scope;
}
set
{
- this.OnAssociationIdChanging(value);
- this.ReportPropertyChanging("AssociationId");
- this._AssociationId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("AssociationId");
- this.OnAssociationIdChanged();
+ this.OnScopeChanging(value);
+ this.ReportPropertyChanging("Scope");
+ this._Scope = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
+ this.ReportPropertyChanged("Scope");
+ this.OnScopeChanged();
}
}
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private int _AssociationId;
+ private string _Scope;
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnAssociationIdChanging(int value);
+ partial void OnScopeChanging(string value);
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnAssociationIdChanged();
+ partial void OnScopeChanged();
/// <summary>
- /// Gets or sets the Provider Endpoint URL the association is with.
+ /// There are no comments for Client in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
- [global::System.Runtime.Serialization.DataMemberAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string DistinguishingFactor
- {
- get
- {
- return this._DistinguishingFactor;
- }
- set
- {
- this.OnDistinguishingFactorChanging(value);
- this.ReportPropertyChanging("DistinguishingFactor");
- this._DistinguishingFactor = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
- this.ReportPropertyChanged("DistinguishingFactor");
- this.OnDistinguishingFactorChanged();
- }
- }
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _DistinguishingFactor;
+ [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_Consumer", "Client")]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnDistinguishingFactorChanging(string value);
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnDistinguishingFactorChanged();
- /// <summary>
- /// There are no comments for property AssociationHandle in the schema.
- /// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
+ [global::System.Xml.Serialization.XmlIgnoreAttribute()]
+ [global::System.Xml.Serialization.SoapIgnoreAttribute()]
[global::System.Runtime.Serialization.DataMemberAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public string AssociationHandle
+ public Client Client
{
get
{
- return this._AssociationHandle;
+ return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Client>("DatabaseModel.FK_IssuedToken_Consumer", "Client").Value;
}
set
{
- this.OnAssociationHandleChanging(value);
- this.ReportPropertyChanging("AssociationHandle");
- this._AssociationHandle = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
- this.ReportPropertyChanged("AssociationHandle");
- this.OnAssociationHandleChanged();
+ ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Client>("DatabaseModel.FK_IssuedToken_Consumer", "Client").Value = value;
}
}
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private string _AssociationHandle;
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnAssociationHandleChanging(string value);
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnAssociationHandleChanged();
/// <summary>
- /// There are no comments for property ExpirationUtc in the schema.
+ /// There are no comments for Client in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
- [global::System.Runtime.Serialization.DataMemberAttribute()]
+ [global::System.ComponentModel.BrowsableAttribute(false)]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public global::System.DateTime ExpirationUtc
+ [global::System.Runtime.Serialization.DataMemberAttribute()]
+ public global::System.Data.Objects.DataClasses.EntityReference<Client> ClientReference
{
get
{
- return this._ExpirationUtc;
+ return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Client>("DatabaseModel.FK_IssuedToken_Consumer", "Client");
}
set
{
- this.OnExpirationUtcChanging(value);
- this.ReportPropertyChanging("ExpirationUtc");
- this._ExpirationUtc = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("ExpirationUtc");
- this.OnExpirationUtcChanged();
+ if ((value != null))
+ {
+ ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Client>("DatabaseModel.FK_IssuedToken_Consumer", "Client", value);
+ }
}
}
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private global::System.DateTime _ExpirationUtc;
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnExpirationUtcChanging(global::System.DateTime value);
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnExpirationUtcChanged();
/// <summary>
- /// There are no comments for property PrivateData in the schema.
+ /// There are no comments for User in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
- [global::System.Runtime.Serialization.DataMemberAttribute()]
+ [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_User", "User")]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public byte[] PrivateData
+ [global::System.Xml.Serialization.XmlIgnoreAttribute()]
+ [global::System.Xml.Serialization.SoapIgnoreAttribute()]
+ [global::System.Runtime.Serialization.DataMemberAttribute()]
+ public User User
{
get
{
- return global::System.Data.Objects.DataClasses.StructuralObject.GetValidValue(this._PrivateData);
+ return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User").Value;
}
set
{
- this.OnPrivateDataChanging(value);
- this.ReportPropertyChanging("PrivateData");
- this._PrivateData = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
- this.ReportPropertyChanged("PrivateData");
- this.OnPrivateDataChanged();
+ ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User").Value = value;
}
}
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private byte[] _PrivateData;
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnPrivateDataChanging(byte[] value);
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnPrivateDataChanged();
/// <summary>
- /// There are no comments for property PrivateDataLength in the schema.
+ /// There are no comments for User in the schema.
/// </summary>
- [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
- [global::System.Runtime.Serialization.DataMemberAttribute()]
+ [global::System.ComponentModel.BrowsableAttribute(false)]
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- public int PrivateDataLength
+ [global::System.Runtime.Serialization.DataMemberAttribute()]
+ public global::System.Data.Objects.DataClasses.EntityReference<User> UserReference
{
get
{
- return this._PrivateDataLength;
+ return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User");
}
set
{
- this.OnPrivateDataLengthChanging(value);
- this.ReportPropertyChanging("PrivateDataLength");
- this._PrivateDataLength = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
- this.ReportPropertyChanged("PrivateDataLength");
- this.OnPrivateDataLengthChanged();
+ if ((value != null))
+ {
+ ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User", value);
+ }
}
}
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- private int _PrivateDataLength;
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnPrivateDataLengthChanging(int value);
- [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
- partial void OnPrivateDataLengthChanged();
}
}
diff --git a/projecttemplates/RelyingPartyLogic/Model.IssuedAccessToken.cs b/projecttemplates/RelyingPartyLogic/Model.IssuedAccessToken.cs
deleted file mode 100644
index 25d983b..0000000
--- a/projecttemplates/RelyingPartyLogic/Model.IssuedAccessToken.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="Model.IssuedAccessToken.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace RelyingPartyLogic {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using DotNetOpenAuth.OAuth.ChannelElements;
-
- public partial class IssuedAccessToken : IServiceProviderAccessToken {
- /// <summary>
- /// Gets the roles that the OAuth principal should belong to.
- /// </summary>
- /// <value>
- /// The roles that the user belongs to, or a subset of these according to the rights
- /// granted when the user authorized the request token.
- /// </value>
- string[] IServiceProviderAccessToken.Roles {
- get {
- List<string> roles = new List<string>();
-
- // Include the roles the user who authorized this OAuth token has.
- roles.AddRange(this.User.Roles.Select(r => r.Name));
-
- // Always add an extra role to indicate this is an OAuth-authorized request.
- // This allows us to deny access to account management pages to OAuth requests.
- roles.Add("delegated");
-
- return roles.ToArray();
- }
- }
-
- /// <summary>
- /// Gets the username of the principal that will be impersonated by this access token.
- /// </summary>
- /// <value>
- /// The name of the user who authorized the OAuth request token originally.
- /// </value>
- string IServiceProviderAccessToken.Username {
- get {
- // We don't really have the concept of a single username, but we
- // can use any of the authentication tokens instead since that
- // is what the rest of the web site expects.
- if (!this.UserReference.IsLoaded) {
- this.UserReference.Load();
- }
- if (!this.User.AuthenticationTokens.IsLoaded) {
- this.User.AuthenticationTokens.Load();
- }
- return this.User.AuthenticationTokens.First().ClaimedIdentifier;
- }
- }
-
- /// <summary>
- /// Gets the expiration date (local time) for the access token.
- /// </summary>
- /// <value>
- /// The expiration date, or <c>null</c> if there is no expiration date.
- /// </value>
- DateTime? IServiceProviderAccessToken.ExpirationDate {
- get { return this.ExpirationDateUtc.HasValue ? (DateTime?)this.ExpirationDateUtc.Value.ToLocalTime() : null; }
- }
-
- partial void OnExpirationDateUtcChanging(DateTime? value) {
- if (value.HasValue) {
- Utilities.VerifyThrowNotLocalTime(value.Value);
- }
- }
- }
-}
diff --git a/projecttemplates/RelyingPartyLogic/Model.IssuedRequestToken.cs b/projecttemplates/RelyingPartyLogic/Model.IssuedRequestToken.cs
deleted file mode 100644
index 1e96eb7..0000000
--- a/projecttemplates/RelyingPartyLogic/Model.IssuedRequestToken.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="Model.IssuedRequestToken.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace RelyingPartyLogic {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using DotNetOpenAuth.OAuth.ChannelElements;
-
- public partial class IssuedRequestToken : IServiceProviderRequestToken {
- /// <summary>
- /// Gets or sets the callback associated specifically with this token, if any.
- /// </summary>
- /// <value>
- /// The callback URI; or <c>null</c> if no callback was specifically assigned to this token.
- /// </value>
- public Uri Callback {
- get { return this.CallbackAsString != null ? new Uri(this.CallbackAsString) : null; }
- set { this.CallbackAsString = value != null ? value.AbsoluteUri : null; }
- }
-
- /// <summary>
- /// Gets or sets the version of the Consumer that requested this token.
- /// </summary>
- /// <remarks>
- /// This property is used to determine whether a <see cref="VerificationCode"/> must be
- /// generated when the user authorizes the Consumer or not.
- /// </remarks>
- Version IServiceProviderRequestToken.ConsumerVersion {
- get { return this.ConsumerVersionAsString != null ? new Version(this.ConsumerVersionAsString) : null; }
- set { this.ConsumerVersionAsString = value != null ? value.ToString() : null; }
- }
-
- /// <summary>
- /// Gets the consumer key that requested this token.
- /// </summary>
- string IServiceProviderRequestToken.ConsumerKey {
- get { return this.Consumer.ConsumerKey; }
- }
-
- /// <summary>
- /// Gets the (local) date that this request token was first created on.
- /// </summary>
- DateTime IServiceProviderRequestToken.CreatedOn {
- get { return this.CreatedOnUtc.ToLocalTime(); }
- }
-
- /// <summary>
- /// Authorizes this request token to allow exchange for an access token.
- /// </summary>
- /// <remarks>
- /// Call this method when the user has completed web-based authorization.
- /// </remarks>
- public void Authorize() {
- this.User = Database.LoggedInUser;
- Database.DataContext.SaveChanges();
- }
- }
-}
diff --git a/projecttemplates/RelyingPartyLogic/Model.edmx b/projecttemplates/RelyingPartyLogic/Model.edmx
index 9d7ec7b..a003493 100644
--- a/projecttemplates/RelyingPartyLogic/Model.edmx
+++ b/projecttemplates/RelyingPartyLogic/Model.edmx
@@ -4,27 +4,27 @@
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
- <Schema Namespace="DatabaseModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
+ <Schema Namespace="DatabaseModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
<EntityContainer Name="DatabaseModelStoreContainer">
- <EntitySet Name="AuthenticationToken" EntityType="DatabaseModel.Store.AuthenticationToken" store:Type="Tables" Schema="dbo" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
- <EntitySet Name="Consumer" EntityType="DatabaseModel.Store.Consumer" store:Type="Tables" Schema="dbo" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
- <EntitySet Name="IssuedToken" EntityType="DatabaseModel.Store.IssuedToken" store:Type="Tables" Schema="dbo" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
- <EntitySet Name="Nonce" EntityType="DatabaseModel.Store.Nonce" store:Type="Tables" Schema="dbo" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
- <EntitySet Name="OpenIDAssociation" EntityType="DatabaseModel.Store.OpenIDAssociation" store:Type="Tables" Schema="dbo" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
- <EntitySet Name="Role" EntityType="DatabaseModel.Store.Role" store:Type="Tables" Schema="dbo" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
- <EntitySet Name="User" EntityType="DatabaseModel.Store.User" store:Type="Tables" Schema="dbo" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
- <EntitySet Name="UserRole" EntityType="DatabaseModel.Store.UserRole" store:Type="Tables" Schema="dbo" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
+ <EntitySet Name="AuthenticationToken" EntityType="DatabaseModel.Store.AuthenticationToken" store:Type="Tables" Schema="dbo" />
+ <EntitySet Name="Client" EntityType="DatabaseModel.Store.Client" store:Type="Tables" Schema="dbo" />
+ <EntitySet Name="ClientAuthorization" EntityType="DatabaseModel.Store.ClientAuthorization" store:Type="Tables" Schema="dbo" />
+ <EntitySet Name="Nonce" EntityType="DatabaseModel.Store.Nonce" store:Type="Tables" Schema="dbo" />
+ <EntitySet Name="OpenIDAssociation" EntityType="DatabaseModel.Store.OpenIDAssociation" store:Type="Tables" Schema="dbo" />
+ <EntitySet Name="Role" EntityType="DatabaseModel.Store.Role" store:Type="Tables" Schema="dbo" />
+ <EntitySet Name="User" EntityType="DatabaseModel.Store.User" store:Type="Tables" Schema="dbo" />
+ <EntitySet Name="UserRole" EntityType="DatabaseModel.Store.UserRole" store:Type="Tables" Schema="dbo" />
<AssociationSet Name="FK_AuthenticationToken_User" Association="DatabaseModel.Store.FK_AuthenticationToken_User">
<End Role="User" EntitySet="User" />
<End Role="AuthenticationToken" EntitySet="AuthenticationToken" />
</AssociationSet>
<AssociationSet Name="FK_IssuedToken_Consumer" Association="DatabaseModel.Store.FK_IssuedToken_Consumer">
- <End Role="Consumer" EntitySet="Consumer" />
- <End Role="IssuedToken" EntitySet="IssuedToken" />
+ <End Role="Client" EntitySet="Client" />
+ <End Role="ClientAuthorization" EntitySet="ClientAuthorization" />
</AssociationSet>
<AssociationSet Name="FK_IssuedToken_User" Association="DatabaseModel.Store.FK_IssuedToken_User">
<End Role="User" EntitySet="User" />
- <End Role="IssuedToken" EntitySet="IssuedToken" />
+ <End Role="ClientAuthorization" EntitySet="ClientAuthorization" />
</AssociationSet>
<AssociationSet Name="FK_UserRole_Role" Association="DatabaseModel.Store.FK_UserRole_Role">
<End Role="Role" EntitySet="Role" />
@@ -47,35 +47,26 @@
<Property Name="LastUsed" Type="datetime" Nullable="false" />
<Property Name="UsageCount" Type="int" Nullable="false" />
</EntityType>
- <EntityType Name="Consumer">
+ <EntityType Name="Client">
<Key>
- <PropertyRef Name="ConsumerId" />
+ <PropertyRef Name="ClientId" />
</Key>
- <Property Name="ConsumerId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
- <Property Name="ConsumerKey" Type="nvarchar" Nullable="false" MaxLength="255" />
- <Property Name="ConsumerSecret" Type="nvarchar" MaxLength="255" />
- <Property Name="X509Certificate" Type="image" />
- <Property Name="Callback" Type="nvarchar" MaxLength="2048" />
- <Property Name="VerificationCodeFormat" Type="int" Nullable="false" />
- <Property Name="VerificationCodeLength" Type="int" Nullable="false" />
- <Property Name="Name" Type="nvarchar" MaxLength="50" />
+ <Property Name="ClientId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
+ <Property Name="ClientIdentifier" Type="varchar" Nullable="false" MaxLength="255" />
+ <Property Name="ClientSecret" Type="varchar" MaxLength="255" />
+ <Property Name="Callback" Type="varchar" MaxLength="2048" />
+ <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" />
</EntityType>
- <EntityType Name="IssuedToken">
+ <EntityType Name="ClientAuthorization">
<Key>
- <PropertyRef Name="IssuedTokenId" />
+ <PropertyRef Name="AuthorizationId" />
</Key>
- <Property Name="IssuedTokenId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
- <Property Name="ConsumerId" Type="int" Nullable="false" />
- <Property Name="UserId" Type="int" />
- <Property Name="Token" Type="nvarchar" Nullable="false" MaxLength="255" />
- <Property Name="TokenSecret" Type="nvarchar" Nullable="false" MaxLength="255" />
+ <Property Name="AuthorizationId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
+ <Property Name="ClientId" Type="int" Nullable="false" />
+ <Property Name="UserId" Type="int" Nullable="false" />
<Property Name="CreatedOn" Type="datetime" Nullable="false" />
- <Property Name="Callback" Type="nvarchar" MaxLength="2048" />
- <Property Name="VerificationCode" Type="nvarchar" MaxLength="255" />
- <Property Name="ConsumerVersion" Type="varchar" MaxLength="10" />
<Property Name="ExpirationDate" Type="datetime" />
- <Property Name="IsAccessToken" Type="bit" Nullable="false" />
- <Property Name="Scope" Type="nvarchar" MaxLength="255" />
+ <Property Name="Scope" Type="varchar" MaxLength="2048" />
</EntityType>
<EntityType Name="Nonce">
<Key>
@@ -95,7 +86,7 @@
<Property Name="DistinguishingFactor" Type="varchar" Nullable="false" MaxLength="255" />
<Property Name="AssociationHandle" Type="varchar" Nullable="false" MaxLength="255" />
<Property Name="Expiration" Type="datetime" Nullable="false" />
- <Property Name="PrivateData" Type="binary" Nullable="false" MaxLength="32" />
+ <Property Name="PrivateData" Type="binary" Nullable="false" MaxLength="64" />
<Property Name="PrivateDataLength" Type="int" Nullable="false" />
</EntityType>
<EntityType Name="Role">
@@ -139,29 +130,29 @@
</ReferentialConstraint>
</Association>
<Association Name="FK_IssuedToken_Consumer">
- <End Role="Consumer" Type="DatabaseModel.Store.Consumer" Multiplicity="1">
+ <End Role="Client" Type="DatabaseModel.Store.Client" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
- <End Role="IssuedToken" Type="DatabaseModel.Store.IssuedToken" Multiplicity="*" />
+ <End Role="ClientAuthorization" Type="DatabaseModel.Store.ClientAuthorization" Multiplicity="*" />
<ReferentialConstraint>
- <Principal Role="Consumer">
- <PropertyRef Name="ConsumerId" />
+ <Principal Role="Client">
+ <PropertyRef Name="ClientId" />
</Principal>
- <Dependent Role="IssuedToken">
- <PropertyRef Name="ConsumerId" />
+ <Dependent Role="ClientAuthorization">
+ <PropertyRef Name="ClientId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_IssuedToken_User">
- <End Role="User" Type="DatabaseModel.Store.User" Multiplicity="0..1">
+ <End Role="User" Type="DatabaseModel.Store.User" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
- <End Role="IssuedToken" Type="DatabaseModel.Store.IssuedToken" Multiplicity="*" />
+ <End Role="ClientAuthorization" Type="DatabaseModel.Store.ClientAuthorization" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="User">
<PropertyRef Name="UserId" />
</Principal>
- <Dependent Role="IssuedToken">
+ <Dependent Role="ClientAuthorization">
<PropertyRef Name="UserId" />
</Dependent>
</ReferentialConstraint>
@@ -208,20 +199,23 @@
<End Role="User" EntitySet="Users" />
</AssociationSet>
<EntitySet Name="AuthenticationTokens" EntityType="DatabaseModel.AuthenticationToken" />
- <EntitySet Name="Consumers" EntityType="DatabaseModel.Consumer" />
- <EntitySet Name="IssuedTokens" EntityType="DatabaseModel.IssuedToken" />
<AssociationSet Name="FK_AuthenticationToken_User" Association="DatabaseModel.FK_AuthenticationToken_User">
<End Role="User" EntitySet="Users" />
<End Role="AuthenticationToken" EntitySet="AuthenticationTokens" /></AssociationSet>
- <AssociationSet Name="FK_IssuedToken_Consumer1" Association="DatabaseModel.FK_IssuedToken_Consumer1">
- <End Role="Consumer" EntitySet="Consumers" />
- <End Role="IssuedToken" EntitySet="IssuedTokens" /></AssociationSet>
- <AssociationSet Name="FK_IssuedToken_User1" Association="DatabaseModel.FK_IssuedToken_User1">
- <End Role="User" EntitySet="Users" />
- <End Role="IssuedToken" EntitySet="IssuedTokens" /></AssociationSet>
<EntitySet Name="Nonces" EntityType="DatabaseModel.Nonce" />
<EntitySet Name="OpenIdAssociations" EntityType="DatabaseModel.OpenIdAssociation" />
- <FunctionImport Name="ClearExpiredNonces" /></EntityContainer>
+ <FunctionImport Name="ClearExpiredNonces" />
+ <EntitySet Name="Clients" EntityType="DatabaseModel.Client" />
+ <EntitySet Name="ClientAuthorizations" EntityType="DatabaseModel.ClientAuthorization" />
+ <AssociationSet Name="FK_IssuedToken_Consumer" Association="DatabaseModel.FK_IssuedToken_Consumer">
+ <End Role="Client" EntitySet="Clients" />
+ <End Role="ClientAuthorization" EntitySet="ClientAuthorizations" />
+ </AssociationSet>
+ <AssociationSet Name="FK_IssuedToken_User" Association="DatabaseModel.FK_IssuedToken_User">
+ <End Role="User" EntitySet="Users" />
+ <End Role="ClientAuthorization" EntitySet="ClientAuthorizations" />
+ </AssociationSet>
+ </EntityContainer>
<EntityType Name="AuthenticationToken" Abstract="false">
<Key>
<PropertyRef Name="AuthenticationTokenId" /></Key>
@@ -253,48 +247,14 @@
<Property Name="CreatedOnUtc" Type="DateTime" Nullable="false" a:SetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
<Property Name="UserId" Type="Int32" Nullable="false" a:SetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
<NavigationProperty Name="AuthenticationTokens" Relationship="DatabaseModel.FK_AuthenticationToken_User" FromRole="User" ToRole="AuthenticationToken" />
- <NavigationProperty Name="IssuedTokens" Relationship="DatabaseModel.FK_IssuedToken_User1" FromRole="User" ToRole="IssuedToken" /></EntityType>
+ <NavigationProperty Name="ClientAuthorizations" Relationship="DatabaseModel.FK_IssuedToken_User" FromRole="User" ToRole="ClientAuthorization" /></EntityType>
<Association Name="UserRole">
<End Role="Role" Type="DatabaseModel.Role" Multiplicity="*" />
<End Role="User" Type="DatabaseModel.User" Multiplicity="*" />
</Association>
- <EntityType Name="Consumer">
- <Key>
- <PropertyRef Name="ConsumerId" /></Key>
- <Property Name="ConsumerKey" Type="String" Nullable="false" />
- <Property Name="ConsumerSecret" Type="String" Nullable="true" />
- <Property Name="X509CertificateAsBinary" Type="Binary" Nullable="true" a:SetterAccess="Private" a:GetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
- <Property Name="CallbackAsString" Type="String" Nullable="true" />
- <Property Name="VerificationCodeFormatAsInt" Type="Int32" Nullable="false" a:GetterAccess="Private" a:SetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
- <Property Name="VerificationCodeLength" Type="Int32" Nullable="false" />
- <Property Name="ConsumerId" Type="Int32" Nullable="false" a:SetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
- <Property Name="Name" Type="String" Nullable="true" />
- <NavigationProperty Name="IssuedTokens" Relationship="DatabaseModel.FK_IssuedToken_Consumer1" FromRole="Consumer" ToRole="IssuedToken" /></EntityType>
- <EntityType Name="IssuedToken" Abstract="true">
- <Key>
- <PropertyRef Name="IssuedTokenId" /></Key>
- <Property Name="Token" Type="String" Nullable="false" />
- <Property Name="TokenSecret" Type="String" Nullable="false" />
- <Property Name="CreatedOnUtc" Type="DateTime" Nullable="false" a:SetterAccess="Internal" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
- <Property Name="Scope" Type="String" Nullable="true" />
- <Property Name="IssuedTokenId" Type="Int32" Nullable="false" a:SetterAccess="Internal" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
- <NavigationProperty Name="Consumer" Relationship="DatabaseModel.FK_IssuedToken_Consumer1" FromRole="IssuedToken" ToRole="Consumer" />
- <NavigationProperty Name="User" Relationship="DatabaseModel.FK_IssuedToken_User1" FromRole="IssuedToken" ToRole="User" /></EntityType>
- <EntityType Name="IssuedRequestToken" BaseType="DatabaseModel.IssuedToken">
- <Property Name="ConsumerVersionAsString" Type="String" Nullable="false" a:GetterAccess="Private" a:SetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
- <Property Name="VerificationCode" Type="String" Nullable="true" />
- <Property Name="CallbackAsString" Type="String" Nullable="true" a:GetterAccess="Private" a:SetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" /></EntityType>
- <EntityType Name="IssuedAccessToken" BaseType="DatabaseModel.IssuedToken">
- <Property Name="ExpirationDateUtc" Type="DateTime" Nullable="true" /></EntityType>
<Association Name="FK_AuthenticationToken_User">
<End Type="DatabaseModel.User" Role="User" Multiplicity="1" />
<End Type="DatabaseModel.AuthenticationToken" Role="AuthenticationToken" Multiplicity="*" /></Association>
- <Association Name="FK_IssuedToken_Consumer1">
- <End Type="DatabaseModel.Consumer" Role="Consumer" Multiplicity="1" />
- <End Type="DatabaseModel.IssuedToken" Role="IssuedToken" Multiplicity="*" /></Association>
- <Association Name="FK_IssuedToken_User1">
- <End Type="DatabaseModel.User" Role="User" Multiplicity="0..1" />
- <End Type="DatabaseModel.IssuedToken" Role="IssuedToken" Multiplicity="*" /></Association>
<EntityType Name="Nonce" a:TypeAccess="Public" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration">
<Key>
<PropertyRef Name="NonceId" /></Key>
@@ -315,7 +275,37 @@
<Property Name="AssociationHandle" Type="String" Nullable="false" />
<Property Name="ExpirationUtc" Type="DateTime" Nullable="false" />
<Property Name="PrivateData" Type="Binary" Nullable="false" />
- <Property Name="PrivateDataLength" Type="Int32" Nullable="false" /></EntityType></Schema>
+ <Property Name="PrivateDataLength" Type="Int32" Nullable="false" /></EntityType>
+ <EntityType Name="Client">
+ <Key>
+ <PropertyRef Name="ClientId" />
+ </Key>
+ <Property Type="Int32" Name="ClientId" Nullable="false" a:StoreGeneratedPattern="Identity" xmlns:a="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
+ <Property Type="String" Name="ClientIdentifier" Nullable="false" MaxLength="255" FixedLength="false" Unicode="true" />
+ <Property Type="String" Name="ClientSecret" MaxLength="255" FixedLength="false" Unicode="true" />
+ <Property Type="String" Name="CallbackAsString" MaxLength="2048" FixedLength="false" Unicode="true" />
+ <Property Type="String" Name="Name" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
+ <NavigationProperty Name="ClientAuthorizations" Relationship="DatabaseModel.FK_IssuedToken_Consumer" FromRole="Client" ToRole="ClientAuthorization" />
+ </EntityType>
+ <EntityType Name="ClientAuthorization">
+ <Key>
+ <PropertyRef Name="AuthorizationId" />
+ </Key>
+ <Property Type="Int32" Name="AuthorizationId" Nullable="false" a:StoreGeneratedPattern="Identity" xmlns:a="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
+ <Property Type="DateTime" Name="CreatedOnUtc" Nullable="false" />
+ <Property Type="DateTime" Name="ExpirationDate" />
+ <Property Type="String" Name="Scope" MaxLength="2048" FixedLength="false" Unicode="false" />
+ <NavigationProperty Name="Client" Relationship="DatabaseModel.FK_IssuedToken_Consumer" FromRole="ClientAuthorization" ToRole="Client" />
+ <NavigationProperty Name="User" Relationship="DatabaseModel.FK_IssuedToken_User" FromRole="ClientAuthorization" ToRole="User" />
+ </EntityType>
+ <Association Name="FK_IssuedToken_Consumer">
+ <End Type="DatabaseModel.Client" Role="Client" Multiplicity="1" />
+ <End Type="DatabaseModel.ClientAuthorization" Role="ClientAuthorization" Multiplicity="*" />
+ </Association>
+ <Association Name="FK_IssuedToken_User">
+ <End Type="DatabaseModel.User" Role="User" Multiplicity="1" />
+ <End Type="DatabaseModel.ClientAuthorization" Role="ClientAuthorization" Multiplicity="*" />
+ </Association></Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
@@ -358,54 +348,11 @@
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
- <EntitySetMapping Name="Consumers">
- <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.Consumer)">
- <MappingFragment StoreEntitySet="Consumer">
- <ScalarProperty Name="Name" ColumnName="Name" />
- <ScalarProperty Name="ConsumerId" ColumnName="ConsumerId" />
- <ScalarProperty Name="VerificationCodeLength" ColumnName="VerificationCodeLength" />
- <ScalarProperty Name="VerificationCodeFormatAsInt" ColumnName="VerificationCodeFormat" />
- <ScalarProperty Name="CallbackAsString" ColumnName="Callback" />
- <ScalarProperty Name="X509CertificateAsBinary" ColumnName="X509Certificate" />
- <ScalarProperty Name="ConsumerSecret" ColumnName="ConsumerSecret" />
- <ScalarProperty Name="ConsumerKey" ColumnName="ConsumerKey" /></MappingFragment></EntityTypeMapping></EntitySetMapping>
- <EntitySetMapping Name="IssuedTokens">
- <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.IssuedToken)">
- <MappingFragment StoreEntitySet="IssuedToken">
- <ScalarProperty Name="IssuedTokenId" ColumnName="IssuedTokenId" />
- <ScalarProperty Name="Scope" ColumnName="Scope" />
- <ScalarProperty Name="CreatedOnUtc" ColumnName="CreatedOn" />
- <ScalarProperty Name="TokenSecret" ColumnName="TokenSecret" />
- <ScalarProperty Name="Token" ColumnName="Token" />
- </MappingFragment></EntityTypeMapping>
- <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.IssuedRequestToken)">
- <MappingFragment StoreEntitySet="IssuedToken">
- <ScalarProperty Name="IssuedTokenId" ColumnName="IssuedTokenId" />
- <ScalarProperty Name="CallbackAsString" ColumnName="Callback" />
- <ScalarProperty Name="ConsumerVersionAsString" ColumnName="ConsumerVersion" />
- <ScalarProperty Name="VerificationCode" ColumnName="VerificationCode" />
- <Condition ColumnName="IsAccessToken" Value="0" /></MappingFragment></EntityTypeMapping>
- <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.IssuedAccessToken)">
- <MappingFragment StoreEntitySet="IssuedToken">
- <ScalarProperty Name="IssuedTokenId" ColumnName="IssuedTokenId" />
- <ScalarProperty Name="ExpirationDateUtc" ColumnName="ExpirationDate" />
- <Condition ColumnName="IsAccessToken" Value="1" /></MappingFragment></EntityTypeMapping></EntitySetMapping>
<AssociationSetMapping Name="FK_AuthenticationToken_User" TypeName="DatabaseModel.FK_AuthenticationToken_User" StoreEntitySet="AuthenticationToken">
<EndProperty Name="AuthenticationToken">
<ScalarProperty Name="AuthenticationTokenId" ColumnName="AuthenticationTokenId" /></EndProperty>
<EndProperty Name="User">
<ScalarProperty Name="UserId" ColumnName="UserId" /></EndProperty></AssociationSetMapping>
- <AssociationSetMapping Name="FK_IssuedToken_Consumer1" TypeName="DatabaseModel.FK_IssuedToken_Consumer1" StoreEntitySet="IssuedToken">
- <EndProperty Name="IssuedToken">
- <ScalarProperty Name="IssuedTokenId" ColumnName="IssuedTokenId" /></EndProperty>
- <EndProperty Name="Consumer">
- <ScalarProperty Name="ConsumerId" ColumnName="ConsumerId" /></EndProperty></AssociationSetMapping>
- <AssociationSetMapping Name="FK_IssuedToken_User1" TypeName="DatabaseModel.FK_IssuedToken_User1" StoreEntitySet="IssuedToken">
- <EndProperty Name="IssuedToken">
- <ScalarProperty Name="IssuedTokenId" ColumnName="IssuedTokenId" /></EndProperty>
- <EndProperty Name="User">
- <ScalarProperty Name="UserId" ColumnName="UserId" /></EndProperty>
- <Condition ColumnName="UserId" IsNull="false" /></AssociationSetMapping>
<EntitySetMapping Name="Nonces">
<EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.Nonce)">
<MappingFragment StoreEntitySet="Nonce">
@@ -423,7 +370,44 @@
<ScalarProperty Name="AssociationHandle" ColumnName="AssociationHandle" />
<ScalarProperty Name="DistinguishingFactor" ColumnName="DistinguishingFactor" />
<ScalarProperty Name="AssociationId" ColumnName="AssociationId" /></MappingFragment></EntityTypeMapping></EntitySetMapping>
- <FunctionImportMapping FunctionImportName="ClearExpiredNonces" FunctionName="DatabaseModel.Store.ClearExpiredNonces" /></EntityContainerMapping>
+ <FunctionImportMapping FunctionImportName="ClearExpiredNonces" FunctionName="DatabaseModel.Store.ClearExpiredNonces" />
+ <EntitySetMapping Name="Clients">
+ <EntityTypeMapping TypeName="DatabaseModel.Client">
+ <MappingFragment StoreEntitySet="Client">
+ <ScalarProperty Name="Name" ColumnName="Name" />
+ <ScalarProperty Name="CallbackAsString" ColumnName="Callback" />
+ <ScalarProperty Name="ClientSecret" ColumnName="ClientSecret" />
+ <ScalarProperty Name="ClientIdentifier" ColumnName="ClientIdentifier" />
+ <ScalarProperty Name="ClientId" ColumnName="ClientId" />
+ </MappingFragment>
+ </EntityTypeMapping>
+ </EntitySetMapping>
+ <EntitySetMapping Name="ClientAuthorizations">
+ <EntityTypeMapping TypeName="DatabaseModel.ClientAuthorization">
+ <MappingFragment StoreEntitySet="ClientAuthorization">
+ <ScalarProperty Name="Scope" ColumnName="Scope" />
+ <ScalarProperty Name="ExpirationDate" ColumnName="ExpirationDate" />
+ <ScalarProperty Name="CreatedOnUtc" ColumnName="CreatedOn" />
+ <ScalarProperty Name="AuthorizationId" ColumnName="AuthorizationId" />
+ </MappingFragment>
+ </EntityTypeMapping>
+ </EntitySetMapping>
+ <AssociationSetMapping Name="FK_IssuedToken_Consumer" TypeName="DatabaseModel.FK_IssuedToken_Consumer" StoreEntitySet="ClientAuthorization">
+ <EndProperty Name="ClientAuthorization">
+ <ScalarProperty Name="AuthorizationId" ColumnName="AuthorizationId" />
+ </EndProperty>
+ <EndProperty Name="Client">
+ <ScalarProperty Name="ClientId" ColumnName="ClientId" />
+ </EndProperty>
+ </AssociationSetMapping>
+ <AssociationSetMapping Name="FK_IssuedToken_User" TypeName="DatabaseModel.FK_IssuedToken_User" StoreEntitySet="ClientAuthorization">
+ <EndProperty Name="ClientAuthorization">
+ <ScalarProperty Name="AuthorizationId" ColumnName="AuthorizationId" />
+ </EndProperty>
+ <EndProperty Name="User">
+ <ScalarProperty Name="UserId" ColumnName="UserId" />
+ </EndProperty>
+ </AssociationSetMapping></EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
@@ -437,11 +421,13 @@
<edmx:Options>
<DesignerInfoPropertySet xmlns="http://schemas.microsoft.com/ado/2007/06/edmx">
<DesignerProperty Name="ValidateOnBuild" Value="true" />
+ <DesignerProperty Name="EnablePluralization" Value="True" />
+ <DesignerProperty Name="IncludeForeignKeysInModel" Value="False" />
</DesignerInfoPropertySet>
</edmx:Options>
<!-- Diagram content (shape and connector positions) -->
<edmx:Diagrams>
- <Diagram Name="Model" ZoomLevel="56" xmlns="http://schemas.microsoft.com/ado/2007/06/edmx">
+ <Diagram Name="Model" ZoomLevel="101" xmlns="http://schemas.microsoft.com/ado/2007/06/edmx">
<EntityTypeShape EntityType="DatabaseModel.AuthenticationToken" Width="1.875" PointX="5.25" PointY="0.75" Height="2.5571907552083339" IsExpanded="true" />
<EntityTypeShape EntityType="DatabaseModel.Role" Width="1.5" PointX="0.75" PointY="1.25" Height="1.59568359375" IsExpanded="true" />
<EntityTypeShape EntityType="DatabaseModel.User" Width="1.75" PointX="2.875" PointY="0.5" Height="3.1340950520833339" IsExpanded="true" />
@@ -451,30 +437,20 @@
<InheritanceConnector EntityType="DatabaseModel.AuthenticationToken">
<ConnectorPoint PointX="6.5625" PointY="3.375" />
<ConnectorPoint PointX="6.5625" PointY="2.9129850260416665" /></InheritanceConnector>
- <EntityTypeShape EntityType="DatabaseModel.Consumer" Width="2.125" PointX="0.5" PointY="3.625" Height="2.1725878906249996" />
- <EntityTypeShape EntityType="DatabaseModel.IssuedToken" Width="2" PointX="5.25" PointY="3.875" Height="2.7494921874999996" />
- <EntityTypeShape EntityType="DatabaseModel.IssuedRequestToken" Width="2" PointX="4.25" PointY="7" Height="1.5956835937499996" />
- <EntityTypeShape EntityType="DatabaseModel.IssuedAccessToken" Width="1.625" PointX="6.5" PointY="7" Height="1.2110807291666657" />
- <InheritanceConnector EntityType="DatabaseModel.IssuedRequestToken" ManuallyRouted="false">
- <ConnectorPoint PointX="5.75" PointY="6.6244921875" />
- <ConnectorPoint PointX="5.75" PointY="7" />
- </InheritanceConnector>
- <InheritanceConnector EntityType="DatabaseModel.IssuedAccessToken" ManuallyRouted="false">
- <ConnectorPoint PointX="6.875" PointY="6.6244921875" />
- <ConnectorPoint PointX="6.875" PointY="7" />
- </InheritanceConnector>
<AssociationConnector Association="DatabaseModel.FK_AuthenticationToken_User">
- <ConnectorPoint PointX="4.625" PointY="1.4776205358072916" />
- <ConnectorPoint PointX="5.25" PointY="1.4776205358072916" /></AssociationConnector>
- <AssociationConnector Association="DatabaseModel.FK_IssuedToken_Consumer1">
- <ConnectorPoint PointX="2.625" PointY="4.8322661624685885" />
- <ConnectorPoint PointX="5.25" PointY="4.8322661624685885" />
- </AssociationConnector>
- <AssociationConnector Association="DatabaseModel.FK_IssuedToken_User1">
- <ConnectorPoint PointX="3.75" PointY="3.6340950520833339" />
- <ConnectorPoint PointX="3.75" PointY="4.0627779870647478" />
- <ConnectorPoint PointX="5.25" PointY="4.0627779870647478" /></AssociationConnector>
- <EntityTypeShape EntityType="DatabaseModel.Nonce" Width="1.5" PointX="0.5" PointY="7.75" Height="1.9802864583333326" />
- <EntityTypeShape EntityType="DatabaseModel.OpenIdAssociation" Width="1.75" PointX="2.25" PointY="7.75" Height="1.9802864583333333" /></Diagram></edmx:Diagrams>
+ <ConnectorPoint PointX="4.625" PointY="1.9324446614583337" />
+ <ConnectorPoint PointX="5.25" PointY="1.9324446614583337" /></AssociationConnector>
+ <EntityTypeShape EntityType="DatabaseModel.Nonce" Width="1.5" PointX="9.375" PointY="0.75" Height="1.9802864583333326" />
+ <EntityTypeShape EntityType="DatabaseModel.OpenIdAssociation" Width="1.75" PointX="7.375" PointY="0.75" Height="2.1725878906249996" />
+ <EntityTypeShape EntityType="DatabaseModel.Client" Width="1.625" PointX="5.25" PointY="3.75" Height="2.1725878906249996" />
+ <EntityTypeShape EntityType="DatabaseModel.ClientAuthorization" Width="1.75" PointX="2.875" PointY="3.75" Height="2.1725878906250031" />
+ <AssociationConnector Association="DatabaseModel.FK_IssuedToken_Consumer" >
+ <ConnectorPoint PointX="5.25" PointY="4.8362939453125" />
+ <ConnectorPoint PointX="4.625" PointY="4.8362939453125" />
+ </AssociationConnector>
+ <AssociationConnector Association="DatabaseModel.FK_IssuedToken_User" >
+ <ConnectorPoint PointX="3.75" PointY="3.2494921875" />
+ <ConnectorPoint PointX="3.75" PointY="3.75" />
+ </AssociationConnector></Diagram></edmx:Diagrams>
</edmx:Designer>
</edmx:Edmx> \ No newline at end of file
diff --git a/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs b/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs
index e47e4ee..c0685bc 100644
--- a/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs
+++ b/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs
@@ -12,9 +12,7 @@ namespace RelyingPartyLogic {
using System.Web;
using System.Web.Security;
using DotNetOpenAuth.Messaging;
- using DotNetOpenAuth.OAuth;
- using DotNetOpenAuth.OAuth.ChannelElements;
- using DotNetOpenAuth.OAuth.Messages;
+ using DotNetOpenAuth.OAuth2;
public class OAuthAuthenticationModule : IHttpModule {
private HttpApplication application;
@@ -51,10 +49,13 @@ namespace RelyingPartyLogic {
return;
}
- IDirectedProtocolMessage incomingMessage = OAuthServiceProvider.ServiceProvider.ReadRequest(new HttpRequestInfo(this.application.Context.Request));
- var authorization = incomingMessage as AccessProtectedResourceRequest;
- if (authorization != null) {
- this.application.Context.User = OAuthServiceProvider.ServiceProvider.CreatePrincipal(authorization);
+ var tokenAnalyzer = new SpecialAccessTokenAnalyzer(OAuthAuthorizationServer.AsymmetricKey, OAuthAuthorizationServer.AsymmetricKey);
+ var resourceServer = new ResourceServer(tokenAnalyzer);
+
+ IPrincipal principal;
+ var errorMessage = resourceServer.VerifyAccess(new HttpRequestInfo(this.application.Context.Request), out principal);
+ if (errorMessage == null) {
+ this.application.Context.User = principal;
}
}
@@ -70,7 +71,7 @@ namespace RelyingPartyLogic {
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Web.Security.RoleManagerEventArgs"/> instance containing the event data.</param>
private void roleManager_GetRoles(object sender, RoleManagerEventArgs e) {
- if (this.application.User is OAuthPrincipal) {
+ if (this.application.User is DotNetOpenAuth.OAuth.ChannelElements.OAuthPrincipal) {
e.RolesPopulated = true;
}
}
diff --git a/projecttemplates/RelyingPartyLogic/OAuthAuthorizationManager.cs b/projecttemplates/RelyingPartyLogic/OAuthAuthorizationManager.cs
index 35af472..6ac2977 100644
--- a/projecttemplates/RelyingPartyLogic/OAuthAuthorizationManager.cs
+++ b/projecttemplates/RelyingPartyLogic/OAuthAuthorizationManager.cs
@@ -15,6 +15,7 @@ namespace RelyingPartyLogic {
using System.ServiceModel.Security;
using DotNetOpenAuth;
using DotNetOpenAuth.OAuth;
+ using DotNetOpenAuth.OAuth2;
/// <summary>
/// A WCF extension to authenticate incoming messages using OAuth.
@@ -28,15 +29,16 @@ namespace RelyingPartyLogic {
return false;
}
- HttpRequestMessageProperty httpDetails = operationContext.RequestContext.RequestMessage.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
- Uri requestUri = operationContext.RequestContext.RequestMessage.Properties["OriginalHttpRequestUri"] as Uri;
- ServiceProvider sp = OAuthServiceProvider.ServiceProvider;
- try {
- var auth = sp.ReadProtectedResourceAuthorization(httpDetails, requestUri);
- if (auth != null) {
- var accessToken = Database.DataContext.IssuedTokens.OfType<IssuedAccessToken>().First(token => token.Token == auth.AccessToken);
+ var httpDetails = operationContext.RequestContext.RequestMessage.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
+ var requestUri = operationContext.RequestContext.RequestMessage.Properties["OriginalHttpRequestUri"] as Uri;
- var principal = sp.CreatePrincipal(auth);
+ var tokenAnalyzer = new SpecialAccessTokenAnalyzer(OAuthAuthorizationServer.AsymmetricKey, OAuthAuthorizationServer.AsymmetricKey);
+ var resourceServer = new ResourceServer(tokenAnalyzer);
+
+ try {
+ IPrincipal principal;
+ var errorResponse = resourceServer.VerifyAccess(httpDetails, requestUri, out principal);
+ if (errorResponse == null) {
var policy = new OAuthPrincipalAuthorizationPolicy(principal);
var policies = new List<IAuthorizationPolicy> {
policy,
@@ -56,8 +58,7 @@ namespace RelyingPartyLogic {
};
// Only allow this method call if the access token scope permits it.
- string[] scopes = accessToken.Scope.Split('|');
- if (scopes.Contains(operationContext.IncomingMessageHeaders.Action)) {
+ if (principal.IsInRole(operationContext.IncomingMessageHeaders.Action)) {
return true;
}
}
diff --git a/projecttemplates/RelyingPartyLogic/OAuthAuthorizationServer.cs b/projecttemplates/RelyingPartyLogic/OAuthAuthorizationServer.cs
new file mode 100644
index 0000000..2b207f9
--- /dev/null
+++ b/projecttemplates/RelyingPartyLogic/OAuthAuthorizationServer.cs
@@ -0,0 +1,176 @@
+//-----------------------------------------------------------------------
+// <copyright file="OAuthAuthorizationServer.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace RelyingPartyLogic {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Security.Cryptography;
+ using System.Text;
+ using System.Web;
+
+ using DotNetOpenAuth.Messaging.Bindings;
+ using DotNetOpenAuth.OAuth2;
+ using DotNetOpenAuth.OAuth2.ChannelElements;
+ using DotNetOpenAuth.OAuth2.Messages;
+
+ /// <summary>
+ /// Provides OAuth 2.0 authorization server information to DotNetOpenAuth.
+ /// </summary>
+ public class OAuthAuthorizationServer : IAuthorizationServer {
+ internal static readonly RSAParameters AsymmetricKey;
+
+ private static readonly byte[] secret;
+
+ private readonly INonceStore nonceStore = new NonceDbStore();
+
+ static OAuthAuthorizationServer() {
+ // TODO: Replace this sample code with real code.
+ // For this sample, we just generate random secrets.
+ RandomNumberGenerator crypto = new RNGCryptoServiceProvider();
+ secret = new byte[16];
+ crypto.GetBytes(secret);
+
+ AsymmetricKey = new RSACryptoServiceProvider().ExportParameters(true);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="OAuthAuthorizationServer"/> class.
+ /// </summary>
+ public OAuthAuthorizationServer() {
+ }
+
+ #region IAuthorizationServer Members
+
+ /// <summary>
+ /// Gets the secret used to symmetrically encrypt and sign authorization codes and refresh tokens.
+ /// </summary>
+ /// <value></value>
+ /// <remarks>
+ /// This secret should be kept strictly confidential in the authorization server(s)
+ /// and NOT shared with the resource server. Anyone with this secret can mint
+ /// tokens to essentially grant themselves access to anything they want.
+ /// </remarks>
+ public byte[] Secret {
+ get { return secret; }
+ }
+
+ /// <summary>
+ /// Gets the asymmetric private key to use for signing access tokens.
+ /// </summary>
+ /// <value></value>
+ /// <remarks>
+ /// The public key in the private/public key pair will be used by the resource
+ /// servers to validate that the access token is minted by a trusted authorization server.
+ /// </remarks>
+ public RSAParameters AccessTokenSigningPrivateKey {
+ get { return AsymmetricKey; }
+ }
+
+ /// <summary>
+ /// Gets the authorization code nonce store to use to ensure that authorization codes can only be used once.
+ /// </summary>
+ /// <value>The authorization code nonce store.</value>
+ public INonceStore VerificationCodeNonceStore {
+ get { return this.nonceStore; }
+ }
+
+ /// <summary>
+ /// Gets the client with a given identifier.
+ /// </summary>
+ /// <param name="clientIdentifier">The client identifier.</param>
+ /// <returns>The client registration. Never null.</returns>
+ /// <exception cref="ArgumentException">Thrown when no client with the given identifier is registered with this authorization server.</exception>
+ public IConsumerDescription GetClient(string clientIdentifier) {
+ try {
+ return Database.DataContext.Clients.First(c => c.ClientIdentifier == clientIdentifier);
+ } catch (InvalidOperationException ex) {
+ throw new ArgumentOutOfRangeException("No client by that identifier.", ex);
+ }
+ }
+
+ /// <summary>
+ /// Determines whether a described authorization is (still) valid.
+ /// </summary>
+ /// <param name="authorization">The authorization.</param>
+ /// <returns>
+ /// <c>true</c> if the original authorization is still valid; otherwise, <c>false</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>When establishing that an authorization is still valid,
+ /// it's very important to only match on recorded authorizations that
+ /// meet these criteria:</para>
+ /// 1) The client identifier matches.
+ /// 2) The user account matches.
+ /// 3) The scope on the recorded authorization must include all scopes in the given authorization.
+ /// 4) The date the recorded authorization was issued must be <em>no later</em> that the date the given authorization was issued.
+ /// <para>One possible scenario is where the user authorized a client, later revoked authorization,
+ /// and even later reinstated authorization. This subsequent recorded authorization
+ /// would not satisfy requirement #4 in the above list. This is important because the revocation
+ /// the user went through should invalidate all previously issued tokens as a matter of
+ /// security in the event the user was revoking access in order to sever authorization on a stolen
+ /// account or piece of hardware in which the tokens were stored. </para>
+ /// </remarks>
+ public bool IsAuthorizationValid(IAuthorizationDescription authorization) {
+ return this.IsAuthorizationValid(authorization.Scope, authorization.ClientIdentifier, authorization.UtcIssued, authorization.User);
+ }
+
+ #endregion
+
+ public bool CanBeAutoApproved(EndUserAuthorizationRequest authorizationRequest) {
+ if (authorizationRequest == null) {
+ throw new ArgumentNullException("authorizationRequest");
+ }
+
+ // NEVER issue an auto-approval to a client that would end up getting an access token immediately
+ // (without a client secret), as that would allow ANY client to spoof an approved client's identity
+ // and obtain unauthorized access to user data.
+ if (authorizationRequest.ResponseType == EndUserAuthorizationResponseType.AuthorizationCode) {
+ // Never issue auto-approval if the client secret is blank, since that too makes it easy to spoof
+ // a client's identity and obtain unauthorized access.
+ var requestingClient = Database.DataContext.Clients.First(c => c.ClientIdentifier == authorizationRequest.ClientIdentifier);
+ if (!string.IsNullOrEmpty(requestingClient.ClientSecret)) {
+ return this.IsAuthorizationValid(
+ authorizationRequest.Scope,
+ authorizationRequest.ClientIdentifier,
+ DateTime.UtcNow,
+ HttpContext.Current.User.Identity.Name);
+ }
+ }
+
+ // Default to not auto-approving.
+ return false;
+ }
+
+ private bool IsAuthorizationValid(string requestedScope, string clientIdentifier, DateTime issuedUtc, string username)
+ {
+ var stringCompare = StringComparer.Ordinal;
+ var requestedScopes = OAuthUtilities.BreakUpScopes(requestedScope, stringCompare);
+
+ var grantedScopeStrings = from auth in Database.DataContext.ClientAuthorizations
+ where
+ auth.Client.ClientIdentifier == clientIdentifier &&
+ auth.CreatedOnUtc <= issuedUtc &&
+ auth.User.AuthenticationTokens.Any(token => token.ClaimedIdentifier == username)
+ select auth.Scope;
+
+ if (!grantedScopeStrings.Any()) {
+ // No granted authorizations prior to the issuance of this token, so it must have been revoked.
+ // Even if later authorizations restore this client's ability to call in, we can't allow
+ // access tokens issued before the re-authorization because the revoked authorization should
+ // effectively and permanently revoke all access and refresh tokens.
+ return false;
+ }
+
+ var grantedScopes = new HashSet<string>(stringCompare);
+ foreach (string scope in grantedScopeStrings) {
+ grantedScopes.UnionWith(OAuthUtilities.BreakUpScopes(scope, stringCompare));
+ }
+
+ return requestedScopes.IsSubsetOf(grantedScopes);
+ }
+ }
+}
diff --git a/projecttemplates/RelyingPartyLogic/OAuthConsumerTokenManager.cs b/projecttemplates/RelyingPartyLogic/OAuthConsumerTokenManager.cs
deleted file mode 100644
index 64e6be8..0000000
--- a/projecttemplates/RelyingPartyLogic/OAuthConsumerTokenManager.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="OAuthConsumerTokenManager.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace RelyingPartyLogic {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using DotNetOpenAuth.OAuth.ChannelElements;
-
- public class OAuthConsumerTokenManager : OAuthTokenManager, IConsumerTokenManager {
- /// <summary>
- /// Initializes a new instance of the <see cref="OAuthConsumerTokenManager"/> class.
- /// </summary>
- /// <param name="consumerKey">The consumer key.</param>
- /// <param name="consumerSecret">The consumer secret.</param>
- public OAuthConsumerTokenManager(string consumerKey, string consumerSecret) {
- if (String.IsNullOrEmpty(consumerKey)) {
- throw new ArgumentNullException("consumerKey");
- }
- if (consumerSecret == null) {
- throw new ArgumentNullException("consumerSecret");
- }
-
- this.ConsumerKey = consumerKey;
- this.ConsumerSecret = consumerSecret;
- }
-
- #region IConsumerTokenManager Members
-
- /// <summary>
- /// Gets the consumer key.
- /// </summary>
- /// <value>The consumer key.</value>
- public string ConsumerKey { get; private set; }
-
- /// <summary>
- /// Gets the consumer secret.
- /// </summary>
- /// <value>The consumer secret.</value>
- public string ConsumerSecret { get; private set; }
-
- #endregion
- }
-}
diff --git a/projecttemplates/RelyingPartyLogic/OAuthPrincipalAuthorizationPolicy.cs b/projecttemplates/RelyingPartyLogic/OAuthPrincipalAuthorizationPolicy.cs
index ddd0b3f..482f44b 100644
--- a/projecttemplates/RelyingPartyLogic/OAuthPrincipalAuthorizationPolicy.cs
+++ b/projecttemplates/RelyingPartyLogic/OAuthPrincipalAuthorizationPolicy.cs
@@ -10,18 +10,19 @@ namespace RelyingPartyLogic {
using System.IdentityModel.Claims;
using System.IdentityModel.Policy;
using System.Linq;
+ using System.Security.Principal;
using System.Web;
using DotNetOpenAuth.OAuth.ChannelElements;
public class OAuthPrincipalAuthorizationPolicy : IAuthorizationPolicy {
private readonly Guid uniqueId = Guid.NewGuid();
- private readonly OAuthPrincipal principal;
+ private readonly IPrincipal principal;
/// <summary>
/// Initializes a new instance of the <see cref="OAuthPrincipalAuthorizationPolicy"/> class.
/// </summary>
/// <param name="principal">The principal.</param>
- public OAuthPrincipalAuthorizationPolicy(OAuthPrincipal principal) {
+ public OAuthPrincipalAuthorizationPolicy(IPrincipal principal) {
this.principal = principal;
}
diff --git a/projecttemplates/RelyingPartyLogic/OAuthServiceProvider.cs b/projecttemplates/RelyingPartyLogic/OAuthServiceProvider.cs
index 807da2d..9b6fb50 100644
--- a/projecttemplates/RelyingPartyLogic/OAuthServiceProvider.cs
+++ b/projecttemplates/RelyingPartyLogic/OAuthServiceProvider.cs
@@ -10,9 +10,9 @@ namespace RelyingPartyLogic {
using System.Linq;
using System.Web;
using DotNetOpenAuth.Messaging;
- using DotNetOpenAuth.OAuth;
- using DotNetOpenAuth.OAuth.ChannelElements;
- using DotNetOpenAuth.OAuth.Messages;
+ using DotNetOpenAuth.OAuth2;
+ using DotNetOpenAuth.OAuth2.ChannelElements;
+ using DotNetOpenAuth.OAuth2.Messages;
public class OAuthServiceProvider {
private const string PendingAuthorizationRequestSessionKey = "PendingAuthorizationRequest";
@@ -20,28 +20,26 @@ namespace RelyingPartyLogic {
/// <summary>
/// The shared service description for this web site.
/// </summary>
- private static ServiceProviderDescription serviceDescription;
-
- private static OAuthServiceProviderTokenManager tokenManager;
+ private static AuthorizationServerDescription authorizationServerDescription;
/// <summary>
- /// The shared service provider object.
+ /// The shared authorization server.
/// </summary>
- private static ServiceProvider serviceProvider;
+ private static WebServerAuthorizationServer authorizationServer;
/// <summary>
- /// The lock to synchronize initialization of the <see cref="serviceProvider"/> field.
+ /// The lock to synchronize initialization of the <see cref="authorizationServer"/> field.
/// </summary>
- private static object initializerLock = new object();
+ private static readonly object InitializerLock = new object();
/// <summary>
/// Gets the service provider.
/// </summary>
/// <value>The service provider.</value>
- public static ServiceProvider ServiceProvider {
+ public static WebServerAuthorizationServer AuthorizationServer {
get {
EnsureInitialized();
- return serviceProvider;
+ return authorizationServer;
}
}
@@ -49,83 +47,28 @@ namespace RelyingPartyLogic {
/// Gets the service description.
/// </summary>
/// <value>The service description.</value>
- public static ServiceProviderDescription ServiceDescription {
+ public static AuthorizationServerDescription AuthorizationServerDescription {
get {
EnsureInitialized();
- return serviceDescription;
- }
- }
-
- public static UserAuthorizationRequest PendingAuthorizationRequest {
- get { return HttpContext.Current.Session[PendingAuthorizationRequestSessionKey] as UserAuthorizationRequest; }
- set { HttpContext.Current.Session[PendingAuthorizationRequestSessionKey] = value; }
- }
-
- public static Consumer PendingAuthorizationConsumer {
- get {
- ITokenContainingMessage message = PendingAuthorizationRequest;
- if (message == null) {
- throw new InvalidOperationException();
- }
-
- return Database.DataContext.IssuedTokens.OfType<IssuedRequestToken>().Include("Consumer").First(t => t.Token == message.Token).Consumer;
- }
- }
-
- public static void AuthorizePendingRequestToken() {
- var response = AuthorizePendingRequestTokenAndGetResponse();
- if (response != null) {
- serviceProvider.Channel.Send(response);
- }
- }
-
- public static OutgoingWebResponse AuthorizePendingRequestTokenAsWebResponse() {
- var response = AuthorizePendingRequestTokenAndGetResponse();
- if (response != null) {
- return serviceProvider.Channel.PrepareResponse(response);
- } else {
- return null;
+ return authorizationServerDescription;
}
}
- private static UserAuthorizationResponse AuthorizePendingRequestTokenAndGetResponse() {
- var pendingRequest = PendingAuthorizationRequest;
- if (pendingRequest == null) {
- throw new InvalidOperationException("No pending authorization request to authorize.");
- }
-
- ITokenContainingMessage msg = pendingRequest;
- var token = Database.DataContext.IssuedTokens.OfType<IssuedRequestToken>().First(t => t.Token == msg.Token);
- token.Authorize();
-
- PendingAuthorizationRequest = null;
- var response = serviceProvider.PrepareAuthorizationResponse(pendingRequest);
- return response;
- }
-
/// <summary>
- /// Initializes the <see cref="serviceProvider"/> field if it has not yet been initialized.
+ /// Initializes the <see cref="authorizationServer"/> field if it has not yet been initialized.
/// </summary>
private static void EnsureInitialized() {
- if (serviceProvider == null) {
- lock (initializerLock) {
- if (serviceDescription == null) {
- var postEndpoint = new MessageReceivingEndpoint(new Uri(Utilities.ApplicationRoot, "OAuth.ashx"), HttpDeliveryMethods.PostRequest);
- var getEndpoint = new MessageReceivingEndpoint(postEndpoint.Location, HttpDeliveryMethods.GetRequest);
- serviceDescription = new ServiceProviderDescription {
- TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() },
- RequestTokenEndpoint = postEndpoint,
- AccessTokenEndpoint = postEndpoint,
- UserAuthorizationEndpoint = getEndpoint,
+ if (authorizationServer == null) {
+ lock (InitializerLock) {
+ if (authorizationServerDescription == null) {
+ authorizationServerDescription = new AuthorizationServerDescription {
+ AuthorizationEndpoint = new Uri(Utilities.ApplicationRoot, "OAuth.ashx"),
+ TokenEndpoint = new Uri(Utilities.ApplicationRoot, "OAuth.ashx"),
};
}
- if (tokenManager == null) {
- tokenManager = new OAuthServiceProviderTokenManager();
- }
-
- if (serviceProvider == null) {
- serviceProvider = new ServiceProvider(serviceDescription, tokenManager);
+ if (authorizationServer == null) {
+ authorizationServer = new WebServerAuthorizationServer(new OAuthAuthorizationServer());
}
}
}
diff --git a/projecttemplates/RelyingPartyLogic/OAuthServiceProviderTokenManager.cs b/projecttemplates/RelyingPartyLogic/OAuthServiceProviderTokenManager.cs
deleted file mode 100644
index 4ae50ce..0000000
--- a/projecttemplates/RelyingPartyLogic/OAuthServiceProviderTokenManager.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="OAuthServiceProviderTokenManager.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace RelyingPartyLogic {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using DotNetOpenAuth.OAuth.ChannelElements;
-
- public class OAuthServiceProviderTokenManager : OAuthTokenManager, IServiceProviderTokenManager {
- /// <summary>
- /// Initializes a new instance of the <see cref="OAuthServiceProviderTokenManager"/> class.
- /// </summary>
- public OAuthServiceProviderTokenManager() {
- }
-
- #region IServiceProviderTokenManager Members
-
- /// <summary>
- /// Gets the Consumer description for a given a Consumer Key.
- /// </summary>
- /// <param name="consumerKey">The Consumer Key.</param>
- /// <returns>
- /// A description of the consumer. Never null.
- /// </returns>
- /// <exception cref="KeyNotFoundException">Thrown if the consumer key cannot be found.</exception>
- public IConsumerDescription GetConsumer(string consumerKey) {
- try {
- return Database.DataContext.Consumers.First(c => c.ConsumerKey == consumerKey);
- } catch (InvalidOperationException) {
- throw new KeyNotFoundException();
- }
- }
-
- /// <summary>
- /// Checks whether a given request token has already been authorized
- /// by some user for use by the Consumer that requested it.
- /// </summary>
- /// <param name="requestToken">The Consumer's request token.</param>
- /// <returns>
- /// True if the request token has already been fully authorized by the user
- /// who owns the relevant protected resources. False if the token has not yet
- /// been authorized, has expired or does not exist.
- /// </returns>
- public bool IsRequestTokenAuthorized(string requestToken) {
- return Database.DataContext.IssuedTokens.OfType<IssuedRequestToken>().Any(
- t => t.Token == requestToken && t.User != null);
- }
-
- /// <summary>
- /// Gets details on the named request token.
- /// </summary>
- /// <param name="token">The request token.</param>
- /// <returns>A description of the token. Never null.</returns>
- /// <exception cref="KeyNotFoundException">Thrown if the token cannot be found.</exception>
- /// <remarks>
- /// It is acceptable for implementations to find the token, see that it has expired,
- /// delete it from the database and then throw <see cref="KeyNotFoundException"/>,
- /// or alternatively it can return the expired token anyway and the OAuth channel will
- /// log and throw the appropriate error.
- /// </remarks>
- public IServiceProviderRequestToken GetRequestToken(string token) {
- try {
- return Database.DataContext.IssuedTokens.OfType<IssuedRequestToken>().First(tok => tok.Token == token);
- } catch (InvalidOperationException) {
- throw new KeyNotFoundException();
- }
- }
-
- /// <summary>
- /// Gets details on the named access token.
- /// </summary>
- /// <param name="token">The access token.</param>
- /// <returns>A description of the token. Never null.</returns>
- /// <exception cref="KeyNotFoundException">Thrown if the token cannot be found.</exception>
- /// <remarks>
- /// It is acceptable for implementations to find the token, see that it has expired,
- /// delete it from the database and then throw <see cref="KeyNotFoundException"/>,
- /// or alternatively it can return the expired token anyway and the OAuth channel will
- /// log and throw the appropriate error.
- /// </remarks>
- public IServiceProviderAccessToken GetAccessToken(string token) {
- try {
- return Database.DataContext.IssuedTokens.OfType<IssuedAccessToken>().First(tok => tok.Token == token);
- } catch (InvalidOperationException) {
- throw new KeyNotFoundException();
- }
- }
-
- /// <summary>
- /// Persists any changes made to the token.
- /// </summary>
- /// <param name="token">The token whose properties have been changed.</param>
- /// <remarks>
- /// This library will invoke this method after making a set
- /// of changes to the token as part of a web request to give the host
- /// the opportunity to persist those changes to a database.
- /// Depending on the object persistence framework the host site uses,
- /// this method MAY not need to do anything (if changes made to the token
- /// will automatically be saved without any extra handling).
- /// </remarks>
- public void UpdateToken(IServiceProviderRequestToken token) {
- Database.DataContext.SaveChanges();
- }
-
- #endregion
- }
-}
diff --git a/projecttemplates/RelyingPartyLogic/OAuthTokenManager.cs b/projecttemplates/RelyingPartyLogic/OAuthTokenManager.cs
deleted file mode 100644
index fbf808c..0000000
--- a/projecttemplates/RelyingPartyLogic/OAuthTokenManager.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="OAuthTokenManager.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace RelyingPartyLogic {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography.X509Certificates;
- using System.Web;
- using DotNetOpenAuth.OAuth;
- using DotNetOpenAuth.OAuth.ChannelElements;
- using DotNetOpenAuth.OAuth.Messages;
-
- /// <summary>
- /// The token manager this web site uses in its roles both as
- /// a consumer and as a service provider.
- /// </summary>
- public class OAuthTokenManager : ITokenManager {
- /// <summary>
- /// Initializes a new instance of the <see cref="OAuthTokenManager"/> class.
- /// </summary>
- protected OAuthTokenManager() {
- }
-
- #region ITokenManager Members
-
- /// <summary>
- /// Gets the Token Secret given a request or access token.
- /// </summary>
- /// <param name="token">The request or access token.</param>
- /// <returns>
- /// The secret associated with the given token.
- /// </returns>
- /// <exception cref="ArgumentException">Thrown if the secret cannot be found for the given token.</exception>
- public string GetTokenSecret(string token) {
- try {
- return Database.DataContext.IssuedTokens.First(t => t.Token == token).TokenSecret;
- } catch (InvalidOperationException) {
- throw new ArgumentOutOfRangeException();
- }
- }
-
- /// <summary>
- /// Stores a newly generated unauthorized request token, secret, and optional
- /// application-specific parameters for later recall.
- /// </summary>
- /// <param name="request">The request message that resulted in the generation of a new unauthorized request token.</param>
- /// <param name="response">The response message that includes the unauthorized request token.</param>
- /// <exception cref="ArgumentException">Thrown if the consumer key is not registered, or a required parameter was not found in the parameters collection.</exception>
- /// <remarks>
- /// Request tokens stored by this method SHOULD NOT associate any user account with this token.
- /// It usually opens up security holes in your application to do so. Instead, you associate a user
- /// account with access tokens (not request tokens) in the <see cref="ExpireRequestTokenAndStoreNewAccessToken"/>
- /// method.
- /// </remarks>
- public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response) {
- Consumer consumer;
- try {
- consumer = Database.DataContext.Consumers.First(c => c.ConsumerKey == request.ConsumerKey);
- } catch (InvalidOperationException) {
- throw new ArgumentOutOfRangeException();
- }
-
- var token = new IssuedRequestToken {
- Callback = request.Callback,
- Consumer = consumer,
- Token = response.Token,
- TokenSecret = response.TokenSecret,
- };
- string scope;
- if (request.ExtraData.TryGetValue("scope", out scope)) {
- token.Scope = scope;
- }
- Database.DataContext.AddToIssuedTokens(token);
- Database.DataContext.SaveChanges();
- }
-
- /// <summary>
- /// Deletes a request token and its associated secret and stores a new access token and secret.
- /// </summary>
- /// <param name="consumerKey">The Consumer that is exchanging its request token for an access token.</param>
- /// <param name="requestToken">The Consumer's request token that should be deleted/expired.</param>
- /// <param name="accessToken">The new access token that is being issued to the Consumer.</param>
- /// <param name="accessTokenSecret">The secret associated with the newly issued access token.</param>
- /// <remarks>
- /// <para>
- /// Any scope of granted privileges associated with the request token from the
- /// original call to <see cref="StoreNewRequestToken"/> should be carried over
- /// to the new Access Token.
- /// </para>
- /// <para>
- /// To associate a user account with the new access token,
- /// <see cref="System.Web.HttpContext.User">HttpContext.Current.User</see> may be
- /// useful in an ASP.NET web application within the implementation of this method.
- /// Alternatively you may store the access token here without associating with a user account,
- /// and wait until <see cref="WebConsumer.ProcessUserAuthorization()"/> or
- /// <see cref="DesktopConsumer.ProcessUserAuthorization(string, string)"/> return the access
- /// token to associate the access token with a user account at that point.
- /// </para>
- /// </remarks>
- public void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret) {
- var requestTokenEntity = Database.DataContext.IssuedTokens.OfType<IssuedRequestToken>()
- .Include("User")
- .First(t => t.Consumer.ConsumerKey == consumerKey && t.Token == requestToken);
-
- var accessTokenEntity = new IssuedAccessToken {
- Token = accessToken,
- TokenSecret = accessTokenSecret,
- ExpirationDateUtc = null, // currently, our access tokens don't expire
- User = requestTokenEntity.User,
- Scope = requestTokenEntity.Scope,
- Consumer = requestTokenEntity.Consumer,
- };
-
- Database.DataContext.DeleteObject(requestTokenEntity);
- Database.DataContext.AddToIssuedTokens(accessTokenEntity);
- Database.DataContext.SaveChanges();
- }
-
- /// <summary>
- /// Classifies a token as a request token or an access token.
- /// </summary>
- /// <param name="token">The token to classify.</param>
- /// <returns>
- /// Request or Access token, or invalid if the token is not recognized.
- /// </returns>
- public TokenType GetTokenType(string token) {
- IssuedToken tok = Database.DataContext.IssuedTokens.FirstOrDefault(t => t.Token == token);
- if (tok == null) {
- return TokenType.InvalidToken;
- } else {
- return tok is IssuedAccessToken ? TokenType.AccessToken : TokenType.RequestToken;
- }
- }
-
- #endregion
- }
-}
diff --git a/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj b/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj
index 338622c..06dee41 100644
--- a/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj
+++ b/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj
@@ -106,31 +106,28 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Model.cs" />
- <Compile Include="Model.IssuedToken.cs" />
+ <Compile Include="Model.ClientAuthorization.cs" />
<Compile Include="Database.cs" />
<Compile Include="DataRoleProvider.cs" />
<Compile Include="Model.AuthenticationToken.cs" />
- <Compile Include="Model.Consumer.cs" />
+ <Compile Include="Model.Client.cs" />
<Compile Include="Model.Designer.cs">
<DependentUpon>Model.edmx</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
- <Compile Include="Model.IssuedAccessToken.cs" />
- <Compile Include="Model.IssuedRequestToken.cs" />
<Compile Include="Model.OpenIdAssociation.cs" />
<Compile Include="Model.User.cs" />
<Compile Include="NonceDbStore.cs" />
+ <Compile Include="OAuthAuthorizationServer.cs" />
<Compile Include="OAuthAuthenticationModule.cs" />
<Compile Include="OAuthAuthorizationManager.cs" />
- <Compile Include="OAuthConsumerTokenManager.cs" />
<Compile Include="OAuthPrincipalAuthorizationPolicy.cs" />
<Compile Include="OAuthServiceProvider.cs" />
- <Compile Include="OAuthServiceProviderTokenManager.cs" />
- <Compile Include="OAuthTokenManager.cs" />
<Compile Include="Policies.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RelyingPartyApplicationDbStore.cs" />
+ <Compile Include="SpecialAccessTokenAnalyzer.cs" />
<Compile Include="Utilities.cs" />
</ItemGroup>
<ItemGroup>
@@ -144,12 +141,12 @@
<Project>{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}</Project>
<Name>DotNetOpenAuth</Name>
</ProjectReference>
- <ProjectReference Include="..\RelyingPartyDatabase\RelyingPartyDatabase.dbproj">
- <Name>RelyingPartyDatabase</Name>
- <!-- Deploy the latest SQL script first, so that this project can embed the latest version. -->
- <Targets>Build;Deploy</Targets>
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
- </ProjectReference>
+ <ProjectReference Include="..\RelyingPartyDatabase\RelyingPartyDatabase.dbproj">
+ <Name>RelyingPartyDatabase</Name>
+ <!-- Deploy the latest SQL script first, so that this project can embed the latest version. -->
+ <Targets>Build;Deploy</Targets>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="CreateDatabase.sql" />
diff --git a/projecttemplates/RelyingPartyLogic/SpecialAccessTokenAnalyzer.cs b/projecttemplates/RelyingPartyLogic/SpecialAccessTokenAnalyzer.cs
new file mode 100644
index 0000000..f189433
--- /dev/null
+++ b/projecttemplates/RelyingPartyLogic/SpecialAccessTokenAnalyzer.cs
@@ -0,0 +1,36 @@
+//-----------------------------------------------------------------------
+// <copyright file="SpecialAccessTokenAnalyzer.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace RelyingPartyLogic {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Security.Cryptography;
+ using System.Text;
+
+ using DotNetOpenAuth.OAuth2;
+
+ internal class SpecialAccessTokenAnalyzer : StandardAccessTokenAnalyzer {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SpecialAccessTokenAnalyzer"/> class.
+ /// </summary>
+ /// <param name="authorizationServerPublicSigningKey">The authorization server public signing key.</param>
+ /// <param name="resourceServerPrivateEncryptionKey">The resource server private encryption key.</param>
+ internal SpecialAccessTokenAnalyzer(RSAParameters authorizationServerPublicSigningKey, RSAParameters resourceServerPrivateEncryptionKey)
+ : base(authorizationServerPublicSigningKey, resourceServerPrivateEncryptionKey) {
+ }
+
+ public override bool TryValidateAccessToken(DotNetOpenAuth.Messaging.IDirectedProtocolMessage message, string accessToken, out string user, out string scope) {
+ bool result = base.TryValidateAccessToken(message, accessToken, out user, out scope);
+ if (result) {
+ // Ensure that clients coming in this way always belong to the oauth_client role.
+ scope += " " + "oauth_client";
+ }
+
+ return result;
+ }
+ }
+}