diff options
Diffstat (limited to 'projecttemplates/RelyingPartyLogic')
25 files changed, 0 insertions, 3869 deletions
diff --git a/projecttemplates/RelyingPartyLogic/.gitignore b/projecttemplates/RelyingPartyLogic/.gitignore deleted file mode 100644 index 673a3d9..0000000 --- a/projecttemplates/RelyingPartyLogic/.gitignore +++ /dev/null @@ -1 +0,0 @@ -CreateDatabase.sql diff --git a/projecttemplates/RelyingPartyLogic/DataRoleProvider.cs b/projecttemplates/RelyingPartyLogic/DataRoleProvider.cs deleted file mode 100644 index cefc270..0000000 --- a/projecttemplates/RelyingPartyLogic/DataRoleProvider.cs +++ /dev/null @@ -1,123 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="DataRoleProvider.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Web; - using System.Web.Security; - - public class DataRoleProvider : RoleProvider { - public override string ApplicationName { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public override void AddUsersToRoles(string[] usernames, string[] roleNames) { - var users = from token in Database.DataContext.AuthenticationTokens - where usernames.Contains(token.ClaimedIdentifier) - select token.User; - var roles = from role in Database.DataContext.Roles - where roleNames.Contains(role.Name, StringComparer.OrdinalIgnoreCase) - select role; - foreach (User user in users) { - foreach (Role role in roles) { - user.Roles.Add(role); - } - } - } - - public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { - var users = from token in Database.DataContext.AuthenticationTokens - where usernames.Contains(token.ClaimedIdentifier) - select token.User; - var roles = from role in Database.DataContext.Roles - where roleNames.Contains(role.Name, StringComparer.OrdinalIgnoreCase) - select role; - foreach (User user in users) { - foreach (Role role in roles) { - user.Roles.Remove(role); - } - } - } - - public override void CreateRole(string roleName) { - Database.DataContext.AddToRoles(new Role { Name = roleName }); - } - - /// <summary> - /// Removes a role from the data source for the configured applicationName. - /// </summary> - /// <param name="roleName">The name of the role to delete.</param> - /// <param name="throwOnPopulatedRole">If true, throw an exception if <paramref name="roleName"/> has one or more members and do not delete <paramref name="roleName"/>.</param> - /// <returns> - /// true if the role was successfully deleted; otherwise, false. - /// </returns> - public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) { - Role role = Database.DataContext.Roles.SingleOrDefault(r => r.Name == roleName); - if (role == null) { - return false; - } - - if (throwOnPopulatedRole && role.Users.Count > 0) { - throw new InvalidOperationException(); - } - - Database.DataContext.DeleteObject(roleName); - return true; - } - - /// <summary> - /// Gets an array of user names in a role where the user name contains the specified user name to match. - /// </summary> - /// <param name="roleName">The role to search in.</param> - /// <param name="usernameToMatch">The user name to search for.</param> - /// <returns> - /// A string array containing the names of all the users where the user name matches <paramref name="usernameToMatch"/> and the user is a member of the specified role. - /// </returns> - public override string[] FindUsersInRole(string roleName, string usernameToMatch) { - return (from role in Database.DataContext.Roles - where role.Name == roleName - from user in role.Users - from authTokens in user.AuthenticationTokens - where authTokens.ClaimedIdentifier == usernameToMatch - select authTokens.ClaimedIdentifier).ToArray(); - } - - public override string[] GetAllRoles() { - return Database.DataContext.Roles.Select(role => role.Name).ToArray(); - } - - public override string[] GetRolesForUser(string username) { - return (from authToken in Database.DataContext.AuthenticationTokens - where authToken.ClaimedIdentifier == username - from role in authToken.User.Roles - select role.Name).ToArray(); - } - - public override string[] GetUsersInRole(string roleName) { - return (from role in Database.DataContext.Roles - where string.Equals(role.Name, roleName, StringComparison.OrdinalIgnoreCase) - from user in role.Users - from token in user.AuthenticationTokens - select token.ClaimedIdentifier).ToArray(); - } - - public override bool IsUserInRole(string username, string roleName) { - Role role = Database.DataContext.Roles.SingleOrDefault(r => string.Equals(r.Name, roleName, StringComparison.OrdinalIgnoreCase)); - if (role != null) { - return role.Users.Any(user => user.AuthenticationTokens.Any(token => token.ClaimedIdentifier == username)); - } - - return false; - } - - public override bool RoleExists(string roleName) { - return Database.DataContext.Roles.Any(role => string.Equals(role.Name, roleName, StringComparison.OrdinalIgnoreCase)); - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/Database.cs b/projecttemplates/RelyingPartyLogic/Database.cs deleted file mode 100644 index 58f372f..0000000 --- a/projecttemplates/RelyingPartyLogic/Database.cs +++ /dev/null @@ -1,145 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="Database.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Data; - using System.Data.EntityClient; - using System.Data.SqlClient; - using System.Linq; - using System.ServiceModel; - using System.Text; - using System.Web; - - public class Database : IHttpModule, IDisposable { - private const string DataContextKey = "DataContext"; - - private const string DataContextTransactionKey = "DataContextTransaction"; - - /// <summary> - /// Initializes a new instance of the <see cref="Database"/> class. - /// </summary> - public Database() { - } - - public static User LoggedInUser { - get { return DataContext.AuthenticationTokens.Where(token => token.ClaimedIdentifier == HttpContext.Current.User.Identity.Name).Select(token => token.User).FirstOrDefault(); } - } - - /// <summary> - /// Gets the transaction-protected database connection for the current request. - /// </summary> - public static DatabaseEntities DataContext { - get { - DatabaseEntities dataContext = DataContextSimple; - if (dataContext == null) { - dataContext = new DatabaseEntities(); - dataContext.Connection.Open(); - DataContextTransaction = (EntityTransaction)dataContext.Connection.BeginTransaction(); - DataContextSimple = dataContext; - } - - return dataContext; - } - } - - /// <summary> - /// Gets a value indicating whether the data context is already initialized. - /// </summary> - internal static bool IsDataContextInitialized { - get { return DataContextSimple != null; } - } - - internal static EntityTransaction DataContextTransaction { - get { - if (HttpContext.Current != null) { - return HttpContext.Current.Items[DataContextTransactionKey] as EntityTransaction; - } else if (OperationContext.Current != null) { - object data; - if (OperationContext.Current.IncomingMessageProperties.TryGetValue(DataContextTransactionKey, out data)) { - return data as EntityTransaction; - } else { - return null; - } - } else { - throw new InvalidOperationException(); - } - } - - private set { - if (HttpContext.Current != null) { - HttpContext.Current.Items[DataContextTransactionKey] = value; - } else if (OperationContext.Current != null) { - OperationContext.Current.IncomingMessageProperties[DataContextTransactionKey] = value; - } else { - throw new InvalidOperationException(); - } - } - } - - private static DatabaseEntities DataContextSimple { - get { - if (HttpContext.Current != null) { - return HttpContext.Current.Items[DataContextKey] as DatabaseEntities; - } else if (OperationContext.Current != null) { - object data; - if (OperationContext.Current.IncomingMessageProperties.TryGetValue(DataContextKey, out data)) { - return data as DatabaseEntities; - } else { - return null; - } - } else { - throw new InvalidOperationException(); - } - } - - set { - if (HttpContext.Current != null) { - HttpContext.Current.Items[DataContextKey] = value; - } else if (OperationContext.Current != null) { - OperationContext.Current.IncomingMessageProperties[DataContextKey] = value; - } else { - throw new InvalidOperationException(); - } - } - } - - public void Dispose() { - } - - void IHttpModule.Init(HttpApplication context) { - context.EndRequest += this.Application_EndRequest; - context.Error += this.Application_Error; - } - - protected void Application_EndRequest(object sender, EventArgs e) { - CommitAndCloseDatabaseIfNecessary(); - } - - protected void Application_Error(object sender, EventArgs e) { - if (DataContextTransaction != null) { - DataContextTransaction.Rollback(); - DataContextTransaction.Dispose(); - DataContextTransaction = null; - } - } - - private static void CommitAndCloseDatabaseIfNecessary() { - var dataContext = DataContextSimple; - if (dataContext != null) { - dataContext.SaveChanges(); - if (DataContextTransaction != null) { - DataContextTransaction.Commit(); - DataContextTransaction.Dispose(); - } - - dataContext.Dispose(); - DataContextSimple = null; - } - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/Model.AuthenticationToken.cs b/projecttemplates/RelyingPartyLogic/Model.AuthenticationToken.cs deleted file mode 100644 index d6564da..0000000 --- a/projecttemplates/RelyingPartyLogic/Model.AuthenticationToken.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Web; - - public partial class AuthenticationToken { - /// <summary> - /// Initializes a new instance of the <see cref="AuthenticationToken"/> class. - /// </summary> - public AuthenticationToken() { - this.CreatedOnUtc = DateTime.UtcNow; - this.LastUsedUtc = DateTime.UtcNow; - this.UsageCount = 1; - } - - public bool IsInfoCard { - get { return this.ClaimedIdentifier.StartsWith(UriPrefixForInfoCard); } - } - - private static string UriPrefixForInfoCard { - get { return new Uri(Utilities.ApplicationRoot, "infocard/").AbsoluteUri; } - } - - public static string SynthesizeClaimedIdentifierFromInfoCard(string uniqueId) { - string synthesizedClaimedId = UriPrefixForInfoCard + Uri.EscapeDataString(uniqueId); - return synthesizedClaimedId; - } - - partial void OnLastUsedUtcChanging(DateTime value) { - Utilities.VerifyThrowNotLocalTime(value); - } - - partial void OnCreatedOnUtcChanging(DateTime value) { - Utilities.VerifyThrowNotLocalTime(value); - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/Model.Client.cs b/projecttemplates/RelyingPartyLogic/Model.Client.cs deleted file mode 100644 index 2b06958..0000000 --- a/projecttemplates/RelyingPartyLogic/Model.Client.cs +++ /dev/null @@ -1,68 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="Model.Client.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using DotNetOpenAuth.Messaging; - using DotNetOpenAuth.OAuth2; - - public partial class Client : IClientDescription { - #region IConsumerDescription Members - - /// <summary> - /// Gets the callback to use when an individual authorization request - /// does not include an explicit callback URI. - /// </summary> - /// <value> - /// An absolute URL; or <c>null</c> if none is registered. - /// </value> - Uri IClientDescription.DefaultCallback { - get { return string.IsNullOrEmpty(this.CallbackAsString) ? null : new Uri(this.CallbackAsString); } - } - - /// <summary> - /// Gets the type of the client. - /// </summary> - ClientType IClientDescription.ClientType { - get { return (ClientType)this.ClientType; } - } - - /// <summary> - /// Gets a value indicating whether a non-empty secret is registered for this client. - /// </summary> - bool IClientDescription.HasNonEmptySecret { - get { return !string.IsNullOrEmpty(this.ClientSecret); } - } - - /// <summary> - /// Checks whether the specified client secret is correct. - /// </summary> - /// <param name="secret">The secret obtained from the client.</param> - /// <returns><c>true</c> if the secret matches the one in the authorization server's record for the client; <c>false</c> otherwise.</returns> - /// <remarks> - /// All string equality checks, whether checking secrets or their hashes, - /// should be done using <see cref="MessagingUtilities.EqualsConstantTime"/> to mitigate timing attacks. - /// </remarks> - bool IClientDescription.IsValidClientSecret(string secret) { - return MessagingUtilities.EqualsConstantTime(secret, this.ClientSecret); - } - - /// <summary> - /// Determines whether a callback URI included in a client's authorization request - /// is among those allowed callbacks for the registered client. - /// </summary> - /// <param name="callback">The absolute URI the client has requested the authorization result be received at.</param> - /// <returns> - /// <c>true</c> if the callback URL is allowable for this client; otherwise, <c>false</c>. - /// </returns> - bool IClientDescription.IsCallbackAllowed(Uri callback) { - return string.IsNullOrEmpty(this.CallbackAsString) || callback == new Uri(this.CallbackAsString); - } - - #endregion - } -} diff --git a/projecttemplates/RelyingPartyLogic/Model.ClientAuthorization.cs b/projecttemplates/RelyingPartyLogic/Model.ClientAuthorization.cs deleted file mode 100644 index 4b1b8b1..0000000 --- a/projecttemplates/RelyingPartyLogic/Model.ClientAuthorization.cs +++ /dev/null @@ -1,26 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="Model.ClientAuthorization.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. 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 ClientAuthorization { - /// <summary> - /// Initializes a new instance of the <see cref="ClientAuthorization"/> class. - /// </summary> - public ClientAuthorization() { - this.CreatedOnUtc = DateTime.UtcNow; - } - - partial void OnCreatedOnUtcChanging(DateTime value) { - Utilities.VerifyThrowNotLocalTime(value); - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/Model.Designer.cs b/projecttemplates/RelyingPartyLogic/Model.Designer.cs deleted file mode 100644 index df854b4..0000000 --- a/projecttemplates/RelyingPartyLogic/Model.Designer.cs +++ /dev/null @@ -1,1598 +0,0 @@ -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated from a template. -// -// Manual changes to this file may cause unexpected behavior in your application. -// Manual changes to this file will be overwritten if the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -using System; -using System.ComponentModel; -using System.Data.EntityClient; -using System.Data.Objects; -using System.Data.Objects.DataClasses; -using System.Linq; -using System.Runtime.Serialization; -using System.Xml.Serialization; - -[assembly: EdmSchemaAttribute()] -#region EDM Relationship Metadata - -[assembly: EdmRelationshipAttribute("DatabaseModel", "UserRole", "Role", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.Role), "User", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.User))] -[assembly: EdmRelationshipAttribute("DatabaseModel", "FK_AuthenticationToken_User", "User", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RelyingPartyLogic.User), "AuthenticationToken", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.AuthenticationToken))] -[assembly: EdmRelationshipAttribute("DatabaseModel", "FK_IssuedToken_Consumer", "Client", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RelyingPartyLogic.Client), "ClientAuthorization", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.ClientAuthorization))] -[assembly: EdmRelationshipAttribute("DatabaseModel", "FK_IssuedToken_User", "User", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RelyingPartyLogic.User), "ClientAuthorization", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.ClientAuthorization))] - -#endregion - -namespace RelyingPartyLogic -{ - #region Contexts - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - public partial class DatabaseEntities : ObjectContext - { - #region Constructors - - /// <summary> - /// Initializes a new DatabaseEntities object using the connection string found in the 'DatabaseEntities' section of the application configuration file. - /// </summary> - public DatabaseEntities() : base("name=DatabaseEntities", "DatabaseEntities") - { - OnContextCreated(); - } - - /// <summary> - /// Initialize a new DatabaseEntities object. - /// </summary> - public DatabaseEntities(string connectionString) : base(connectionString, "DatabaseEntities") - { - OnContextCreated(); - } - - /// <summary> - /// Initialize a new DatabaseEntities object. - /// </summary> - public DatabaseEntities(EntityConnection connection) : base(connection, "DatabaseEntities") - { - OnContextCreated(); - } - - #endregion - - #region Partial Methods - - partial void OnContextCreated(); - - #endregion - - #region ObjectSet Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - public ObjectSet<Role> Roles - { - get - { - if ((_Roles == null)) - { - _Roles = base.CreateObjectSet<Role>("Roles"); - } - return _Roles; - } - } - private ObjectSet<Role> _Roles; - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - public ObjectSet<User> Users - { - get - { - if ((_Users == null)) - { - _Users = base.CreateObjectSet<User>("Users"); - } - return _Users; - } - } - private ObjectSet<User> _Users; - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - public ObjectSet<AuthenticationToken> AuthenticationTokens - { - get - { - if ((_AuthenticationTokens == null)) - { - _AuthenticationTokens = base.CreateObjectSet<AuthenticationToken>("AuthenticationTokens"); - } - return _AuthenticationTokens; - } - } - private ObjectSet<AuthenticationToken> _AuthenticationTokens; - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - public ObjectSet<Nonce> Nonces - { - get - { - if ((_Nonces == null)) - { - _Nonces = base.CreateObjectSet<Nonce>("Nonces"); - } - return _Nonces; - } - } - private ObjectSet<Nonce> _Nonces; - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - public ObjectSet<Client> Clients - { - get - { - if ((_Clients == null)) - { - _Clients = base.CreateObjectSet<Client>("Clients"); - } - return _Clients; - } - } - private ObjectSet<Client> _Clients; - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - public ObjectSet<ClientAuthorization> ClientAuthorizations - { - get - { - if ((_ClientAuthorizations == null)) - { - _ClientAuthorizations = base.CreateObjectSet<ClientAuthorization>("ClientAuthorizations"); - } - return _ClientAuthorizations; - } - } - private ObjectSet<ClientAuthorization> _ClientAuthorizations; - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - public ObjectSet<SymmetricCryptoKey> SymmetricCryptoKeys - { - get - { - if ((_SymmetricCryptoKeys == null)) - { - _SymmetricCryptoKeys = base.CreateObjectSet<SymmetricCryptoKey>("SymmetricCryptoKeys"); - } - return _SymmetricCryptoKeys; - } - } - private ObjectSet<SymmetricCryptoKey> _SymmetricCryptoKeys; - - #endregion - - #region AddTo Methods - - /// <summary> - /// Deprecated Method for adding a new object to the Roles EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. - /// </summary> - public void AddToRoles(Role role) - { - base.AddObject("Roles", role); - } - - /// <summary> - /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. - /// </summary> - public void AddToUsers(User user) - { - base.AddObject("Users", user); - } - - /// <summary> - /// Deprecated Method for adding a new object to the AuthenticationTokens EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. - /// </summary> - public void AddToAuthenticationTokens(AuthenticationToken authenticationToken) - { - base.AddObject("AuthenticationTokens", authenticationToken); - } - - /// <summary> - /// Deprecated Method for adding a new object to the Nonces EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. - /// </summary> - public void AddToNonces(Nonce nonce) - { - base.AddObject("Nonces", nonce); - } - - /// <summary> - /// Deprecated Method for adding a new object to the Clients EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. - /// </summary> - public void AddToClients(Client client) - { - base.AddObject("Clients", client); - } - - /// <summary> - /// Deprecated Method for adding a new object to the ClientAuthorizations EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. - /// </summary> - public void AddToClientAuthorizations(ClientAuthorization clientAuthorization) - { - base.AddObject("ClientAuthorizations", clientAuthorization); - } - - /// <summary> - /// Deprecated Method for adding a new object to the SymmetricCryptoKeys EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. - /// </summary> - public void AddToSymmetricCryptoKeys(SymmetricCryptoKey symmetricCryptoKey) - { - base.AddObject("SymmetricCryptoKeys", symmetricCryptoKey); - } - - #endregion - - #region Function Imports - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - public int ClearExpiredNonces() - { - return base.ExecuteFunction("ClearExpiredNonces"); - } - - #endregion - - } - - #endregion - - #region Entities - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="AuthenticationToken")] - [Serializable()] - [DataContractAttribute(IsReference=true)] - public partial class AuthenticationToken : EntityObject - { - #region Factory Method - - /// <summary> - /// Create a new AuthenticationToken object. - /// </summary> - /// <param name="claimedIdentifier">Initial value of the ClaimedIdentifier property.</param> - /// <param name="createdOnUtc">Initial value of the CreatedOnUtc property.</param> - /// <param name="lastUsedUtc">Initial value of the LastUsedUtc property.</param> - /// <param name="usageCount">Initial value of the UsageCount property.</param> - /// <param name="authenticationTokenId">Initial value of the AuthenticationTokenId property.</param> - public static AuthenticationToken CreateAuthenticationToken(global::System.String claimedIdentifier, global::System.DateTime createdOnUtc, global::System.DateTime lastUsedUtc, global::System.Int32 usageCount, global::System.Int32 authenticationTokenId) - { - AuthenticationToken authenticationToken = new AuthenticationToken(); - authenticationToken.ClaimedIdentifier = claimedIdentifier; - authenticationToken.CreatedOnUtc = createdOnUtc; - authenticationToken.LastUsedUtc = lastUsedUtc; - authenticationToken.UsageCount = usageCount; - authenticationToken.AuthenticationTokenId = authenticationTokenId; - return authenticationToken; - } - - #endregion - - #region Primitive Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.String ClaimedIdentifier - { - get - { - return _ClaimedIdentifier; - } - set - { - OnClaimedIdentifierChanging(value); - ReportPropertyChanging("ClaimedIdentifier"); - _ClaimedIdentifier = StructuralObject.SetValidValue(value, false); - ReportPropertyChanged("ClaimedIdentifier"); - OnClaimedIdentifierChanged(); - } - } - private global::System.String _ClaimedIdentifier; - partial void OnClaimedIdentifierChanging(global::System.String value); - partial void OnClaimedIdentifierChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)] - [DataMemberAttribute()] - public global::System.String FriendlyIdentifier - { - get - { - return _FriendlyIdentifier; - } - set - { - OnFriendlyIdentifierChanging(value); - ReportPropertyChanging("FriendlyIdentifier"); - _FriendlyIdentifier = StructuralObject.SetValidValue(value, true); - ReportPropertyChanged("FriendlyIdentifier"); - OnFriendlyIdentifierChanged(); - } - } - private global::System.String _FriendlyIdentifier; - partial void OnFriendlyIdentifierChanging(global::System.String value); - partial void OnFriendlyIdentifierChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.DateTime CreatedOnUtc - { - get - { - return _CreatedOnUtc; - } - private set - { - OnCreatedOnUtcChanging(value); - ReportPropertyChanging("CreatedOnUtc"); - _CreatedOnUtc = StructuralObject.SetValidValue(value); - ReportPropertyChanged("CreatedOnUtc"); - OnCreatedOnUtcChanged(); - } - } - private global::System.DateTime _CreatedOnUtc; - partial void OnCreatedOnUtcChanging(global::System.DateTime value); - partial void OnCreatedOnUtcChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.DateTime LastUsedUtc - { - get - { - return _LastUsedUtc; - } - set - { - OnLastUsedUtcChanging(value); - ReportPropertyChanging("LastUsedUtc"); - _LastUsedUtc = StructuralObject.SetValidValue(value); - ReportPropertyChanged("LastUsedUtc"); - OnLastUsedUtcChanged(); - } - } - private global::System.DateTime _LastUsedUtc; - partial void OnLastUsedUtcChanging(global::System.DateTime value); - partial void OnLastUsedUtcChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.Int32 UsageCount - { - get - { - return _UsageCount; - } - set - { - OnUsageCountChanging(value); - ReportPropertyChanging("UsageCount"); - _UsageCount = StructuralObject.SetValidValue(value); - ReportPropertyChanged("UsageCount"); - OnUsageCountChanged(); - } - } - private global::System.Int32 _UsageCount; - partial void OnUsageCountChanging(global::System.Int32 value); - partial void OnUsageCountChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] - [DataMemberAttribute()] - public global::System.Int32 AuthenticationTokenId - { - get - { - return _AuthenticationTokenId; - } - private set - { - if (_AuthenticationTokenId != value) - { - OnAuthenticationTokenIdChanging(value); - ReportPropertyChanging("AuthenticationTokenId"); - _AuthenticationTokenId = StructuralObject.SetValidValue(value); - ReportPropertyChanged("AuthenticationTokenId"); - OnAuthenticationTokenIdChanged(); - } - } - } - private global::System.Int32 _AuthenticationTokenId; - partial void OnAuthenticationTokenIdChanging(global::System.Int32 value); - partial void OnAuthenticationTokenIdChanged(); - - #endregion - - - #region Navigation Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [XmlIgnoreAttribute()] - [SoapIgnoreAttribute()] - [DataMemberAttribute()] - [EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_AuthenticationToken_User", "User")] - public User User - { - get - { - return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_AuthenticationToken_User", "User").Value; - } - set - { - ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_AuthenticationToken_User", "User").Value = value; - } - } - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [BrowsableAttribute(false)] - [DataMemberAttribute()] - public EntityReference<User> UserReference - { - get - { - return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_AuthenticationToken_User", "User"); - } - set - { - if ((value != null)) - { - ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<User>("DatabaseModel.FK_AuthenticationToken_User", "User", value); - } - } - } - - #endregion - - } - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="Client")] - [Serializable()] - [DataContractAttribute(IsReference=true)] - public partial class Client : EntityObject - { - #region Factory Method - - /// <summary> - /// Create a new Client object. - /// </summary> - /// <param name="clientId">Initial value of the ClientId property.</param> - /// <param name="clientIdentifier">Initial value of the ClientIdentifier property.</param> - /// <param name="name">Initial value of the Name property.</param> - /// <param name="clientType">Initial value of the ClientType property.</param> - public static Client CreateClient(global::System.Int32 clientId, global::System.String clientIdentifier, global::System.String name, global::System.Int32 clientType) - { - Client client = new Client(); - client.ClientId = clientId; - client.ClientIdentifier = clientIdentifier; - client.Name = name; - client.ClientType = clientType; - return client; - } - - #endregion - - #region Primitive Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] - [DataMemberAttribute()] - public global::System.Int32 ClientId - { - get - { - return _ClientId; - } - set - { - if (_ClientId != value) - { - OnClientIdChanging(value); - ReportPropertyChanging("ClientId"); - _ClientId = StructuralObject.SetValidValue(value); - ReportPropertyChanged("ClientId"); - OnClientIdChanged(); - } - } - } - private global::System.Int32 _ClientId; - partial void OnClientIdChanging(global::System.Int32 value); - partial void OnClientIdChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.String ClientIdentifier - { - get - { - return _ClientIdentifier; - } - set - { - OnClientIdentifierChanging(value); - ReportPropertyChanging("ClientIdentifier"); - _ClientIdentifier = StructuralObject.SetValidValue(value, false); - ReportPropertyChanged("ClientIdentifier"); - OnClientIdentifierChanged(); - } - } - private global::System.String _ClientIdentifier; - partial void OnClientIdentifierChanging(global::System.String value); - partial void OnClientIdentifierChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)] - [DataMemberAttribute()] - public global::System.String ClientSecret - { - get - { - return _ClientSecret; - } - set - { - OnClientSecretChanging(value); - ReportPropertyChanging("ClientSecret"); - _ClientSecret = StructuralObject.SetValidValue(value, true); - ReportPropertyChanged("ClientSecret"); - OnClientSecretChanged(); - } - } - private global::System.String _ClientSecret; - partial void OnClientSecretChanging(global::System.String value); - partial void OnClientSecretChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)] - [DataMemberAttribute()] - public global::System.String CallbackAsString - { - get - { - return _CallbackAsString; - } - set - { - OnCallbackAsStringChanging(value); - ReportPropertyChanging("CallbackAsString"); - _CallbackAsString = StructuralObject.SetValidValue(value, true); - ReportPropertyChanged("CallbackAsString"); - OnCallbackAsStringChanged(); - } - } - private global::System.String _CallbackAsString; - partial void OnCallbackAsStringChanging(global::System.String value); - partial void OnCallbackAsStringChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.String Name - { - get - { - return _Name; - } - set - { - OnNameChanging(value); - ReportPropertyChanging("Name"); - _Name = StructuralObject.SetValidValue(value, false); - ReportPropertyChanged("Name"); - OnNameChanged(); - } - } - private global::System.String _Name; - partial void OnNameChanging(global::System.String value); - partial void OnNameChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.Int32 ClientType - { - get - { - return _ClientType; - } - set - { - OnClientTypeChanging(value); - ReportPropertyChanging("ClientType"); - _ClientType = StructuralObject.SetValidValue(value); - ReportPropertyChanged("ClientType"); - OnClientTypeChanged(); - } - } - private global::System.Int32 _ClientType; - partial void OnClientTypeChanging(global::System.Int32 value); - partial void OnClientTypeChanged(); - - #endregion - - - #region Navigation Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [XmlIgnoreAttribute()] - [SoapIgnoreAttribute()] - [DataMemberAttribute()] - [EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_Consumer", "ClientAuthorization")] - public EntityCollection<ClientAuthorization> ClientAuthorizations - { - get - { - return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<ClientAuthorization>("DatabaseModel.FK_IssuedToken_Consumer", "ClientAuthorization"); - } - set - { - if ((value != null)) - { - ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<ClientAuthorization>("DatabaseModel.FK_IssuedToken_Consumer", "ClientAuthorization", value); - } - } - } - - #endregion - - } - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="ClientAuthorization")] - [Serializable()] - [DataContractAttribute(IsReference=true)] - public partial class ClientAuthorization : EntityObject - { - #region Factory Method - - /// <summary> - /// Create a new ClientAuthorization object. - /// </summary> - /// <param name="authorizationId">Initial value of the AuthorizationId property.</param> - /// <param name="createdOnUtc">Initial value of the CreatedOnUtc property.</param> - public static ClientAuthorization CreateClientAuthorization(global::System.Int32 authorizationId, global::System.DateTime createdOnUtc) - { - ClientAuthorization clientAuthorization = new ClientAuthorization(); - clientAuthorization.AuthorizationId = authorizationId; - clientAuthorization.CreatedOnUtc = createdOnUtc; - return clientAuthorization; - } - - #endregion - - #region Primitive Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] - [DataMemberAttribute()] - public global::System.Int32 AuthorizationId - { - get - { - return _AuthorizationId; - } - set - { - if (_AuthorizationId != value) - { - OnAuthorizationIdChanging(value); - ReportPropertyChanging("AuthorizationId"); - _AuthorizationId = StructuralObject.SetValidValue(value); - ReportPropertyChanged("AuthorizationId"); - OnAuthorizationIdChanged(); - } - } - } - private global::System.Int32 _AuthorizationId; - partial void OnAuthorizationIdChanging(global::System.Int32 value); - partial void OnAuthorizationIdChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.DateTime CreatedOnUtc - { - get - { - return _CreatedOnUtc; - } - set - { - OnCreatedOnUtcChanging(value); - ReportPropertyChanging("CreatedOnUtc"); - _CreatedOnUtc = StructuralObject.SetValidValue(value); - ReportPropertyChanged("CreatedOnUtc"); - OnCreatedOnUtcChanged(); - } - } - private global::System.DateTime _CreatedOnUtc; - partial void OnCreatedOnUtcChanging(global::System.DateTime value); - partial void OnCreatedOnUtcChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)] - [DataMemberAttribute()] - public Nullable<global::System.DateTime> ExpirationDateUtc - { - get - { - return _ExpirationDateUtc; - } - set - { - OnExpirationDateUtcChanging(value); - ReportPropertyChanging("ExpirationDateUtc"); - _ExpirationDateUtc = StructuralObject.SetValidValue(value); - ReportPropertyChanged("ExpirationDateUtc"); - OnExpirationDateUtcChanged(); - } - } - private Nullable<global::System.DateTime> _ExpirationDateUtc; - partial void OnExpirationDateUtcChanging(Nullable<global::System.DateTime> value); - partial void OnExpirationDateUtcChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)] - [DataMemberAttribute()] - public global::System.String Scope - { - get - { - return _Scope; - } - set - { - OnScopeChanging(value); - ReportPropertyChanging("Scope"); - _Scope = StructuralObject.SetValidValue(value, true); - ReportPropertyChanged("Scope"); - OnScopeChanged(); - } - } - private global::System.String _Scope; - partial void OnScopeChanging(global::System.String value); - partial void OnScopeChanged(); - - #endregion - - - #region Navigation Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [XmlIgnoreAttribute()] - [SoapIgnoreAttribute()] - [DataMemberAttribute()] - [EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_Consumer", "Client")] - public Client Client - { - get - { - return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Client>("DatabaseModel.FK_IssuedToken_Consumer", "Client").Value; - } - set - { - ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Client>("DatabaseModel.FK_IssuedToken_Consumer", "Client").Value = value; - } - } - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [BrowsableAttribute(false)] - [DataMemberAttribute()] - public EntityReference<Client> ClientReference - { - get - { - return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Client>("DatabaseModel.FK_IssuedToken_Consumer", "Client"); - } - set - { - if ((value != null)) - { - ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<Client>("DatabaseModel.FK_IssuedToken_Consumer", "Client", value); - } - } - } - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [XmlIgnoreAttribute()] - [SoapIgnoreAttribute()] - [DataMemberAttribute()] - [EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_User", "User")] - public User User - { - get - { - return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User").Value; - } - set - { - ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User").Value = value; - } - } - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [BrowsableAttribute(false)] - [DataMemberAttribute()] - public EntityReference<User> UserReference - { - get - { - return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User"); - } - set - { - if ((value != null)) - { - ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User", value); - } - } - } - - #endregion - - } - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="Nonce")] - [Serializable()] - [DataContractAttribute(IsReference=true)] - public partial class Nonce : EntityObject - { - #region Factory Method - - /// <summary> - /// Create a new Nonce object. - /// </summary> - /// <param name="nonceId">Initial value of the NonceId property.</param> - /// <param name="context">Initial value of the Context property.</param> - /// <param name="code">Initial value of the Code property.</param> - /// <param name="issuedUtc">Initial value of the IssuedUtc property.</param> - /// <param name="expiresUtc">Initial value of the ExpiresUtc property.</param> - public static Nonce CreateNonce(global::System.Int32 nonceId, global::System.String context, global::System.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; - } - - #endregion - - #region Primitive Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] - [DataMemberAttribute()] - public global::System.Int32 NonceId - { - get - { - return _NonceId; - } - set - { - if (_NonceId != value) - { - OnNonceIdChanging(value); - ReportPropertyChanging("NonceId"); - _NonceId = StructuralObject.SetValidValue(value); - ReportPropertyChanged("NonceId"); - OnNonceIdChanged(); - } - } - } - private global::System.Int32 _NonceId; - partial void OnNonceIdChanging(global::System.Int32 value); - partial void OnNonceIdChanged(); - - /// <summary> - /// Gets or sets the Provider Endpoint URL the nonce came from. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.String Context - { - get - { - return _Context; - } - set - { - OnContextChanging(value); - ReportPropertyChanging("Context"); - _Context = StructuralObject.SetValidValue(value, false); - ReportPropertyChanged("Context"); - OnContextChanged(); - } - } - private global::System.String _Context; - partial void OnContextChanging(global::System.String value); - partial void OnContextChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.String Code - { - get - { - return _Code; - } - set - { - OnCodeChanging(value); - ReportPropertyChanging("Code"); - _Code = StructuralObject.SetValidValue(value, false); - ReportPropertyChanged("Code"); - OnCodeChanged(); - } - } - private global::System.String _Code; - partial void OnCodeChanging(global::System.String value); - partial void OnCodeChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.DateTime IssuedUtc - { - get - { - return _IssuedUtc; - } - set - { - OnIssuedUtcChanging(value); - ReportPropertyChanging("IssuedUtc"); - _IssuedUtc = StructuralObject.SetValidValue(value); - ReportPropertyChanged("IssuedUtc"); - OnIssuedUtcChanged(); - } - } - private global::System.DateTime _IssuedUtc; - partial void OnIssuedUtcChanging(global::System.DateTime value); - partial void OnIssuedUtcChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.DateTime ExpiresUtc - { - get - { - return _ExpiresUtc; - } - set - { - OnExpiresUtcChanging(value); - ReportPropertyChanging("ExpiresUtc"); - _ExpiresUtc = StructuralObject.SetValidValue(value); - ReportPropertyChanged("ExpiresUtc"); - OnExpiresUtcChanged(); - } - } - private global::System.DateTime _ExpiresUtc; - partial void OnExpiresUtcChanging(global::System.DateTime value); - partial void OnExpiresUtcChanged(); - - #endregion - - - } - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="Role")] - [Serializable()] - [DataContractAttribute(IsReference=true)] - public partial class Role : EntityObject - { - #region Factory Method - - /// <summary> - /// Create a new Role object. - /// </summary> - /// <param name="name">Initial value of the Name property.</param> - /// <param name="roleId">Initial value of the RoleId property.</param> - public static Role CreateRole(global::System.String name, global::System.Int32 roleId) - { - Role role = new Role(); - role.Name = name; - role.RoleId = roleId; - return role; - } - - #endregion - - #region Primitive Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.String Name - { - get - { - return _Name; - } - set - { - OnNameChanging(value); - ReportPropertyChanging("Name"); - _Name = StructuralObject.SetValidValue(value, false); - ReportPropertyChanged("Name"); - OnNameChanged(); - } - } - private global::System.String _Name; - partial void OnNameChanging(global::System.String value); - partial void OnNameChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] - [DataMemberAttribute()] - public global::System.Int32 RoleId - { - get - { - return _RoleId; - } - private set - { - if (_RoleId != value) - { - OnRoleIdChanging(value); - ReportPropertyChanging("RoleId"); - _RoleId = StructuralObject.SetValidValue(value); - ReportPropertyChanged("RoleId"); - OnRoleIdChanged(); - } - } - } - private global::System.Int32 _RoleId; - partial void OnRoleIdChanging(global::System.Int32 value); - partial void OnRoleIdChanged(); - - #endregion - - - #region Navigation Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [XmlIgnoreAttribute()] - [SoapIgnoreAttribute()] - [DataMemberAttribute()] - [EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "UserRole", "User")] - public EntityCollection<User> Users - { - get - { - return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<User>("DatabaseModel.UserRole", "User"); - } - set - { - if ((value != null)) - { - ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<User>("DatabaseModel.UserRole", "User", value); - } - } - } - - #endregion - - } - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="SymmetricCryptoKey")] - [Serializable()] - [DataContractAttribute(IsReference=true)] - public partial class SymmetricCryptoKey : EntityObject - { - #region Factory Method - - /// <summary> - /// Create a new SymmetricCryptoKey object. - /// </summary> - /// <param name="cryptoKeyId">Initial value of the CryptoKeyId property.</param> - /// <param name="bucket">Initial value of the Bucket property.</param> - /// <param name="handle">Initial value of the Handle property.</param> - /// <param name="expirationUtc">Initial value of the ExpirationUtc property.</param> - /// <param name="secret">Initial value of the Secret property.</param> - public static SymmetricCryptoKey CreateSymmetricCryptoKey(global::System.Int32 cryptoKeyId, global::System.String bucket, global::System.String handle, global::System.DateTime expirationUtc, global::System.Byte[] secret) - { - SymmetricCryptoKey symmetricCryptoKey = new SymmetricCryptoKey(); - symmetricCryptoKey.CryptoKeyId = cryptoKeyId; - symmetricCryptoKey.Bucket = bucket; - symmetricCryptoKey.Handle = handle; - symmetricCryptoKey.ExpirationUtc = expirationUtc; - symmetricCryptoKey.Secret = secret; - return symmetricCryptoKey; - } - - #endregion - - #region Primitive Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] - [DataMemberAttribute()] - public global::System.Int32 CryptoKeyId - { - get - { - return _CryptoKeyId; - } - set - { - if (_CryptoKeyId != value) - { - OnCryptoKeyIdChanging(value); - ReportPropertyChanging("CryptoKeyId"); - _CryptoKeyId = StructuralObject.SetValidValue(value); - ReportPropertyChanged("CryptoKeyId"); - OnCryptoKeyIdChanged(); - } - } - } - private global::System.Int32 _CryptoKeyId; - partial void OnCryptoKeyIdChanging(global::System.Int32 value); - partial void OnCryptoKeyIdChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.String Bucket - { - get - { - return _Bucket; - } - set - { - OnBucketChanging(value); - ReportPropertyChanging("Bucket"); - _Bucket = StructuralObject.SetValidValue(value, false); - ReportPropertyChanged("Bucket"); - OnBucketChanged(); - } - } - private global::System.String _Bucket; - partial void OnBucketChanging(global::System.String value); - partial void OnBucketChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.String Handle - { - get - { - return _Handle; - } - set - { - OnHandleChanging(value); - ReportPropertyChanging("Handle"); - _Handle = StructuralObject.SetValidValue(value, false); - ReportPropertyChanged("Handle"); - OnHandleChanged(); - } - } - private global::System.String _Handle; - partial void OnHandleChanging(global::System.String value); - partial void OnHandleChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.DateTime ExpirationUtc - { - get - { - return _ExpirationUtc; - } - set - { - OnExpirationUtcChanging(value); - ReportPropertyChanging("ExpirationUtc"); - _ExpirationUtc = StructuralObject.SetValidValue(value); - ReportPropertyChanged("ExpirationUtc"); - OnExpirationUtcChanged(); - } - } - private global::System.DateTime _ExpirationUtc; - partial void OnExpirationUtcChanging(global::System.DateTime value); - partial void OnExpirationUtcChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.Byte[] Secret - { - get - { - return StructuralObject.GetValidValue(_Secret); - } - set - { - OnSecretChanging(value); - ReportPropertyChanging("Secret"); - _Secret = StructuralObject.SetValidValue(value, false); - ReportPropertyChanged("Secret"); - OnSecretChanged(); - } - } - private global::System.Byte[] _Secret; - partial void OnSecretChanging(global::System.Byte[] value); - partial void OnSecretChanged(); - - #endregion - - - } - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="User")] - [Serializable()] - [DataContractAttribute(IsReference=true)] - public partial class User : EntityObject - { - #region Factory Method - - /// <summary> - /// Create a new User object. - /// </summary> - /// <param name="emailAddressVerified">Initial value of the EmailAddressVerified property.</param> - /// <param name="createdOnUtc">Initial value of the CreatedOnUtc property.</param> - /// <param name="userId">Initial value of the UserId property.</param> - public static User CreateUser(global::System.Boolean emailAddressVerified, global::System.DateTime createdOnUtc, global::System.Int32 userId) - { - User user = new User(); - user.EmailAddressVerified = emailAddressVerified; - user.CreatedOnUtc = createdOnUtc; - user.UserId = userId; - return user; - } - - #endregion - - #region Primitive Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)] - [DataMemberAttribute()] - public global::System.String FirstName - { - get - { - return _FirstName; - } - set - { - OnFirstNameChanging(value); - ReportPropertyChanging("FirstName"); - _FirstName = StructuralObject.SetValidValue(value, true); - ReportPropertyChanged("FirstName"); - OnFirstNameChanged(); - } - } - private global::System.String _FirstName; - partial void OnFirstNameChanging(global::System.String value); - partial void OnFirstNameChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)] - [DataMemberAttribute()] - public global::System.String LastName - { - get - { - return _LastName; - } - set - { - OnLastNameChanging(value); - ReportPropertyChanging("LastName"); - _LastName = StructuralObject.SetValidValue(value, true); - ReportPropertyChanged("LastName"); - OnLastNameChanged(); - } - } - private global::System.String _LastName; - partial void OnLastNameChanging(global::System.String value); - partial void OnLastNameChanged(); - - /// <summary> - /// The email address claimed to be controlled by the user. Whether it is actually owned by the user is indicated by the EmailAddressVerified property. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)] - [DataMemberAttribute()] - public global::System.String EmailAddress - { - get - { - return _EmailAddress; - } - set - { - OnEmailAddressChanging(value); - ReportPropertyChanging("EmailAddress"); - _EmailAddress = StructuralObject.SetValidValue(value, true); - ReportPropertyChanged("EmailAddress"); - OnEmailAddressChanged(); - } - } - private global::System.String _EmailAddress; - partial void OnEmailAddressChanging(global::System.String value); - partial void OnEmailAddressChanged(); - - /// <summary> - /// A value indicating whether the email address has been verified as actually owned by this user. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.Boolean EmailAddressVerified - { - get - { - return _EmailAddressVerified; - } - set - { - OnEmailAddressVerifiedChanging(value); - ReportPropertyChanging("EmailAddressVerified"); - _EmailAddressVerified = StructuralObject.SetValidValue(value); - ReportPropertyChanged("EmailAddressVerified"); - OnEmailAddressVerifiedChanged(); - } - } - private global::System.Boolean _EmailAddressVerified; - partial void OnEmailAddressVerifiedChanging(global::System.Boolean value); - partial void OnEmailAddressVerifiedChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] - [DataMemberAttribute()] - public global::System.DateTime CreatedOnUtc - { - get - { - return _CreatedOnUtc; - } - private set - { - OnCreatedOnUtcChanging(value); - ReportPropertyChanging("CreatedOnUtc"); - _CreatedOnUtc = StructuralObject.SetValidValue(value); - ReportPropertyChanged("CreatedOnUtc"); - OnCreatedOnUtcChanged(); - } - } - private global::System.DateTime _CreatedOnUtc; - partial void OnCreatedOnUtcChanging(global::System.DateTime value); - partial void OnCreatedOnUtcChanged(); - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] - [DataMemberAttribute()] - public global::System.Int32 UserId - { - get - { - return _UserId; - } - private set - { - if (_UserId != value) - { - OnUserIdChanging(value); - ReportPropertyChanging("UserId"); - _UserId = StructuralObject.SetValidValue(value); - ReportPropertyChanged("UserId"); - OnUserIdChanged(); - } - } - } - private global::System.Int32 _UserId; - partial void OnUserIdChanging(global::System.Int32 value); - partial void OnUserIdChanged(); - - #endregion - - - #region Navigation Properties - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [XmlIgnoreAttribute()] - [SoapIgnoreAttribute()] - [DataMemberAttribute()] - [EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "UserRole", "Role")] - public EntityCollection<Role> Roles - { - get - { - return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Role>("DatabaseModel.UserRole", "Role"); - } - set - { - if ((value != null)) - { - ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Role>("DatabaseModel.UserRole", "Role", value); - } - } - } - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [XmlIgnoreAttribute()] - [SoapIgnoreAttribute()] - [DataMemberAttribute()] - [EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_AuthenticationToken_User", "AuthenticationToken")] - public EntityCollection<AuthenticationToken> AuthenticationTokens - { - get - { - return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<AuthenticationToken>("DatabaseModel.FK_AuthenticationToken_User", "AuthenticationToken"); - } - set - { - if ((value != null)) - { - ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<AuthenticationToken>("DatabaseModel.FK_AuthenticationToken_User", "AuthenticationToken", value); - } - } - } - - /// <summary> - /// No Metadata Documentation available. - /// </summary> - [XmlIgnoreAttribute()] - [SoapIgnoreAttribute()] - [DataMemberAttribute()] - [EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_User", "ClientAuthorization")] - public EntityCollection<ClientAuthorization> ClientAuthorizations - { - get - { - return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<ClientAuthorization>("DatabaseModel.FK_IssuedToken_User", "ClientAuthorization"); - } - set - { - if ((value != null)) - { - ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<ClientAuthorization>("DatabaseModel.FK_IssuedToken_User", "ClientAuthorization", value); - } - } - } - - #endregion - - } - - #endregion - - -} diff --git a/projecttemplates/RelyingPartyLogic/Model.User.cs b/projecttemplates/RelyingPartyLogic/Model.User.cs deleted file mode 100644 index b92fa31..0000000 --- a/projecttemplates/RelyingPartyLogic/Model.User.cs +++ /dev/null @@ -1,98 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="Model.User.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.IdentityModel.Claims; - using System.Linq; - using System.Web; - using DotNetOpenAuth.InfoCard; - using DotNetOpenAuth.OpenId; - using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; - using DotNetOpenAuth.OpenId.RelyingParty; - - public partial class User { - /// <summary> - /// Initializes a new instance of the <see cref="User"/> class. - /// </summary> - public User() { - this.CreatedOnUtc = DateTime.UtcNow; - } - - public static AuthenticationToken ProcessUserLogin(IAuthenticationResponse openIdResponse) { - bool trustedEmail = Policies.ProviderEndpointsProvidingTrustedEmails.Contains(openIdResponse.Provider.Uri); - return ProcessUserLogin(openIdResponse.ClaimedIdentifier, openIdResponse.FriendlyIdentifierForDisplay, openIdResponse.GetExtension<ClaimsResponse>(), null, trustedEmail); - } - - public static AuthenticationToken ProcessUserLogin(Token samlToken) { - bool trustedEmail = false; // we don't trust InfoCard email addresses, since these can be self-issued. - return ProcessUserLogin( - AuthenticationToken.SynthesizeClaimedIdentifierFromInfoCard(samlToken.UniqueId), - samlToken.SiteSpecificId, - null, - samlToken, - trustedEmail); - } - - private static AuthenticationToken ProcessUserLogin(string claimedIdentifier, string friendlyIdentifier, ClaimsResponse claims, Token samlToken, bool trustedEmail) { - // Create an account for this user if we don't already have one. - AuthenticationToken openidToken = Database.DataContext.AuthenticationTokens.FirstOrDefault(token => token.ClaimedIdentifier == claimedIdentifier); - if (openidToken == null) { - // this is a user we haven't seen before. - User user = new User(); - openidToken = new AuthenticationToken { - ClaimedIdentifier = claimedIdentifier, - FriendlyIdentifier = friendlyIdentifier, - }; - user.AuthenticationTokens.Add(openidToken); - - // Gather information about the user if it's available. - if (claims != null) { - if (!string.IsNullOrEmpty(claims.Email)) { - user.EmailAddress = claims.Email; - user.EmailAddressVerified = trustedEmail; - } - if (!string.IsNullOrEmpty(claims.FullName)) { - if (claims.FullName.IndexOf(' ') > 0) { - user.FirstName = claims.FullName.Substring(0, claims.FullName.IndexOf(' ')).Trim(); - user.LastName = claims.FullName.Substring(claims.FullName.IndexOf(' ')).Trim(); - } else { - user.FirstName = claims.FullName; - } - } - } else if (samlToken != null) { - string email, givenName, surname; - if (samlToken.Claims.TryGetValue(ClaimTypes.Email, out email)) { - user.EmailAddress = email; - user.EmailAddressVerified = trustedEmail; - } - if (samlToken.Claims.TryGetValue(ClaimTypes.GivenName, out givenName)) { - user.FirstName = givenName; - } - if (samlToken.Claims.TryGetValue(ClaimTypes.Surname, out surname)) { - user.LastName = surname; - } - } - - Database.DataContext.AddToUsers(user); - } else { - openidToken.UsageCount++; - openidToken.LastUsedUtc = DateTime.UtcNow; - } - return openidToken; - } - - partial void OnCreatedOnUtcChanging(DateTime value) { - Utilities.VerifyThrowNotLocalTime(value); - } - - partial void OnEmailAddressChanged() { - // Whenever the email address is changed, we must reset its verified status. - this.EmailAddressVerified = false; - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/Model.cs b/projecttemplates/RelyingPartyLogic/Model.cs deleted file mode 100644 index c3b297d..0000000 --- a/projecttemplates/RelyingPartyLogic/Model.cs +++ /dev/null @@ -1,34 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="Model.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Data; - using System.Data.Common; - using System.Data.EntityClient; - using System.Data.Objects; - using System.Linq; - using System.Text; - - public partial class DatabaseEntities { - /// <summary> - /// Clears the expired nonces. - /// </summary> - /// <param name="transaction">The transaction to use, if any.</param> - internal void ClearExpiredNonces(EntityTransaction transaction) { - this.ExecuteCommand(transaction, "DatabaseEntities.ClearExpiredNonces"); - } - - /// <summary> - /// Clears the expired associations. - /// </summary> - /// <param name="transaction">The transaction to use, if any.</param> - internal void ClearExpiredCryptoKeys(EntityTransaction transaction) { - this.ExecuteCommand(transaction, "DatabaseEntities.ClearExpiredCryptoKeys"); - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/Model.edmx b/projecttemplates/RelyingPartyLogic/Model.edmx deleted file mode 100644 index 1845e1c..0000000 --- a/projecttemplates/RelyingPartyLogic/Model.edmx +++ /dev/null @@ -1,459 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx"> - <!-- EF Runtime content --> - <edmx:Runtime> - <!-- SSDL content --> - <edmx:StorageModels> - <Schema Namespace="DatabaseModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns="http://schemas.microsoft.com/ado/2009/02/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="Client" EntityType="DatabaseModel.Store.Client" store:Type="Tables" Schema="dbo" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" /> - <EntitySet Name="ClientAuthorization" EntityType="DatabaseModel.Store.ClientAuthorization" store:Type="Tables" Schema="dbo" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" /> - <EntitySet Name="CryptoKey" EntityType="DatabaseModel.Store.CryptoKey" 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="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" /> - <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="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="ClientAuthorization" EntitySet="ClientAuthorization" /> - </AssociationSet> - <AssociationSet Name="FK_UserRole_Role" Association="DatabaseModel.Store.FK_UserRole_Role"> - <End Role="Role" EntitySet="Role" /> - <End Role="UserRole" EntitySet="UserRole" /> - </AssociationSet> - <AssociationSet Name="FK_UserRole_User" Association="DatabaseModel.Store.FK_UserRole_User"> - <End Role="User" EntitySet="User" /> - <End Role="UserRole" EntitySet="UserRole" /> - </AssociationSet> - </EntityContainer> - <EntityType Name="AuthenticationToken"> - <Key> - <PropertyRef Name="AuthenticationTokenId" /> - </Key> - <Property Name="AuthenticationTokenId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" /> - <Property Name="UserId" Type="int" Nullable="false" /> - <Property Name="OpenIdClaimedIdentifier" Type="nvarchar" Nullable="false" MaxLength="250" /> - <Property Name="OpenIdFriendlyIdentifier" Type="nvarchar" MaxLength="250" /> - <Property Name="CreatedOn" Type="datetime" Nullable="false" /> - <Property Name="LastUsed" Type="datetime" Nullable="false" /> - <Property Name="UsageCount" Type="int" Nullable="false" /> - </EntityType> - <EntityType Name="Client"> - <Key> - <PropertyRef Name="ClientId" /> - </Key> - <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="ClientType" Type="int" Nullable="false" /> - <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" /> - </EntityType> - <EntityType Name="ClientAuthorization"> - <Key> - <PropertyRef Name="AuthorizationId" /> - </Key> - <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="ExpirationDate" Type="datetime" /> - <Property Name="Scope" Type="varchar" MaxLength="2048" /> - </EntityType> - <EntityType Name="CryptoKey"> - <Key> - <PropertyRef Name="CryptoKeyId" /> - </Key> - <Property Name="CryptoKeyId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" /> - <Property Name="Bucket" Type="varchar" Nullable="false" MaxLength="255" /> - <Property Name="Handle" Type="varchar" Nullable="false" MaxLength="255" /> - <Property Name="Expiration" Type="datetime" Nullable="false" /> - <Property Name="Secret" Type="varbinary" Nullable="false" MaxLength="4096" /> - </EntityType> - <EntityType Name="Nonce"> - <Key> - <PropertyRef Name="NonceId" /> - </Key> - <Property Name="NonceId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" /> - <Property Name="Context" Type="varchar" Nullable="false" MaxLength="255" /> - <Property Name="Code" Type="varchar" Nullable="false" MaxLength="255" /> - <Property Name="Issued" Type="datetime" Nullable="false" /> - <Property Name="Expires" Type="datetime" Nullable="false" /> - </EntityType> - <EntityType Name="Role"> - <Key> - <PropertyRef Name="RoleId" /> - </Key> - <Property Name="RoleId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" /> - <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" /> - </EntityType> - <EntityType Name="User"> - <Key> - <PropertyRef Name="UserId" /> - </Key> - <Property Name="UserId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" /> - <Property Name="FirstName" Type="nvarchar" MaxLength="50" /> - <Property Name="LastName" Type="nvarchar" MaxLength="50" /> - <Property Name="EmailAddress" Type="nvarchar" MaxLength="100" /> - <Property Name="EmailAddressVerified" Type="bit" Nullable="false" /> - <Property Name="CreatedOn" Type="datetime" Nullable="false" /> - </EntityType> - <EntityType Name="UserRole"> - <Key> - <PropertyRef Name="UserId" /> - <PropertyRef Name="RoleId" /> - </Key> - <Property Name="UserId" Type="int" Nullable="false" /> - <Property Name="RoleId" Type="int" Nullable="false" /> - </EntityType> - <Association Name="FK_AuthenticationToken_User"> - <End Role="User" Type="DatabaseModel.Store.User" Multiplicity="1"> - <OnDelete Action="Cascade" /> - </End> - <End Role="AuthenticationToken" Type="DatabaseModel.Store.AuthenticationToken" Multiplicity="*" /> - <ReferentialConstraint> - <Principal Role="User"> - <PropertyRef Name="UserId" /> - </Principal> - <Dependent Role="AuthenticationToken"> - <PropertyRef Name="UserId" /> - </Dependent> - </ReferentialConstraint> - </Association> - <Association Name="FK_IssuedToken_Consumer"> - <End Role="Client" Type="DatabaseModel.Store.Client" Multiplicity="1"> - <OnDelete Action="Cascade" /> - </End> - <End Role="ClientAuthorization" Type="DatabaseModel.Store.ClientAuthorization" Multiplicity="*" /> - <ReferentialConstraint> - <Principal Role="Client"> - <PropertyRef Name="ClientId" /> - </Principal> - <Dependent Role="ClientAuthorization"> - <PropertyRef Name="ClientId" /> - </Dependent> - </ReferentialConstraint> - </Association> - <Association Name="FK_IssuedToken_User"> - <End Role="User" Type="DatabaseModel.Store.User" Multiplicity="1"> - <OnDelete Action="Cascade" /> - </End> - <End Role="ClientAuthorization" Type="DatabaseModel.Store.ClientAuthorization" Multiplicity="*" /> - <ReferentialConstraint> - <Principal Role="User"> - <PropertyRef Name="UserId" /> - </Principal> - <Dependent Role="ClientAuthorization"> - <PropertyRef Name="UserId" /> - </Dependent> - </ReferentialConstraint> - </Association> - <Association Name="FK_UserRole_Role"> - <End Role="Role" Type="DatabaseModel.Store.Role" Multiplicity="1"> - <OnDelete Action="Cascade" /> - </End> - <End Role="UserRole" Type="DatabaseModel.Store.UserRole" Multiplicity="*" /> - <ReferentialConstraint> - <Principal Role="Role"> - <PropertyRef Name="RoleId" /> - </Principal> - <Dependent Role="UserRole"> - <PropertyRef Name="RoleId" /> - </Dependent> - </ReferentialConstraint> - </Association> - <Association Name="FK_UserRole_User"> - <End Role="User" Type="DatabaseModel.Store.User" Multiplicity="1"> - <OnDelete Action="Cascade" /> - </End> - <End Role="UserRole" Type="DatabaseModel.Store.UserRole" Multiplicity="*" /> - <ReferentialConstraint> - <Principal Role="User"> - <PropertyRef Name="UserId" /> - </Principal> - <Dependent Role="UserRole"> - <PropertyRef Name="UserId" /> - </Dependent> - </ReferentialConstraint> - </Association> - <Function Name="ClearExpiredCryptoKeys" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" /> - <Function Name="ClearExpiredNonces" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" /> - </Schema></edmx:StorageModels> - <!-- CSDL content --> - <edmx:ConceptualModels> - <Schema Namespace="DatabaseModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2008/09/edm"> - <EntityContainer Name="DatabaseEntities"> - <EntitySet Name="Roles" EntityType="DatabaseModel.Role" /> - <EntitySet Name="Users" EntityType="DatabaseModel.User" /> - <AssociationSet Name="UserRole" Association="DatabaseModel.UserRole"> - <End Role="Role" EntitySet="Roles" /> - <End Role="User" EntitySet="Users" /> - </AssociationSet> - <EntitySet Name="AuthenticationTokens" EntityType="DatabaseModel.AuthenticationToken" /> - <AssociationSet Name="FK_AuthenticationToken_User" Association="DatabaseModel.FK_AuthenticationToken_User"> - <End Role="User" EntitySet="Users" /> - <End Role="AuthenticationToken" EntitySet="AuthenticationTokens" /></AssociationSet> - <EntitySet Name="Nonces" EntityType="DatabaseModel.Nonce" /> - <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> - <EntitySet Name="SymmetricCryptoKeys" EntityType="DatabaseModel.SymmetricCryptoKey" /> - </EntityContainer> - <EntityType Name="AuthenticationToken" Abstract="false"> - <Key> - <PropertyRef Name="AuthenticationTokenId" /></Key> - <Property Name="ClaimedIdentifier" Type="String" Nullable="false" /> - <Property Name="FriendlyIdentifier" Type="String" Nullable="true" /> - <Property Name="CreatedOnUtc" Type="DateTime" Nullable="false" a:SetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" /> - <Property Name="LastUsedUtc" Type="DateTime" Nullable="false" /> - <Property Name="UsageCount" Type="Int32" Nullable="false" /> - <Property Name="AuthenticationTokenId" Type="Int32" Nullable="false" a:SetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" /> - <NavigationProperty Name="User" Relationship="DatabaseModel.FK_AuthenticationToken_User" FromRole="AuthenticationToken" ToRole="User" /></EntityType> - <EntityType Name="Role"> - <Key> - <PropertyRef Name="RoleId" /></Key> - <Property Name="Name" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="false" /> - <NavigationProperty Name="Users" Relationship="DatabaseModel.UserRole" FromRole="Role" ToRole="User" /> - <Property Name="RoleId" Type="Int32" Nullable="false" a:SetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" /></EntityType> - <EntityType Name="User"> - <Key> - <PropertyRef Name="UserId" /></Key> - <Property Name="FirstName" Type="String" MaxLength="50" Unicode="true" FixedLength="false" /> - <Property Name="LastName" Type="String" MaxLength="50" Unicode="true" FixedLength="false" /> - <Property Name="EmailAddress" Type="String" MaxLength="100" Unicode="true" FixedLength="false"> - <Documentation> - <Summary>The email address claimed to be controlled by the user. Whether it is actually owned by the user is indicated by the EmailAddressVerified property.</Summary></Documentation></Property> - <NavigationProperty Name="Roles" Relationship="DatabaseModel.UserRole" FromRole="User" ToRole="Role" /> - <Property Name="EmailAddressVerified" Type="Boolean" Nullable="false"> - <Documentation> - <Summary>A value indicating whether the email address has been verified as actually owned by this user.</Summary></Documentation></Property> - <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="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> - <Association Name="FK_AuthenticationToken_User"> - <End Type="DatabaseModel.User" Role="User" Multiplicity="1" /> - <End Type="DatabaseModel.AuthenticationToken" Role="AuthenticationToken" Multiplicity="*" /></Association> - <EntityType Name="Nonce" a:TypeAccess="Public" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration"> - <Key> - <PropertyRef Name="NonceId" /></Key> - <Property Name="NonceId" Type="Int32" Nullable="false" /> - <Property Name="Context" Type="String" Nullable="false"> - <Documentation> - <Summary>Gets or sets the Provider Endpoint URL the nonce came from.</Summary></Documentation></Property> - <Property Name="Code" Type="String" Nullable="false" /> - <Property Name="IssuedUtc" Type="DateTime" Nullable="false" /> - <Property Name="ExpiresUtc" Type="DateTime" 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" /> - <Property Type="Int32" Name="ClientType" Nullable="false" /> - </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="ExpirationDateUtc" Nullable="true" /> - <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> - <EntityType Name="SymmetricCryptoKey"> - <Key> - <PropertyRef Name="CryptoKeyId" /> - </Key> - <Property Type="Int32" Name="CryptoKeyId" Nullable="false" a:StoreGeneratedPattern="Identity" xmlns:a="http://schemas.microsoft.com/ado/2009/02/edm/annotation" /> - <Property Type="String" Name="Bucket" Nullable="false" MaxLength="255" FixedLength="false" Unicode="false" /> - <Property Type="String" Name="Handle" Nullable="false" MaxLength="255" FixedLength="false" Unicode="false" /> - <Property Type="DateTime" Name="ExpirationUtc" Nullable="false" /> - <Property Type="Binary" Name="Secret" Nullable="false" MaxLength="4096" FixedLength="false" /> - </EntityType></Schema> - </edmx:ConceptualModels> - <!-- C-S mapping content --> - <edmx:Mappings> - <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs"> - <EntityContainerMapping StorageEntityContainer="DatabaseModelStoreContainer" CdmEntityContainer="DatabaseEntities"> - <EntitySetMapping Name="Roles"> - <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.Role)"> - <MappingFragment StoreEntitySet="Role"> - <ScalarProperty Name="RoleId" ColumnName="RoleId" /> - <ScalarProperty Name="Name" ColumnName="Name" /> - </MappingFragment> - </EntityTypeMapping> - </EntitySetMapping> - <EntitySetMapping Name="Users"> - <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.User)"> - <MappingFragment StoreEntitySet="User"> - <ScalarProperty Name="UserId" ColumnName="UserId" /> - <ScalarProperty Name="CreatedOnUtc" ColumnName="CreatedOn" /> - <ScalarProperty Name="EmailAddressVerified" ColumnName="EmailAddressVerified" /> - <ScalarProperty Name="FirstName" ColumnName="FirstName" /> - <ScalarProperty Name="LastName" ColumnName="LastName" /> - <ScalarProperty Name="EmailAddress" ColumnName="EmailAddress" /> - </MappingFragment> - </EntityTypeMapping> - </EntitySetMapping> - <AssociationSetMapping Name="UserRole" TypeName="DatabaseModel.UserRole" StoreEntitySet="UserRole"> - <EndProperty Name="User"> - <ScalarProperty Name="UserId" ColumnName="UserId" /></EndProperty> - <EndProperty Name="Role"> - <ScalarProperty Name="RoleId" ColumnName="RoleId" /></EndProperty> - </AssociationSetMapping> - <EntitySetMapping Name="AuthenticationTokens"><EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.AuthenticationToken)"> - <MappingFragment StoreEntitySet="AuthenticationToken"> - <ScalarProperty Name="AuthenticationTokenId" ColumnName="AuthenticationTokenId" /> - <ScalarProperty Name="UsageCount" ColumnName="UsageCount" /> - <ScalarProperty Name="LastUsedUtc" ColumnName="LastUsed" /> - <ScalarProperty Name="CreatedOnUtc" ColumnName="CreatedOn" /> - <ScalarProperty Name="FriendlyIdentifier" ColumnName="OpenIdFriendlyIdentifier" /> - <ScalarProperty Name="ClaimedIdentifier" ColumnName="OpenIdClaimedIdentifier" /> - </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> - <EntitySetMapping Name="Nonces"> - <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.Nonce)"> - <MappingFragment StoreEntitySet="Nonce"> - <ScalarProperty Name="ExpiresUtc" ColumnName="Expires" /> - <ScalarProperty Name="IssuedUtc" ColumnName="Issued" /> - <ScalarProperty Name="Code" ColumnName="Code" /> - <ScalarProperty Name="Context" ColumnName="Context" /> - <ScalarProperty Name="NonceId" ColumnName="NonceId" /></MappingFragment></EntityTypeMapping></EntitySetMapping> - <FunctionImportMapping FunctionImportName="ClearExpiredNonces" FunctionName="DatabaseModel.Store.ClearExpiredNonces" /> - <EntitySetMapping Name="Clients"> - <EntityTypeMapping TypeName="DatabaseModel.Client"> - <MappingFragment StoreEntitySet="Client"> - <ScalarProperty Name="ClientType" ColumnName="ClientType" /> - <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="ExpirationDateUtc" 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> - <EntitySetMapping Name="SymmetricCryptoKeys"> - <EntityTypeMapping TypeName="DatabaseModel.SymmetricCryptoKey"> - <MappingFragment StoreEntitySet="CryptoKey"> - <ScalarProperty Name="Secret" ColumnName="Secret" /> - <ScalarProperty Name="ExpirationUtc" ColumnName="Expiration" /> - <ScalarProperty Name="Handle" ColumnName="Handle" /> - <ScalarProperty Name="Bucket" ColumnName="Bucket" /> - <ScalarProperty Name="CryptoKeyId" ColumnName="CryptoKeyId" /> - </MappingFragment> - </EntityTypeMapping> - </EntitySetMapping></EntityContainerMapping> - </Mapping> - </edmx:Mappings> - </edmx:Runtime> - <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) --> - <edmx:Designer> - <edmx:Connection> - <DesignerInfoPropertySet xmlns="http://schemas.microsoft.com/ado/2008/10/edmx"> - <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" /> - </DesignerInfoPropertySet> - </edmx:Connection> - <edmx:Options> - <DesignerInfoPropertySet xmlns="http://schemas.microsoft.com/ado/2008/10/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="101" xmlns="http://schemas.microsoft.com/ado/2008/10/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" /> - <AssociationConnector Association="DatabaseModel.UserRole" ManuallyRouted="false"> - <ConnectorPoint PointX="2.25" PointY="2.047841796875" /> - <ConnectorPoint PointX="2.875" PointY="2.047841796875" /></AssociationConnector> - <InheritanceConnector EntityType="DatabaseModel.AuthenticationToken"> - <ConnectorPoint PointX="6.5625" PointY="3.375" /> - <ConnectorPoint PointX="6.5625" PointY="2.9129850260416665" /></InheritanceConnector> - <AssociationConnector Association="DatabaseModel.FK_AuthenticationToken_User"> - <ConnectorPoint PointX="4.625" PointY="1.9324446614583337" /> - <ConnectorPoint PointX="5.25" PointY="1.9324446614583337" /></AssociationConnector> - <EntityTypeShape EntityType="DatabaseModel.Nonce" Width="1.5" PointX="9.625" PointY="0.75" Height="1.9802864583333326" /> - <EntityTypeShape EntityType="DatabaseModel.Client" Width="1.625" PointX="5.25" PointY="3.75" Height="2.3648893229166665" /> - <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.8362939453125016" /> - <ConnectorPoint PointX="4.625" PointY="4.8362939453125016" /> - </AssociationConnector> - <AssociationConnector Association="DatabaseModel.FK_IssuedToken_User"> - <ConnectorPoint PointX="3.75" PointY="3.2494921875" /> - <ConnectorPoint PointX="3.75" PointY="3.75" /> - </AssociationConnector> - <EntityTypeShape EntityType="DatabaseModel.SymmetricCryptoKey" Width="1.875" PointX="7.5" PointY="0.75" Height="1.9802864583333317" /></Diagram></edmx:Diagrams> - </edmx:Designer> -</edmx:Edmx>
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyLogic/NonceDbStore.cs b/projecttemplates/RelyingPartyLogic/NonceDbStore.cs deleted file mode 100644 index 3de2371..0000000 --- a/projecttemplates/RelyingPartyLogic/NonceDbStore.cs +++ /dev/null @@ -1,133 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="NonceDbStore.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Data; - using System.Data.Common; - using System.Data.EntityClient; - using System.Linq; - using System.Text; - using DotNetOpenAuth.Configuration; - using DotNetOpenAuth.Messaging.Bindings; - - /// <summary> - /// A database-backed nonce store for OpenID and OAuth services. - /// </summary> - public class NonceDbStore : INonceStore { - private const int NonceClearingInterval = 5; - - /// <summary> - /// A counter that tracks how many nonce stores have been done. - /// </summary> - private static int nonceClearingCounter; - - /// <summary> - /// Initializes a new instance of the <see cref="NonceDbStore"/> class. - /// </summary> - public NonceDbStore() { - } - - #region INonceStore Members - - /// <summary> - /// Stores a given nonce and timestamp. - /// </summary> - /// <param name="context">The context, or namespace, within which the - /// <paramref name="nonce"/> must be unique. - /// The context SHOULD be treated as case-sensitive. - /// The value will never be <c>null</c> but may be the empty string.</param> - /// <param name="nonce">A series of random characters.</param> - /// <param name="timestampUtc">The UTC timestamp that together with the nonce string make it unique - /// within the given <paramref name="context"/>. - /// The timestamp may also be used by the data store to clear out old nonces.</param> - /// <returns> - /// True if the context+nonce+timestamp (combination) was not previously in the database. - /// False if the nonce was stored previously with the same timestamp and context. - /// </returns> - /// <remarks> - /// The nonce must be stored for no less than the maximum time window a message may - /// be processed within before being discarded as an expired message. - /// This maximum message age can be looked up via the - /// <see cref="DotNetOpenAuth.Configuration.MessagingElement.MaximumMessageLifetime"/> - /// property, accessible via the <see cref="DotNetOpenAuth.Configuration.MessagingElement.Configuration"/> - /// property. - /// </remarks> - public bool StoreNonce(string context, string nonce, DateTime timestampUtc) { - try { - using (var dataContext = new TransactedDatabaseEntities(IsolationLevel.ReadCommitted)) { - Nonce nonceEntity = new Nonce { - Context = context, - Code = nonce, - IssuedUtc = timestampUtc, - ExpiresUtc = timestampUtc + DotNetOpenAuthSection.Messaging.MaximumMessageLifetime, - }; - - // The database columns [context] and [code] MUST be using - // a case sensitive collation for this to be secure. - dataContext.AddToNonces(nonceEntity); - } - } catch (UpdateException) { - // A nonce collision - return false; - } - - // Only clear nonces after successfully storing a nonce. - // This mitigates cheap DoS attacks that take up a lot of - // database cycles. - ClearNoncesIfAppropriate(); - return true; - } - - #endregion - - /// <summary> - /// Clears the nonces if appropriate. - /// </summary> - private static void ClearNoncesIfAppropriate() { - if (++nonceClearingCounter % NonceClearingInterval == 0) { - using (var dataContext = new TransactedDatabaseEntities(IsolationLevel.ReadCommitted)) { - dataContext.ClearExpiredNonces(dataContext.Transaction); - } - } - } - - /// <summary> - /// A transacted data context. - /// </summary> - protected class TransactedDatabaseEntities : DatabaseEntities { - /// <summary> - /// Initializes a new instance of the <see cref="TransactedDatabaseEntities"/> class. - /// </summary> - /// <param name="isolationLevel">The isolation level.</param> - public TransactedDatabaseEntities(IsolationLevel isolationLevel) { - this.Connection.Open(); - this.Transaction = (EntityTransaction)this.Connection.BeginTransaction(isolationLevel); - } - - /// <summary> - /// Gets the transaction for this data context. - /// </summary> - public EntityTransaction Transaction { get; private set; } - - /// <summary> - /// Releases the resources used by the object context. - /// </summary> - /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> - protected override void Dispose(bool disposing) { - try { - this.SaveChanges(); - this.Transaction.Commit(); - } finally { - this.Connection.Close(); - } - - base.Dispose(disposing); - } - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs b/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs deleted file mode 100644 index 3d37e1f..0000000 --- a/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs +++ /dev/null @@ -1,93 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="OAuthAuthenticationModule.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Security.Claims; - using System.Security.Principal; - using System.Threading; - using System.Threading.Tasks; - using System.Web; - using System.Web.Security; - using DotNetOpenAuth.Messaging; - using DotNetOpenAuth.OAuth2; - - public class OAuthAuthenticationModule : IHttpModule { - private HttpApplication application; - - #region IHttpModule Members - - /// <summary> - /// Initializes a module and prepares it to handle requests. - /// </summary> - /// <param name="context">An <see cref="T:System.Web.HttpApplication"/> that provides access to the methods, properties, and events common to all application objects within an ASP.NET application</param> - public void Init(HttpApplication context) { - this.application = context; - this.application.AuthenticateRequest += this.context_AuthenticateRequest; - - // Register an event that allows us to override roles for OAuth requests. - var roleManager = (RoleManagerModule)this.application.Modules["RoleManager"]; - roleManager.GetRoles += this.roleManager_GetRoles; - } - - /// <summary> - /// Disposes of the resources (other than memory) used by the module that implements <see cref="T:System.Web.IHttpModule"/>. - /// </summary> - public void Dispose() { - } - - /// <summary> - /// Handles the AuthenticateRequest event of the HttpApplication. - /// </summary> - /// <param name="sender">The source of the event.</param> - /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> - private void context_AuthenticateRequest(object sender, EventArgs e) { - // Don't read OAuth messages directed at the OAuth controller or else we'll fail nonce checks. - if (this.IsOAuthControllerRequest()) { - return; - } - - using (var crypto = OAuthResourceServer.CreateRSA()) { - var tokenAnalyzer = new SpecialAccessTokenAnalyzer(crypto, crypto); - var resourceServer = new ResourceServer(tokenAnalyzer); - var context = this.application.Context; - Task.Run( - async delegate { - ProtocolFaultResponseException exception = null; - try { - IPrincipal principal = await resourceServer.GetPrincipalAsync(new HttpRequestWrapper(context.Request)); - context.User = principal; - return; - } catch (ProtocolFaultResponseException ex) { - exception = ex; - } - - var errorResponse = await exception.CreateErrorResponseAsync(CancellationToken.None); - await errorResponse.SendAsync(); - }).Wait(); - } - } - - #endregion - - private bool IsOAuthControllerRequest() { - return string.Equals(this.application.Context.Request.Url.AbsolutePath, "/OAuth.ashx", StringComparison.OrdinalIgnoreCase); - } - - /// <summary> - /// Handles the GetRoles event of the roleManager control. - /// </summary> - /// <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 ClaimsPrincipal) { - e.RolesPopulated = true; - } - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/OAuthAuthorizationManager.cs b/projecttemplates/RelyingPartyLogic/OAuthAuthorizationManager.cs deleted file mode 100644 index f40cf36..0000000 --- a/projecttemplates/RelyingPartyLogic/OAuthAuthorizationManager.cs +++ /dev/null @@ -1,77 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="OAuthAuthorizationManager.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.IdentityModel.Policy; - using System.Linq; - using System.Security.Principal; - using System.ServiceModel; - using System.ServiceModel.Channels; - using System.ServiceModel.Security; - using System.Threading; - using System.Threading.Tasks; - using DotNetOpenAuth; - using DotNetOpenAuth.Messaging; - using DotNetOpenAuth.OAuth; - using DotNetOpenAuth.OAuth2; - - /// <summary> - /// A WCF extension to authenticate incoming messages using OAuth. - /// </summary> - public class OAuthAuthorizationManager : ServiceAuthorizationManager { - public OAuthAuthorizationManager() { - } - - protected override bool CheckAccessCore(OperationContext operationContext) { - if (!base.CheckAccessCore(operationContext)) { - return false; - } - - var httpDetails = operationContext.RequestContext.RequestMessage.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty; - var requestUri = operationContext.RequestContext.RequestMessage.Properties.Via; - - return Task.Run( - async delegate { - using (var crypto = OAuthResourceServer.CreateRSA()) { - var tokenAnalyzer = new SpecialAccessTokenAnalyzer(crypto, crypto); - var resourceServer = new ResourceServer(tokenAnalyzer); - ProtocolFaultResponseException exception = null; - try { - IPrincipal principal = - await resourceServer.GetPrincipalAsync(httpDetails, requestUri, CancellationToken.None, operationContext.IncomingMessageHeaders.Action); - var policy = new OAuthPrincipalAuthorizationPolicy(principal); - var policies = new List<IAuthorizationPolicy> { policy, }; - - var securityContext = new ServiceSecurityContext(policies.AsReadOnly()); - if (operationContext.IncomingMessageProperties.Security != null) { - operationContext.IncomingMessageProperties.Security.ServiceSecurityContext = securityContext; - } else { - operationContext.IncomingMessageProperties.Security = new SecurityMessageProperty { - ServiceSecurityContext = securityContext, - }; - } - - securityContext.AuthorizationContext.Properties["Identities"] = new List<IIdentity> { principal.Identity, }; - - return true; - } catch (ProtocolFaultResponseException ex) { - // Return the appropriate unauthorized response to the client. - exception = ex; - } catch (DotNetOpenAuth.Messaging.ProtocolException /* ex*/) { - ////Logger.Error("Error processing OAuth messages.", ex); - } - - var errorResponse = await exception.CreateErrorResponseAsync(CancellationToken.None); - await errorResponse.SendAsync(); - } - - return false; - }).Result; - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/OAuthAuthorizationServer.cs b/projecttemplates/RelyingPartyLogic/OAuthAuthorizationServer.cs deleted file mode 100644 index f5b1186..0000000 --- a/projecttemplates/RelyingPartyLogic/OAuthAuthorizationServer.cs +++ /dev/null @@ -1,203 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="OAuthAuthorizationServer.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Security.Cryptography; - using System.Security.Cryptography.X509Certificates; - 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 : IAuthorizationServerHost { - private static readonly RSACryptoServiceProvider SigningKey = new RSACryptoServiceProvider(); - - private readonly INonceStore nonceStore = new NonceDbStore(); - - /// <summary> - /// Initializes a new instance of the <see cref="OAuthAuthorizationServer"/> class. - /// </summary> - public OAuthAuthorizationServer() { - this.CryptoKeyStore = new RelyingPartyApplicationDbStore(); - } - - #region IAuthorizationServerHost Members - - public ICryptoKeyStore CryptoKeyStore { get; private set; } - - /// <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 NonceStore { - get { return this.nonceStore; } - } - - /// <summary> - /// Gets the crypto service provider with the asymmetric private key to use for signing access tokens. - /// </summary> - /// <value> - /// Must not be null, and must contain the private key. - /// </value> - /// <returns>A crypto service provider instance that contains the private key.</returns> - public RSACryptoServiceProvider AccessTokenSigningKey { - get { return SigningKey; } - } - - /// <summary> - /// Obtains parameters to go into the formulation of an access token. - /// </summary> - /// <param name="accessTokenRequestMessage">Details regarding the resources that the access token will grant access to, and the identity of the client - /// that will receive that access. - /// Based on this information the receiving resource server can be determined and the lifetime of the access - /// token can be set based on the sensitivity of the resources.</param> - /// <returns> - /// A non-null parameters instance that DotNetOpenAuth will dispose after it has been used. - /// </returns> - public AccessTokenResult CreateAccessToken(IAccessTokenRequest accessTokenRequestMessage) { - var accessToken = new AuthorizationServerAccessToken() { - // For this sample, we assume just one resource server. - // If this authorization server needs to mint access tokens for more than one resource server, - // we'd look at the request message passed to us and decide which public key to return. - ResourceServerEncryptionKey = OAuthResourceServer.CreateRSA(), - }; - - var result = new AccessTokenResult(accessToken); - return result; - } - - /// <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 IClientDescription 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); - } - - /// <summary> - /// Determines whether a given set of resource owner credentials is valid based on the authorization server's user database - /// and if so records an authorization entry such that subsequent calls to <see cref="IsAuthorizationValid" /> would - /// return <c>true</c>. - /// </summary> - /// <param name="userName">Username on the account.</param> - /// <param name="password">The user's password.</param> - /// <param name="accessRequest">The access request the credentials came with. - /// This may be useful if the authorization server wishes to apply some policy based on the client that is making the request.</param> - /// <returns> - /// A value that describes the result of the authorization check. - /// </returns> - public AutomatedUserAuthorizationCheckResponse CheckAuthorizeResourceOwnerCredentialGrant(string userName, string password, IAccessTokenRequest accessRequest) { - // This web site delegates user authentication to OpenID Providers, and as such no users have local passwords with this server. - throw new NotSupportedException(); - } - - /// <summary> - /// Determines whether an access token request given a client credential grant should be authorized - /// and if so records an authorization entry such that subsequent calls to <see cref="IsAuthorizationValid" /> would - /// return <c>true</c>. - /// </summary> - /// <param name="accessRequest">The access request the credentials came with. - /// This may be useful if the authorization server wishes to apply some policy based on the client that is making the request.</param> - /// <returns> - /// A value that describes the result of the authorization check. - /// </returns> - public AutomatedAuthorizationCheckResponse CheckAuthorizeClientCredentialsGrant(IAccessTokenRequest accessRequest) { - throw new NotImplementedException(); - } - - #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(HashSet<string> requestedScopes, string clientIdentifier, DateTime issuedUtc, string username) { - var grantedScopeStrings = from auth in Database.DataContext.ClientAuthorizations - where - auth.Client.ClientIdentifier == clientIdentifier && - auth.CreatedOnUtc <= issuedUtc && - (!auth.ExpirationDateUtc.HasValue || auth.ExpirationDateUtc.Value >= DateTime.UtcNow) && - 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>(OAuthUtilities.ScopeStringComparer); - foreach (string scope in grantedScopeStrings) { - grantedScopes.UnionWith(OAuthUtilities.SplitScopes(scope)); - } - - return requestedScopes.IsSubsetOf(grantedScopes); - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/OAuthPrincipalAuthorizationPolicy.cs b/projecttemplates/RelyingPartyLogic/OAuthPrincipalAuthorizationPolicy.cs deleted file mode 100644 index d53bf9e..0000000 --- a/projecttemplates/RelyingPartyLogic/OAuthPrincipalAuthorizationPolicy.cs +++ /dev/null @@ -1,54 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="OAuthPrincipalAuthorizationPolicy.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - 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 IPrincipal principal; - - /// <summary> - /// Initializes a new instance of the <see cref="OAuthPrincipalAuthorizationPolicy"/> class. - /// </summary> - /// <param name="principal">The principal.</param> - public OAuthPrincipalAuthorizationPolicy(IPrincipal principal) { - this.principal = principal; - } - - #region IAuthorizationComponent Members - - /// <summary> - /// Gets a unique ID for this instance. - /// </summary> - public string Id { - get { return this.uniqueId.ToString(); } - } - - #endregion - - #region IAuthorizationPolicy Members - - public ClaimSet Issuer { - get { return ClaimSet.System; } - } - - public bool Evaluate(EvaluationContext evaluationContext, ref object state) { - evaluationContext.AddClaimSet(this, new DefaultClaimSet(Claim.CreateNameClaim(this.principal.Identity.Name))); - evaluationContext.Properties["Principal"] = this.principal; - return true; - } - - #endregion - } -}
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyLogic/OAuthResourceServer.cs b/projecttemplates/RelyingPartyLogic/OAuthResourceServer.cs deleted file mode 100644 index fe55f8b..0000000 --- a/projecttemplates/RelyingPartyLogic/OAuthResourceServer.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Security.Cryptography; - using System.Text; - - public static class OAuthResourceServer { - private static readonly RSAParameters ResourceServerKeyPair = CreateRSAKey(); - - internal static RSACryptoServiceProvider CreateRSA() { - var rsa = new RSACryptoServiceProvider(); - rsa.ImportParameters(ResourceServerKeyPair); - return rsa; - } - - /// <summary> - /// Creates the RSA key used by all the crypto service provider instances we create. - /// </summary> - /// <returns>RSA data that includes the private key.</returns> - private static RSAParameters CreateRSAKey() { - // As we generate a new random key, we need to set the UseMachineKeyStore flag so that this doesn't - // crash on IIS. For more information: - // http://social.msdn.microsoft.com/Forums/en-US/clr/thread/7ea48fd0-8d6b-43ed-b272-1a0249ae490f?prof=required - var cspParameters = new CspParameters(); - cspParameters.Flags = CspProviderFlags.UseArchivableKey | CspProviderFlags.UseMachineKeyStore; - var asymmetricKey = new RSACryptoServiceProvider(cspParameters); - return asymmetricKey.ExportParameters(true); - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/OAuthServiceProvider.cs b/projecttemplates/RelyingPartyLogic/OAuthServiceProvider.cs deleted file mode 100644 index b6ba45e..0000000 --- a/projecttemplates/RelyingPartyLogic/OAuthServiceProvider.cs +++ /dev/null @@ -1,77 +0,0 @@ -//-----------------------------------------------------------------------
-// <copyright file="OAuthServiceProvider.cs" company="Outercurve Foundation">
-// Copyright (c) Outercurve Foundation. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace RelyingPartyLogic {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using DotNetOpenAuth.Messaging;
- using DotNetOpenAuth.OAuth2;
- using DotNetOpenAuth.OAuth2.ChannelElements;
- using DotNetOpenAuth.OAuth2.Messages;
-
- public class OAuthServiceProvider {
- private const string PendingAuthorizationRequestSessionKey = "PendingAuthorizationRequest";
-
- /// <summary>
- /// The lock to synchronize initialization of the <see cref="authorizationServer"/> field.
- /// </summary>
- private static readonly object InitializerLock = new object();
-
- /// <summary>
- /// The shared service description for this web site.
- /// </summary>
- private static AuthorizationServerDescription authorizationServerDescription;
-
- /// <summary>
- /// The shared authorization server.
- /// </summary>
- private static AuthorizationServer authorizationServer;
-
- /// <summary>
- /// Gets the service provider.
- /// </summary>
- /// <value>The service provider.</value>
- public static AuthorizationServer AuthorizationServer {
- get {
- EnsureInitialized();
- return authorizationServer;
- }
- }
-
- /// <summary>
- /// Gets the service description.
- /// </summary>
- /// <value>The service description.</value>
- public static AuthorizationServerDescription AuthorizationServerDescription {
- get {
- EnsureInitialized();
- return authorizationServerDescription;
- }
- }
-
- /// <summary>
- /// Initializes the <see cref="authorizationServer"/> field if it has not yet been initialized.
- /// </summary>
- private static void EnsureInitialized() {
- 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 (authorizationServer == null) {
- authorizationServer = new AuthorizationServer(new OAuthAuthorizationServer());
- }
- }
- }
- }
- }
-}
diff --git a/projecttemplates/RelyingPartyLogic/Policies.cs b/projecttemplates/RelyingPartyLogic/Policies.cs deleted file mode 100644 index 93129a8..0000000 --- a/projecttemplates/RelyingPartyLogic/Policies.cs +++ /dev/null @@ -1,23 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="Policies.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Web; - - public class Policies { - /// <summary> - /// The set of OP Endpoints that we trust pre-verify email addresses before sending them - /// with positive assertions. - /// </summary> - public static readonly Uri[] ProviderEndpointsProvidingTrustedEmails = new Uri[] { - new Uri("https://www.google.com/accounts/o8/ud"), - new Uri("https://open.login.yahooapis.com/openid/op/auth"), - }; - } -} diff --git a/projecttemplates/RelyingPartyLogic/Properties/AssemblyInfo.cs b/projecttemplates/RelyingPartyLogic/Properties/AssemblyInfo.cs deleted file mode 100644 index 8cb040c..0000000 --- a/projecttemplates/RelyingPartyLogic/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("RelyingPartyLogic")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft IT")] -[assembly: AssemblyProduct("RelyingPartyLogic")] -[assembly: AssemblyCopyright("Copyright © Microsoft IT 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("86d51499-3206-4eea-9bfe-b7950dac606b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/projecttemplates/RelyingPartyLogic/RelyingPartyApplicationDbStore.cs b/projecttemplates/RelyingPartyLogic/RelyingPartyApplicationDbStore.cs deleted file mode 100644 index 8afd3d4..0000000 --- a/projecttemplates/RelyingPartyLogic/RelyingPartyApplicationDbStore.cs +++ /dev/null @@ -1,94 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="RelyingPartyApplicationDbStore.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Data; - using System.Linq; - using DotNetOpenAuth; - using DotNetOpenAuth.Messaging.Bindings; - using DotNetOpenAuth.OpenId; - - /// <summary> - /// A database-backed state store for OpenID relying parties. - /// </summary> - public class RelyingPartyApplicationDbStore : NonceDbStore, ICryptoKeyAndNonceStore { - /// <summary> - /// Initializes a new instance of the <see cref="RelyingPartyApplicationDbStore"/> class. - /// </summary> - public RelyingPartyApplicationDbStore() { - } - - #region ICryptoStore Members - - public CryptoKey GetKey(string bucket, string handle) { - using (var dataContext = new TransactedDatabaseEntities(System.Data.IsolationLevel.ReadCommitted)) { - var associations = from assoc in dataContext.SymmetricCryptoKeys - where assoc.Bucket == bucket - where assoc.Handle == handle - where assoc.ExpirationUtc > DateTime.UtcNow - select assoc; - return associations.AsEnumerable() - .Select(assoc => new CryptoKey(assoc.Secret, assoc.ExpirationUtc.AsUtc())) - .FirstOrDefault(); - } - } - - public IEnumerable<KeyValuePair<string, CryptoKey>> GetKeys(string bucket) { - using (var dataContext = new TransactedDatabaseEntities(System.Data.IsolationLevel.ReadCommitted)) { - var relevantAssociations = from assoc in dataContext.SymmetricCryptoKeys - where assoc.Bucket == bucket - where assoc.ExpirationUtc > DateTime.UtcNow - orderby assoc.ExpirationUtc descending - select assoc; - var qualifyingAssociations = relevantAssociations.AsEnumerable() - .Select(assoc => new KeyValuePair<string, CryptoKey>(assoc.Handle, new CryptoKey(assoc.Secret, assoc.ExpirationUtc.AsUtc()))); - return qualifyingAssociations.ToList(); // the data context is closing, so we must cache the result. - } - } - - public void StoreKey(string bucket, string handle, CryptoKey key) { - using (var dataContext = new TransactedDatabaseEntities(System.Data.IsolationLevel.ReadCommitted)) { - var sharedAssociation = new SymmetricCryptoKey { - Bucket = bucket, - Handle = handle, - ExpirationUtc = key.ExpiresUtc, - Secret = key.Key, - }; - - dataContext.AddToSymmetricCryptoKeys(sharedAssociation); - } - } - - public void RemoveKey(string bucket, string handle) { - using (var dataContext = new TransactedDatabaseEntities(System.Data.IsolationLevel.ReadCommitted)) { - var association = dataContext.SymmetricCryptoKeys.FirstOrDefault(a => a.Bucket == bucket && a.Handle == handle); - if (association != null) { - dataContext.DeleteObject(association); - } else { - } - } - } - - #endregion - - /// <summary> - /// Clears all expired associations from the store. - /// </summary> - /// <remarks> - /// If another algorithm is in place to periodically clear out expired associations, - /// this method call may be ignored. - /// This should be done frequently enough to avoid a memory leak, but sparingly enough - /// to not be a performance drain. - /// </remarks> - internal void ClearExpiredCryptoKeys() { - using (var dataContext = new TransactedDatabaseEntities(IsolationLevel.ReadCommitted)) { - dataContext.ClearExpiredCryptoKeys(dataContext.Transaction); - } - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj b/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj deleted file mode 100644 index fed94c3..0000000 --- a/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj +++ /dev/null @@ -1,249 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.30729</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{17932639-1F50-48AF-B0A5-E2BF832F82CC}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>RelyingPartyLogic</RootNamespace> - <AssemblyName>RelyingPartyLogic</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - <FileUpgradeFlags> - </FileUpgradeFlags> - <OldToolsVersion>3.5</OldToolsVersion> - <UpgradeBackupLocation /> - <IsWebBootstrapper>false</IsWebBootstrapper> - <TargetFrameworkProfile /> - <PublishUrl>publish\</PublishUrl> - <Install>true</Install> - <InstallFrom>Disk</InstallFrom> - <UpdateEnabled>false</UpdateEnabled> - <UpdateMode>Foreground</UpdateMode> - <UpdateInterval>7</UpdateInterval> - <UpdateIntervalUnits>Days</UpdateIntervalUnits> - <UpdatePeriodically>false</UpdatePeriodically> - <UpdateRequired>false</UpdateRequired> - <MapFileExtensions>true</MapFileExtensions> - <ApplicationRevision>0</ApplicationRevision> - <ApplicationVersion>1.0.0.%2a</ApplicationVersion> - <UseApplicationTrust>false</UseApplicationTrust> - <BootstrapperEnabled>true</BootstrapperEnabled> - <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\src\</SolutionDir> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> - </PropertyGroup> - <ItemGroup> - <Reference Include="Microsoft.SqlServer.ConnectionInfo" /> - <Reference Include="Microsoft.SqlServer.Smo" /> - <Reference Include="Microsoft.SqlServer.Management.Sdk.Sfc" /> - <Reference Include="System" /> - <Reference Include="System.Data" /> - <Reference Include="System.Core"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.Data.DataSetExtensions"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.Data.Entity"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.Data.Linq"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.IdentityModel"> - <RequiredTargetFramework>3.0</RequiredTargetFramework> - </Reference> - <Reference Include="System.Net.Http" /> - <Reference Include="System.Net.Http.WebRequest" /> - <Reference Include="System.Runtime.Serialization"> - <RequiredTargetFramework>3.0</RequiredTargetFramework> - </Reference> - <Reference Include="System.Security" /> - <Reference Include="System.ServiceModel"> - <RequiredTargetFramework>3.0</RequiredTargetFramework> - </Reference> - <Reference Include="System.Web.Abstractions" /> - <Reference Include="System.Web.Entity"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.Web.Extensions"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.Xml.Linq"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.Drawing" /> - <Reference Include="System.Web" /> - <Reference Include="System.Xml" /> - <Reference Include="System.Configuration" /> - <Reference Include="System.Web.Services" /> - <Reference Include="System.EnterpriseServices" /> - <Reference Include="System.Web.Mobile" /> - <Reference Include="System.Web.ApplicationServices" Condition=" '$(TargetFrameworkVersion)' != 'v3.5' "> - <RequiredTargetFramework>v4.0</RequiredTargetFramework> - </Reference> - </ItemGroup> - <ItemGroup> - <Compile Include="Model.cs" /> - <Compile Include="Model.ClientAuthorization.cs" /> - <Compile Include="Database.cs" /> - <Compile Include="DataRoleProvider.cs" /> - <Compile Include="Model.AuthenticationToken.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.User.cs" /> - <Compile Include="NonceDbStore.cs" /> - <Compile Include="OAuthAuthorizationServer.cs" /> - <Compile Include="OAuthAuthenticationModule.cs" /> - <Compile Include="OAuthAuthorizationManager.cs" /> - <Compile Include="OAuthPrincipalAuthorizationPolicy.cs" /> - <Compile Include="OAuthResourceServer.cs" /> - <Compile Include="OAuthServiceProvider.cs" /> - <Compile Include="Policies.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="RelyingPartyApplicationDbStore.cs" /> - <Compile Include="SpecialAccessTokenAnalyzer.cs" /> - <Compile Include="Utilities.cs" /> - </ItemGroup> - <ItemGroup> - <EntityDeploy Include="Model.edmx"> - <Generator>EntityModelCodeGenerator</Generator> - <LastGenOutput>Model.Designer.cs</LastGenOutput> - </EntityDeploy> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\..\src\DotNetOpenAuth.InfoCard\DotNetOpenAuth.InfoCard.csproj"> - <Project>{408D10B8-34BA-4CBD-B7AA-FEB1907ABA4C}</Project> - <Name>DotNetOpenAuth.InfoCard</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.Core\DotNetOpenAuth.Core.csproj"> - <Project>{60426312-6AE5-4835-8667-37EDEA670222}</Project> - <Name>DotNetOpenAuth.Core</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OAuth.Common\DotNetOpenAuth.OAuth.Common.csproj"> - <Project>{115217C5-22CD-415C-A292-0DD0238CDD89}</Project> - <Name>DotNetOpenAuth.OAuth.Common</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OAuth.ServiceProvider\DotNetOpenAuth.OAuth.ServiceProvider.csproj"> - <Project>{FED1923A-6D70-49B5-A37A-FB744FEC1C86}</Project> - <Name>DotNetOpenAuth.OAuth.ServiceProvider</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OAuth2.AuthorizationServer\DotNetOpenAuth.OAuth2.AuthorizationServer.csproj"> - <Project>{99BB7543-EA16-43EE-A7BC-D7A25A3B22F6}</Project> - <Name>DotNetOpenAuth.OAuth2.AuthorizationServer</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OAuth2.ClientAuthorization\DotNetOpenAuth.OAuth2.ClientAuthorization.csproj"> - <Project>{CCF3728A-B3D7-404A-9BC6-75197135F2D7}</Project> - <Name>DotNetOpenAuth.OAuth2.ClientAuthorization</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OAuth2.Client\DotNetOpenAuth.OAuth2.Client.csproj"> - <Project>{CDEDD439-7F35-4E6E-8605-4E70BDC4CC99}</Project> - <Name>DotNetOpenAuth.OAuth2.Client</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OAuth2.ResourceServer\DotNetOpenAuth.OAuth2.ResourceServer.csproj"> - <Project>{A1A3150A-7B0E-4A34-8E35-045296CD3C76}</Project> - <Name>DotNetOpenAuth.OAuth2.ResourceServer</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OAuth2\DotNetOpenAuth.OAuth2.csproj"> - <Project>{56459A6C-6BA2-4BAC-A9C0-27E3BD961FA6}</Project> - <Name>DotNetOpenAuth.OAuth2</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OAuth\DotNetOpenAuth.OAuth.csproj"> - <Project>{A288FCC8-6FCF-46DA-A45E-5F9281556361}</Project> - <Name>DotNetOpenAuth.OAuth</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OpenId.RelyingParty.UI\DotNetOpenAuth.OpenId.RelyingParty.UI.csproj"> - <Project>{1ED8D424-F8AB-4050-ACEB-F27F4F909484}</Project> - <Name>DotNetOpenAuth.OpenId.RelyingParty.UI</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OpenId.RelyingParty\DotNetOpenAuth.OpenId.RelyingParty.csproj"> - <Project>{F458AB60-BA1C-43D9-8CEF-EC01B50BE87B}</Project> - <Name>DotNetOpenAuth.OpenId.RelyingParty</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OpenId.UI\DotNetOpenAuth.OpenId.UI.csproj"> - <Project>{75E13AAE-7D51-4421-ABFD-3F3DC91F576E}</Project> - <Name>DotNetOpenAuth.OpenId.UI</Name> - </ProjectReference> - <ProjectReference Include="..\..\src\DotNetOpenAuth.OpenId\DotNetOpenAuth.OpenId.csproj"> - <Project>{3896A32A-E876-4C23-B9B8-78E17D134CD3}</Project> - <Name>DotNetOpenAuth.OpenId</Name> - </ProjectReference> - <ProjectReference Include="..\RelyingPartyDatabase\RelyingPartyDatabase.sqlproj"> - <Name>RelyingPartyDatabase</Name> - <!-- Deploy the latest SQL script first, so that this project can embed the latest version. --> - <Targets>GetDeployScriptPath</Targets> - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> - </ProjectReference> - </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="CreateDatabase.sql" /> - </ItemGroup> - <ItemGroup> - <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> - <Visible>False</Visible> - <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName> - <Install>false</Install> - </BootstrapperPackage> - <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> - <Visible>False</Visible> - <ProductName>.NET Framework 3.5 SP1</ProductName> - <Install>true</Install> - </BootstrapperPackage> - <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> - <Visible>False</Visible> - <ProductName>Windows Installer 3.1</ProductName> - <Install>true</Install> - </BootstrapperPackage> - </ItemGroup> - <ItemGroup> - <None Include="packages.config" /> - </ItemGroup> - <Target Name="CopySqlDeployScript"> - <MSBuild Projects="..\RelyingPartyDatabase\RelyingPartyDatabase.sqlproj" Targets="GetDeployScriptPath"> - <Output TaskParameter="TargetOutputs" PropertyName="SqlDeployScriptPath" /> - </MSBuild> - <Copy SourceFiles="$(SqlDeployScriptPath)" DestinationFiles="CreateDatabase.sql" /> - </Target> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> - <PropertyGroup> - <PrepareResourceNamesDependsOn> - CopySqlDeployScript; - $(PrepareResourceNamesDependsOn) - </PrepareResourceNamesDependsOn> - </PropertyGroup> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> - <Import Project="$(SolutionDir)\.nuget\nuget.targets" /> -</Project>
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.vstemplate b/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.vstemplate deleted file mode 100644 index 243d820..0000000 --- a/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.vstemplate +++ /dev/null @@ -1,11 +0,0 @@ -<VSTemplate Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project"> - <TemplateData> - <Name>ASP.NET OpenID-InfoCard RP</Name> - <Description>An ASP.NET web forms web site that accepts OpenID and InfoCard logins</Description> - <ProjectType>CSharp</ProjectType> - <Icon>__TemplateIcon.ico</Icon> - </TemplateData> - <TemplateContent> - <Project File="RelyingPartyLogic.csproj" ReplaceParameters="true" /> - </TemplateContent> -</VSTemplate>
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyLogic/SpecialAccessTokenAnalyzer.cs b/projecttemplates/RelyingPartyLogic/SpecialAccessTokenAnalyzer.cs deleted file mode 100644 index e8b00b5..0000000 --- a/projecttemplates/RelyingPartyLogic/SpecialAccessTokenAnalyzer.cs +++ /dev/null @@ -1,35 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="SpecialAccessTokenAnalyzer.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. 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(RSACryptoServiceProvider authorizationServerPublicSigningKey, RSACryptoServiceProvider resourceServerPrivateEncryptionKey) - : base(authorizationServerPublicSigningKey, resourceServerPrivateEncryptionKey) { - } - - public override AccessToken DeserializeAccessToken(DotNetOpenAuth.Messaging.IDirectedProtocolMessage message, string accessToken) { - var token = base.DeserializeAccessToken(message, accessToken); - - // Ensure that clients coming in this way always belong to the oauth_client role. - token.Scope.Add("oauth_client"); - - return token; - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/Utilities.cs b/projecttemplates/RelyingPartyLogic/Utilities.cs deleted file mode 100644 index 440dbe7..0000000 --- a/projecttemplates/RelyingPartyLogic/Utilities.cs +++ /dev/null @@ -1,159 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="Utilities.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Data; - using System.Data.Common; - using System.Data.EntityClient; - using System.Data.Objects; - using System.Data.SqlClient; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Text; - using System.Web; - using DotNetOpenAuth.OpenId; - using Microsoft.SqlServer.Management.Common; - using Microsoft.SqlServer.Management.Smo; - - public static class Utilities { - internal const string DefaultNamespace = "RelyingPartyLogic"; - - /// <summary> - /// Gets the full URI of the web application root. Guaranteed to end in a slash. - /// </summary> - public static Uri ApplicationRoot { - get { - string appRoot = HttpContext.Current.Request.ApplicationPath; - if (!appRoot.EndsWith("/", StringComparison.Ordinal)) { - appRoot += "/"; - } - - return new Uri(HttpContext.Current.Request.Url, appRoot); - } - } - - public static void CreateDatabase(Identifier claimedId, string friendlyId, string databaseName) { - const string SqlFormat = @" -{0} -GO -EXEC [dbo].[AddUser] 'admin', 'admin', '{1}', '{2}' -GO -"; - var removeSnippets = new string[] { @" -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" }; - string databasePath = HttpContext.Current.Server.MapPath("~/App_Data/" + databaseName + ".mdf"); - StringBuilder schemaSqlBuilder = new StringBuilder(); - using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(DefaultNamespace + ".CreateDatabase.sql"))) { - schemaSqlBuilder.Append(sr.ReadToEnd()); - } - foreach (string remove in removeSnippets) { - schemaSqlBuilder.Replace(remove, string.Empty); - } - schemaSqlBuilder.Replace("Path1_Placeholder", HttpContext.Current.Server.MapPath("~/App_Data/")); - schemaSqlBuilder.Replace("WEBROOT", databasePath); - schemaSqlBuilder.Replace("$(DatabaseName)", databaseName); - - string sql = string.Format(CultureInfo.InvariantCulture, SqlFormat, schemaSqlBuilder, claimedId, "Admin"); - - var serverConnection = new ServerConnection(".\\sqlexpress"); - try { - serverConnection.ExecuteNonQuery(sql); - } finally { - try { - var server = new Server(serverConnection); - server.DetachDatabase(databaseName, true); - } catch (FailedOperationException) { - } - serverConnection.Disconnect(); - } - } - - public static int ExecuteCommand(this ObjectContext objectContext, string command) { - // Try to automatically add the appropriate transaction if one is known. - EntityTransaction transaction = null; - if (Database.IsDataContextInitialized && Database.DataContext == objectContext) { - transaction = Database.DataContextTransaction; - } - return ExecuteCommand(objectContext, transaction, command); - } - - /// <summary> - /// Executes a SQL command against the SQL connection. - /// </summary> - /// <param name="objectContext">The object context.</param> - /// <param name="transaction">The transaction to use, if any.</param> - /// <param name="command">The command to execute.</param> - /// <returns>The result of executing the command.</returns> - public static int ExecuteCommand(this ObjectContext objectContext, EntityTransaction transaction, string command) { - if (objectContext == null) { - throw new ArgumentNullException("objectContext"); - } - if (string.IsNullOrEmpty(command)) { - throw new ArgumentNullException("command"); - } - - DbConnection connection = (EntityConnection)objectContext.Connection; - bool opening = connection.State == ConnectionState.Closed; - if (opening) { - connection.Open(); - } - - DbCommand cmd = connection.CreateCommand(); - cmd.Transaction = transaction; - cmd.CommandText = command; - cmd.CommandType = CommandType.StoredProcedure; - try { - return cmd.ExecuteNonQuery(); - } finally { - if (opening && connection.State == ConnectionState.Open) { - connection.Close(); - } - } - } - - internal static void VerifyThrowNotLocalTime(DateTime value) { - // When we want UTC time, we have to accept Unspecified kind - // because that's how it is set to us in the database. - if (value.Kind == DateTimeKind.Local) { - throw new ArgumentException("DateTime must be given in UTC time but was " + value.Kind.ToString()); - } - } - - /// <summary> - /// Ensures that local times are converted to UTC times. Unspecified kinds are recast to UTC with no conversion. - /// </summary> - /// <param name="value">The date-time to convert.</param> - /// <returns>The date-time in UTC time.</returns> - internal static DateTime AsUtc(this DateTime value) { - if (value.Kind == DateTimeKind.Unspecified) { - return new DateTime(value.Ticks, DateTimeKind.Utc); - } - - return value.ToUniversalTime(); - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/packages.config b/projecttemplates/RelyingPartyLogic/packages.config deleted file mode 100644 index d8ffcb7..0000000 --- a/projecttemplates/RelyingPartyLogic/packages.config +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<packages> - <package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net45" /> -</packages>
\ No newline at end of file |