Skip to content

Commit

Permalink
Updated project version numbers. Updated README.md. Added documentati…
Browse files Browse the repository at this point in the history
…on for the configuration of session token storage in a database.
  • Loading branch information
rafidzal committed May 26, 2021
1 parent 610da73 commit a58ccec
Show file tree
Hide file tree
Showing 16 changed files with 155 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Systemic Pty Ltd")]
[assembly: AssemblyProduct("Sif.Framework.EnvironmentProvider")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2020")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.2.1.13")]
[assembly: AssemblyFileVersion("3.2.1.13")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Systemic Pty Ltd")]
[assembly: AssemblyProduct("Sif.Framework.Test")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2020")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.2.1.13")]
[assembly: AssemblyFileVersion("3.2.1.13")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
2 changes: 1 addition & 1 deletion Code/Sif3Framework/Sif.Framework/Sif.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472;net461</TargetFrameworks>
<Version>4.0.0</Version>
<Version>5.0.0</Version>
<Authors>Rafidzal Rafiq</Authors>
<Company>Systemic Pty Ltd</Company>
<Product>SIF Framework library</Product>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Systemic Pty Ltd")]
[assembly: AssemblyProduct("Sif.Framework.Demo.Au.Consumer")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2020")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.2.1.13")]
[assembly: AssemblyFileVersion("3.2.1.13")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Systemic Pty Ltd")]
[assembly: AssemblyProduct("Sif.Framework.Demo.Au.Provider")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2020")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.2.1.13")]
[assembly: AssemblyFileVersion("3.2.1.13")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Systemic Pty Ltd")]
[assembly: AssemblyProduct("Sif.Framework.Demo.Broker")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2020")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.2.1.13")]
[assembly: AssemblyFileVersion("3.2.1.13")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Systemic Pty Ltd")]
[assembly: AssemblyProduct("Sif.Framework.Demo.Hits.Consumer")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2020")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.2.1.13")]
[assembly: AssemblyFileVersion("3.2.1.13")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Systemic Pty Ltd")]
[assembly: AssemblyProduct("Sif.Framework.Demo.Setup")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2018")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.2.1.12")]
[assembly: AssemblyFileVersion("3.2.1.12")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
[assembly: AssemblyTitle("Sif.Framework.Demo.Uk.Consumer")]
[assembly: AssemblyDescription("Consumer created to demonstrate SIF 3 Framework usage.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ZiNET Data Solutions Limited")]
[assembly: AssemblyCompany("Systemic Pty Ltd")]
[assembly: AssemblyProduct("Sif.Framework.Demo.Uk.Consumer")]
[assembly: AssemblyCopyright("Crown Copyright © Department for Education (UK) 2016")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.2.1.11")]
[assembly: AssemblyFileVersion("3.2.1.11")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[assembly: AssemblyTitle("Sif.Framework.Demo.Uk.Provider")]
[assembly: AssemblyDescription("Provider created to demonstrate SIF 3 Framework usage.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ZiNET Data Solutions Limited")]
[assembly: AssemblyCompany("Systemic Pty Ltd")]
[assembly: AssemblyProduct("Sif.Framework.Demo.Uk.Provider")]
[assembly: AssemblyCopyright("Crown Copyright © Department for Education (UK) 2016")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.2.1.11")]
[assembly: AssemblyFileVersion("3.2.1.11")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Systemic Pty Ltd")]
[assembly: AssemblyProduct("Sif.Framework.Demo.Us.Consumer")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2018")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.2.1.11")]
[assembly: AssemblyFileVersion("3.2.1.11")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Systemic Pty Ltd")]
[assembly: AssemblyProduct("Sif.Framework.Demo.Us.Provider")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2018")]
[assembly: AssemblyCopyright("Copyright © Systemic Pty Ltd 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.2.1.11")]
[assembly: AssemblyFileVersion("3.2.1.11")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
6 changes: 5 additions & 1 deletion Documentation/Backward incompatible changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Backward incompatible changes


### **3.2.1.14 -> 4.0.0**

- The public Consumer(Environment) constructor has been made protected.
Expand All @@ -13,3 +12,8 @@
- The empty default constructor of the AuthorisationService class has been removed.
- The Sif.Framework project only targets .NET Standard 2.0, .NET Framework 4.7.2 and .NET Framework 4.6.1. It no longer targets .NET Frameworks 4.6.2, 4.7 and 4.7.1.
- The ConsumerRegistrationService and ProviderRegistrationService static properties of the static RegistrationManager class have been made obsolete.

### **4.0.1 -> 5.0.0**

- Renamed the ISessionService method HasSession(string) to HasSessionToken(string).
- Various methods in the ISessionService interface have been modified to throw AlreadyExistsException, ArgumentNullException, DuplicateFoundException and NotFoundException as appropriate.
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Managing application settings and session tokens from a database

Both SIF Consumers and Providers now support the passing of SIF Framework application settings and session tokens through constructor parameters. This allows these values to be read from any source (including a database) and not just from the SifFramework.config file (which is used by default if no constructor parameters are specified).

## SIF Consumer

The following modifications were made to the Demo AU Consumer.

### Common configuration

> 1. Installed the System.Data.SQLite NuGet package (not to be used for a production system).
> 1. Installed the Tardigrade.Framework.EntityFramework NuGet package.
> 1. Added an SQLite database file. Ensure that the `Build Action` is `None` and that the `Copy to Output Directory` is `Copy if newer`.
> 1. Configured the App.config file to support SQLite with EntityFramework 6, including defining the database file to be used. Instructions for the use of SQLite with EntityFramework is not within the scope of this document.
### Application settings

> 1. Created an AppSettings database table. An appropriate SQL script for the AppSettings database table can be found in the `Scripts\SQL\Application settings table` directory.
> 1. Updated the Demo AU Consumer classes to implement the constructors that pass an IFrameworkSettings parameter.
> 1. In the ConsumerApp class, read the application settings from the database and passed them to the constructor of the SIF Consumer (in this case, StudentPersonalConsumer).
To read the application settings from a database, the following code is used:

```cs
IFrameworkSettings settings =
new ConsumerSettings(
new ApplicationConfiguration(
new AppSettingsConfigurationSource("name=FrameworkConfigDb")));
```

The AppSettingsConfigurationSource constructor takes a connection string name that has been configured in the App.config file. The database file is referenced by default from the `bin\Debug` directory with the `|DataDirectory|` substitution string.

The AppSettingsConfigurationSource and ApplicationConfiguration classes are referenced from the Tardigrade.Framework.EntityFramework and Tardigrade.Framework NuGet packages respectively.

### Session tokens

> 1. Installed the Sif.Framework.EntityFramework NuGet package.
> 1. Created a Sessions database table. An appropriate SQL script for the Sessions database table can be found in the `Scripts\SQL\Session table` directory.
> 1. Updated the Demo AU Consumer classes to implement the constructors that pass an ISessionService parameter.
> 1. In the ConsumerApp class, created the session service and passed it to the constructor of the SIF Consumer (in this case, StudentPersonalConsumer).
To create the session service, the following code is used:

```cs
DbContext dbContext = new SessionDbContext("name=FrameworkConfigDb");
IRepository<Session, Guid> repository = new Repository<Session, Guid>(dbContext);
IObjectService<Session, Guid> service = new ObjectService<Session, Guid>(repository);
ISessionService sessionService = new SessionService(service);
```

The SessionDbContext constructor takes a connection string name that has been configured in the App.config file. The database file is referenced by default from the `bin\Debug` directory with the `|DataDirectory|` substitution string.

The Repository and ObjectService classes are referenced from the Tardigrade.Framework.EntityFramework and Tardigrade.Framework NuGet packages respectively. The SessionDbContext and SessionService classes are referenced from the Sif.Framework.EntityFramework NuGet package.

## SIF Provider

The following modifications were made to the Demo AU Provider.

### Common configuration

> 1. Installed the System.Data.SQLite NuGet package (not to be used for a production system).
> 1. Installed the Tardigrade.Framework.EntityFramework NuGet package.
> 1. Added an SQLite database file to the App_Data directory. Ensure that the `Build Action` is `None` and that the `Copy to Output Directory` is `Copy if newer`.
> 1. Configured the Web.config file to support SQLite with EntityFramework 6, including defining the database file to be used. Instructions for the use of SQLite with EntityFramework is not within the scope of this document.
> 1. Added the `demo.frameworkConfigSource` application setting to the Web.config file and set it's value to `Database`.
### Application settings

> 1. Created an AppSettings database table. An appropriate SQL script for the AppSettings databaes table can be found in the `Scripts\SQL\Application settings table` directory.
> 1. Updated the Global.asax.cs file to read the application settings from the database and pass them to the `RegistrationManager.GetProviderRegistrationService(IFrameworkSettings, ISessionService)` method. All previous references to `SettingsManager.ProviderSettings` were replaced.
> 1. Updated the Demo AU Providers to implement the constructors that pass an IFrameworkSettings parameter.
To read the application settings from a database, the following code is used:

```cs
IFrameworkSettings settings =
new ProviderSettings(
new ApplicationConfiguration(
new AppSettingsConfigurationSource("name=FrameworkConfigDb")));
```

The AppSettingsConfigurationSource constructor takes a connection string name that has been configured in the Web.config file. The database file is referenced by default from the `App_Data` directory with the `|DataDirectory|` substitution string.

The AppSettingsConfigurationSource and ApplicationConfiguration classes are referenced from the Tardigrade.Framework.EntityFramework and Tardigrade.Framework NuGet packages respectively.

### Session tokens

> 1. Installed the Sif.Framework.EntityFramework NuGet package.
> 1. Created a Sessions database table. An appropriate SQL script for the Sessions database table can be found in the `Scripts\SQL\Session table` directory.
> 1. Updated the Global.asax.cs file to create a session service to pass to the `RegistrationManager.GetProviderRegistrationService(IFrameworkSettings, ISessionService)` method.
> 1. Updated the Demo AU Providers to implement the constructors that pass an ISessionService parameter.
To create the session service, the following code is used:

```cs
DbContext dbContext = new SessionDbContext("name=FrameworkConfigDb");
IRepository<Session, Guid> repository = new Repository<Session, Guid>(dbContext);
IObjectService<Session, Guid> service = new ObjectService<Session, Guid>(repository);
ISessionService sessionService = new SessionService(service);
```

The SessionDbContext constructor takes a connection string name that has been configured in the Web.config file. The database file is referenced by default from the `App_Data` directory with the `|DataDirectory|` substitution string.

The Repository and ObjectService classes are referenced from the Tardigrade.Framework.EntityFramework and Tardigrade.Framework NuGet packages respectively. The SessionDbContext and SessionService classes are referenced from the Sif.Framework.EntityFramework NuGet package.
Loading

0 comments on commit a58ccec

Please sign in to comment.