diff options
-rw-r--r-- | projecttemplates/WebFormsRelyingParty/Code/OAuthTokenManager.cs | 33 | ||||
-rw-r--r-- | projecttemplates/WebFormsRelyingParty/Model.Designer.cs | 253 | ||||
-rw-r--r-- | projecttemplates/WebFormsRelyingParty/Model.IssuedAccessToken.cs (renamed from projecttemplates/WebFormsRelyingParty/Model.IssuedToken.cs) | 16 | ||||
-rw-r--r-- | projecttemplates/WebFormsRelyingParty/Model.IssuedRequestToken.cs | 23 | ||||
-rw-r--r-- | projecttemplates/WebFormsRelyingParty/Model.edmx | 60 | ||||
-rw-r--r-- | projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj | 3 |
6 files changed, 217 insertions, 171 deletions
diff --git a/projecttemplates/WebFormsRelyingParty/Code/OAuthTokenManager.cs b/projecttemplates/WebFormsRelyingParty/Code/OAuthTokenManager.cs index 8653fd0..a685b70 100644 --- a/projecttemplates/WebFormsRelyingParty/Code/OAuthTokenManager.cs +++ b/projecttemplates/WebFormsRelyingParty/Code/OAuthTokenManager.cs @@ -88,8 +88,8 @@ namespace WebFormsRelyingParty.Code { /// 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); + return Global.DataContext.IssuedToken.OfType<IssuedRequestToken>().Any( + t => t.Token == requestToken && t.User != null); } /// <summary> @@ -106,7 +106,7 @@ namespace WebFormsRelyingParty.Code { /// </remarks> public IServiceProviderRequestToken GetRequestToken(string token) { try { - return Global.DataContext.IssuedToken.First(tok => !tok.IsAccessToken && tok.Token == token); + return Global.DataContext.IssuedToken.OfType<IssuedRequestToken>().First(tok => tok.Token == token); } catch (InvalidOperationException) { throw new KeyNotFoundException(); } @@ -126,7 +126,7 @@ namespace WebFormsRelyingParty.Code { /// </remarks> public IServiceProviderAccessToken GetAccessToken(string token) { try { - return Global.DataContext.IssuedToken.First(tok => tok.IsAccessToken && tok.Token == token); + return Global.DataContext.IssuedToken.OfType<IssuedAccessToken>().First(tok => tok.Token == token); } catch (InvalidOperationException) { throw new KeyNotFoundException(); } @@ -189,11 +189,10 @@ namespace WebFormsRelyingParty.Code { throw new ArgumentOutOfRangeException(); } - var token = new IssuedToken { + var token = new IssuedRequestToken { Callback = request.Callback, Consumer = consumer, CreatedOn = DateTime.Now, - ExpirationDate = DateTime.Now.AddHours(1), Token = response.Token, TokenSecret = response.TokenSecret, }; @@ -202,16 +201,18 @@ namespace WebFormsRelyingParty.Code { } 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); + var requestTokenEntity = Global.DataContext.IssuedToken.OfType<IssuedRequestToken>().First( + t => t.Consumer.ConsumerKey == consumerKey && t.Token == requestToken); + Global.DataContext.DeleteObject(requestTokenEntity); - // 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; + var accessTokenEntity = new IssuedAccessToken { + Token = accessToken, + TokenSecret = accessTokenSecret, + ExpirationDate = null, // currently, our access tokens don't expire + CreatedOn = DateTime.Now, + }; + + Global.DataContext.AddToIssuedToken(accessTokenEntity); Global.DataContext.SaveChanges(); } @@ -227,7 +228,7 @@ namespace WebFormsRelyingParty.Code { if (tok == null) { return TokenType.InvalidToken; } else { - return tok.IsAccessToken ? TokenType.AccessToken : TokenType.RequestToken; + return tok is IssuedAccessToken ? TokenType.AccessToken : TokenType.RequestToken; } } diff --git a/projecttemplates/WebFormsRelyingParty/Model.Designer.cs b/projecttemplates/WebFormsRelyingParty/Model.Designer.cs index 22d6b7c..95ba3d3 100644 --- a/projecttemplates/WebFormsRelyingParty/Model.Designer.cs +++ b/projecttemplates/WebFormsRelyingParty/Model.Designer.cs @@ -15,7 +15,7 @@ [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/10/2009 8:32:12 AM +// Generation date: 11/10/2009 8:47:09 AM namespace WebFormsRelyingParty { @@ -802,29 +802,11 @@ namespace WebFormsRelyingParty [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 + [global::System.Runtime.Serialization.KnownTypeAttribute(typeof(global::WebFormsRelyingParty.IssuedRequestToken))] + [global::System.Runtime.Serialization.KnownTypeAttribute(typeof(global::WebFormsRelyingParty.IssuedAccessToken))] + public abstract 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)] @@ -917,193 +899,228 @@ namespace WebFormsRelyingParty partial void OnCreatedOnChanging(global::System.DateTime value); partial void OnCreatedOnChanged(); /// <summary> - /// There are no comments for Property CallbackAsString in the schema. + /// There are no comments for Consumer in the schema. /// </summary> - [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [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 string CallbackAsString + public Consumer Consumer { get { - return this._CallbackAsString; + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer").Value; } set { - this.OnCallbackAsStringChanging(value); - this.ReportPropertyChanging("CallbackAsString"); - this._CallbackAsString = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true); - this.ReportPropertyChanged("CallbackAsString"); - this.OnCallbackAsStringChanged(); + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer").Value = value; } } - private string _CallbackAsString; - partial void OnCallbackAsStringChanging(string value); - partial void OnCallbackAsStringChanged(); /// <summary> - /// There are no comments for Property VerificationCode in the schema. + /// There are no comments for Consumer in the schema. /// </summary> - [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.ComponentModel.BrowsableAttribute(false)] [global::System.Runtime.Serialization.DataMemberAttribute()] - public string VerificationCode + public global::System.Data.Objects.DataClasses.EntityReference<Consumer> ConsumerReference { get { - return this._VerificationCode; + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer"); } set { - this.OnVerificationCodeChanging(value); - this.ReportPropertyChanging("VerificationCode"); - this._VerificationCode = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true); - this.ReportPropertyChanged("VerificationCode"); - this.OnVerificationCodeChanged(); + if ((value != null)) + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer", value); + } } } - private string _VerificationCode; - partial void OnVerificationCodeChanging(string value); - partial void OnVerificationCodeChanged(); /// <summary> - /// There are no comments for Property ConsumerVersionAsString in the schema. + /// There are no comments for User in the schema. /// </summary> - [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [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 string ConsumerVersionAsString + public User User { get { - return this._ConsumerVersionAsString; + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User").Value; } set { - this.OnConsumerVersionAsStringChanging(value); - this.ReportPropertyChanging("ConsumerVersionAsString"); - this._ConsumerVersionAsString = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); - this.ReportPropertyChanged("ConsumerVersionAsString"); - this.OnConsumerVersionAsStringChanged(); + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User").Value = value; } } - private string _ConsumerVersionAsString; - partial void OnConsumerVersionAsStringChanging(string value); - partial void OnConsumerVersionAsStringChanged(); /// <summary> - /// There are no comments for Property ExpirationDate in the schema. + /// There are no comments for User in the schema. /// </summary> - [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.ComponentModel.BrowsableAttribute(false)] [global::System.Runtime.Serialization.DataMemberAttribute()] - public global::System.Nullable<global::System.DateTime> ExpirationDate + public global::System.Data.Objects.DataClasses.EntityReference<User> UserReference { get { - return this._ExpirationDate; + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User"); } set { - this.OnExpirationDateChanging(value); - this.ReportPropertyChanging("ExpirationDate"); - this._ExpirationDate = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); - this.ReportPropertyChanged("ExpirationDate"); - this.OnExpirationDateChanged(); + if ((value != null)) + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User", value); + } } } - 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 DatabaseModel.IssuedRequestToken in the schema. + /// </summary> + /// <KeyProperties> + /// TokenId + /// </KeyProperties> + [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="IssuedRequestToken")] + [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] + [global::System.Serializable()] + public partial class IssuedRequestToken : IssuedToken + { + /// <summary> + /// Create a new IssuedRequestToken object. + /// </summary> + /// <param name="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> + public static IssuedRequestToken CreateIssuedRequestToken(int tokenId, string token, string tokenSecret, global::System.DateTime createdOn, string consumerVersionAsString) + { + IssuedRequestToken issuedRequestToken = new IssuedRequestToken(); + issuedRequestToken.TokenId = tokenId; + issuedRequestToken.Token = token; + issuedRequestToken.TokenSecret = tokenSecret; + issuedRequestToken.CreatedOn = createdOn; + issuedRequestToken.ConsumerVersionAsString = consumerVersionAsString; + return issuedRequestToken; + } /// <summary> - /// There are no comments for Property IsAccessToken in the schema. + /// 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 bool IsAccessToken + public string ConsumerVersionAsString { get { - return this._IsAccessToken; + return this._ConsumerVersionAsString; } set { - this.OnIsAccessTokenChanging(value); - this.ReportPropertyChanging("IsAccessToken"); - this._IsAccessToken = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); - this.ReportPropertyChanged("IsAccessToken"); - this.OnIsAccessTokenChanged(); + this.OnConsumerVersionAsStringChanging(value); + this.ReportPropertyChanging("ConsumerVersionAsString"); + this._ConsumerVersionAsString = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); + this.ReportPropertyChanged("ConsumerVersionAsString"); + this.OnConsumerVersionAsStringChanged(); } } - private bool _IsAccessToken; - partial void OnIsAccessTokenChanging(bool value); - partial void OnIsAccessTokenChanged(); + private string _ConsumerVersionAsString; + partial void OnConsumerVersionAsStringChanging(string value); + partial void OnConsumerVersionAsStringChanged(); /// <summary> - /// There are no comments for Consumer in the schema. + /// There are no comments for Property VerificationCode 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.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] - public Consumer Consumer + public string VerificationCode { get { - return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer").Value; + return this._VerificationCode; } set { - ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer").Value = value; + 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 Consumer in the schema. + /// There are no comments for Property CallbackAsString in the schema. /// </summary> - [global::System.ComponentModel.BrowsableAttribute(false)] + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] - public global::System.Data.Objects.DataClasses.EntityReference<Consumer> ConsumerReference + public string CallbackAsString { get { - return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer"); + return this._CallbackAsString; } set { - if ((value != null)) - { - ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Consumer>("DatabaseModel.FK_IssuedToken_Consumer", "Consumer", value); - } + 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 DatabaseModel.IssuedAccessToken in the schema. + /// </summary> + /// <KeyProperties> + /// TokenId + /// </KeyProperties> + [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="IssuedAccessToken")] + [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] + [global::System.Serializable()] + public partial class IssuedAccessToken : IssuedToken + { /// <summary> - /// There are no comments for User in the schema. + /// Create a new IssuedAccessToken object. /// </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 + /// <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> + public static IssuedAccessToken CreateIssuedAccessToken(int tokenId, string token, string tokenSecret, global::System.DateTime createdOn) { - 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; - } + IssuedAccessToken issuedAccessToken = new IssuedAccessToken(); + issuedAccessToken.TokenId = tokenId; + issuedAccessToken.Token = token; + issuedAccessToken.TokenSecret = tokenSecret; + issuedAccessToken.CreatedOn = createdOn; + return issuedAccessToken; } /// <summary> - /// There are no comments for User in the schema. + /// There are no comments for Property ExpirationDate in the schema. /// </summary> - [global::System.ComponentModel.BrowsableAttribute(false)] + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] - public global::System.Data.Objects.DataClasses.EntityReference<User> UserReference + public global::System.Nullable<global::System.DateTime> ExpirationDate { get { - return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User"); + return this._ExpirationDate; } set { - if ((value != null)) - { - ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<User>("DatabaseModel.FK_IssuedToken_User", "User", value); - } + 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(); } } diff --git a/projecttemplates/WebFormsRelyingParty/Model.IssuedToken.cs b/projecttemplates/WebFormsRelyingParty/Model.IssuedAccessToken.cs index 11afa50..ee254ac 100644 --- a/projecttemplates/WebFormsRelyingParty/Model.IssuedToken.cs +++ b/projecttemplates/WebFormsRelyingParty/Model.IssuedAccessToken.cs @@ -5,12 +5,7 @@ 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; } - } - + public partial class IssuedAccessToken : IServiceProviderAccessToken { string[] IServiceProviderAccessToken.Roles { get { List<string> roles = new List<string>(); @@ -34,14 +29,5 @@ 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.IssuedRequestToken.cs b/projecttemplates/WebFormsRelyingParty/Model.IssuedRequestToken.cs new file mode 100644 index 0000000..08378de --- /dev/null +++ b/projecttemplates/WebFormsRelyingParty/Model.IssuedRequestToken.cs @@ -0,0 +1,23 @@ +namespace WebFormsRelyingParty { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using DotNetOpenAuth.OAuth.ChannelElements; + + public partial class IssuedRequestToken : IServiceProviderRequestToken { + public Uri Callback { + get { return this.CallbackAsString != null ? new Uri(this.CallbackAsString) : null; } + set { this.CallbackAsString = value != null ? value.AbsoluteUri : null; } + } + + 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 787cc29..d2eed5a 100644 --- a/projecttemplates/WebFormsRelyingParty/Model.edmx +++ b/projecttemplates/WebFormsRelyingParty/Model.edmx @@ -187,7 +187,8 @@ <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> + <End Role="IssuedTokens" EntitySet="IssuedToken" /></AssociationSet> + </EntityContainer> <EntityType Name="AuthenticationToken" Abstract="false"> <Key> <PropertyRef Name="Id" /></Key> @@ -237,18 +238,13 @@ <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"> + <EntityType Name="IssuedToken" Abstract="true"> <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"> @@ -256,7 +252,13 @@ <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> + <End Type="DatabaseModel.IssuedToken" Role="IssuedTokens" Multiplicity="*" /></Association> + <EntityType Name="IssuedRequestToken" BaseType="DatabaseModel.IssuedToken"> + <Property Name="ConsumerVersionAsString" Type="String" Nullable="false" /> + <Property Name="VerificationCode" Type="String" Nullable="true" /> + <Property Name="CallbackAsString" Type="String" Nullable="true" /></EntityType> + <EntityType Name="IssuedAccessToken" BaseType="DatabaseModel.IssuedToken"> + <Property Name="ExpirationDate" Type="DateTime" Nullable="true" /></EntityType></Schema> </edmx:ConceptualModels> <!-- C-S mapping content --> <edmx:Mappings> @@ -315,15 +317,22 @@ <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> + <ScalarProperty Name="TokenId" ColumnName="TokenId" /></MappingFragment></EntityTypeMapping> + <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.IssuedRequestToken)"> + <MappingFragment StoreEntitySet="IssuedToken" > + <ScalarProperty Name="CallbackAsString" ColumnName="Callback" /> + <ScalarProperty Name="ConsumerVersionAsString" ColumnName="ConsumerVersion" /> + <ScalarProperty Name="VerificationCode" ColumnName="VerificationCode" /> + <ScalarProperty Name="TokenId" ColumnName="TokenId" /> + <Condition ColumnName="IsAccessToken" Value="0" /></MappingFragment></EntityTypeMapping> + <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.IssuedAccessToken)"> + <MappingFragment StoreEntitySet="IssuedToken" > + <ScalarProperty Name="ExpirationDate" ColumnName="ExpirationDate" /> + <ScalarProperty Name="TokenId" ColumnName="TokenId" /> + <Condition ColumnName="IsAccessToken" Value="1" /></MappingFragment></EntityTypeMapping></EntitySetMapping> <AssociationSetMapping Name="FK_IssuedToken_Consumer" TypeName="DatabaseModel.FK_IssuedToken_Consumer" StoreEntitySet="IssuedToken"> <EndProperty Name="IssuedTokens"> <ScalarProperty Name="TokenId" ColumnName="TokenId" /></EndProperty> @@ -366,15 +375,24 @@ <ConnectorPoint PointX="4.625" PointY="2.0189925130208337" /> <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" /> + <EntityTypeShape EntityType="DatabaseModel.IssuedToken" Width="2" PointX="4.5" PointY="3.625" Height="2.1725878906249996" /> <AssociationConnector Association="DatabaseModel.FK_IssuedToken_Consumer" ManuallyRouted="false" > - <ConnectorPoint PointX="2.625" PointY="4.9035953776041659" /> - <ConnectorPoint PointX="5.375" PointY="4.9035953776041659" /> + <ConnectorPoint PointX="2.625" PointY="5.359375" /> + <ConnectorPoint PointX="4.5" PointY="5.359375" /> </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> + <ConnectorPoint PointX="3.6874995" PointY="3.4321907552083331" /> + <ConnectorPoint PointX="3.6874995" PointY="4.005208333333333" /> + <ConnectorPoint PointX="4.5" PointY="4.005208333333333" /> + </AssociationConnector> + <EntityTypeShape EntityType="DatabaseModel.IssuedRequestToken" Width="2" PointX="4.25" PointY="6.25" Height="1.5956835937499996" /> + <EntityTypeShape EntityType="DatabaseModel.IssuedAccessToken" Width="1.625" PointX="6.5" PointY="6.25" Height="1.2110807291666657" /> + <InheritanceConnector EntityType="DatabaseModel.IssuedRequestToken"> + <ConnectorPoint PointX="5.375" PointY="5.797587890625" /> + <ConnectorPoint PointX="5.375" PointY="6.25" /></InheritanceConnector> + <InheritanceConnector EntityType="DatabaseModel.IssuedAccessToken"> + <ConnectorPoint PointX="6.5" PointY="4.7112939453125" /> + <ConnectorPoint PointX="7.34375" PointY="4.7112939453125" /> + <ConnectorPoint PointX="7.34375" PointY="6.25" /></InheritanceConnector></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 18ed7a4..23ae988 100644 --- a/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj +++ b/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj @@ -89,7 +89,8 @@ <ItemGroup> <Compile Include="Code\OAuthTokenManager.cs" /> <Compile Include="Code\Policies.cs" /> - <Compile Include="Model.IssuedToken.cs" /> + <Compile Include="Model.IssuedRequestToken.cs" /> + <Compile Include="Model.IssuedAccessToken.cs" /> <Compile Include="Model.Consumer.cs" /> <Compile Include="Model.User.cs" /> <Compile Include="LoginFrame.aspx.cs"> |