diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-10 08:36:21 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-10 08:36:21 -0800 |
commit | 8f53e90739e6b0511598c9cdde1820a96788b4ce (patch) | |
tree | f184205563c61eec364e56f2bd7e74b91c1b06cd | |
parent | 75737b85f5dce833c4fed0b1c839150fc1e6c3dc (diff) | |
download | DotNetOpenAuth-8f53e90739e6b0511598c9cdde1820a96788b4ce.zip DotNetOpenAuth-8f53e90739e6b0511598c9cdde1820a96788b4ce.tar.gz DotNetOpenAuth-8f53e90739e6b0511598c9cdde1820a96788b4ce.tar.bz2 |
Added initial OAuth token manager and entities.
Haven't checked in changes to db generating SQL yet.
6 files changed, 1089 insertions, 6 deletions
diff --git a/projecttemplates/WebFormsRelyingParty/Code/OAuthTokenManager.cs b/projecttemplates/WebFormsRelyingParty/Code/OAuthTokenManager.cs new file mode 100644 index 0000000..8653fd0 --- /dev/null +++ b/projecttemplates/WebFormsRelyingParty/Code/OAuthTokenManager.cs @@ -0,0 +1,262 @@ +//----------------------------------------------------------------------- +// <copyright file="OAuthTokenManager.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace WebFormsRelyingParty.Code { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using DotNetOpenAuth.OAuth.ChannelElements; + using DotNetOpenAuth.OAuth.Messages; + using System.Security.Cryptography.X509Certificates; + using DotNetOpenAuth.OAuth; + + /// <summary> + /// The token manager this web site uses in its roles both as + /// a consumer and as a service provider. + /// </summary> + public class OAuthTokenManager : IConsumerTokenManager, IServiceProviderTokenManager { + /// <summary> + /// Initializes a new instance of the <see cref="OAuthTokenManager"/> class + /// for use as a Consumer. + /// </summary> + /// <param name="consumerKey">The consumer key.</param> + /// <param name="consumerSecret">The consumer secret.</param> + private OAuthTokenManager(string consumerKey, string consumerSecret) { + if (String.IsNullOrEmpty(consumerKey)) { + throw new ArgumentNullException("consumerKey"); + } + if (consumerSecret == null) { + throw new ArgumentNullException("consumerSecret"); + } + + this.ConsumerKey = consumerKey; + this.ConsumerSecret = consumerSecret; + } + + /// <summary> + /// Initializes a new instance of the <see cref="OAuthTokenManager"/> class. + /// </summary> + private OAuthTokenManager() { + } + + #region IConsumerTokenManager Members + + /// <summary> + /// Gets the consumer key. + /// </summary> + /// <value>The consumer key.</value> + public string ConsumerKey { get; private set; } + + /// <summary> + /// Gets the consumer secret. + /// </summary> + /// <value>The consumer secret.</value> + public string ConsumerSecret { get; private set; } + + #endregion + + #region IServiceProviderTokenManager Members + + /// <summary> + /// Gets the Consumer description for a given a Consumer Key. + /// </summary> + /// <param name="consumerKey">The Consumer Key.</param> + /// <returns> + /// A description of the consumer. Never null. + /// </returns> + /// <exception cref="KeyNotFoundException">Thrown if the consumer key cannot be found.</exception> + public IConsumerDescription GetConsumer(string consumerKey) { + try { + return Global.DataContext.Consumer.First(c => c.ConsumerKey == consumerKey); + } catch (InvalidOperationException) { + throw new KeyNotFoundException(); + } + } + + /// <summary> + /// Checks whether a given request token has already been authorized + /// by some user for use by the Consumer that requested it. + /// </summary> + /// <param name="requestToken">The Consumer's request token.</param> + /// <returns> + /// True if the request token has already been fully authorized by the user + /// who owns the relevant protected resources. False if the token has not yet + /// been authorized, has expired or does not exist. + /// </returns> + public bool IsRequestTokenAuthorized(string requestToken) { + return Global.DataContext.IssuedToken.Any( + t => t.Token == requestToken && !t.IsAccessToken && t.User != null); + } + + /// <summary> + /// Gets details on the named request token. + /// </summary> + /// <param name="token">The request token.</param> + /// <returns>A description of the token. Never null.</returns> + /// <exception cref="KeyNotFoundException">Thrown if the token cannot be found.</exception> + /// <remarks> + /// It is acceptable for implementations to find the token, see that it has expired, + /// delete it from the database and then throw <see cref="KeyNotFoundException"/>, + /// or alternatively it can return the expired token anyway and the OAuth channel will + /// log and throw the appropriate error. + /// </remarks> + public IServiceProviderRequestToken GetRequestToken(string token) { + try { + return Global.DataContext.IssuedToken.First(tok => !tok.IsAccessToken && tok.Token == token); + } catch (InvalidOperationException) { + throw new KeyNotFoundException(); + } + } + + /// <summary> + /// Gets details on the named access token. + /// </summary> + /// <param name="token">The access token.</param> + /// <returns>A description of the token. Never null.</returns> + /// <exception cref="KeyNotFoundException">Thrown if the token cannot be found.</exception> + /// <remarks> + /// It is acceptable for implementations to find the token, see that it has expired, + /// delete it from the database and then throw <see cref="KeyNotFoundException"/>, + /// or alternatively it can return the expired token anyway and the OAuth channel will + /// log and throw the appropriate error. + /// </remarks> + public IServiceProviderAccessToken GetAccessToken(string token) { + try { + return Global.DataContext.IssuedToken.First(tok => tok.IsAccessToken && tok.Token == token); + } catch (InvalidOperationException) { + throw new KeyNotFoundException(); + } + } + + /// <summary> + /// Persists any changes made to the token. + /// </summary> + /// <param name="token">The token whose properties have been changed.</param> + /// <remarks> + /// This library will invoke this method after making a set + /// of changes to the token as part of a web request to give the host + /// the opportunity to persist those changes to a database. + /// Depending on the object persistence framework the host site uses, + /// this method MAY not need to do anything (if changes made to the token + /// will automatically be saved without any extra handling). + /// </remarks> + public void UpdateToken(IServiceProviderRequestToken token) { + Global.DataContext.SaveChanges(); + } + + #endregion + + #region ITokenManager Members + + /// <summary> + /// Gets the Token Secret given a request or access token. + /// </summary> + /// <param name="token">The request or access token.</param> + /// <returns> + /// The secret associated with the given token. + /// </returns> + /// <exception cref="ArgumentException">Thrown if the secret cannot be found for the given token.</exception> + public string GetTokenSecret(string token) { + try { + return Global.DataContext.IssuedToken.First(t => t.Token == token).TokenSecret; + } catch (InvalidOperationException) { + throw new ArgumentOutOfRangeException(); + } + } + + /// <summary> + /// Stores a newly generated unauthorized request token, secret, and optional + /// application-specific parameters for later recall. + /// </summary> + /// <param name="request">The request message that resulted in the generation of a new unauthorized request token.</param> + /// <param name="response">The response message that includes the unauthorized request token.</param> + /// <exception cref="ArgumentException">Thrown if the consumer key is not registered, or a required parameter was not found in the parameters collection.</exception> + /// <remarks> + /// Request tokens stored by this method SHOULD NOT associate any user account with this token. + /// It usually opens up security holes in your application to do so. Instead, you associate a user + /// account with access tokens (not request tokens) in the <see cref="ExpireRequestTokenAndStoreNewAccessToken"/> + /// method. + /// </remarks> + public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response) { + Consumer consumer; + try { + consumer = Global.DataContext.Consumer.First(c => c.ConsumerKey == request.ConsumerKey); + } catch (InvalidOperationException) { + throw new ArgumentOutOfRangeException(); + } + + var token = new IssuedToken { + Callback = request.Callback, + Consumer = consumer, + CreatedOn = DateTime.Now, + ExpirationDate = DateTime.Now.AddHours(1), + Token = response.Token, + TokenSecret = response.TokenSecret, + }; + Global.DataContext.AddToIssuedToken(token); + Global.DataContext.SaveChanges(); + } + + public void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret) { + var token = Global.DataContext.IssuedToken.First( + t => t.Consumer.ConsumerKey == consumerKey && !t.IsAccessToken && t.Token == requestToken); + + // Repurpose this request token to be our access token. + token.Token = accessToken; + token.TokenSecret = accessTokenSecret; + token.ExpirationDate = null; // currently, our access tokens don't expire + token.IsAccessToken = true; + token.VerificationCode = null; + token.CreatedOn = DateTime.Now; + Global.DataContext.SaveChanges(); + } + + /// <summary> + /// Classifies a token as a request token or an access token. + /// </summary> + /// <param name="token">The token to classify.</param> + /// <returns> + /// Request or Access token, or invalid if the token is not recognized. + /// </returns> + public TokenType GetTokenType(string token) { + IssuedToken tok = Global.DataContext.IssuedToken.FirstOrDefault(t => t.Token == token); + if (tok == null) { + return TokenType.InvalidToken; + } else { + return tok.IsAccessToken ? TokenType.AccessToken : TokenType.RequestToken; + } + } + + #endregion + + /// <summary> + /// Creates a token manager for use when this web site acts as a consumer of + /// another OAuth service provider. + /// </summary> + /// <param name="consumerKey">The consumer key.</param> + /// <param name="consumerSecret">The consumer secret.</param> + /// <returns>The token manager.</returns> + internal static IConsumerTokenManager CreateConsumer(string consumerKey, string consumerSecret) { + if (String.IsNullOrEmpty(consumerKey)) { + throw new ArgumentNullException("consumerKey"); + } + if (consumerSecret == null) { + throw new ArgumentNullException("consumerSecret"); + } + + return new OAuthTokenManager(consumerKey, consumerSecret); + } + + /// <summary> + /// Creates a token manager suitable for this web site acting as an OAuth service provider. + /// </summary> + /// <returns>The token manager.</returns> + internal static IServiceProviderTokenManager CreateServiceProvider() { + return new OAuthTokenManager(); + } + } +} diff --git a/projecttemplates/WebFormsRelyingParty/Model.Consumer.cs b/projecttemplates/WebFormsRelyingParty/Model.Consumer.cs new file mode 100644 index 0000000..20a1ccc --- /dev/null +++ b/projecttemplates/WebFormsRelyingParty/Model.Consumer.cs @@ -0,0 +1,34 @@ +namespace WebFormsRelyingParty { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Security.Cryptography.X509Certificates; + using System.Web; + using DotNetOpenAuth.OAuth; + using DotNetOpenAuth.OAuth.ChannelElements; + + public partial class Consumer : IConsumerDescription { + public VerificationCodeFormat VerificationCodeFormat { + get { return (VerificationCodeFormat)this.VerificationCodeFormatAsInt; } + set { this.VerificationCodeFormatAsInt = (int)value; } + } + + public X509Certificate2 Certificate { + get { return this.X509CertificateAsBinary != null ? new X509Certificate2(this.X509CertificateAsBinary) : null; } + set { this.X509CertificateAsBinary = value != null ? value.RawData : null; } + } + + public Uri Callback { + get { return this.CallbackAsString != null ? new Uri(this.CallbackAsString) : null; } + set { this.CallbackAsString = value != null ? value.AbsoluteUri : null; } + } + + string IConsumerDescription.Secret { + get { return this.ConsumerSecret; } + } + + string IConsumerDescription.Key { + get { return this.ConsumerKey; } + } + } +} diff --git a/projecttemplates/WebFormsRelyingParty/Model.Designer.cs b/projecttemplates/WebFormsRelyingParty/Model.Designer.cs index 321d83b..22d6b7c 100644 --- a/projecttemplates/WebFormsRelyingParty/Model.Designer.cs +++ b/projecttemplates/WebFormsRelyingParty/Model.Designer.cs @@ -11,9 +11,11 @@ [assembly: global::System.Data.Objects.DataClasses.EdmSchemaAttribute()] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "UserRole", "Role", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(WebFormsRelyingParty.Role), "User", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(WebFormsRelyingParty.User))] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "UserAuthenticationToken", "User", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(WebFormsRelyingParty.User), "AuthenticationToken", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(WebFormsRelyingParty.AuthenticationToken))] +[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "FK_IssuedToken_Consumer", "Consumer", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(WebFormsRelyingParty.Consumer), "IssuedTokens", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(WebFormsRelyingParty.IssuedToken))] +[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "FK_IssuedToken_User", "User", global::System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(WebFormsRelyingParty.User), "IssuedTokens", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(WebFormsRelyingParty.IssuedToken))] // Original file name: -// Generation date: 11/9/2009 7:05:56 AM +// Generation date: 11/10/2009 8:32:12 AM namespace WebFormsRelyingParty { @@ -93,6 +95,36 @@ namespace WebFormsRelyingParty } private global::System.Data.Objects.ObjectQuery<AuthenticationToken> _AuthenticationToken; /// <summary> + /// There are no comments for Consumer in the schema. + /// </summary> + public global::System.Data.Objects.ObjectQuery<Consumer> Consumer + { + get + { + if ((this._Consumer == null)) + { + this._Consumer = base.CreateQuery<Consumer>("[Consumer]"); + } + return this._Consumer; + } + } + private global::System.Data.Objects.ObjectQuery<Consumer> _Consumer; + /// <summary> + /// There are no comments for IssuedToken in the schema. + /// </summary> + public global::System.Data.Objects.ObjectQuery<IssuedToken> IssuedToken + { + get + { + if ((this._IssuedToken == null)) + { + this._IssuedToken = base.CreateQuery<IssuedToken>("[IssuedToken]"); + } + return this._IssuedToken; + } + } + private global::System.Data.Objects.ObjectQuery<IssuedToken> _IssuedToken; + /// <summary> /// There are no comments for Role in the schema. /// </summary> public void AddToRole(Role role) @@ -113,6 +145,20 @@ namespace WebFormsRelyingParty { base.AddObject("AuthenticationToken", authenticationToken); } + /// <summary> + /// There are no comments for Consumer in the schema. + /// </summary> + public void AddToConsumer(Consumer consumer) + { + base.AddObject("Consumer", consumer); + } + /// <summary> + /// There are no comments for IssuedToken in the schema. + /// </summary> + public void AddToIssuedToken(IssuedToken issuedToken) + { + base.AddObject("IssuedToken", issuedToken); + } } /// <summary> /// There are no comments for DatabaseModel.AuthenticationToken in the schema. @@ -515,5 +561,549 @@ namespace WebFormsRelyingParty } } } + /// <summary> + /// There are no comments for IssuedToken in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_User", "IssuedTokens")] + [global::System.Xml.Serialization.XmlIgnoreAttribute()] + [global::System.Xml.Serialization.SoapIgnoreAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public global::System.Data.Objects.DataClasses.EntityCollection<IssuedToken> IssuedToken + { + get + { + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<IssuedToken>("DatabaseModel.FK_IssuedToken_User", "IssuedTokens"); + } + set + { + if ((value != null)) + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<IssuedToken>("DatabaseModel.FK_IssuedToken_User", "IssuedTokens", value); + } + } + } + } + /// <summary> + /// There are no comments for DatabaseModel.Consumer in the schema. + /// </summary> + /// <KeyProperties> + /// ConsumerId + /// </KeyProperties> + [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="Consumer")] + [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] + [global::System.Serializable()] + public partial class Consumer : global::System.Data.Objects.DataClasses.EntityObject + { + /// <summary> + /// Create a new Consumer object. + /// </summary> + /// <param name="consumerKey">Initial value of ConsumerKey.</param> + /// <param name="verificationCodeFormatAsInt">Initial value of VerificationCodeFormatAsInt.</param> + /// <param name="verificationCodeLength">Initial value of VerificationCodeLength.</param> + /// <param name="consumerId">Initial value of ConsumerId.</param> + public static Consumer CreateConsumer(string consumerKey, int verificationCodeFormatAsInt, int verificationCodeLength, int consumerId) + { + Consumer consumer = new Consumer(); + consumer.ConsumerKey = consumerKey; + consumer.VerificationCodeFormatAsInt = verificationCodeFormatAsInt; + consumer.VerificationCodeLength = verificationCodeLength; + consumer.ConsumerId = consumerId; + return consumer; + } + /// <summary> + /// There are no comments for Property ConsumerKey in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string ConsumerKey + { + get + { + return this._ConsumerKey; + } + set + { + this.OnConsumerKeyChanging(value); + this.ReportPropertyChanging("ConsumerKey"); + this._ConsumerKey = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); + this.ReportPropertyChanged("ConsumerKey"); + this.OnConsumerKeyChanged(); + } + } + private string _ConsumerKey; + partial void OnConsumerKeyChanging(string value); + partial void OnConsumerKeyChanged(); + /// <summary> + /// There are no comments for Property ConsumerSecret in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string ConsumerSecret + { + get + { + return this._ConsumerSecret; + } + set + { + this.OnConsumerSecretChanging(value); + this.ReportPropertyChanging("ConsumerSecret"); + this._ConsumerSecret = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true); + this.ReportPropertyChanged("ConsumerSecret"); + this.OnConsumerSecretChanged(); + } + } + private string _ConsumerSecret; + partial void OnConsumerSecretChanging(string value); + partial void OnConsumerSecretChanged(); + /// <summary> + /// There are no comments for Property X509CertificateAsBinary in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public byte[] X509CertificateAsBinary + { + get + { + return global::System.Data.Objects.DataClasses.StructuralObject.GetValidValue(this._X509CertificateAsBinary); + } + set + { + this.OnX509CertificateAsBinaryChanging(value); + this.ReportPropertyChanging("X509CertificateAsBinary"); + this._X509CertificateAsBinary = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true); + this.ReportPropertyChanged("X509CertificateAsBinary"); + this.OnX509CertificateAsBinaryChanged(); + } + } + private byte[] _X509CertificateAsBinary; + partial void OnX509CertificateAsBinaryChanging(byte[] value); + partial void OnX509CertificateAsBinaryChanged(); + /// <summary> + /// There are no comments for Property CallbackAsString in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string CallbackAsString + { + get + { + return this._CallbackAsString; + } + set + { + this.OnCallbackAsStringChanging(value); + this.ReportPropertyChanging("CallbackAsString"); + this._CallbackAsString = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true); + this.ReportPropertyChanged("CallbackAsString"); + this.OnCallbackAsStringChanged(); + } + } + private string _CallbackAsString; + partial void OnCallbackAsStringChanging(string value); + partial void OnCallbackAsStringChanged(); + /// <summary> + /// There are no comments for Property VerificationCodeFormatAsInt in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public int VerificationCodeFormatAsInt + { + get + { + return this._VerificationCodeFormatAsInt; + } + set + { + this.OnVerificationCodeFormatAsIntChanging(value); + this.ReportPropertyChanging("VerificationCodeFormatAsInt"); + this._VerificationCodeFormatAsInt = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("VerificationCodeFormatAsInt"); + this.OnVerificationCodeFormatAsIntChanged(); + } + } + private int _VerificationCodeFormatAsInt; + partial void OnVerificationCodeFormatAsIntChanging(int value); + partial void OnVerificationCodeFormatAsIntChanged(); + /// <summary> + /// There are no comments for Property VerificationCodeLength in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public int VerificationCodeLength + { + get + { + return this._VerificationCodeLength; + } + set + { + this.OnVerificationCodeLengthChanging(value); + this.ReportPropertyChanging("VerificationCodeLength"); + this._VerificationCodeLength = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("VerificationCodeLength"); + this.OnVerificationCodeLengthChanged(); + } + } + private int _VerificationCodeLength; + partial void OnVerificationCodeLengthChanging(int value); + partial void OnVerificationCodeLengthChanged(); + /// <summary> + /// There are no comments for Property ConsumerId in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public int ConsumerId + { + get + { + return this._ConsumerId; + } + set + { + this.OnConsumerIdChanging(value); + this.ReportPropertyChanging("ConsumerId"); + this._ConsumerId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("ConsumerId"); + this.OnConsumerIdChanged(); + } + } + private int _ConsumerId; + partial void OnConsumerIdChanging(int value); + partial void OnConsumerIdChanged(); + /// <summary> + /// There are no comments for IssuedToken in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_Consumer", "IssuedTokens")] + [global::System.Xml.Serialization.XmlIgnoreAttribute()] + [global::System.Xml.Serialization.SoapIgnoreAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public global::System.Data.Objects.DataClasses.EntityCollection<IssuedToken> IssuedToken + { + get + { + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<IssuedToken>("DatabaseModel.FK_IssuedToken_Consumer", "IssuedTokens"); + } + set + { + if ((value != null)) + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<IssuedToken>("DatabaseModel.FK_IssuedToken_Consumer", "IssuedTokens", value); + } + } + } + } + /// <summary> + /// There are no comments for DatabaseModel.IssuedToken in the schema. + /// </summary> + /// <KeyProperties> + /// TokenId + /// </KeyProperties> + [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="IssuedToken")] + [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] + [global::System.Serializable()] + public partial class IssuedToken : global::System.Data.Objects.DataClasses.EntityObject + { + /// <summary> + /// Create a new IssuedToken object. + /// </summary> + /// <param name="tokenId">Initial value of TokenId.</param> + /// <param name="token">Initial value of Token.</param> + /// <param name="tokenSecret">Initial value of TokenSecret.</param> + /// <param name="createdOn">Initial value of CreatedOn.</param> + /// <param name="consumerVersionAsString">Initial value of ConsumerVersionAsString.</param> + /// <param name="isAccessToken">Initial value of IsAccessToken.</param> + public static IssuedToken CreateIssuedToken(int tokenId, string token, string tokenSecret, global::System.DateTime createdOn, string consumerVersionAsString, bool isAccessToken) + { + IssuedToken issuedToken = new IssuedToken(); + issuedToken.TokenId = tokenId; + issuedToken.Token = token; + issuedToken.TokenSecret = tokenSecret; + issuedToken.CreatedOn = createdOn; + issuedToken.ConsumerVersionAsString = consumerVersionAsString; + issuedToken.IsAccessToken = isAccessToken; + return issuedToken; + } + /// <summary> + /// There are no comments for Property TokenId in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public int TokenId + { + get + { + return this._TokenId; + } + set + { + this.OnTokenIdChanging(value); + this.ReportPropertyChanging("TokenId"); + this._TokenId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("TokenId"); + this.OnTokenIdChanged(); + } + } + private int _TokenId; + partial void OnTokenIdChanging(int value); + partial void OnTokenIdChanged(); + /// <summary> + /// There are no comments for Property Token in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string Token + { + get + { + return this._Token; + } + set + { + this.OnTokenChanging(value); + this.ReportPropertyChanging("Token"); + this._Token = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); + this.ReportPropertyChanged("Token"); + this.OnTokenChanged(); + } + } + private string _Token; + partial void OnTokenChanging(string value); + partial void OnTokenChanged(); + /// <summary> + /// There are no comments for Property TokenSecret in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string TokenSecret + { + get + { + return this._TokenSecret; + } + set + { + this.OnTokenSecretChanging(value); + this.ReportPropertyChanging("TokenSecret"); + this._TokenSecret = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); + this.ReportPropertyChanged("TokenSecret"); + this.OnTokenSecretChanged(); + } + } + private string _TokenSecret; + partial void OnTokenSecretChanging(string value); + partial void OnTokenSecretChanged(); + /// <summary> + /// There are no comments for Property CreatedOn in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public global::System.DateTime CreatedOn + { + get + { + return this._CreatedOn; + } + set + { + this.OnCreatedOnChanging(value); + this.ReportPropertyChanging("CreatedOn"); + this._CreatedOn = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("CreatedOn"); + this.OnCreatedOnChanged(); + } + } + private global::System.DateTime _CreatedOn; + partial void OnCreatedOnChanging(global::System.DateTime value); + partial void OnCreatedOnChanged(); + /// <summary> + /// There are no comments for Property CallbackAsString in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string CallbackAsString + { + get + { + return this._CallbackAsString; + } + set + { + this.OnCallbackAsStringChanging(value); + this.ReportPropertyChanging("CallbackAsString"); + this._CallbackAsString = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true); + this.ReportPropertyChanged("CallbackAsString"); + this.OnCallbackAsStringChanged(); + } + } + private string _CallbackAsString; + partial void OnCallbackAsStringChanging(string value); + partial void OnCallbackAsStringChanged(); + /// <summary> + /// There are no comments for Property VerificationCode in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string VerificationCode + { + get + { + return this._VerificationCode; + } + set + { + this.OnVerificationCodeChanging(value); + this.ReportPropertyChanging("VerificationCode"); + this._VerificationCode = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true); + this.ReportPropertyChanged("VerificationCode"); + this.OnVerificationCodeChanged(); + } + } + private string _VerificationCode; + partial void OnVerificationCodeChanging(string value); + partial void OnVerificationCodeChanged(); + /// <summary> + /// There are no comments for Property ConsumerVersionAsString in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string ConsumerVersionAsString + { + get + { + return this._ConsumerVersionAsString; + } + set + { + this.OnConsumerVersionAsStringChanging(value); + this.ReportPropertyChanging("ConsumerVersionAsString"); + this._ConsumerVersionAsString = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); + this.ReportPropertyChanged("ConsumerVersionAsString"); + this.OnConsumerVersionAsStringChanged(); + } + } + private string _ConsumerVersionAsString; + partial void OnConsumerVersionAsStringChanging(string value); + partial void OnConsumerVersionAsStringChanged(); + /// <summary> + /// There are no comments for Property ExpirationDate in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public global::System.Nullable<global::System.DateTime> ExpirationDate + { + get + { + return this._ExpirationDate; + } + set + { + this.OnExpirationDateChanging(value); + this.ReportPropertyChanging("ExpirationDate"); + this._ExpirationDate = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("ExpirationDate"); + this.OnExpirationDateChanged(); + } + } + private global::System.Nullable<global::System.DateTime> _ExpirationDate; + partial void OnExpirationDateChanging(global::System.Nullable<global::System.DateTime> value); + partial void OnExpirationDateChanged(); + /// <summary> + /// There are no comments for Property IsAccessToken in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public bool IsAccessToken + { + get + { + return this._IsAccessToken; + } + set + { + this.OnIsAccessTokenChanging(value); + this.ReportPropertyChanging("IsAccessToken"); + this._IsAccessToken = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("IsAccessToken"); + this.OnIsAccessTokenChanged(); + } + } + private bool _IsAccessToken; + partial void OnIsAccessTokenChanging(bool value); + partial void OnIsAccessTokenChanged(); + /// <summary> + /// There are no comments for Consumer in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_Consumer", "Consumer")] + [global::System.Xml.Serialization.XmlIgnoreAttribute()] + [global::System.Xml.Serialization.SoapIgnoreAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public Consumer Consumer + { + get + { + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer").Value; + } + set + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer").Value = value; + } + } + /// <summary> + /// There are no comments for Consumer in the schema. + /// </summary> + [global::System.ComponentModel.BrowsableAttribute(false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public global::System.Data.Objects.DataClasses.EntityReference<Consumer> ConsumerReference + { + get + { + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer"); + } + set + { + if ((value != null)) + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer", value); + } + } + } + /// <summary> + /// There are no comments for User in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "FK_IssuedToken_User", "User")] + [global::System.Xml.Serialization.XmlIgnoreAttribute()] + [global::System.Xml.Serialization.SoapIgnoreAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public User User + { + get + { + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User").Value; + } + set + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User").Value = value; + } + } + /// <summary> + /// There are no comments for User in the schema. + /// </summary> + [global::System.ComponentModel.BrowsableAttribute(false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public global::System.Data.Objects.DataClasses.EntityReference<User> UserReference + { + get + { + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User"); + } + set + { + if ((value != null)) + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User", value); + } + } + } } } diff --git a/projecttemplates/WebFormsRelyingParty/Model.IssuedToken.cs b/projecttemplates/WebFormsRelyingParty/Model.IssuedToken.cs new file mode 100644 index 0000000..11afa50 --- /dev/null +++ b/projecttemplates/WebFormsRelyingParty/Model.IssuedToken.cs @@ -0,0 +1,47 @@ +namespace WebFormsRelyingParty { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using DotNetOpenAuth.OAuth.ChannelElements; + + public partial class IssuedToken : IServiceProviderRequestToken, IServiceProviderAccessToken { + public Uri Callback { + get { return this.CallbackAsString != null ? new Uri(this.CallbackAsString) : null; } + set { this.CallbackAsString = value != null ? value.AbsoluteUri : null; } + } + + string[] IServiceProviderAccessToken.Roles { + get { + List<string> roles = new List<string>(); + + // Include the roles the user who authorized this OAuth token has. + // TODO: code here + + // Always add an extra role to indicate this is an OAuth-authorized request. + // This allows us to deny access to account management pages to OAuth requests. + roles.Add("OAuthToken"); + + return roles.ToArray(); + } + } + + string IServiceProviderAccessToken.Username { + get { + // We don't really have the concept of a single username, but we + // can use any of the authentication tokens instead since that + // is what the rest of the web site expects. + return this.User.AuthenticationTokens.First().ClaimedIdentifier; + } + } + + Version IServiceProviderRequestToken.ConsumerVersion { + get { return this.ConsumerVersionAsString != null ? new Version(this.ConsumerVersionAsString) : null; } + set { this.ConsumerVersionAsString = value != null ? value.ToString() : null; } + } + + string IServiceProviderRequestToken.ConsumerKey { + get { return this.Consumer.ConsumerKey; } + } + } +} diff --git a/projecttemplates/WebFormsRelyingParty/Model.edmx b/projecttemplates/WebFormsRelyingParty/Model.edmx index af72a25..787cc29 100644 --- a/projecttemplates/WebFormsRelyingParty/Model.edmx +++ b/projecttemplates/WebFormsRelyingParty/Model.edmx @@ -7,6 +7,8 @@ <Schema Namespace="DatabaseModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl"> <EntityContainer Name="DatabaseModelStoreContainer"> <EntitySet Name="AuthenticationToken" EntityType="DatabaseModel.Store.AuthenticationToken" store:Type="Tables" Schema="dbo" /> + <EntitySet Name="Consumer" EntityType="DatabaseModel.Store.Consumer" store:Type="Tables" Schema="dbo" /> + <EntitySet Name="IssuedToken" EntityType="DatabaseModel.Store.IssuedToken" store:Type="Tables" Schema="dbo" /> <EntitySet Name="Role" EntityType="DatabaseModel.Store.Role" store:Type="Tables" Schema="dbo" /> <EntitySet Name="User" EntityType="DatabaseModel.Store.User" store:Type="Tables" Schema="dbo" /> <EntitySet Name="UserRole" EntityType="DatabaseModel.Store.UserRole" store:Type="Tables" Schema="dbo" /> @@ -14,6 +16,14 @@ <End Role="User" EntitySet="User" /> <End Role="AuthenticationToken" EntitySet="AuthenticationToken" /> </AssociationSet> + <AssociationSet Name="FK_IssuedToken_Consumer" Association="DatabaseModel.Store.FK_IssuedToken_Consumer"> + <End Role="Consumer" EntitySet="Consumer" /> + <End Role="IssuedToken" EntitySet="IssuedToken" /> + </AssociationSet> + <AssociationSet Name="FK_IssuedToken_User" Association="DatabaseModel.Store.FK_IssuedToken_User"> + <End Role="User" EntitySet="User" /> + <End Role="IssuedToken" EntitySet="IssuedToken" /> + </AssociationSet> <AssociationSet Name="FK_UserRole_Role" Association="DatabaseModel.Store.FK_UserRole_Role"> <End Role="Role" EntitySet="Role" /> <End Role="UserRole" EntitySet="UserRole" /> @@ -32,6 +42,34 @@ <Property Name="OpenIdClaimedIdentifier" Type="nvarchar" Nullable="false" MaxLength="250" /> <Property Name="OpenIdFriendlyIdentifier" Type="nvarchar" MaxLength="250" /> </EntityType> + <EntityType Name="Consumer"> + <Key> + <PropertyRef Name="ConsumerId" /> + </Key> + <Property Name="ConsumerId" Type="int" Nullable="false" /> + <Property Name="ConsumerKey" Type="nvarchar" Nullable="false" MaxLength="255" /> + <Property Name="ConsumerSecret" Type="nvarchar" MaxLength="255" /> + <Property Name="X509Certificate" Type="image" /> + <Property Name="Callback" Type="nvarchar" MaxLength="2048" /> + <Property Name="VerificationCodeFormat" Type="int" Nullable="false" /> + <Property Name="VerificationCodeLength" Type="int" Nullable="false" /> + </EntityType> + <EntityType Name="IssuedToken"> + <Key> + <PropertyRef Name="TokenId" /> + </Key> + <Property Name="TokenId" Type="int" Nullable="false" /> + <Property Name="ConsumerId" Type="int" Nullable="false" /> + <Property Name="UserId" Type="int" /> + <Property Name="Token" Type="nvarchar" Nullable="false" MaxLength="255" /> + <Property Name="TokenSecret" Type="nvarchar" Nullable="false" MaxLength="255" /> + <Property Name="CreatedOn" Type="datetime" Nullable="false" /> + <Property Name="Callback" Type="nvarchar" MaxLength="2048" /> + <Property Name="VerificationCode" Type="nvarchar" MaxLength="255" /> + <Property Name="ConsumerVersion" Type="varchar" MaxLength="10" /> + <Property Name="ExpirationDate" Type="datetime" /> + <Property Name="IsAccessToken" Type="bit" Nullable="false" /> + </EntityType> <EntityType Name="Role"> <Key> <PropertyRef Name="Id" /> @@ -71,6 +109,34 @@ </Dependent> </ReferentialConstraint> </Association> + <Association Name="FK_IssuedToken_Consumer"> + <End Role="Consumer" Type="DatabaseModel.Store.Consumer" Multiplicity="1"> + <OnDelete Action="Cascade" /> + </End> + <End Role="IssuedToken" Type="DatabaseModel.Store.IssuedToken" Multiplicity="*" /> + <ReferentialConstraint> + <Principal Role="Consumer"> + <PropertyRef Name="ConsumerId" /> + </Principal> + <Dependent Role="IssuedToken"> + <PropertyRef Name="ConsumerId" /> + </Dependent> + </ReferentialConstraint> + </Association> + <Association Name="FK_IssuedToken_User"> + <End Role="User" Type="DatabaseModel.Store.User" Multiplicity="0..1"> + <OnDelete Action="Cascade" /> + </End> + <End Role="IssuedToken" Type="DatabaseModel.Store.IssuedToken" Multiplicity="*" /> + <ReferentialConstraint> + <Principal Role="User"> + <PropertyRef Name="Id" /> + </Principal> + <Dependent Role="IssuedToken"> + <PropertyRef Name="UserId" /> + </Dependent> + </ReferentialConstraint> + </Association> <Association Name="FK_UserRole_Role"> <End Role="Role" Type="DatabaseModel.Store.Role" Multiplicity="1"> <OnDelete Action="Cascade" /> @@ -114,7 +180,14 @@ <AssociationSet Name="UserAuthenticationToken" Association="DatabaseModel.UserAuthenticationToken"> <End Role="User" EntitySet="User" /> <End Role="AuthenticationToken" EntitySet="AuthenticationToken" /></AssociationSet> - </EntityContainer> + <EntitySet Name="Consumer" EntityType="DatabaseModel.Consumer" /> + <EntitySet Name="IssuedToken" EntityType="DatabaseModel.IssuedToken" /> + <AssociationSet Name="FK_IssuedToken_Consumer" Association="DatabaseModel.FK_IssuedToken_Consumer"> + <End Role="Consumer" EntitySet="Consumer" /> + <End Role="IssuedTokens" EntitySet="IssuedToken" /></AssociationSet> + <AssociationSet Name="FK_IssuedToken_User" Association="DatabaseModel.FK_IssuedToken_User"> + <End Role="User" EntitySet="User" /> + <End Role="IssuedTokens" EntitySet="IssuedToken" /></AssociationSet></EntityContainer> <EntityType Name="AuthenticationToken" Abstract="false"> <Key> <PropertyRef Name="Id" /></Key> @@ -145,14 +218,45 @@ <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> - </EntityType> + <NavigationProperty Name="IssuedToken" Relationship="DatabaseModel.FK_IssuedToken_User" FromRole="User" ToRole="IssuedTokens" /></EntityType> <Association Name="UserRole"> <End Role="Role" Type="DatabaseModel.Role" Multiplicity="*" /> <End Role="User" Type="DatabaseModel.User" Multiplicity="*" /> </Association> <Association Name="UserAuthenticationToken"> <End Type="DatabaseModel.User" Role="User" Multiplicity="1" /> - <End Type="DatabaseModel.AuthenticationToken" Role="AuthenticationToken" Multiplicity="*" /></Association></Schema> + <End Type="DatabaseModel.AuthenticationToken" Role="AuthenticationToken" Multiplicity="*" /></Association> + <EntityType Name="Consumer"> + <Key> + <PropertyRef Name="ConsumerId" /></Key> + <Property Name="ConsumerKey" Type="String" Nullable="false" /> + <Property Name="ConsumerSecret" Type="String" Nullable="true" /> + <Property Name="X509CertificateAsBinary" Type="Binary" Nullable="true" /> + <Property Name="CallbackAsString" Type="String" Nullable="true" /> + <Property Name="VerificationCodeFormatAsInt" Type="Int32" Nullable="false" /> + <Property Name="VerificationCodeLength" Type="Int32" Nullable="false" /> + <Property Name="ConsumerId" Type="Int32" Nullable="false" /> + <NavigationProperty Name="IssuedToken" Relationship="DatabaseModel.FK_IssuedToken_Consumer" FromRole="Consumer" ToRole="IssuedTokens" /></EntityType> + <EntityType Name="IssuedToken"> + <Key> + <PropertyRef Name="TokenId" /></Key> + <Property Name="TokenId" Type="Int32" Nullable="false" /> + <Property Name="Token" Type="String" Nullable="false" /> + <Property Name="TokenSecret" Type="String" Nullable="false" /> + <Property Name="CreatedOn" Type="DateTime" Nullable="false" /> + <Property Name="CallbackAsString" Type="String" Nullable="true" /> + <Property Name="VerificationCode" Type="String" Nullable="true" /> + <Property Name="ConsumerVersionAsString" Type="String" Nullable="false" /> + <Property Name="ExpirationDate" Type="DateTime" Nullable="true" /> + <Property Name="IsAccessToken" Type="Boolean" Nullable="false" /> + <NavigationProperty Name="Consumer" Relationship="DatabaseModel.FK_IssuedToken_Consumer" FromRole="IssuedTokens" ToRole="Consumer" /> + <NavigationProperty Name="User" Relationship="DatabaseModel.FK_IssuedToken_User" FromRole="IssuedTokens" ToRole="User" /></EntityType> + <Association Name="FK_IssuedToken_Consumer"> + <End Type="DatabaseModel.Consumer" Role="Consumer" Multiplicity="1" /> + <End Type="DatabaseModel.IssuedToken" Role="IssuedTokens" Multiplicity="*" /></Association> + <Association Name="FK_IssuedToken_User"> + <End Type="DatabaseModel.User" Role="User" Multiplicity="0..1" /> + <End Type="DatabaseModel.IssuedToken" Role="IssuedTokens" Multiplicity="*" /></Association></Schema> </edmx:ConceptualModels> <!-- C-S mapping content --> <edmx:Mappings> @@ -198,7 +302,39 @@ <ScalarProperty Name="Id" ColumnName="Id" /></EndProperty> <EndProperty Name="User"> <ScalarProperty Name="Id" ColumnName="UserId" /></EndProperty></AssociationSetMapping> - </EntityContainerMapping> + <EntitySetMapping Name="Consumer"> + <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.Consumer)"> + <MappingFragment StoreEntitySet="Consumer"> + <ScalarProperty Name="ConsumerId" ColumnName="ConsumerId" /> + <ScalarProperty Name="VerificationCodeLength" ColumnName="VerificationCodeLength" /> + <ScalarProperty Name="VerificationCodeFormatAsInt" ColumnName="VerificationCodeFormat" /> + <ScalarProperty Name="CallbackAsString" ColumnName="Callback" /> + <ScalarProperty Name="X509CertificateAsBinary" ColumnName="X509Certificate" /> + <ScalarProperty Name="ConsumerSecret" ColumnName="ConsumerSecret" /> + <ScalarProperty Name="ConsumerKey" ColumnName="ConsumerKey" /></MappingFragment></EntityTypeMapping></EntitySetMapping> + <EntitySetMapping Name="IssuedToken"> + <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.IssuedToken)"> + <MappingFragment StoreEntitySet="IssuedToken"> + <ScalarProperty Name="IsAccessToken" ColumnName="IsAccessToken" /> + <ScalarProperty Name="ExpirationDate" ColumnName="ExpirationDate" /> + <ScalarProperty Name="ConsumerVersionAsString" ColumnName="ConsumerVersion" /> + <ScalarProperty Name="VerificationCode" ColumnName="VerificationCode" /> + <ScalarProperty Name="CallbackAsString" ColumnName="Callback" /> + <ScalarProperty Name="CreatedOn" ColumnName="CreatedOn" /> + <ScalarProperty Name="TokenSecret" ColumnName="TokenSecret" /> + <ScalarProperty Name="Token" ColumnName="Token" /> + <ScalarProperty Name="TokenId" ColumnName="TokenId" /></MappingFragment></EntityTypeMapping></EntitySetMapping> + <AssociationSetMapping Name="FK_IssuedToken_Consumer" TypeName="DatabaseModel.FK_IssuedToken_Consumer" StoreEntitySet="IssuedToken"> + <EndProperty Name="IssuedTokens"> + <ScalarProperty Name="TokenId" ColumnName="TokenId" /></EndProperty> + <EndProperty Name="Consumer"> + <ScalarProperty Name="ConsumerId" ColumnName="ConsumerId" /></EndProperty></AssociationSetMapping> + <AssociationSetMapping Name="FK_IssuedToken_User" TypeName="DatabaseModel.FK_IssuedToken_User" StoreEntitySet="IssuedToken"> + <EndProperty Name="IssuedTokens"> + <ScalarProperty Name="TokenId" ColumnName="TokenId" /></EndProperty> + <EndProperty Name="User"> + <ScalarProperty Name="Id" ColumnName="UserId" /></EndProperty> + <Condition ColumnName="UserId" IsNull="false" /></AssociationSetMapping></EntityContainerMapping> </Mapping> </edmx:Mappings> </edmx:Runtime> @@ -228,6 +364,17 @@ <ConnectorPoint PointX="6.5625" PointY="2.9129850260416665" /></InheritanceConnector> <AssociationConnector Association="DatabaseModel.UserAuthenticationToken"> <ConnectorPoint PointX="4.625" PointY="2.0189925130208337" /> - <ConnectorPoint PointX="5.25" PointY="2.0189925130208337" /></AssociationConnector></Diagram></edmx:Diagrams> + <ConnectorPoint PointX="5.25" PointY="2.0189925130208337" /></AssociationConnector> + <EntityTypeShape EntityType="DatabaseModel.Consumer" Width="2.125" PointX="0.5" PointY="3.625" Height="2.1725878906249996" /> + <EntityTypeShape EntityType="DatabaseModel.IssuedToken" Width="2" PointX="5.375" PointY="3.625" Height="3.1340950520833326" /> + <AssociationConnector Association="DatabaseModel.FK_IssuedToken_Consumer" ManuallyRouted="false" > + <ConnectorPoint PointX="2.625" PointY="4.9035953776041659" /> + <ConnectorPoint PointX="5.375" PointY="4.9035953776041659" /> + </AssociationConnector> + <AssociationConnector Association="DatabaseModel.FK_IssuedToken_User" > + <ConnectorPoint PointX="4.625" PointY="3.2038378906250005" /> + <ConnectorPoint PointX="7.28125" PointY="3.2038378906250005" /> + <ConnectorPoint PointX="7.28125" PointY="3.625" /> + </AssociationConnector></Diagram></edmx:Diagrams> </edmx:Designer> </edmx:Edmx>
\ No newline at end of file diff --git a/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj b/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj index 43bdef4..18ed7a4 100644 --- a/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj +++ b/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj @@ -87,7 +87,10 @@ <Content Include="Web.config" /> </ItemGroup> <ItemGroup> + <Compile Include="Code\OAuthTokenManager.cs" /> <Compile Include="Code\Policies.cs" /> + <Compile Include="Model.IssuedToken.cs" /> + <Compile Include="Model.Consumer.cs" /> <Compile Include="Model.User.cs" /> <Compile Include="LoginFrame.aspx.cs"> <DependentUpon>LoginFrame.aspx</DependentUpon> |