diff options
21 files changed, 483 insertions, 572 deletions
diff --git a/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlsettings b/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlsettings index 5f3b26c..f83aff5 100644 --- a/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlsettings +++ b/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlsettings @@ -38,9 +38,10 @@ <Recovery>SIMPLE</Recovery> <RecursiveTriggersEnabled>False</RecursiveTriggersEnabled> <ServiceBrokerOption>DisableBroker</ServiceBrokerOption> + <SupplementalLoggingOn>False</SupplementalLoggingOn> <TornPageDetection>False</TornPageDetection> <Trustworthy>False</Trustworthy> <UpdateOptions>READ_WRITE</UpdateOptions> - <VardecimalStorageFormatOn>False</VardecimalStorageFormatOn> + <VardecimalStorageFormatOn>True</VardecimalStorageFormatOn> </Properties> </CatalogProperties>
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj b/projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj index 3df061c..4743bc3 100644 --- a/projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj +++ b/projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj @@ -200,9 +200,6 @@ <Build Include="Schema Objects\Schemas\dbo\Tables\Indexes\IX_Nonce_Expires.index.sql"> <SubType>Code</SubType> </Build> - <Build Include="Schema Objects\Schemas\dbo\Tables\Indexes\IX_OpenIDAssociations.index.sql"> - <SubType>Code</SubType> - </Build> <Build Include="Schema Objects\Schemas\dbo\Tables\IssuedToken.table.sql"> <SubType>Code</SubType> <AnsiNulls>On</AnsiNulls> @@ -235,9 +232,6 @@ <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_Nonce.pkey.sql"> <SubType>Code</SubType> </Build> - <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_OpenIDAssociations.pkey.sql"> - <SubType>Code</SubType> - </Build> <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_Role.pkey.sql"> <SubType>Code</SubType> </Build> @@ -255,11 +249,6 @@ <AnsiNulls>On</AnsiNulls> <QuotedIdentifier>On</QuotedIdentifier> </Build> - <Build Include="Schema Objects\Schemas\dbo\Tables\OpenIDAssociation.table.sql"> - <SubType>Code</SubType> - <AnsiNulls>On</AnsiNulls> - <QuotedIdentifier>On</QuotedIdentifier> - </Build> <Build Include="Schema Objects\Schemas\dbo\Tables\Role.table.sql"> <SubType>Code</SubType> <AnsiNulls>On</AnsiNulls> @@ -319,6 +308,17 @@ <AnsiNulls>On</AnsiNulls> <QuotedIdentifier>On</QuotedIdentifier> </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Indexes\IX_CryptoKeys.index.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_CryptoKeys.pkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\CryptoKey.table.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> -</Project> +</Project>
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/CryptoKey.table.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/CryptoKey.table.sql new file mode 100644 index 0000000..a5af46c --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/CryptoKey.table.sql @@ -0,0 +1,10 @@ +CREATE TABLE [dbo].[CryptoKey] ( + [CryptoKeyId] INT IDENTITY (1, 1) NOT NULL, + [Bucket] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [Handle] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [Expiration] DATETIME NOT NULL, + [Secret] VARBINARY (4096) NOT NULL +); + + + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_CryptoKeys.index.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_CryptoKeys.index.sql new file mode 100644 index 0000000..bd8876e --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_CryptoKeys.index.sql @@ -0,0 +1,4 @@ +CREATE UNIQUE NONCLUSTERED INDEX [IX_CryptoKeys] + ON [dbo].[CryptoKey]([Bucket] ASC, [Handle] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0) + ON [PRIMARY]; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_OpenIDAssociations.index.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_OpenIDAssociations.index.sql deleted file mode 100644 index 83fd9f4..0000000 --- a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_OpenIDAssociations.index.sql +++ /dev/null @@ -1,3 +0,0 @@ -CREATE UNIQUE NONCLUSTERED INDEX [IX_OpenIDAssociations] - ON [dbo].[OpenIDAssociation]([ProviderEndpoint] ASC, [AssociationHandle] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); - diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_CryptoKeys.pkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_CryptoKeys.pkey.sql new file mode 100644 index 0000000..ebe7f67 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_CryptoKeys.pkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[CryptoKey] + ADD CONSTRAINT [PK_CryptoKeys] PRIMARY KEY CLUSTERED ([CryptoKeyId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_OpenIDAssociations.pkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_OpenIDAssociations.pkey.sql deleted file mode 100644 index cdadaf7..0000000 --- a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_OpenIDAssociations.pkey.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE [dbo].[OpenIDAssociation] - ADD CONSTRAINT [PK_OpenIDAssociations] PRIMARY KEY CLUSTERED ([AssociationId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); - diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/OpenIDAssociation.table.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/OpenIDAssociation.table.sql deleted file mode 100644 index 520a21e..0000000 --- a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/OpenIDAssociation.table.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE [dbo].[OpenIDAssociation] ( - [AssociationId] INT IDENTITY (1, 1) NOT NULL, - [ProviderEndpoint] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [AssociationHandle] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [Expiration] DATETIME NOT NULL, - [PrivateData] BINARY (64) NOT NULL, - [PrivateDataLength] INT NOT NULL -); - diff --git a/projecttemplates/RelyingPartyLogic/Model.Designer.cs b/projecttemplates/RelyingPartyLogic/Model.Designer.cs index c29bd96..1169aa2 100644 --- a/projecttemplates/RelyingPartyLogic/Model.Designer.cs +++ b/projecttemplates/RelyingPartyLogic/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.One, typeof(RelyingPartyLogic.User), "ClientAuthorization", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RelyingPartyLogic.ClientAuthorization))] // Original file name: -// Generation date: 5/10/2011 6:33:00 AM +// Generation date: 5/15/2011 5:33:40 PM namespace RelyingPartyLogic { @@ -118,23 +118,6 @@ namespace RelyingPartyLogic [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] private global::System.Data.Objects.ObjectQuery<Nonce> _Nonces; /// <summary> - /// There are no comments for OpenIdAssociations in the schema. - /// </summary> - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - public global::System.Data.Objects.ObjectQuery<OpenIdAssociation> OpenIdAssociations - { - get - { - if ((this._OpenIdAssociations == null)) - { - this._OpenIdAssociations = base.CreateQuery<OpenIdAssociation>("[OpenIdAssociations]"); - } - return this._OpenIdAssociations; - } - } - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - private global::System.Data.Objects.ObjectQuery<OpenIdAssociation> _OpenIdAssociations; - /// <summary> /// There are no comments for Clients in the schema. /// </summary> [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] @@ -169,6 +152,23 @@ namespace RelyingPartyLogic [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] private global::System.Data.Objects.ObjectQuery<ClientAuthorization> _ClientAuthorizations; /// <summary> + /// There are no comments for SymmetricCryptoKeys in the schema. + /// </summary> + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + public global::System.Data.Objects.ObjectQuery<SymmetricCryptoKey> SymmetricCryptoKeys + { + get + { + if ((this._SymmetricCryptoKeys == null)) + { + this._SymmetricCryptoKeys = base.CreateQuery<SymmetricCryptoKey>("[SymmetricCryptoKeys]"); + } + return this._SymmetricCryptoKeys; + } + } + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + private global::System.Data.Objects.ObjectQuery<SymmetricCryptoKey> _SymmetricCryptoKeys; + /// <summary> /// There are no comments for Roles in the schema. /// </summary> [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] @@ -201,14 +201,6 @@ namespace RelyingPartyLogic base.AddObject("Nonces", nonce); } /// <summary> - /// There are no comments for OpenIdAssociations in the schema. - /// </summary> - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - public void AddToOpenIdAssociations(OpenIdAssociation openIdAssociation) - { - base.AddObject("OpenIdAssociations", openIdAssociation); - } - /// <summary> /// There are no comments for Clients in the schema. /// </summary> [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] @@ -224,6 +216,14 @@ namespace RelyingPartyLogic { base.AddObject("ClientAuthorizations", clientAuthorization); } + /// <summary> + /// There are no comments for SymmetricCryptoKeys in the schema. + /// </summary> + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + public void AddToSymmetricCryptoKeys(SymmetricCryptoKey symmetricCryptoKey) + { + base.AddObject("SymmetricCryptoKeys", symmetricCryptoKey); + } } /// <summary> /// There are no comments for DatabaseModel.AuthenticationToken in the schema. @@ -980,201 +980,6 @@ namespace RelyingPartyLogic partial void OnExpiresUtcChanged(); } /// <summary> - /// There are no comments for DatabaseModel.OpenIdAssociation in the schema. - /// </summary> - /// <KeyProperties> - /// AssociationId - /// </KeyProperties> - [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="OpenIdAssociation")] - [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] - [global::System.Serializable()] - public partial class OpenIdAssociation : global::System.Data.Objects.DataClasses.EntityObject - { - /// <summary> - /// Create a new OpenIdAssociation object. - /// </summary> - /// <param name="associationId">Initial value of AssociationId.</param> - /// <param name="providerEndpoint">Initial value of ProviderEndpoint.</param> - /// <param name="associationHandle">Initial value of AssociationHandle.</param> - /// <param name="expirationUtc">Initial value of ExpirationUtc.</param> - /// <param name="privateData">Initial value of PrivateData.</param> - /// <param name="privateDataLength">Initial value of PrivateDataLength.</param> - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - public static OpenIdAssociation CreateOpenIdAssociation(int associationId, string providerEndpoint, string associationHandle, global::System.DateTime expirationUtc, byte[] privateData, int privateDataLength) - { - OpenIdAssociation openIdAssociation = new OpenIdAssociation(); - openIdAssociation.AssociationId = associationId; - openIdAssociation.ProviderEndpoint = providerEndpoint; - openIdAssociation.AssociationHandle = associationHandle; - openIdAssociation.ExpirationUtc = expirationUtc; - openIdAssociation.PrivateData = privateData; - openIdAssociation.PrivateDataLength = privateDataLength; - return openIdAssociation; - } - /// <summary> - /// There are no comments for property AssociationId in the schema. - /// </summary> - [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] - [global::System.Runtime.Serialization.DataMemberAttribute()] - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - public int AssociationId - { - get - { - return this._AssociationId; - } - set - { - this.OnAssociationIdChanging(value); - this.ReportPropertyChanging("AssociationId"); - this._AssociationId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); - this.ReportPropertyChanged("AssociationId"); - this.OnAssociationIdChanged(); - } - } - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - private int _AssociationId; - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnAssociationIdChanging(int value); - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnAssociationIdChanged(); - /// <summary> - /// Gets or sets the Provider Endpoint URL the association is with. - /// </summary> - [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] - [global::System.Runtime.Serialization.DataMemberAttribute()] - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - public string ProviderEndpoint - { - get - { - return this._ProviderEndpoint; - } - set - { - this.OnProviderEndpointChanging(value); - this.ReportPropertyChanging("ProviderEndpoint"); - this._ProviderEndpoint = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); - this.ReportPropertyChanged("ProviderEndpoint"); - this.OnProviderEndpointChanged(); - } - } - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - private string _ProviderEndpoint; - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnProviderEndpointChanging(string value); - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnProviderEndpointChanged(); - /// <summary> - /// There are no comments for property AssociationHandle in the schema. - /// </summary> - [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] - [global::System.Runtime.Serialization.DataMemberAttribute()] - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - public string AssociationHandle - { - get - { - return this._AssociationHandle; - } - set - { - this.OnAssociationHandleChanging(value); - this.ReportPropertyChanging("AssociationHandle"); - this._AssociationHandle = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); - this.ReportPropertyChanged("AssociationHandle"); - this.OnAssociationHandleChanged(); - } - } - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - private string _AssociationHandle; - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnAssociationHandleChanging(string value); - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnAssociationHandleChanged(); - /// <summary> - /// There are no comments for property ExpirationUtc in the schema. - /// </summary> - [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] - [global::System.Runtime.Serialization.DataMemberAttribute()] - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - public global::System.DateTime ExpirationUtc - { - get - { - return this._ExpirationUtc; - } - set - { - this.OnExpirationUtcChanging(value); - this.ReportPropertyChanging("ExpirationUtc"); - this._ExpirationUtc = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); - this.ReportPropertyChanged("ExpirationUtc"); - this.OnExpirationUtcChanged(); - } - } - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - private global::System.DateTime _ExpirationUtc; - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnExpirationUtcChanging(global::System.DateTime value); - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnExpirationUtcChanged(); - /// <summary> - /// There are no comments for property PrivateData in the schema. - /// </summary> - [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] - [global::System.Runtime.Serialization.DataMemberAttribute()] - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - public byte[] PrivateData - { - get - { - return global::System.Data.Objects.DataClasses.StructuralObject.GetValidValue(this._PrivateData); - } - set - { - this.OnPrivateDataChanging(value); - this.ReportPropertyChanging("PrivateData"); - this._PrivateData = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); - this.ReportPropertyChanged("PrivateData"); - this.OnPrivateDataChanged(); - } - } - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - private byte[] _PrivateData; - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnPrivateDataChanging(byte[] value); - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnPrivateDataChanged(); - /// <summary> - /// There are no comments for property PrivateDataLength in the schema. - /// </summary> - [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] - [global::System.Runtime.Serialization.DataMemberAttribute()] - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - public int PrivateDataLength - { - get - { - return this._PrivateDataLength; - } - set - { - this.OnPrivateDataLengthChanging(value); - this.ReportPropertyChanging("PrivateDataLength"); - this._PrivateDataLength = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); - this.ReportPropertyChanged("PrivateDataLength"); - this.OnPrivateDataLengthChanged(); - } - } - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - private int _PrivateDataLength; - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnPrivateDataLengthChanging(int value); - [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] - partial void OnPrivateDataLengthChanged(); - } - /// <summary> /// There are no comments for DatabaseModel.Client in the schema. /// </summary> /// <KeyProperties> @@ -1569,4 +1374,170 @@ namespace RelyingPartyLogic } } } + /// <summary> + /// There are no comments for DatabaseModel.SymmetricCryptoKey in the schema. + /// </summary> + /// <KeyProperties> + /// CryptoKeyId + /// </KeyProperties> + [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="SymmetricCryptoKey")] + [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] + [global::System.Serializable()] + public partial class SymmetricCryptoKey : global::System.Data.Objects.DataClasses.EntityObject + { + /// <summary> + /// Create a new SymmetricCryptoKey object. + /// </summary> + /// <param name="cryptoKeyId">Initial value of CryptoKeyId.</param> + /// <param name="bucket">Initial value of Bucket.</param> + /// <param name="handle">Initial value of Handle.</param> + /// <param name="expirationUtc">Initial value of ExpirationUtc.</param> + /// <param name="secret">Initial value of Secret.</param> + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + public static SymmetricCryptoKey CreateSymmetricCryptoKey(int cryptoKeyId, string bucket, string handle, global::System.DateTime expirationUtc, byte[] secret) + { + SymmetricCryptoKey symmetricCryptoKey = new SymmetricCryptoKey(); + symmetricCryptoKey.CryptoKeyId = cryptoKeyId; + symmetricCryptoKey.Bucket = bucket; + symmetricCryptoKey.Handle = handle; + symmetricCryptoKey.ExpirationUtc = expirationUtc; + symmetricCryptoKey.Secret = secret; + return symmetricCryptoKey; + } + /// <summary> + /// There are no comments for property CryptoKeyId in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + public int CryptoKeyId + { + get + { + return this._CryptoKeyId; + } + set + { + this.OnCryptoKeyIdChanging(value); + this.ReportPropertyChanging("CryptoKeyId"); + this._CryptoKeyId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("CryptoKeyId"); + this.OnCryptoKeyIdChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + private int _CryptoKeyId; + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + partial void OnCryptoKeyIdChanging(int value); + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + partial void OnCryptoKeyIdChanged(); + /// <summary> + /// There are no comments for property Bucket in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + public string Bucket + { + get + { + return this._Bucket; + } + set + { + this.OnBucketChanging(value); + this.ReportPropertyChanging("Bucket"); + this._Bucket = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); + this.ReportPropertyChanged("Bucket"); + this.OnBucketChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + private string _Bucket; + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + partial void OnBucketChanging(string value); + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + partial void OnBucketChanged(); + /// <summary> + /// There are no comments for property Handle in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + public string Handle + { + get + { + return this._Handle; + } + set + { + this.OnHandleChanging(value); + this.ReportPropertyChanging("Handle"); + this._Handle = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); + this.ReportPropertyChanged("Handle"); + this.OnHandleChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + private string _Handle; + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + partial void OnHandleChanging(string value); + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + partial void OnHandleChanged(); + /// <summary> + /// There are no comments for property ExpirationUtc in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + public global::System.DateTime ExpirationUtc + { + get + { + return this._ExpirationUtc; + } + set + { + this.OnExpirationUtcChanging(value); + this.ReportPropertyChanging("ExpirationUtc"); + this._ExpirationUtc = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("ExpirationUtc"); + this.OnExpirationUtcChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + private global::System.DateTime _ExpirationUtc; + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + partial void OnExpirationUtcChanging(global::System.DateTime value); + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + partial void OnExpirationUtcChanged(); + /// <summary> + /// There are no comments for property Secret in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + public byte[] Secret + { + get + { + return global::System.Data.Objects.DataClasses.StructuralObject.GetValidValue(this._Secret); + } + set + { + this.OnSecretChanging(value); + this.ReportPropertyChanging("Secret"); + this._Secret = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); + this.ReportPropertyChanged("Secret"); + this.OnSecretChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + private byte[] _Secret; + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + partial void OnSecretChanging(byte[] value); + [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")] + partial void OnSecretChanged(); + } } diff --git a/projecttemplates/RelyingPartyLogic/Model.OpenIdAssociation.cs b/projecttemplates/RelyingPartyLogic/Model.OpenIdAssociation.cs deleted file mode 100644 index 94ab09a..0000000 --- a/projecttemplates/RelyingPartyLogic/Model.OpenIdAssociation.cs +++ /dev/null @@ -1,18 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="Model.OpenIdAssociation.cs" company="Andrew Arnott"> -// Copyright (c) Andrew Arnott. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace RelyingPartyLogic { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - - public partial class OpenIdAssociation { - partial void OnPrivateDataChanged() { - this.PrivateDataLength = this.PrivateData.Length; - } - } -} diff --git a/projecttemplates/RelyingPartyLogic/Model.edmx b/projecttemplates/RelyingPartyLogic/Model.edmx index 7a52358..5968b03 100644 --- a/projecttemplates/RelyingPartyLogic/Model.edmx +++ b/projecttemplates/RelyingPartyLogic/Model.edmx @@ -9,8 +9,8 @@ <EntitySet Name="AuthenticationToken" EntityType="DatabaseModel.Store.AuthenticationToken" store:Type="Tables" Schema="dbo" /> <EntitySet Name="Client" EntityType="DatabaseModel.Store.Client" store:Type="Tables" Schema="dbo" /> <EntitySet Name="ClientAuthorization" EntityType="DatabaseModel.Store.ClientAuthorization" store:Type="Tables" Schema="dbo" /> + <EntitySet Name="CryptoKey" EntityType="DatabaseModel.Store.CryptoKey" store:Type="Tables" Schema="dbo" /> <EntitySet Name="Nonce" EntityType="DatabaseModel.Store.Nonce" store:Type="Tables" Schema="dbo" /> - <EntitySet Name="OpenIDAssociation" EntityType="DatabaseModel.Store.OpenIDAssociation" store:Type="Tables" Schema="dbo" /> <EntitySet Name="Role" EntityType="DatabaseModel.Store.Role" store:Type="Tables" Schema="dbo" /> <EntitySet Name="User" EntityType="DatabaseModel.Store.User" store:Type="Tables" Schema="dbo" /> <EntitySet Name="UserRole" EntityType="DatabaseModel.Store.UserRole" store:Type="Tables" Schema="dbo" /> @@ -68,6 +68,16 @@ <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" /> @@ -78,17 +88,6 @@ <Property Name="Issued" Type="datetime" Nullable="false" /> <Property Name="Expires" Type="datetime" Nullable="false" /> </EntityType> - <EntityType Name="OpenIDAssociation"> - <Key> - <PropertyRef Name="AssociationId" /> - </Key> - <Property Name="AssociationId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" /> - <Property Name="ProviderEndpoint" Type="varchar" Nullable="false" MaxLength="255" /> - <Property Name="AssociationHandle" Type="varchar" Nullable="false" MaxLength="255" /> - <Property Name="Expiration" Type="datetime" Nullable="false" /> - <Property Name="PrivateData" Type="binary" Nullable="false" MaxLength="64" /> - <Property Name="PrivateDataLength" Type="int" Nullable="false" /> - </EntityType> <EntityType Name="Role"> <Key> <PropertyRef Name="RoleId" /> @@ -203,7 +202,6 @@ <End Role="User" EntitySet="Users" /> <End Role="AuthenticationToken" EntitySet="AuthenticationTokens" /></AssociationSet> <EntitySet Name="Nonces" EntityType="DatabaseModel.Nonce" /> - <EntitySet Name="OpenIdAssociations" EntityType="DatabaseModel.OpenIdAssociation" /> <FunctionImport Name="ClearExpiredNonces" /> <EntitySet Name="Clients" EntityType="DatabaseModel.Client" /> <EntitySet Name="ClientAuthorizations" EntityType="DatabaseModel.ClientAuthorization" /> @@ -215,6 +213,7 @@ <End Role="User" EntitySet="Users" /> <End Role="ClientAuthorization" EntitySet="ClientAuthorizations" /> </AssociationSet> + <EntitySet Name="SymmetricCryptoKeys" EntityType="DatabaseModel.SymmetricCryptoKey" /> </EntityContainer> <EntityType Name="AuthenticationToken" Abstract="false"> <Key> @@ -265,18 +264,6 @@ <Property Name="Code" Type="String" Nullable="false" /> <Property Name="IssuedUtc" Type="DateTime" Nullable="false" /> <Property Name="ExpiresUtc" Type="DateTime" Nullable="false" /></EntityType> - <EntityType Name="OpenIdAssociation" a:TypeAccess="Public" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration"> - <Key> - <PropertyRef Name="AssociationId" /></Key> - <Property Name="AssociationId" Type="Int32" Nullable="false" /> - <Property Name="ProviderEndpoint" Type="String" Nullable="false" FixedLength="false" MaxLength="255" Unicode="false"> - <Documentation> - <Summary>Gets or sets the Provider Endpoint URL the association is with.</Summary></Documentation></Property> - <Property Name="AssociationHandle" Type="String" Nullable="false" /> - <Property Name="ExpirationUtc" Type="DateTime" Nullable="false" /> - <Property Name="PrivateData" Type="Binary" Nullable="false" /> - <Property Name="PrivateDataLength" Type="Int32" Nullable="false" /> - </EntityType> <EntityType Name="Client"> <Key> <PropertyRef Name="ClientId" /> @@ -306,7 +293,17 @@ <Association Name="FK_IssuedToken_User"> <End Type="DatabaseModel.User" Role="User" Multiplicity="1" /> <End Type="DatabaseModel.ClientAuthorization" Role="ClientAuthorization" Multiplicity="*" /> - </Association></Schema> + </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> @@ -362,15 +359,6 @@ <ScalarProperty Name="Code" ColumnName="Code" /> <ScalarProperty Name="Context" ColumnName="Context" /> <ScalarProperty Name="NonceId" ColumnName="NonceId" /></MappingFragment></EntityTypeMapping></EntitySetMapping> - <EntitySetMapping Name="OpenIdAssociations"> - <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.OpenIdAssociation)"> - <MappingFragment StoreEntitySet="OpenIDAssociation"> - <ScalarProperty Name="ProviderEndpoint" ColumnName="ProviderEndpoint" /> - <ScalarProperty Name="PrivateDataLength" ColumnName="PrivateDataLength" /> - <ScalarProperty Name="PrivateData" ColumnName="PrivateData" /> - <ScalarProperty Name="ExpirationUtc" ColumnName="Expiration" /> - <ScalarProperty Name="AssociationHandle" ColumnName="AssociationHandle" /> - <ScalarProperty Name="AssociationId" ColumnName="AssociationId" /></MappingFragment></EntityTypeMapping></EntitySetMapping> <FunctionImportMapping FunctionImportName="ClearExpiredNonces" FunctionName="DatabaseModel.Store.ClearExpiredNonces" /> <EntitySetMapping Name="Clients"> <EntityTypeMapping TypeName="DatabaseModel.Client"> @@ -408,7 +396,18 @@ <EndProperty Name="User"> <ScalarProperty Name="UserId" ColumnName="UserId" /> </EndProperty> - </AssociationSetMapping></EntityContainerMapping> + </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> @@ -441,8 +440,7 @@ <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.375" PointY="0.75" Height="1.9802864583333326" /> - <EntityTypeShape EntityType="DatabaseModel.OpenIdAssociation" Width="1.75" PointX="7.375" PointY="0.75" Height="2.172587890625" /> + <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.1725878906249996" /> <EntityTypeShape EntityType="DatabaseModel.ClientAuthorization" Width="1.75" PointX="2.875" PointY="3.75" Height="2.1725878906250031" /> <AssociationConnector Association="DatabaseModel.FK_IssuedToken_Consumer" > @@ -452,6 +450,7 @@ <AssociationConnector Association="DatabaseModel.FK_IssuedToken_User" > <ConnectorPoint PointX="3.75" PointY="3.2494921875" /> <ConnectorPoint PointX="3.75" PointY="3.75" /> - </AssociationConnector></Diagram></edmx:Diagrams> + </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/RelyingPartyApplicationDbStore.cs b/projecttemplates/RelyingPartyLogic/RelyingPartyApplicationDbStore.cs index 85667e3..910d6b2 100644 --- a/projecttemplates/RelyingPartyLogic/RelyingPartyApplicationDbStore.cs +++ b/projecttemplates/RelyingPartyLogic/RelyingPartyApplicationDbStore.cs @@ -10,6 +10,7 @@ namespace RelyingPartyLogic { using System.Data; using System.Linq; using System.Text; + using DotNetOpenAuth; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.RelyingParty; @@ -23,102 +24,53 @@ namespace RelyingPartyLogic { public RelyingPartyApplicationDbStore() { } - #region IRelyingPartyApplicationStore Members + #region ICryptoStore Members - /// <summary> - /// Saves an <see cref="Association"/> for later recall. - /// </summary> - /// <param name="providerEndpoint">The Uri (for relying parties) or Smart/Dumb (for providers).</param> - /// <param name="association">The association to store.</param> - /// <remarks> - /// TODO: what should implementations do on association handle conflict? - /// </remarks> - public void StoreAssociation(Uri providerEndpoint, Association association) { + public CryptoKey GetKey(string bucket, string handle) { using (var dataContext = new TransactedDatabaseEntities(System.Data.IsolationLevel.ReadCommitted)) { - var sharedAssociation = new OpenIdAssociation { - ProviderEndpoint = providerEndpoint.AbsoluteUri, - AssociationHandle = association.Handle, - ExpirationUtc = association.Expires, - PrivateData = association.SerializePrivateData(), - }; - - dataContext.AddToOpenIdAssociations(sharedAssociation); + 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(); } } - /// <summary> - /// Gets the best association (the one with the longest remaining life) for a given key. - /// </summary> - /// <param name="providerEndpoint">The Uri (for relying parties) or Smart/Dumb (for Providers).</param> - /// <param name="securityRequirements">The security requirements that the returned association must meet.</param> - /// <returns> - /// The requested association, or null if no unexpired <see cref="Association"/>s exist for the given key. - /// </returns> - /// <remarks> - /// In the event that multiple associations exist for the given - /// <paramref name="providerEndpoint"/>, it is important for the - /// implementation for this method to use the <paramref name="securityRequirements"/> - /// to pick the best (highest grade or longest living as the host's policy may dictate) - /// association that fits the security requirements. - /// Associations that are returned that do not meet the security requirements will be - /// ignored and a new association created. - /// </remarks> - public Association GetAssociation(Uri providerEndpoint, SecuritySettings securityRequirements) { + public IEnumerable<KeyValuePair<string, CryptoKey>> GetKeys(string bucket) { using (var dataContext = new TransactedDatabaseEntities(System.Data.IsolationLevel.ReadCommitted)) { - var relevantAssociations = from assoc in dataContext.OpenIdAssociations - where assoc.ProviderEndpoint == providerEndpoint.AbsoluteUri + var relevantAssociations = from assoc in dataContext.SymmetricCryptoKeys + where assoc.Bucket == bucket where assoc.ExpirationUtc > DateTime.UtcNow - where assoc.PrivateDataLength * 8 >= securityRequirements.MinimumHashBitLength - where assoc.PrivateDataLength * 8 <= securityRequirements.MaximumHashBitLength orderby assoc.ExpirationUtc descending select assoc; var qualifyingAssociations = relevantAssociations.AsEnumerable() - .Select(assoc => DeserializeAssociation(assoc)); - return qualifyingAssociations.FirstOrDefault(); + .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. } } - /// <summary> - /// Gets the association for a given key and handle. - /// </summary> - /// <param name="providerEndpoint">The Uri (for relying parties) or Smart/Dumb (for Providers).</param> - /// <param name="handle">The handle of the specific association that must be recalled.</param> - /// <returns> - /// The requested association, or null if no unexpired <see cref="Association"/>s exist for the given key and handle. - /// </returns> - public Association GetAssociation(Uri providerEndpoint, string handle) { + public void StoreKey(string bucket, string handle, CryptoKey key) { using (var dataContext = new TransactedDatabaseEntities(System.Data.IsolationLevel.ReadCommitted)) { - var associations = from assoc in dataContext.OpenIdAssociations - where assoc.ProviderEndpoint == providerEndpoint.AbsoluteUri - where assoc.AssociationHandle == handle - where assoc.ExpirationUtc > DateTime.UtcNow - select assoc; - return associations.AsEnumerable() - .Select(assoc => DeserializeAssociation(assoc)) - .FirstOrDefault(); + var sharedAssociation = new SymmetricCryptoKey { + Bucket = bucket, + Handle = handle, + ExpirationUtc = key.ExpiresUtc, + Secret = key.Key, + }; + + dataContext.AddToSymmetricCryptoKeys(sharedAssociation); } } - /// <summary> - /// Removes a specified handle that may exist in the store. - /// </summary> - /// <param name="providerEndpoint">The Uri (for relying parties) or Smart/Dumb (for Providers).</param> - /// <param name="handle">The handle of the specific association that must be deleted.</param> - /// <returns> - /// True if the association existed in this store previous to this call. - /// </returns> - /// <remarks> - /// No exception should be thrown if the association does not exist in the store - /// before this call. - /// </remarks> - public bool RemoveAssociation(Uri providerEndpoint, string handle) { + public void RemoveKey(string bucket, string handle) { using (var dataContext = new TransactedDatabaseEntities(System.Data.IsolationLevel.ReadCommitted)) { - var association = dataContext.OpenIdAssociations.FirstOrDefault(a => a.ProviderEndpoint == providerEndpoint.AbsoluteUri && a.AssociationHandle == handle); + var association = dataContext.SymmetricCryptoKeys.FirstOrDefault(a => a.Bucket == bucket && a.Handle == handle); if (association != null) { dataContext.DeleteObject(association); - return true; } else { - return false; } } } @@ -139,20 +91,5 @@ namespace RelyingPartyLogic { dataContext.ClearExpiredAssociations(dataContext.Transaction); } } - - /// <summary> - /// Deserializes an association from the database. - /// </summary> - /// <param name="association">The association from the database.</param> - /// <returns>The deserialized association.</returns> - private static Association DeserializeAssociation(OpenIdAssociation association) { - if (association == null) { - throw new ArgumentNullException("association"); - } - - byte[] privateData = new byte[association.PrivateDataLength]; - Array.Copy(association.PrivateData, privateData, association.PrivateDataLength); - return Association.Deserialize(association.AssociationHandle, association.ExpirationUtc, privateData); - } } } diff --git a/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj b/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj index 549cad5..6ff2740 100644 --- a/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj +++ b/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj @@ -117,7 +117,6 @@ <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> </Compile> - <Compile Include="Model.OpenIdAssociation.cs" /> <Compile Include="Model.User.cs" /> <Compile Include="NonceDbStore.cs" /> <Compile Include="OAuthAuthorizationServer.cs" /> diff --git a/projecttemplates/RelyingPartyLogic/Utilities.cs b/projecttemplates/RelyingPartyLogic/Utilities.cs index 47212e6..1f07a9e 100644 --- a/projecttemplates/RelyingPartyLogic/Utilities.cs +++ b/projecttemplates/RelyingPartyLogic/Utilities.cs @@ -142,5 +142,18 @@ GO" }; 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/samples/OpenIdRelyingPartyWebForms/Code/CustomStore.cs b/samples/OpenIdRelyingPartyWebForms/Code/CustomStore.cs index 325a5d0..d113c8b 100644 --- a/samples/OpenIdRelyingPartyWebForms/Code/CustomStore.cs +++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStore.cs @@ -1,8 +1,11 @@ namespace OpenIdRelyingPartyWebForms.Code { using System; + using System.Collections.Generic; using System.Data; using System.Globalization; using System.Security.Cryptography; + using DotNetOpenAuth; + using DotNetOpenAuth.Configuration; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.RelyingParty; @@ -29,7 +32,7 @@ /// 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="timestamp">The timestamp that together with the nonce string make it unique. + /// <param name="timestampUtc">The timestamp that together with the nonce string make it unique. /// The timestamp may also be used by the data store to clear out old nonces.</param> /// <returns> /// True if the nonce+timestamp (combination) was not previously in the database. @@ -42,7 +45,7 @@ /// is retrieved or set using the /// <see cref="StandardExpirationBindingElement.MaximumMessageAge"/> property. /// </remarks> - public bool StoreNonce(string context, string nonce, DateTime timestamp) { + public bool StoreNonce(string context, string nonce, DateTime timestampUtc) { // IMPORTANT: If actually persisting to a database that can be reached from // different servers/instances of this class at once, it is vitally important // to protect against race condition attacks by one or more of these: @@ -54,76 +57,73 @@ // at you in the result of a race condition somewhere in your web site UI code // and display some message to have the user try to log in again, and possibly // warn them about a replay attack. - timestamp = timestamp.ToLocalTime(); lock (this) { - if (dataSet.Nonce.FindByIssuedCodeContext(timestamp, nonce, context) != null) { + if (dataSet.Nonce.FindByIssuedUtcCodeContext(timestampUtc, nonce, context) != null) { return false; } - TimeSpan maxMessageAge = DotNetOpenAuth.Configuration.DotNetOpenAuthSection.Configuration.Messaging.MaximumMessageLifetime; - dataSet.Nonce.AddNonceRow(context, nonce, timestamp, timestamp + maxMessageAge); + TimeSpan maxMessageAge = DotNetOpenAuthSection.Configuration.Messaging.MaximumMessageLifetime; + dataSet.Nonce.AddNonceRow(context, nonce, timestampUtc, timestampUtc + maxMessageAge); return true; } } public void ClearExpiredNonces() { - this.removeExpiredRows(dataSet.Nonce, dataSet.Nonce.ExpiresColumn.ColumnName); + this.removeExpiredRows(dataSet.Nonce, dataSet.Nonce.ExpiresUtcColumn.ColumnName); } #endregion - #region IRelyingPartyAssociationStore Members + #region ICryptoKeyStore Members - public void StoreAssociation(Uri providerEndpoint, Association assoc) { - var assocRow = dataSet.Association.NewAssociationRow(); - assocRow.DistinguishingFactor = providerEndpoint.AbsoluteUri; - assocRow.Handle = assoc.Handle; - assocRow.Expires = assoc.Expires.ToLocalTime(); - assocRow.PrivateData = assoc.SerializePrivateData(); - dataSet.Association.AddAssociationRow(assocRow); + public CryptoKey GetKey(string bucket, string handle) { + var assocRow = dataSet.CryptoKey.FindByBucketHandle(bucket, handle); + return new CryptoKey(assocRow.Secret, assocRow.ExpiresUtc); } - public Association GetAssociation(Uri providerEndpoint, SecuritySettings securitySettings) { - // TODO: properly consider the securitySettings when picking an association to return. + public IEnumerable<KeyValuePair<string, CryptoKey>> GetKeys(string bucket) { // properly escape the URL to prevent injection attacks. - string value = providerEndpoint.AbsoluteUri.Replace("'", "''"); + string value = bucket.Replace("'", "''"); string filter = string.Format( CultureInfo.InvariantCulture, "{0} = '{1}'", - dataSet.Association.DistinguishingFactorColumn.ColumnName, + dataSet.CryptoKey.BucketColumn.ColumnName, value); - string sort = dataSet.Association.ExpiresColumn.ColumnName + " DESC"; - DataView view = new DataView(dataSet.Association, filter, sort, DataViewRowState.CurrentRows); + string sort = dataSet.CryptoKey.ExpiresUtcColumn.ColumnName + " DESC"; + DataView view = new DataView(dataSet.CryptoKey, filter, sort, DataViewRowState.CurrentRows); if (view.Count == 0) { - return null; + yield break; + } + + foreach (CustomStoreDataSet.CryptoKeyRow row in view) { + yield return new KeyValuePair<string, CryptoKey>(row.Handle, new CryptoKey(row.Secret, row.ExpiresUtc)); } - var row = (CustomStoreDataSet.AssociationRow)view[0].Row; - return Association.Deserialize(row.Handle, row.Expires.ToUniversalTime(), row.PrivateData); } - public Association GetAssociation(Uri providerEndpoint, string handle) { - var assocRow = dataSet.Association.FindByDistinguishingFactorHandle(providerEndpoint.AbsoluteUri, handle); - return Association.Deserialize(assocRow.Handle, assocRow.Expires, assocRow.PrivateData); + public void StoreKey(string bucket, string handle, CryptoKey key) { + var cryptoKeyRow = dataSet.CryptoKey.NewCryptoKeyRow(); + cryptoKeyRow.Bucket = bucket; + cryptoKeyRow.Handle = handle; + cryptoKeyRow.ExpiresUtc = key.ExpiresUtc; + cryptoKeyRow.Secret = key.Key; + dataSet.CryptoKey.AddCryptoKeyRow(cryptoKeyRow); } - public bool RemoveAssociation(Uri providerEndpoint, string handle) { - var row = dataSet.Association.FindByDistinguishingFactorHandle(providerEndpoint.AbsoluteUri, handle); + public void RemoveKey(string bucket, string handle) { + var row = dataSet.CryptoKey.FindByBucketHandle(bucket, handle); if (row != null) { - dataSet.Association.RemoveAssociationRow(row); - return true; - } else { - return false; + dataSet.CryptoKey.RemoveCryptoKeyRow(row); } } #endregion - internal void ClearExpiredAssociations() { - this.removeExpiredRows(dataSet.Association, dataSet.Association.ExpiresColumn.ColumnName); + internal void ClearExpiredSecrets() { + this.removeExpiredRows(dataSet.CryptoKey, dataSet.CryptoKey.ExpiresUtcColumn.ColumnName); } private void removeExpiredRows(DataTable table, string expiredColumnName) { - string filter = string.Format(CultureInfo.InvariantCulture, "{0} < #{1}#", expiredColumnName, DateTime.Now); + string filter = string.Format(CultureInfo.InvariantCulture, "{0} < #{1}#", expiredColumnName, DateTime.UtcNow); DataView view = new DataView(table, filter, null, DataViewRowState.CurrentRows); for (int i = view.Count - 1; i >= 0; i--) { view.Delete(i); diff --git a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xsd b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xsd index fa161fd..f3270f6 100644 --- a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xsd +++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xsd @@ -9,39 +9,39 @@ </DataSource> </xs:appinfo> </xs:annotation> - <xs:element name="CustomStoreDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="CustomStoreDataSet" msprop:Generator_DataSetName="CustomStoreDataSet" msprop:EnableTableAdapterManager="true"> + <xs:element name="CustomStoreDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:EnableTableAdapterManager="true" msprop:Generator_DataSetName="CustomStoreDataSet" msprop:Generator_UserDSName="CustomStoreDataSet"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> - <xs:element name="Association" msprop:Generator_UserTableName="Association" msprop:Generator_RowDeletedName="AssociationRowDeleted" msprop:Generator_RowChangedName="AssociationRowChanged" msprop:Generator_RowClassName="AssociationRow" msprop:Generator_RowChangingName="AssociationRowChanging" msprop:Generator_RowEvArgName="AssociationRowChangeEvent" msprop:Generator_RowEvHandlerName="AssociationRowChangeEventHandler" msprop:Generator_TableClassName="AssociationDataTable" msprop:Generator_TableVarName="tableAssociation" msprop:Generator_RowDeletingName="AssociationRowDeleting" msprop:Generator_TablePropName="Association"> + <xs:element name="CryptoKey" msprop:Generator_UserTableName="CryptoKey" msprop:Generator_RowEvArgName="CryptoKeyRowChangeEvent" msprop:Generator_TableVarName="tableCryptoKey" msprop:Generator_TablePropName="CryptoKey" msprop:Generator_RowDeletingName="CryptoKeyRowDeleting" msprop:Generator_RowChangingName="CryptoKeyRowChanging" msprop:Generator_RowDeletedName="CryptoKeyRowDeleted" msprop:Generator_TableClassName="CryptoKeyDataTable" msprop:Generator_RowChangedName="CryptoKeyRowChanged" msprop:Generator_RowEvHandlerName="CryptoKeyRowChangeEventHandler" msprop:Generator_RowClassName="CryptoKeyRow"> <xs:complexType> <xs:sequence> - <xs:element name="DistinguishingFactor" msprop:Generator_UserColumnName="DistinguishingFactor" msprop:Generator_ColumnPropNameInRow="DistinguishingFactor" msprop:Generator_ColumnVarNameInTable="columnDistinguishingFactor" msprop:Generator_ColumnPropNameInTable="DistinguishingFactorColumn" type="xs:string" /> - <xs:element name="Handle" msprop:Generator_UserColumnName="Handle" msprop:Generator_ColumnPropNameInRow="Handle" msprop:Generator_ColumnVarNameInTable="columnHandle" msprop:Generator_ColumnPropNameInTable="HandleColumn" type="xs:string" /> - <xs:element name="Expires" msprop:Generator_UserColumnName="Expires" msprop:Generator_ColumnPropNameInRow="Expires" msprop:Generator_ColumnVarNameInTable="columnExpires" msprop:Generator_ColumnPropNameInTable="ExpiresColumn" type="xs:dateTime" /> - <xs:element name="PrivateData" msprop:Generator_UserColumnName="PrivateData" msprop:Generator_ColumnPropNameInRow="PrivateData" msprop:Generator_ColumnVarNameInTable="columnPrivateData" msprop:Generator_ColumnPropNameInTable="PrivateDataColumn" type="xs:base64Binary" /> + <xs:element name="Bucket" msprop:Generator_ColumnVarNameInTable="columnBucket" msprop:Generator_ColumnPropNameInRow="Bucket" msprop:Generator_ColumnPropNameInTable="BucketColumn" msprop:Generator_UserColumnName="Bucket" type="xs:string" /> + <xs:element name="Handle" msprop:Generator_ColumnVarNameInTable="columnHandle" msprop:Generator_ColumnPropNameInRow="Handle" msprop:Generator_ColumnPropNameInTable="HandleColumn" msprop:Generator_UserColumnName="Handle" type="xs:string" /> + <xs:element name="ExpiresUtc" msdata:DateTimeMode="Utc" msprop:Generator_ColumnVarNameInTable="columnExpiresUtc" msprop:Generator_ColumnPropNameInRow="ExpiresUtc" msprop:Generator_ColumnPropNameInTable="ExpiresUtcColumn" msprop:Generator_UserColumnName="ExpiresUtc" type="xs:dateTime" /> + <xs:element name="Secret" msprop:Generator_ColumnVarNameInTable="columnSecret" msprop:Generator_ColumnPropNameInRow="Secret" msprop:Generator_ColumnPropNameInTable="SecretColumn" msprop:Generator_UserColumnName="Secret" type="xs:base64Binary" /> </xs:sequence> </xs:complexType> </xs:element> - <xs:element name="Nonce" msprop:Generator_UserTableName="Nonce" msprop:Generator_RowDeletedName="NonceRowDeleted" msprop:Generator_RowChangedName="NonceRowChanged" msprop:Generator_RowClassName="NonceRow" msprop:Generator_RowChangingName="NonceRowChanging" msprop:Generator_RowEvArgName="NonceRowChangeEvent" msprop:Generator_RowEvHandlerName="NonceRowChangeEventHandler" msprop:Generator_TableClassName="NonceDataTable" msprop:Generator_TableVarName="tableNonce" msprop:Generator_RowDeletingName="NonceRowDeleting" msprop:Generator_TablePropName="Nonce"> + <xs:element name="Nonce" msprop:Generator_UserTableName="Nonce" msprop:Generator_RowEvArgName="NonceRowChangeEvent" msprop:Generator_TableVarName="tableNonce" msprop:Generator_TablePropName="Nonce" msprop:Generator_RowDeletingName="NonceRowDeleting" msprop:Generator_RowChangingName="NonceRowChanging" msprop:Generator_RowDeletedName="NonceRowDeleted" msprop:Generator_TableClassName="NonceDataTable" msprop:Generator_RowChangedName="NonceRowChanged" msprop:Generator_RowEvHandlerName="NonceRowChangeEventHandler" msprop:Generator_RowClassName="NonceRow"> <xs:complexType> <xs:sequence> - <xs:element name="Context" msprop:Generator_UserColumnName="Context" msprop:Generator_ColumnVarNameInTable="columnContext" msprop:Generator_ColumnPropNameInRow="Context" msprop:Generator_ColumnPropNameInTable="ContextColumn" type="xs:string" /> - <xs:element name="Code" msprop:Generator_UserColumnName="Code" msprop:Generator_ColumnVarNameInTable="columnCode" msprop:Generator_ColumnPropNameInRow="Code" msprop:Generator_ColumnPropNameInTable="CodeColumn" type="xs:string" /> - <xs:element name="Issued" msprop:Generator_UserColumnName="Issued" msprop:Generator_ColumnVarNameInTable="columnIssued" msprop:Generator_ColumnPropNameInRow="Issued" msprop:Generator_ColumnPropNameInTable="IssuedColumn" type="xs:dateTime" /> - <xs:element name="Expires" msprop:Generator_UserColumnName="Expires" msprop:Generator_ColumnPropNameInRow="Expires" msprop:Generator_ColumnVarNameInTable="columnExpires" msprop:Generator_ColumnPropNameInTable="ExpiresColumn" type="xs:dateTime" /> + <xs:element name="Context" msprop:Generator_ColumnVarNameInTable="columnContext" msprop:Generator_ColumnPropNameInRow="Context" msprop:Generator_ColumnPropNameInTable="ContextColumn" msprop:Generator_UserColumnName="Context" type="xs:string" /> + <xs:element name="Code" msprop:Generator_ColumnVarNameInTable="columnCode" msprop:Generator_ColumnPropNameInRow="Code" msprop:Generator_ColumnPropNameInTable="CodeColumn" msprop:Generator_UserColumnName="Code" type="xs:string" /> + <xs:element name="IssuedUtc" msdata:DateTimeMode="Utc" msprop:Generator_ColumnVarNameInTable="columnIssuedUtc" msprop:Generator_ColumnPropNameInRow="IssuedUtc" msprop:Generator_ColumnPropNameInTable="IssuedUtcColumn" msprop:Generator_UserColumnName="IssuedUtc" type="xs:dateTime" /> + <xs:element name="ExpiresUtc" msdata:DateTimeMode="Utc" msprop:Generator_ColumnVarNameInTable="columnExpiresUtc" msprop:Generator_ColumnPropNameInRow="ExpiresUtc" msprop:Generator_ColumnPropNameInTable="ExpiresUtcColumn" msprop:Generator_UserColumnName="ExpiresUtc" type="xs:dateTime" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> <xs:unique name="PrimaryKey" msdata:PrimaryKey="true"> - <xs:selector xpath=".//mstns:Association" /> - <xs:field xpath="mstns:DistinguishingFactor" /> + <xs:selector xpath=".//mstns:CryptoKey" /> + <xs:field xpath="mstns:Bucket" /> <xs:field xpath="mstns:Handle" /> </xs:unique> <xs:unique name="Constraint1" msdata:PrimaryKey="true"> <xs:selector xpath=".//mstns:Nonce" /> - <xs:field xpath="mstns:Issued" /> + <xs:field xpath="mstns:IssuedUtc" /> <xs:field xpath="mstns:Code" /> <xs:field xpath="mstns:Context" /> </xs:unique> diff --git a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xss b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xss index ab8f226..631148e 100644 --- a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xss +++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xss @@ -4,9 +4,9 @@ Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. </autogenerated>--> -<DiagramLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ex:showrelationlabel="False" ViewPortX="0" ViewPortY="0" xmlns:ex="urn:schemas-microsoft-com:xml-msdatasource-layout-extended" xmlns="urn:schemas-microsoft-com:xml-msdatasource-layout"> +<DiagramLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ex:showrelationlabel="False" ViewPortX="-10" ViewPortY="-10" xmlns:ex="urn:schemas-microsoft-com:xml-msdatasource-layout-extended" xmlns="urn:schemas-microsoft-com:xml-msdatasource-layout"> <Shapes> - <Shape ID="DesignTable:Association" ZOrder="2" X="349" Y="83" Height="105" Width="154" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="101" /> + <Shape ID="DesignTable:CryptoKey" ZOrder="2" X="349" Y="83" Height="105" Width="154" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="101" /> <Shape ID="DesignTable:Nonce" ZOrder="1" X="604" Y="86" Height="125" Width="150" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="121" /> </Shapes> <Connectors /> diff --git a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs index 9922a4d..fa28b9c 100644 --- a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs +++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. -// Runtime Version:4.0.30104.0 +// Runtime Version:4.0.30319.225 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -24,7 +24,7 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")] public partial class CustomStoreDataSet : global::System.Data.DataSet { - private AssociationDataTable tableAssociation; + private CryptoKeyDataTable tableCryptoKey; private NonceDataTable tableNonce; @@ -56,8 +56,8 @@ namespace OpenIdRelyingPartyWebForms.Code { if ((this.DetermineSchemaSerializationMode(info, context) == global::System.Data.SchemaSerializationMode.IncludeSchema)) { global::System.Data.DataSet ds = new global::System.Data.DataSet(); ds.ReadXmlSchema(new global::System.Xml.XmlTextReader(new global::System.IO.StringReader(strSchema))); - if ((ds.Tables["Association"] != null)) { - base.Tables.Add(new AssociationDataTable(ds.Tables["Association"])); + if ((ds.Tables["CryptoKey"] != null)) { + base.Tables.Add(new CryptoKeyDataTable(ds.Tables["CryptoKey"])); } if ((ds.Tables["Nonce"] != null)) { base.Tables.Add(new NonceDataTable(ds.Tables["Nonce"])); @@ -84,9 +84,9 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.ComponentModel.Browsable(false)] [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)] - public AssociationDataTable Association { + public CryptoKeyDataTable CryptoKey { get { - return this.tableAssociation; + return this.tableCryptoKey; } } @@ -167,8 +167,8 @@ namespace OpenIdRelyingPartyWebForms.Code { this.Reset(); global::System.Data.DataSet ds = new global::System.Data.DataSet(); ds.ReadXml(reader); - if ((ds.Tables["Association"] != null)) { - base.Tables.Add(new AssociationDataTable(ds.Tables["Association"])); + if ((ds.Tables["CryptoKey"] != null)) { + base.Tables.Add(new CryptoKeyDataTable(ds.Tables["CryptoKey"])); } if ((ds.Tables["Nonce"] != null)) { base.Tables.Add(new NonceDataTable(ds.Tables["Nonce"])); @@ -206,10 +206,10 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] internal void InitVars(bool initTable) { - this.tableAssociation = ((AssociationDataTable)(base.Tables["Association"])); + this.tableCryptoKey = ((CryptoKeyDataTable)(base.Tables["CryptoKey"])); if ((initTable == true)) { - if ((this.tableAssociation != null)) { - this.tableAssociation.InitVars(); + if ((this.tableCryptoKey != null)) { + this.tableCryptoKey.InitVars(); } } this.tableNonce = ((NonceDataTable)(base.Tables["Nonce"])); @@ -228,15 +228,15 @@ namespace OpenIdRelyingPartyWebForms.Code { this.Namespace = "http://tempuri.org/CustomStoreDataSet.xsd"; this.EnforceConstraints = true; this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; - this.tableAssociation = new AssociationDataTable(); - base.Tables.Add(this.tableAssociation); + this.tableCryptoKey = new CryptoKeyDataTable(); + base.Tables.Add(this.tableCryptoKey); this.tableNonce = new NonceDataTable(); base.Tables.Add(this.tableNonce); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - private bool ShouldSerializeAssociation() { + private bool ShouldSerializeCryptoKey() { return false; } @@ -302,7 +302,7 @@ namespace OpenIdRelyingPartyWebForms.Code { } [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public delegate void AssociationRowChangeEventHandler(object sender, AssociationRowChangeEvent e); + public delegate void CryptoKeyRowChangeEventHandler(object sender, CryptoKeyRowChangeEvent e); [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] public delegate void NonceRowChangeEventHandler(object sender, NonceRowChangeEvent e); @@ -312,20 +312,20 @@ namespace OpenIdRelyingPartyWebForms.Code { ///</summary> [global::System.Serializable()] [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] - public partial class AssociationDataTable : global::System.Data.TypedTableBase<AssociationRow> { + public partial class CryptoKeyDataTable : global::System.Data.TypedTableBase<CryptoKeyRow> { - private global::System.Data.DataColumn columnDistinguishingFactor; + private global::System.Data.DataColumn columnBucket; private global::System.Data.DataColumn columnHandle; - private global::System.Data.DataColumn columnExpires; + private global::System.Data.DataColumn columnExpiresUtc; - private global::System.Data.DataColumn columnPrivateData; + private global::System.Data.DataColumn columnSecret; [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public AssociationDataTable() { - this.TableName = "Association"; + public CryptoKeyDataTable() { + this.TableName = "CryptoKey"; this.BeginInit(); this.InitClass(); this.EndInit(); @@ -333,7 +333,7 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - internal AssociationDataTable(global::System.Data.DataTable table) { + internal CryptoKeyDataTable(global::System.Data.DataTable table) { this.TableName = table.TableName; if ((table.CaseSensitive != table.DataSet.CaseSensitive)) { this.CaseSensitive = table.CaseSensitive; @@ -350,16 +350,16 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - protected AssociationDataTable(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : + protected CryptoKeyDataTable(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : base(info, context) { this.InitVars(); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public global::System.Data.DataColumn DistinguishingFactorColumn { + public global::System.Data.DataColumn BucketColumn { get { - return this.columnDistinguishingFactor; + return this.columnBucket; } } @@ -373,17 +373,17 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public global::System.Data.DataColumn ExpiresColumn { + public global::System.Data.DataColumn ExpiresUtcColumn { get { - return this.columnExpires; + return this.columnExpiresUtc; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public global::System.Data.DataColumn PrivateDataColumn { + public global::System.Data.DataColumn SecretColumn { get { - return this.columnPrivateData; + return this.columnSecret; } } @@ -398,56 +398,56 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public AssociationRow this[int index] { + public CryptoKeyRow this[int index] { get { - return ((AssociationRow)(this.Rows[index])); + return ((CryptoKeyRow)(this.Rows[index])); } } [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public event AssociationRowChangeEventHandler AssociationRowChanging; + public event CryptoKeyRowChangeEventHandler CryptoKeyRowChanging; [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public event AssociationRowChangeEventHandler AssociationRowChanged; + public event CryptoKeyRowChangeEventHandler CryptoKeyRowChanged; [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public event AssociationRowChangeEventHandler AssociationRowDeleting; + public event CryptoKeyRowChangeEventHandler CryptoKeyRowDeleting; [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public event AssociationRowChangeEventHandler AssociationRowDeleted; + public event CryptoKeyRowChangeEventHandler CryptoKeyRowDeleted; [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public void AddAssociationRow(AssociationRow row) { + public void AddCryptoKeyRow(CryptoKeyRow row) { this.Rows.Add(row); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public AssociationRow AddAssociationRow(string DistinguishingFactor, string Handle, System.DateTime Expires, byte[] PrivateData) { - AssociationRow rowAssociationRow = ((AssociationRow)(this.NewRow())); + public CryptoKeyRow AddCryptoKeyRow(string Bucket, string Handle, System.DateTime ExpiresUtc, byte[] Secret) { + CryptoKeyRow rowCryptoKeyRow = ((CryptoKeyRow)(this.NewRow())); object[] columnValuesArray = new object[] { - DistinguishingFactor, + Bucket, Handle, - Expires, - PrivateData}; - rowAssociationRow.ItemArray = columnValuesArray; - this.Rows.Add(rowAssociationRow); - return rowAssociationRow; + ExpiresUtc, + Secret}; + rowCryptoKeyRow.ItemArray = columnValuesArray; + this.Rows.Add(rowCryptoKeyRow); + return rowCryptoKeyRow; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public AssociationRow FindByDistinguishingFactorHandle(string DistinguishingFactor, string Handle) { - return ((AssociationRow)(this.Rows.Find(new object[] { - DistinguishingFactor, + public CryptoKeyRow FindByBucketHandle(string Bucket, string Handle) { + return ((CryptoKeyRow)(this.Rows.Find(new object[] { + Bucket, Handle}))); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] public override global::System.Data.DataTable Clone() { - AssociationDataTable cln = ((AssociationDataTable)(base.Clone())); + CryptoKeyDataTable cln = ((CryptoKeyDataTable)(base.Clone())); cln.InitVars(); return cln; } @@ -455,62 +455,63 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] protected override global::System.Data.DataTable CreateInstance() { - return new AssociationDataTable(); + return new CryptoKeyDataTable(); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] internal void InitVars() { - this.columnDistinguishingFactor = base.Columns["DistinguishingFactor"]; + this.columnBucket = base.Columns["Bucket"]; this.columnHandle = base.Columns["Handle"]; - this.columnExpires = base.Columns["Expires"]; - this.columnPrivateData = base.Columns["PrivateData"]; + this.columnExpiresUtc = base.Columns["ExpiresUtc"]; + this.columnSecret = base.Columns["Secret"]; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] private void InitClass() { - this.columnDistinguishingFactor = new global::System.Data.DataColumn("DistinguishingFactor", typeof(string), null, global::System.Data.MappingType.Element); - base.Columns.Add(this.columnDistinguishingFactor); + this.columnBucket = new global::System.Data.DataColumn("Bucket", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnBucket); this.columnHandle = new global::System.Data.DataColumn("Handle", typeof(string), null, global::System.Data.MappingType.Element); base.Columns.Add(this.columnHandle); - this.columnExpires = new global::System.Data.DataColumn("Expires", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); - base.Columns.Add(this.columnExpires); - this.columnPrivateData = new global::System.Data.DataColumn("PrivateData", typeof(byte[]), null, global::System.Data.MappingType.Element); - base.Columns.Add(this.columnPrivateData); + this.columnExpiresUtc = new global::System.Data.DataColumn("ExpiresUtc", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnExpiresUtc); + this.columnSecret = new global::System.Data.DataColumn("Secret", typeof(byte[]), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnSecret); this.Constraints.Add(new global::System.Data.UniqueConstraint("PrimaryKey", new global::System.Data.DataColumn[] { - this.columnDistinguishingFactor, + this.columnBucket, this.columnHandle}, true)); - this.columnDistinguishingFactor.AllowDBNull = false; + this.columnBucket.AllowDBNull = false; this.columnHandle.AllowDBNull = false; - this.columnExpires.AllowDBNull = false; - this.columnPrivateData.AllowDBNull = false; + this.columnExpiresUtc.AllowDBNull = false; + this.columnExpiresUtc.DateTimeMode = global::System.Data.DataSetDateTime.Utc; + this.columnSecret.AllowDBNull = false; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public AssociationRow NewAssociationRow() { - return ((AssociationRow)(this.NewRow())); + public CryptoKeyRow NewCryptoKeyRow() { + return ((CryptoKeyRow)(this.NewRow())); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] protected override global::System.Data.DataRow NewRowFromBuilder(global::System.Data.DataRowBuilder builder) { - return new AssociationRow(builder); + return new CryptoKeyRow(builder); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] protected override global::System.Type GetRowType() { - return typeof(AssociationRow); + return typeof(CryptoKeyRow); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] protected override void OnRowChanged(global::System.Data.DataRowChangeEventArgs e) { base.OnRowChanged(e); - if ((this.AssociationRowChanged != null)) { - this.AssociationRowChanged(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + if ((this.CryptoKeyRowChanged != null)) { + this.CryptoKeyRowChanged(this, new CryptoKeyRowChangeEvent(((CryptoKeyRow)(e.Row)), e.Action)); } } @@ -518,8 +519,8 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] protected override void OnRowChanging(global::System.Data.DataRowChangeEventArgs e) { base.OnRowChanging(e); - if ((this.AssociationRowChanging != null)) { - this.AssociationRowChanging(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + if ((this.CryptoKeyRowChanging != null)) { + this.CryptoKeyRowChanging(this, new CryptoKeyRowChangeEvent(((CryptoKeyRow)(e.Row)), e.Action)); } } @@ -527,8 +528,8 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] protected override void OnRowDeleted(global::System.Data.DataRowChangeEventArgs e) { base.OnRowDeleted(e); - if ((this.AssociationRowDeleted != null)) { - this.AssociationRowDeleted(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + if ((this.CryptoKeyRowDeleted != null)) { + this.CryptoKeyRowDeleted(this, new CryptoKeyRowChangeEvent(((CryptoKeyRow)(e.Row)), e.Action)); } } @@ -536,14 +537,14 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] protected override void OnRowDeleting(global::System.Data.DataRowChangeEventArgs e) { base.OnRowDeleting(e); - if ((this.AssociationRowDeleting != null)) { - this.AssociationRowDeleting(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + if ((this.CryptoKeyRowDeleting != null)) { + this.CryptoKeyRowDeleting(this, new CryptoKeyRowChangeEvent(((CryptoKeyRow)(e.Row)), e.Action)); } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public void RemoveAssociationRow(AssociationRow row) { + public void RemoveCryptoKeyRow(CryptoKeyRow row) { this.Rows.Remove(row); } @@ -570,7 +571,7 @@ namespace OpenIdRelyingPartyWebForms.Code { type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; - attribute2.FixedValue = "AssociationDataTable"; + attribute2.FixedValue = "CryptoKeyDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); @@ -622,9 +623,9 @@ namespace OpenIdRelyingPartyWebForms.Code { private global::System.Data.DataColumn columnCode; - private global::System.Data.DataColumn columnIssued; + private global::System.Data.DataColumn columnIssuedUtc; - private global::System.Data.DataColumn columnExpires; + private global::System.Data.DataColumn columnExpiresUtc; [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] @@ -677,17 +678,17 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public global::System.Data.DataColumn IssuedColumn { + public global::System.Data.DataColumn IssuedUtcColumn { get { - return this.columnIssued; + return this.columnIssuedUtc; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public global::System.Data.DataColumn ExpiresColumn { + public global::System.Data.DataColumn ExpiresUtcColumn { get { - return this.columnExpires; + return this.columnExpiresUtc; } } @@ -728,13 +729,13 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public NonceRow AddNonceRow(string Context, string Code, System.DateTime Issued, System.DateTime Expires) { + public NonceRow AddNonceRow(string Context, string Code, System.DateTime IssuedUtc, System.DateTime ExpiresUtc) { NonceRow rowNonceRow = ((NonceRow)(this.NewRow())); object[] columnValuesArray = new object[] { Context, Code, - Issued, - Expires}; + IssuedUtc, + ExpiresUtc}; rowNonceRow.ItemArray = columnValuesArray; this.Rows.Add(rowNonceRow); return rowNonceRow; @@ -742,9 +743,9 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public NonceRow FindByIssuedCodeContext(System.DateTime Issued, string Code, string Context) { + public NonceRow FindByIssuedUtcCodeContext(System.DateTime IssuedUtc, string Code, string Context) { return ((NonceRow)(this.Rows.Find(new object[] { - Issued, + IssuedUtc, Code, Context}))); } @@ -768,8 +769,8 @@ namespace OpenIdRelyingPartyWebForms.Code { internal void InitVars() { this.columnContext = base.Columns["Context"]; this.columnCode = base.Columns["Code"]; - this.columnIssued = base.Columns["Issued"]; - this.columnExpires = base.Columns["Expires"]; + this.columnIssuedUtc = base.Columns["IssuedUtc"]; + this.columnExpiresUtc = base.Columns["ExpiresUtc"]; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -779,18 +780,20 @@ namespace OpenIdRelyingPartyWebForms.Code { base.Columns.Add(this.columnContext); this.columnCode = new global::System.Data.DataColumn("Code", typeof(string), null, global::System.Data.MappingType.Element); base.Columns.Add(this.columnCode); - this.columnIssued = new global::System.Data.DataColumn("Issued", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); - base.Columns.Add(this.columnIssued); - this.columnExpires = new global::System.Data.DataColumn("Expires", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); - base.Columns.Add(this.columnExpires); + this.columnIssuedUtc = new global::System.Data.DataColumn("IssuedUtc", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnIssuedUtc); + this.columnExpiresUtc = new global::System.Data.DataColumn("ExpiresUtc", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnExpiresUtc); this.Constraints.Add(new global::System.Data.UniqueConstraint("Constraint1", new global::System.Data.DataColumn[] { - this.columnIssued, + this.columnIssuedUtc, this.columnCode, this.columnContext}, true)); this.columnContext.AllowDBNull = false; this.columnCode.AllowDBNull = false; - this.columnIssued.AllowDBNull = false; - this.columnExpires.AllowDBNull = false; + this.columnIssuedUtc.AllowDBNull = false; + this.columnIssuedUtc.DateTimeMode = global::System.Data.DataSetDateTime.Utc; + this.columnExpiresUtc.AllowDBNull = false; + this.columnExpiresUtc.DateTimeMode = global::System.Data.DataSetDateTime.Utc; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -920,25 +923,25 @@ namespace OpenIdRelyingPartyWebForms.Code { /// <summary> ///Represents strongly named DataRow class. ///</summary> - public partial class AssociationRow : global::System.Data.DataRow { + public partial class CryptoKeyRow : global::System.Data.DataRow { - private AssociationDataTable tableAssociation; + private CryptoKeyDataTable tableCryptoKey; [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - internal AssociationRow(global::System.Data.DataRowBuilder rb) : + internal CryptoKeyRow(global::System.Data.DataRowBuilder rb) : base(rb) { - this.tableAssociation = ((AssociationDataTable)(this.Table)); + this.tableCryptoKey = ((CryptoKeyDataTable)(this.Table)); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public string DistinguishingFactor { + public string Bucket { get { - return ((string)(this[this.tableAssociation.DistinguishingFactorColumn])); + return ((string)(this[this.tableCryptoKey.BucketColumn])); } set { - this[this.tableAssociation.DistinguishingFactorColumn] = value; + this[this.tableCryptoKey.BucketColumn] = value; } } @@ -946,32 +949,32 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] public string Handle { get { - return ((string)(this[this.tableAssociation.HandleColumn])); + return ((string)(this[this.tableCryptoKey.HandleColumn])); } set { - this[this.tableAssociation.HandleColumn] = value; + this[this.tableCryptoKey.HandleColumn] = value; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public System.DateTime Expires { + public System.DateTime ExpiresUtc { get { - return ((global::System.DateTime)(this[this.tableAssociation.ExpiresColumn])); + return ((global::System.DateTime)(this[this.tableCryptoKey.ExpiresUtcColumn])); } set { - this[this.tableAssociation.ExpiresColumn] = value; + this[this.tableCryptoKey.ExpiresUtcColumn] = value; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public byte[] PrivateData { + public byte[] Secret { get { - return ((byte[])(this[this.tableAssociation.PrivateDataColumn])); + return ((byte[])(this[this.tableCryptoKey.SecretColumn])); } set { - this[this.tableAssociation.PrivateDataColumn] = value; + this[this.tableCryptoKey.SecretColumn] = value; } } } @@ -1014,23 +1017,23 @@ namespace OpenIdRelyingPartyWebForms.Code { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public System.DateTime Issued { + public System.DateTime IssuedUtc { get { - return ((global::System.DateTime)(this[this.tableNonce.IssuedColumn])); + return ((global::System.DateTime)(this[this.tableNonce.IssuedUtcColumn])); } set { - this[this.tableNonce.IssuedColumn] = value; + this[this.tableNonce.IssuedUtcColumn] = value; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public System.DateTime Expires { + public System.DateTime ExpiresUtc { get { - return ((global::System.DateTime)(this[this.tableNonce.ExpiresColumn])); + return ((global::System.DateTime)(this[this.tableNonce.ExpiresUtcColumn])); } set { - this[this.tableNonce.ExpiresColumn] = value; + this[this.tableNonce.ExpiresUtcColumn] = value; } } } @@ -1039,22 +1042,22 @@ namespace OpenIdRelyingPartyWebForms.Code { ///Row event argument class ///</summary> [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public class AssociationRowChangeEvent : global::System.EventArgs { + public class CryptoKeyRowChangeEvent : global::System.EventArgs { - private AssociationRow eventRow; + private CryptoKeyRow eventRow; private global::System.Data.DataRowAction eventAction; [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public AssociationRowChangeEvent(AssociationRow row, global::System.Data.DataRowAction action) { + public CryptoKeyRowChangeEvent(CryptoKeyRow row, global::System.Data.DataRowAction action) { this.eventRow = row; this.eventAction = action; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] - public AssociationRow Row { + public CryptoKeyRow Row { get { return this.eventRow; } diff --git a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs index a73c355..5e0ccf5 100644 --- a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs @@ -29,7 +29,7 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { [SetUp] public void Setup() { this.webHandler = new Mocks.TestWebRequestHandler(); - this.channel = new OpenIdChannel(new AssociationMemoryStore(), new NonceMemoryStore(maximumMessageAge), new RelyingPartySecuritySettings()); + this.channel = new OpenIdChannel(new MemoryCryptoKeyStore(), new NonceMemoryStore(maximumMessageAge), new RelyingPartySecuritySettings()); this.channel.WebRequestHandler = this.webHandler; } diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs index 072ebe0..02a1c00 100644 --- a/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs +++ b/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs @@ -315,7 +315,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { Contract.Requires<ArgumentNullException>(securitySettings != null); SigningBindingElement signingElement; - signingElement = nonVerifying ? null : new SigningBindingElement(new CryptoKeyStoreAsRelyingPartyAssociationStore(cryptoKeyStore)); + signingElement = nonVerifying ? null : new SigningBindingElement(new CryptoKeyStoreAsRelyingPartyAssociationStore(cryptoKeyStore ?? new MemoryCryptoKeyStore())); var extensionFactory = OpenIdExtensionFactoryAggregator.LoadFromConfiguration(); diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs index 6fa2194..6efb57e 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs @@ -137,6 +137,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { this.SecuritySettings.MinimumRequiredOpenIdVersion = ProtocolVersion.V20; } + if (cryptoKeyStore == null) { + cryptoKeyStore = new MemoryCryptoKeyStore(); + } + this.channel = new OpenIdChannel(cryptoKeyStore, nonceStore, this.SecuritySettings); this.AssociationManager = new AssociationManager(this.Channel, new CryptoKeyStoreAsRelyingPartyAssociationStore(cryptoKeyStore), this.SecuritySettings); |