diff --git a/DEPENDENCIES b/DEPENDENCIES
index e69de29b..fcae7a8a 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -0,0 +1,57 @@
+nuget/nuget/-/AutoFixture.AutoFakeItEasy/4.18.0, MIT, approved, #10064
+nuget/nuget/-/AutoFixture.Xunit/4.18.0, MIT, approved, #10082
+nuget/nuget/-/AutoFixture/4.18.0, MIT, approved, #10057
+nuget/nuget/-/Castle.Core/4.3.1, Apache-2.0, approved, clearlydefined
+nuget/nuget/-/EFCore.NamingConventions/7.0.2, Apache-2.0, approved, #10067
+nuget/nuget/-/FakeItEasy/7.4.0, MIT, approved, #10080
+nuget/nuget/-/Fare/2.1.1, MIT, approved, clearlydefined
+nuget/nuget/-/FluentAssertions/6.11.0, Apache-2.0 AND MIT, approved, #10061
+nuget/nuget/-/Flurl.Http.Signed/3.2.4, MIT, approved, #3503
+nuget/nuget/-/Flurl.Signed/3.0.6, MIT, approved, #3501
+nuget/nuget/-/Humanizer.Core/2.14.1, MIT, approved, #10060
+nuget/nuget/-/Json.More.Net/2.0.0, MIT, approved, clearlydefined
+nuget/nuget/-/JsonPointer.Net/4.0.0, MIT, approved, clearlydefined
+nuget/nuget/-/JsonSchema.Net/6.0.3, MIT AND OFL-1.1 AND CC-BY-SA-4.0, approved, #13370
+nuget/nuget/-/Laraue.EfCoreTriggers.Common/7.1.0, MIT, approved, #10247
+nuget/nuget/-/Laraue.EfCoreTriggers.PostgreSql/7.1.0, MIT, approved, #10248
+nuget/nuget/-/Mono.TextTemplating/2.2.1, MIT, approved, clearlydefined
+nuget/nuget/-/Newtonsoft.Json/12.0.2, MIT AND BSD-3-Clause, approved, #11114
+nuget/nuget/-/Newtonsoft.Json/13.0.1, MIT AND BSD-3-Clause, approved, #3266
+nuget/nuget/-/Newtonsoft.Json/13.0.3, MIT AND BSD-3-Clause, approved, #3266
+nuget/nuget/-/Npgsql.EntityFrameworkCore.PostgreSQL/7.0.11, PostgreSQL AND MIT AND Apache-2.0, approved, #10081
+nuget/nuget/-/Npgsql/7.0.6, PostgreSQL, approved, #10062
+nuget/nuget/-/PasswordGenerator/2.1.0, MIT, approved, #3192
+nuget/nuget/-/Portable.BouncyCastle/1.9.0, MIT, approved, clearlydefined
+nuget/nuget/-/SSH.NET/2020.0.2, MIT AND ISC AND LicenseRef-Public-domain AND (MIT AND MS-PL), approved, #10073
+nuget/nuget/-/Serilog.AspNetCore/7.0.0, Apache-2.0 AND MIT, approved, #10084
+nuget/nuget/-/Serilog.Enrichers.CorrelationId/3.0.1, MIT, approved, clearlydefined
+nuget/nuget/-/Serilog.Enrichers.Environment/2.2.0, Apache-2.0, approved, clearlydefined
+nuget/nuget/-/Serilog.Enrichers.Process/2.0.2, Apache-2.0, approved, clearlydefined
+nuget/nuget/-/Serilog.Enrichers.Sensitive/1.7.3, MIT, approved, clearlydefined
+nuget/nuget/-/Serilog.Enrichers.Thread/3.1.0, Apache-2.0, approved, clearlydefined
+nuget/nuget/-/Serilog.Extensions.Hosting/7.0.0, Apache-2.0, approved, #10078
+nuget/nuget/-/Serilog.Extensions.Logging/7.0.0, Apache-2.0, approved, #10070
+nuget/nuget/-/Serilog.Formatting.Compact/1.1.0, Apache-2.0, approved, #11115
+nuget/nuget/-/Serilog.Settings.Configuration/7.0.0, Apache-2.0, approved, #10069
+nuget/nuget/-/Serilog.Sinks.Console/4.1.0, Apache-2.0, approved, #8434
+nuget/nuget/-/Serilog.Sinks.Debug/2.0.0, Apache-2.0, approved, clearlydefined
+nuget/nuget/-/Serilog.Sinks.File/5.0.0, Apache-2.0, approved, #11116
+nuget/nuget/-/Serilog/3.0.1, Apache-2.0, approved, #10063
+nuget/nuget/-/SharpZipLib/1.4.2, MIT AND GFDL-1.3-or-later AND (Apache-2.0 AND MIT) AND WTFPL AND bzip2-1.0.6 AND LicenseRef-Permissive-license-with-conditions AND LicenseRef-Permission-Notice, approved, #10058
+nuget/nuget/-/SshNet.Security.Cryptography/1.3.0, MIT, approved, clearlydefined
+nuget/nuget/-/Swashbuckle.AspNetCore.Swagger/6.5.0, MIT AND Apache-2.0, approved, #7160
+nuget/nuget/-/Swashbuckle.AspNetCore.SwaggerGen/6.5.0, MIT AND Apache-2.0, approved, #7156
+nuget/nuget/-/Swashbuckle.AspNetCore.SwaggerUI/6.5.0, MIT AND Apache-2.0, approved, #7158
+nuget/nuget/-/Swashbuckle.AspNetCore/6.5.0, MIT AND Apache-2.0, approved, #7159
+nuget/nuget/-/Testcontainers.PostgreSql/3.4.0, MIT, approved, #10056
+nuget/nuget/-/Testcontainers/3.4.0, MIT, approved, #10083
+nuget/nuget/-/Xunit.Extensions.AssemblyFixture/2.4.1, MIT, approved, #3502
+nuget/nuget/-/coverlet.collector/6.0.0, MIT, approved, #10075
+nuget/nuget/-/xunit.abstractions/2.0.3, Apache-2.0, approved, clearlydefined
+nuget/nuget/-/xunit.analyzers/1.2.0, Apache-2.0 AND MIT, approved, #10068
+nuget/nuget/-/xunit.assert/2.5.0, Apache-2.0 AND MIT, approved, #10071
+nuget/nuget/-/xunit.core/2.5.0, Apache-2.0 AND MIT, approved, #10059
+nuget/nuget/-/xunit.extensibility.core/2.5.0, Apache-2.0 AND MIT, approved, #10077
+nuget/nuget/-/xunit.extensibility.execution/2.5.0, Apache-2.0 AND MIT, approved, #10074
+nuget/nuget/-/xunit.runner.visualstudio/2.5.0, Apache-2.0 AND MIT, approved, #10065
+nuget/nuget/-/xunit/2.5.0, Apache-2.0 AND MIT, approved, #10072
diff --git a/FILEHEADER.md b/FILEHEADER.md
index 79d8879b..7b905c2c 100644
--- a/FILEHEADER.md
+++ b/FILEHEADER.md
@@ -12,4 +12,4 @@ Every time you create a new file or edit a file that you created and doesn't yet
Currently the following templates are available:
* cx_header_default
-* cx_header_with_#
\ No newline at end of file
+* cx_header_with_#
diff --git a/README.md b/README.md
index 2c922dea..186d3821 100644
--- a/README.md
+++ b/README.md
@@ -22,4 +22,4 @@ dotnet run
## License
Distributed under the Apache 2.0 License.
-See [LICENSE](./LICENSE) for more information
\ No newline at end of file
+See [LICENSE](./LICENSE) for more information
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
new file mode 100644
index 00000000..8f19d9c4
--- /dev/null
+++ b/src/Directory.Build.props
@@ -0,0 +1,25 @@
+
+
+
+
+ 0.1.0
+ rc.1
+
+
diff --git a/src/SsiCredentialIssuer.sln b/src/SsiCredentialIssuer.sln
new file mode 100644
index 00000000..45b97db1
--- /dev/null
+++ b/src/SsiCredentialIssuer.sln
@@ -0,0 +1,177 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "database", "database", "{E9E08CE9-985A-4507-BBD3-9470623986CF}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "issuer", "issuer", "{32D0AE23-BFAA-4D65-AF9D-2DF951BA5A3B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SsiCredentialIssuer.Service", "issuer\SsiCredentialIssuer.Service\SsiCredentialIssuer.Service.csproj", "{6905B6DF-722B-4882-A2CB-5E6BFD0244F2}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SsiCredentialIssuer.Entities", "database\SsiCredentialIssuer.Entities\SsiCredentialIssuer.Entities.csproj", "{5627AA4F-A64B-4878-A139-F3ED6734BDEC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SsiCredentialIssuer.DbAccess", "database\SsiCredentialIssuer.DbAccess\SsiCredentialIssuer.DbAccess.csproj", "{55F32819-B53D-4908-A4C1-F663871474C3}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "credentials", "credentials", "{A79FF417-08E7-4175-8089-5F21054F5BDE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SsiCredentialIssuer.Migrations", "database\SsiCredentialIssuer.Migrations\SsiCredentialIssuer.Migrations.csproj", "{F74763E9-231A-46C9-A160-72863963D17F}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "externalservices", "externalservices", "{A37A220C-4242-4FB2-98ED-EF4B602EF6C1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wallet.Service", "externalservices\Wallet.Service\Wallet.Service.csproj", "{73705ADF-C348-483D-931C-5CDFAB848596}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "processes", "processes", "{A4745993-CEC3-48E9-9765-0401F5B0516C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processes.Library", "processes\Processes.Library\Processes.Library.csproj", "{1D005706-65BF-4A99-A847-69E656CF7529}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processes.Worker", "processes\Processes.Worker\Processes.Worker.csproj", "{DA615C88-8859-41CD-A696-0BE542117008}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processes.Worker.Library", "processes\Processes.Worker.Library\Processes.Worker.Library.csproj", "{7F6B407F-A698-4568-A711-42FD53F06129}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CredentialProcess.Worker", "processes\CredentialProcess.Worker\CredentialProcess.Worker.csproj", "{30C2CCFC-6C76-4A68-8CA1-BA6A4EA28E76}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CredentialProcess.Library", "processes\CredentialProcess.Library\CredentialProcess.Library.csproj", "{28919880-0F47-4D54-B253-E1381984C840}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Portal.Service", "externalservices\Portal.Service\Portal.Service.csproj", "{8AF8FC7D-3448-422A-8739-0690AA700DAD}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SsiCredentialIssuer.Expiry.App", "credentials\SsiCredentialIssuer.Expiry.App\SsiCredentialIssuer.Expiry.App.csproj", "{9F9FFBEE-4256-494F-BEF7-8856145D45EC}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A2FC3E0F-5AFE-44FA-909B-B8016DD1EB44}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SsiCredentialIssuer.Expiry.App.Tests", "..\tests\credentials\SsiCredentialIssuer.Expiry.App.Tests\SsiCredentialIssuer.Expiry.App.Tests.csproj", "{FFB1423F-C41F-46A9-8D5D-115B3BC46682}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processes.Library.Tests", "..\tests\processes\Processes.Library.Tests\Processes.Library.Tests.csproj", "{3AADCF6D-746E-49C8-89DC-96474F70B130}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processes.Worker.Library.Tests", "..\tests\processes\Processes.Worker.Library.Tests\Processes.Worker.Library.Tests.csproj", "{5CEA19ED-04F0-4CC6-8D5D-C54629436EDA}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SsiCredentialIssuer.Service.Tests", "..\tests\issuer\SsiCredentialIssuer.Service.Tests\SsiCredentialIssuer.Service.Tests.csproj", "{D88007E0-603A-49B7-B4E4-AD255B06D252}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Portal.Service.Tests", "..\tests\externalservices\Portal.Service.Tests\Portal.Service.Tests.csproj", "{5A0321D9-F716-47AF-AA96-E5AADC0C26EE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.Shared", "..\tests\Tests.Shared\Tests.Shared.csproj", "{6A1D91F3-B9EC-40CD-9239-1D80FADF8E1A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wallet.Service.Tests", "..\tests\externalservices\Wallet.Service.Tests\Wallet.Service.Tests.csproj", "{F46B828C-3E95-49D0-A3D2-F5A083F5FE7A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SsiCredentialIssuer.DbAccess.Tests", "..\tests\database\SsiCredentialIssuer.DbAccess.Tests\SsiCredentialIssuer.DbAccess.Tests.csproj", "{3967B3E7-093B-438C-81FE-A7CAE5FFAD31}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CredentialProcess.Worker.Tests", "..\tests\processes\CredentialProcess.Worker.Tests\CredentialProcess.Worker.Tests.csproj", "{2D42186B-5BC8-4F60-92D3-FD1FF0F5FF87}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CredentialProcess.Library.Tests", "..\tests\processes\CredentialProcess.Library.Tests\CredentialProcess.Library.Tests.csproj", "{0A9C65F7-62B6-421F-ADA5-709A1EE10901}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6905B6DF-722B-4882-A2CB-5E6BFD0244F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6905B6DF-722B-4882-A2CB-5E6BFD0244F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6905B6DF-722B-4882-A2CB-5E6BFD0244F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6905B6DF-722B-4882-A2CB-5E6BFD0244F2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5627AA4F-A64B-4878-A139-F3ED6734BDEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5627AA4F-A64B-4878-A139-F3ED6734BDEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5627AA4F-A64B-4878-A139-F3ED6734BDEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5627AA4F-A64B-4878-A139-F3ED6734BDEC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {55F32819-B53D-4908-A4C1-F663871474C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {55F32819-B53D-4908-A4C1-F663871474C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {55F32819-B53D-4908-A4C1-F663871474C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {55F32819-B53D-4908-A4C1-F663871474C3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F74763E9-231A-46C9-A160-72863963D17F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F74763E9-231A-46C9-A160-72863963D17F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F74763E9-231A-46C9-A160-72863963D17F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F74763E9-231A-46C9-A160-72863963D17F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {73705ADF-C348-483D-931C-5CDFAB848596}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {73705ADF-C348-483D-931C-5CDFAB848596}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {73705ADF-C348-483D-931C-5CDFAB848596}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {73705ADF-C348-483D-931C-5CDFAB848596}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1D005706-65BF-4A99-A847-69E656CF7529}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1D005706-65BF-4A99-A847-69E656CF7529}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1D005706-65BF-4A99-A847-69E656CF7529}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1D005706-65BF-4A99-A847-69E656CF7529}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DA615C88-8859-41CD-A696-0BE542117008}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DA615C88-8859-41CD-A696-0BE542117008}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DA615C88-8859-41CD-A696-0BE542117008}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DA615C88-8859-41CD-A696-0BE542117008}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7F6B407F-A698-4568-A711-42FD53F06129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7F6B407F-A698-4568-A711-42FD53F06129}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7F6B407F-A698-4568-A711-42FD53F06129}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7F6B407F-A698-4568-A711-42FD53F06129}.Release|Any CPU.Build.0 = Release|Any CPU
+ {30C2CCFC-6C76-4A68-8CA1-BA6A4EA28E76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {30C2CCFC-6C76-4A68-8CA1-BA6A4EA28E76}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {30C2CCFC-6C76-4A68-8CA1-BA6A4EA28E76}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {30C2CCFC-6C76-4A68-8CA1-BA6A4EA28E76}.Release|Any CPU.Build.0 = Release|Any CPU
+ {28919880-0F47-4D54-B253-E1381984C840}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {28919880-0F47-4D54-B253-E1381984C840}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {28919880-0F47-4D54-B253-E1381984C840}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {28919880-0F47-4D54-B253-E1381984C840}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8AF8FC7D-3448-422A-8739-0690AA700DAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8AF8FC7D-3448-422A-8739-0690AA700DAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8AF8FC7D-3448-422A-8739-0690AA700DAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8AF8FC7D-3448-422A-8739-0690AA700DAD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9F9FFBEE-4256-494F-BEF7-8856145D45EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9F9FFBEE-4256-494F-BEF7-8856145D45EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9F9FFBEE-4256-494F-BEF7-8856145D45EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9F9FFBEE-4256-494F-BEF7-8856145D45EC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FFB1423F-C41F-46A9-8D5D-115B3BC46682}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FFB1423F-C41F-46A9-8D5D-115B3BC46682}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FFB1423F-C41F-46A9-8D5D-115B3BC46682}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FFB1423F-C41F-46A9-8D5D-115B3BC46682}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3AADCF6D-746E-49C8-89DC-96474F70B130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3AADCF6D-746E-49C8-89DC-96474F70B130}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3AADCF6D-746E-49C8-89DC-96474F70B130}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3AADCF6D-746E-49C8-89DC-96474F70B130}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5CEA19ED-04F0-4CC6-8D5D-C54629436EDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5CEA19ED-04F0-4CC6-8D5D-C54629436EDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5CEA19ED-04F0-4CC6-8D5D-C54629436EDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5CEA19ED-04F0-4CC6-8D5D-C54629436EDA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D88007E0-603A-49B7-B4E4-AD255B06D252}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D88007E0-603A-49B7-B4E4-AD255B06D252}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D88007E0-603A-49B7-B4E4-AD255B06D252}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D88007E0-603A-49B7-B4E4-AD255B06D252}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5A0321D9-F716-47AF-AA96-E5AADC0C26EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5A0321D9-F716-47AF-AA96-E5AADC0C26EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5A0321D9-F716-47AF-AA96-E5AADC0C26EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5A0321D9-F716-47AF-AA96-E5AADC0C26EE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6A1D91F3-B9EC-40CD-9239-1D80FADF8E1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6A1D91F3-B9EC-40CD-9239-1D80FADF8E1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6A1D91F3-B9EC-40CD-9239-1D80FADF8E1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6A1D91F3-B9EC-40CD-9239-1D80FADF8E1A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F46B828C-3E95-49D0-A3D2-F5A083F5FE7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F46B828C-3E95-49D0-A3D2-F5A083F5FE7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F46B828C-3E95-49D0-A3D2-F5A083F5FE7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F46B828C-3E95-49D0-A3D2-F5A083F5FE7A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3967B3E7-093B-438C-81FE-A7CAE5FFAD31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3967B3E7-093B-438C-81FE-A7CAE5FFAD31}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3967B3E7-093B-438C-81FE-A7CAE5FFAD31}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3967B3E7-093B-438C-81FE-A7CAE5FFAD31}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2D42186B-5BC8-4F60-92D3-FD1FF0F5FF87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2D42186B-5BC8-4F60-92D3-FD1FF0F5FF87}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2D42186B-5BC8-4F60-92D3-FD1FF0F5FF87}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2D42186B-5BC8-4F60-92D3-FD1FF0F5FF87}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0A9C65F7-62B6-421F-ADA5-709A1EE10901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0A9C65F7-62B6-421F-ADA5-709A1EE10901}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0A9C65F7-62B6-421F-ADA5-709A1EE10901}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0A9C65F7-62B6-421F-ADA5-709A1EE10901}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {6905B6DF-722B-4882-A2CB-5E6BFD0244F2} = {32D0AE23-BFAA-4D65-AF9D-2DF951BA5A3B}
+ {5627AA4F-A64B-4878-A139-F3ED6734BDEC} = {E9E08CE9-985A-4507-BBD3-9470623986CF}
+ {55F32819-B53D-4908-A4C1-F663871474C3} = {E9E08CE9-985A-4507-BBD3-9470623986CF}
+ {F74763E9-231A-46C9-A160-72863963D17F} = {E9E08CE9-985A-4507-BBD3-9470623986CF}
+ {73705ADF-C348-483D-931C-5CDFAB848596} = {A37A220C-4242-4FB2-98ED-EF4B602EF6C1}
+ {1D005706-65BF-4A99-A847-69E656CF7529} = {A4745993-CEC3-48E9-9765-0401F5B0516C}
+ {DA615C88-8859-41CD-A696-0BE542117008} = {A4745993-CEC3-48E9-9765-0401F5B0516C}
+ {7F6B407F-A698-4568-A711-42FD53F06129} = {A4745993-CEC3-48E9-9765-0401F5B0516C}
+ {30C2CCFC-6C76-4A68-8CA1-BA6A4EA28E76} = {A4745993-CEC3-48E9-9765-0401F5B0516C}
+ {28919880-0F47-4D54-B253-E1381984C840} = {A4745993-CEC3-48E9-9765-0401F5B0516C}
+ {8AF8FC7D-3448-422A-8739-0690AA700DAD} = {A37A220C-4242-4FB2-98ED-EF4B602EF6C1}
+ {9F9FFBEE-4256-494F-BEF7-8856145D45EC} = {A79FF417-08E7-4175-8089-5F21054F5BDE}
+ {FFB1423F-C41F-46A9-8D5D-115B3BC46682} = {A2FC3E0F-5AFE-44FA-909B-B8016DD1EB44}
+ {3AADCF6D-746E-49C8-89DC-96474F70B130} = {A2FC3E0F-5AFE-44FA-909B-B8016DD1EB44}
+ {5CEA19ED-04F0-4CC6-8D5D-C54629436EDA} = {A2FC3E0F-5AFE-44FA-909B-B8016DD1EB44}
+ {D88007E0-603A-49B7-B4E4-AD255B06D252} = {A2FC3E0F-5AFE-44FA-909B-B8016DD1EB44}
+ {5A0321D9-F716-47AF-AA96-E5AADC0C26EE} = {A2FC3E0F-5AFE-44FA-909B-B8016DD1EB44}
+ {6A1D91F3-B9EC-40CD-9239-1D80FADF8E1A} = {A2FC3E0F-5AFE-44FA-909B-B8016DD1EB44}
+ {F46B828C-3E95-49D0-A3D2-F5A083F5FE7A} = {A2FC3E0F-5AFE-44FA-909B-B8016DD1EB44}
+ {3967B3E7-093B-438C-81FE-A7CAE5FFAD31} = {A2FC3E0F-5AFE-44FA-909B-B8016DD1EB44}
+ {2D42186B-5BC8-4F60-92D3-FD1FF0F5FF87} = {A2FC3E0F-5AFE-44FA-909B-B8016DD1EB44}
+ {0A9C65F7-62B6-421F-ADA5-709A1EE10901} = {A2FC3E0F-5AFE-44FA-909B-B8016DD1EB44}
+ EndGlobalSection
+EndGlobal
diff --git a/src/credentials/SsiCredentialIssuer.Expiry.App/DependencyInjection/ExpiryCheckServiceExtensions.cs b/src/credentials/SsiCredentialIssuer.Expiry.App/DependencyInjection/ExpiryCheckServiceExtensions.cs
new file mode 100644
index 00000000..8ee30dd2
--- /dev/null
+++ b/src/credentials/SsiCredentialIssuer.Expiry.App/DependencyInjection/ExpiryCheckServiceExtensions.cs
@@ -0,0 +1,47 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.DateTimeProvider;
+using System.Diagnostics.CodeAnalysis;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Expiry.App.DependencyInjection;
+
+///
+/// Extension method to register the expiry check service and dependent services
+///
+[ExcludeFromCodeCoverage]
+public static class ExpiryCheckServiceExtensions
+{
+ ///
+ /// Adds the expiry check service
+ ///
+ /// the services
+ /// the configuration section to setup the settings
+ /// the enriched service collection
+ public static IServiceCollection AddExpiryCheckService(this IServiceCollection services, IConfigurationSection section)
+ {
+ services.AddOptions().Bind(section);
+ services
+ .AddTransient()
+ .AddTransient();
+ return services;
+ }
+}
diff --git a/src/credentials/SsiCredentialIssuer.Expiry.App/DependencyInjection/ExpiryCheckServiceSettings.cs b/src/credentials/SsiCredentialIssuer.Expiry.App/DependencyInjection/ExpiryCheckServiceSettings.cs
new file mode 100644
index 00000000..e544c53c
--- /dev/null
+++ b/src/credentials/SsiCredentialIssuer.Expiry.App/DependencyInjection/ExpiryCheckServiceSettings.cs
@@ -0,0 +1,40 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Expiry.App.DependencyInjection;
+
+///
+/// Settings for the ExpiryCheckService
+///
+public class ExpiryCheckServiceSettings
+{
+ ///
+ /// Vcs which are older than the given value will be deleted when expired
+ ///
+ [Required]
+ public int ExpiredVcsToDeleteInMonth { get; init; }
+
+ ///
+ /// Vcs which are older than the given value will be deleted when declined
+ ///
+ [Required]
+ public int InactiveVcsToDeleteInWeeks { get; init; }
+}
diff --git a/src/credentials/SsiCredentialIssuer.Expiry.App/ExpiryCheckService.cs b/src/credentials/SsiCredentialIssuer.Expiry.App/ExpiryCheckService.cs
new file mode 100644
index 00000000..a5017dd0
--- /dev/null
+++ b/src/credentials/SsiCredentialIssuer.Expiry.App/ExpiryCheckService.cs
@@ -0,0 +1,196 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.DateTimeProvider;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Expiry.App.DependencyInjection;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Portal.Service.Models;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Portal.Service.Services;
+using System.Text.Json;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Expiry.App;
+
+///
+/// Service to delete the pending and inactive documents as well as the depending consents from the database
+///
+public class ExpiryCheckService
+{
+ private static readonly JsonSerializerOptions Options = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
+ private readonly IServiceScopeFactory _serviceScopeFactory;
+ private readonly ILogger _logger;
+ private readonly ExpiryCheckServiceSettings _settings;
+
+ ///
+ /// Creates a new instance of
+ ///
+ /// access to the services
+ /// the logger
+ /// The options
+ public ExpiryCheckService(
+ IServiceScopeFactory serviceScopeFactory,
+ ILogger logger,
+ IOptions options)
+ {
+ _serviceScopeFactory = serviceScopeFactory;
+ _logger = logger;
+ _settings = options.Value;
+ }
+
+ ///
+ /// Handles the
+ ///
+ /// Cancellation Token
+ public async Task ExecuteAsync(CancellationToken stoppingToken)
+ {
+ if (!stoppingToken.IsCancellationRequested)
+ {
+ try
+ {
+ using var processServiceScope = _serviceScopeFactory.CreateScope();
+ var repositories = processServiceScope.ServiceProvider.GetRequiredService();
+ var dateTimeProvider = processServiceScope.ServiceProvider.GetRequiredService();
+ var portalService = processServiceScope.ServiceProvider.GetRequiredService();
+
+ using var outerLoopScope = _serviceScopeFactory.CreateScope();
+ var outerLoopRepositories = outerLoopScope.ServiceProvider.GetRequiredService();
+
+ var now = dateTimeProvider.OffsetNow;
+ var companySsiDetailsRepository = repositories.GetInstance();
+ var inactiveVcsToDelete = now.AddDays(-(_settings.InactiveVcsToDeleteInWeeks * 7));
+ var expiredVcsToDelete = now.AddMonths(-_settings.ExpiredVcsToDeleteInMonth);
+
+ var credentials = outerLoopRepositories.GetInstance()
+ .GetExpiryData(now, inactiveVcsToDelete, expiredVcsToDelete);
+ await foreach (var credential in credentials.WithCancellation(stoppingToken).ConfigureAwait(false))
+ {
+ await ProcessCredentials(credential, companySsiDetailsRepository, repositories, portalService,
+ stoppingToken);
+ }
+ }
+ catch (Exception ex)
+ {
+ Environment.ExitCode = 1;
+ _logger.LogError("Verified Credential expiry check failed with error: {Errors}", ex.Message);
+ }
+ }
+ }
+
+ private static async Task ProcessCredentials(
+ CredentialExpiryData data,
+ ICompanySsiDetailsRepository companySsiDetailsRepository,
+ IIssuerRepositories repositories,
+ IPortalService portalService,
+ CancellationToken cancellationToken)
+ {
+ if (data.ScheduleData.IsVcToDelete)
+ {
+ companySsiDetailsRepository.RemoveSsiDetail(data.Id);
+ }
+ else if (data.ScheduleData.IsVcToDecline)
+ {
+ await HandleDecline(data, companySsiDetailsRepository, portalService, cancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ await HandleNotification(data, companySsiDetailsRepository, portalService, cancellationToken).ConfigureAwait(false);
+ }
+
+ // Saving here to make sure the each credential is handled by there own
+ await repositories.SaveAsync().ConfigureAwait(false);
+ }
+
+ private static async ValueTask HandleDecline(
+ CredentialExpiryData data,
+ ICompanySsiDetailsRepository companySsiDetailsRepository,
+ IPortalService portalService,
+ CancellationToken cancellationToken)
+ {
+ var content = JsonSerializer.Serialize(new { Type = data.VerifiedCredentialTypeId, CredentialId = data.Id }, Options);
+ await portalService.AddNotification(content, data.Bpnl, NotificationTypeId.CREDENTIAL_REJECTED, cancellationToken);
+ companySsiDetailsRepository.AttachAndModifyCompanySsiDetails(data.Id, c =>
+ {
+ c.CompanySsiDetailStatusId = data.CompanySsiDetailStatusId;
+ },
+ c =>
+ {
+ c.CompanySsiDetailStatusId = CompanySsiDetailStatusId.INACTIVE;
+ });
+
+ var typeValue = data.VerifiedCredentialTypeId.GetEnumValue() ?? throw new UnexpectedConditionException($"VerifiedCredentialType {data.VerifiedCredentialTypeId} does not exists");
+ var mailParameters = new Dictionary
+ {
+ { "requestName", typeValue },
+ { "reason", "The credential is already expired" }
+ };
+ await portalService.TriggerMail("CredentialRejected", data.Bpnl, mailParameters, cancellationToken);
+ }
+
+ private static async ValueTask HandleNotification(
+ CredentialExpiryData data,
+ ICompanySsiDetailsRepository companySsiDetailsRepository,
+ IPortalService portalService,
+ CancellationToken cancellationToken)
+ {
+ var newExpiryCheckTypeId = data.ScheduleData switch
+ {
+ { IsOneDayNotification: true } => ExpiryCheckTypeId.ONE_DAY,
+ { IsTwoWeeksNotification: true } => ExpiryCheckTypeId.TWO_WEEKS,
+ { IsOneMonthNotification: true } => ExpiryCheckTypeId.ONE_MONTH,
+ _ => throw new UnexpectedConditionException("one of IsVcToDelete, IsOneDayNotification, IsTwoWeeksNotification, IsOneMonthNotification, IsVcToDecline is expected to be true")
+ };
+
+ companySsiDetailsRepository.AttachAndModifyCompanySsiDetails(
+ data.Id,
+ csd =>
+ {
+ csd.ExpiryCheckTypeId = data.ExpiryCheckTypeId;
+ },
+ csd =>
+ {
+ csd.ExpiryCheckTypeId = newExpiryCheckTypeId;
+ });
+
+ var content = JsonSerializer.Serialize(new
+ {
+ Type = data.VerifiedCredentialTypeId,
+ ExpiryDate = data.ExpiryDate?.ToString("O") ?? throw new ConflictException("Expiry Date must be set here"),
+ Version = data.DetailVersion,
+ CredentialId = data.Id,
+ ExpiryCheckTypeId = newExpiryCheckTypeId
+ }, Options);
+ await portalService.AddNotification(content, data.Bpnl, NotificationTypeId.CREDENTIAL_EXPIRY, cancellationToken);
+ var typeValue = data.VerifiedCredentialTypeId.GetEnumValue() ?? throw new UnexpectedConditionException($"VerifiedCredentialType {data.VerifiedCredentialTypeId} does not exists");
+ var mailParameters = new Dictionary
+ {
+ { "typeId", typeValue },
+ { "version", data.DetailVersion ?? "no version" },
+ { "expiryDate", data.ExpiryDate?.ToString("dd MMMM yyyy") ?? throw new ConflictException("Expiry Date must be set here") }
+ };
+
+ await portalService.TriggerMail("CredentialExpiry", data.Bpnl, mailParameters, cancellationToken);
+ }
+}
diff --git a/src/credentials/SsiCredentialIssuer.Expiry.App/Program.cs b/src/credentials/SsiCredentialIssuer.Expiry.App/Program.cs
new file mode 100644
index 00000000..5adce1cb
--- /dev/null
+++ b/src/credentials/SsiCredentialIssuer.Expiry.App/Program.cs
@@ -0,0 +1,68 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Logging;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Expiry.App;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Expiry.App.DependencyInjection;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Portal.Service.DependencyInjection;
+using Serilog;
+using System.Diagnostics.CodeAnalysis;
+
+LoggingExtensions.EnsureInitialized();
+Log.Information("Building worker");
+try
+{
+ var host = Host
+ .CreateDefaultBuilder(args)
+ .ConfigureServices((hostContext, services) =>
+ {
+ services
+ .AddExpiryCheckService(hostContext.Configuration.GetSection("Expiry"))
+ .AddPortalService(hostContext.Configuration.GetSection("Portal"))
+ .AddIssuerRepositories(hostContext.Configuration);
+ })
+ .AddLogging()
+ .Build();
+ Log.Information("Building worker completed");
+
+ using var tokenSource = new CancellationTokenSource();
+ Console.CancelKeyPress += (s, e) =>
+ {
+ Log.Information("Canceling...");
+ tokenSource.Cancel();
+ e.Cancel = true;
+ };
+
+ Log.Information("Start processing");
+ var workerInstance = host.Services.GetRequiredService();
+ await workerInstance.ExecuteAsync(tokenSource.Token).ConfigureAwait(false);
+ Log.Information("Execution finished shutting down");
+}
+catch (Exception ex) when (!ex.GetType().Name.Equals("StopTheHostException", StringComparison.Ordinal))
+{
+ Log.Fatal(ex, "Unhandled exception");
+}
+finally
+{
+ Log.Information("Server Shutting down");
+ Log.CloseAndFlush();
+}
diff --git a/src/credentials/SsiCredentialIssuer.Expiry.App/Properties/launchSettings.json b/src/credentials/SsiCredentialIssuer.Expiry.App/Properties/launchSettings.json
new file mode 100644
index 00000000..bfcfee34
--- /dev/null
+++ b/src/credentials/SsiCredentialIssuer.Expiry.App/Properties/launchSettings.json
@@ -0,0 +1,11 @@
+{
+ "$schema": "http://json.schemastore.org/launchsettings.json",
+ "profiles": {
+ "Credential.App": {
+ "commandName": "Project",
+ "environmentVariables": {
+ "DOTNET_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/src/credentials/SsiCredentialIssuer.Expiry.App/SsiCredentialIssuer.Expiry.App.csproj b/src/credentials/SsiCredentialIssuer.Expiry.App/SsiCredentialIssuer.Expiry.App.csproj
new file mode 100644
index 00000000..4526d1a3
--- /dev/null
+++ b/src/credentials/SsiCredentialIssuer.Expiry.App/SsiCredentialIssuer.Expiry.App.csproj
@@ -0,0 +1,79 @@
+
+
+
+
+
+ Org.Eclipse.TractusX.SsiCredentialIssuer.Expiry.App
+ Org.Eclipse.TractusX.SsiCredentialIssuer.Expiry.App
+ net7.0
+ enable
+ enable
+ 37a22764-0a60-4c2e-a692-d59c4f14abbf
+ Exe
+ Linux
+ ..\..\..
+ True
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Always
+
+
+
+
+
+ Program.cs
+
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+
+
+
+
+
diff --git a/src/credentials/SsiCredentialIssuer.Expiry.App/appsettings.json b/src/credentials/SsiCredentialIssuer.Expiry.App/appsettings.json
new file mode 100644
index 00000000..d559eeb4
--- /dev/null
+++ b/src/credentials/SsiCredentialIssuer.Expiry.App/appsettings.json
@@ -0,0 +1,57 @@
+{
+ "Serilog": {
+ "Using": [ "Serilog.Sinks.Console" ],
+ "MinimumLevel": {
+ "Default": "Information",
+ "Override": {
+ "Microsoft": "Warning",
+ "System": "Information",
+ "Microsoft.Hosting.Lifetime": "Information",
+ "Org.Eclipse.TractusX.Portal.Backend": "Information"
+ }
+ },
+ "WriteTo": [
+ { "Name": "Console" }
+ ],
+ "Enrich": [
+ "FromLogContext"
+ ],
+ "Properties": {
+ "Application": "Org.Eclipse.TractusX.Portal.Backend.Maintenance.App"
+ }
+ },
+ "ConnectionStrings": {
+ "PortalDb": "Server=placeholder;Database=placeholder;Port=5432;User Id=placeholder;Password=placeholder;Ssl Mode=Disable;"
+ },
+ "Expiry": {
+ "ExpiredVcsToDeleteInMonth": 12,
+ "InactiveVcsToDeleteInWeeks": 12
+ },
+ "MailingService": {
+ "Templates": [
+ {
+ "Name": "CredentialRejected",
+ "Setting": {
+ "Subject": "Company Wallet - SSI Credential Request Rejected",
+ "EmailTemplateType": "CredentialRejected"
+ }
+ },
+ {
+ "Name": "CredentialExpiry",
+ "Setting": {
+ "Subject": "Company Wallet - SSI Credential Expired",
+ "EmailTemplateType": "CredentialExpiry"
+ }
+ }
+ ],
+ "Mail": {
+ "SmtpHost": "",
+ "SmtpPort": 587,
+ "SmtpUser": "",
+ "SmtpPassword": ""
+ }
+ },
+ "ProcessIdentity": {
+ "ProcessUserId": ""
+ }
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Extensions/MediaTypeIdExtensions.cs b/src/database/SsiCredentialIssuer.DbAccess/Extensions/MediaTypeIdExtensions.cs
new file mode 100644
index 00000000..c96345d8
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Extensions/MediaTypeIdExtensions.cs
@@ -0,0 +1,65 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.Net.Mime;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Extensions;
+
+public static class MediaTypeIdExtensions
+{
+ public static string MapToMediaType(this MediaTypeId mediaTypeId)
+ {
+ return mediaTypeId switch
+ {
+ MediaTypeId.JPEG => MediaTypeNames.Image.Jpeg,
+ MediaTypeId.GIF => MediaTypeNames.Image.Gif,
+ MediaTypeId.PNG => "image/png",
+ MediaTypeId.SVG => "image/svg+xml",
+ MediaTypeId.TIFF => MediaTypeNames.Image.Tiff,
+ MediaTypeId.PDF => MediaTypeNames.Application.Pdf,
+ MediaTypeId.JSON => MediaTypeNames.Application.Json,
+ MediaTypeId.PEM => "application/x-pem-file",
+ MediaTypeId.CA_CERT => "application/x-x509-ca-cert",
+ MediaTypeId.PKX_CER => "application/pkix-cert",
+ MediaTypeId.OCTET => MediaTypeNames.Application.Octet,
+ _ => throw new ConflictException($"document mediatype {mediaTypeId} is not supported")
+ };
+ }
+
+ public static MediaTypeId ParseMediaTypeId(this string mediaType)
+ {
+ return mediaType.ToLower() switch
+ {
+ MediaTypeNames.Image.Jpeg => MediaTypeId.JPEG,
+ "image/png" => MediaTypeId.PNG,
+ MediaTypeNames.Image.Gif => MediaTypeId.GIF,
+ "image/svg+xml" => MediaTypeId.SVG,
+ MediaTypeNames.Image.Tiff => MediaTypeId.TIFF,
+ MediaTypeNames.Application.Pdf => MediaTypeId.PDF,
+ MediaTypeNames.Application.Json => MediaTypeId.JSON,
+ "application/x-pem-file" => MediaTypeId.PEM,
+ "application/x-x509-ca-cert" => MediaTypeId.CA_CERT,
+ "application/pkix-cert" => MediaTypeId.PKX_CER,
+ MediaTypeNames.Application.Octet => MediaTypeId.OCTET,
+ _ => throw new UnsupportedMediaTypeException($"mediaType '{mediaType}' is not supported")
+ };
+ }
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/IIssuerRepositories.cs b/src/database/SsiCredentialIssuer.DbAccess/IIssuerRepositories.cs
new file mode 100644
index 00000000..e0f19e3e
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/IIssuerRepositories.cs
@@ -0,0 +1,38 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess;
+
+public interface IIssuerRepositories
+{
+ ///
+ /// Attaches the given Entity to the database
+ ///
+ /// the entity that should be attached to the database
+ ///
+ /// Type of the entity
+ /// Returns the attached entity
+ TEntity Attach(TEntity entity, Action? setOptionalParameters = null)
+ where TEntity : class;
+
+ public T GetInstance();
+
+ public Task SaveAsync();
+ void Clear();
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/IssuerRepositories.cs b/src/database/SsiCredentialIssuer.DbAccess/IssuerRepositories.cs
new file mode 100644
index 00000000..b662182d
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/IssuerRepositories.cs
@@ -0,0 +1,78 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.EntityFrameworkCore;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities;
+using System.Collections.Immutable;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess;
+
+public class IssuerRepositories : IIssuerRepositories
+{
+ private readonly IssuerDbContext _dbContext;
+
+ private static readonly IReadOnlyDictionary> Types = new Dictionary> {
+ { typeof(ICompanySsiDetailsRepository), context => new CompanySsiDetailsRepository(context) },
+ { typeof(ICredentialRepository), context => new CredentialRepository(context) },
+ { typeof(IDocumentRepository), context => new DocumentRepository(context) },
+ { typeof(IProcessStepRepository), context => new ProcessStepRepository(context) },
+ }.ToImmutableDictionary();
+
+ public IssuerRepositories(IssuerDbContext dbContext)
+ {
+ _dbContext = dbContext;
+ }
+
+ public RepositoryType GetInstance()
+ {
+ Object? repository = default;
+
+ if (Types.TryGetValue(typeof(RepositoryType), out var createFunc))
+ {
+ repository = createFunc(_dbContext);
+ }
+
+ return (RepositoryType)(repository ?? throw new ArgumentException($"unexpected type {typeof(RepositoryType).Name}", nameof(RepositoryType)));
+ }
+
+ ///
+ public TEntity Attach(TEntity entity, Action? setOptionalParameters = null) where TEntity : class
+ {
+ var attachedEntity = _dbContext.Attach(entity).Entity;
+ setOptionalParameters?.Invoke(attachedEntity);
+
+ return attachedEntity;
+ }
+
+ public Task SaveAsync()
+ {
+ try
+ {
+ return _dbContext.SaveChangesAsync();
+ }
+ catch (DbUpdateConcurrencyException e)
+ {
+ throw new ConflictException("while processing a concurrent update was saved to the database (reason could also be data to be deleted is no longer existing)", e);
+ }
+ }
+
+ public void Clear() => _dbContext.ChangeTracker.Clear();
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/IssuerRepositoriesStartupServiceExtensions.cs b/src/database/SsiCredentialIssuer.DbAccess/IssuerRepositoriesStartupServiceExtensions.cs
new file mode 100644
index 00000000..42d0a7fe
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/IssuerRepositoriesStartupServiceExtensions.cs
@@ -0,0 +1,42 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.DependencyInjection;
+using System.Diagnostics.CodeAnalysis;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess;
+
+public static class IssuerRepositoriesStartupServiceExtensions
+{
+ [ExcludeFromCodeCoverage]
+ public static IServiceCollection AddIssuerRepositories(this IServiceCollection services, IConfiguration configuration)
+ {
+ services.AddScoped()
+ .AddDbAuditing()
+ .AddDbContext(o => o
+ .UseNpgsql(configuration.GetConnectionString("IssuerDb")))
+ .AddHealthChecks()
+ .AddDbContextCheck("IssuerDbContext", tags: new[] { "issuerdb" });
+ return services;
+ }
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/CompanySsiDetailSorting.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/CompanySsiDetailSorting.cs
new file mode 100644
index 00000000..b1fa5105
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Models/CompanySsiDetailSorting.cs
@@ -0,0 +1,38 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+
+///
+/// Possible sorting options for the pagination
+///
+public enum CompanySsiDetailSorting
+{
+ ///
+ /// Ascending by bpnl
+ ///
+ BpnlAsc = 1,
+
+ ///
+ /// Descending by bpnl
+ ///
+ BpnlDesc = 2,
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialDetailData.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialDetailData.cs
new file mode 100644
index 00000000..e04c59d8
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialDetailData.cs
@@ -0,0 +1,34 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+
+public record CredentialDetailData
+(
+ Guid CredentialDetailId,
+ string Bpnl,
+ VerifiedCredentialTypeId CredentialType,
+ string? UseCase,
+ CompanySsiDetailStatusId ParticipantStatus,
+ DateTimeOffset? ExpiryDate,
+ IEnumerable Documents,
+ ExternalTypeDetailData? ExternalTypeDetail
+);
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialExpiryData.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialExpiryData.cs
new file mode 100644
index 00000000..3369d496
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialExpiryData.cs
@@ -0,0 +1,40 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+
+public record CredentialExpiryData(
+ Guid Id,
+ DateTimeOffset? ExpiryDate,
+ ExpiryCheckTypeId? ExpiryCheckTypeId,
+ string? DetailVersion,
+ string Bpnl,
+ CompanySsiDetailStatusId CompanySsiDetailStatusId,
+ VerifiedCredentialTypeId VerifiedCredentialTypeId,
+ CredentialScheduleData ScheduleData);
+
+public record CredentialScheduleData(
+ bool IsVcToDelete,
+ bool IsOneDayNotification,
+ bool IsTwoWeeksNotification,
+ bool IsOneMonthNotification,
+ bool IsVcToDecline
+);
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/DocumentData.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/DocumentData.cs
new file mode 100644
index 00000000..5f2202d4
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Models/DocumentData.cs
@@ -0,0 +1,28 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+
+public record DocumentData
+(
+ Guid DocumentId,
+ string DocumentName,
+ DocumentTypeId argDocumentTypeId);
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/EncryptionTransformationData.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/EncryptionTransformationData.cs
new file mode 100644
index 00000000..d343eba7
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Models/EncryptionTransformationData.cs
@@ -0,0 +1,26 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+
+public record EncryptionTransformationData(
+ byte[]? Secret,
+ byte[]? InitializationVector,
+ int? EncryptionMode
+);
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/ExternalTypeDetailData.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/ExternalTypeDetailData.cs
new file mode 100644
index 00000000..6765c6b2
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Models/ExternalTypeDetailData.cs
@@ -0,0 +1,31 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+
+public record ExternalTypeDetailData(
+ Guid Id,
+ VerifiedCredentialExternalTypeId VerifiedCredentialExternalTypeId,
+ string? Version,
+ string? Template,
+ DateTimeOffset? ValidFrom,
+ DateTimeOffset? Expiry
+);
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/SsiApprovalData.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/SsiApprovalData.cs
new file mode 100644
index 00000000..5f7c46ea
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Models/SsiApprovalData.cs
@@ -0,0 +1,37 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+
+public record SsiApprovalData(
+ CompanySsiDetailStatusId Status,
+ VerifiedCredentialTypeId Type,
+ VerifiedCredentialTypeKindId? Kind,
+ string? Bpn,
+ DetailData? DetailData
+);
+
+public record DetailData(
+ VerifiedCredentialExternalTypeId VerifiedCredentialExternalTypeId,
+ string? Template,
+ string? Version,
+ DateTimeOffset ExpiryDate
+);
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/SsiCertificateTransferData.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/SsiCertificateTransferData.cs
new file mode 100644
index 00000000..9b92cb09
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Models/SsiCertificateTransferData.cs
@@ -0,0 +1,34 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+
+public record SsiCertificateTransferData
+(
+ VerifiedCredentialTypeId CredentialType,
+ IEnumerable Credentials
+);
+
+public record SsiCertificateExternalTypeDetailTransferData
+(
+ ExternalTypeDetailData ExternalDetailData,
+ IEnumerable SsiDetailData
+);
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/TechnicalUserDetails.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/TechnicalUserDetails.cs
new file mode 100644
index 00000000..9250b3bf
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Models/TechnicalUserDetails.cs
@@ -0,0 +1,33 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using System.Text.Json.Serialization;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+
+public record TechnicalUserDetails(
+ [property: JsonPropertyName("walletUrl")] string WalletUrl,
+ [property: JsonPropertyName("clientId")] string ClientId,
+ [property: JsonPropertyName("clientSecret")] string ClientSecret
+);
+
+public record HolderWalletData(
+ [property: JsonPropertyName("walletUrl")] string? WalletUrl,
+ [property: JsonPropertyName("clientId")] string? ClientId
+);
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/UseCaseParticipationTransferData.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/UseCaseParticipationTransferData.cs
new file mode 100644
index 00000000..18f61106
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Models/UseCaseParticipationTransferData.cs
@@ -0,0 +1,44 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+
+public record UseCaseParticipationTransferData
+(
+ string? UseCase,
+ string? Description,
+ VerifiedCredentialTypeId CredentialType,
+ IEnumerable VerifiedCredentials
+);
+
+public record CompanySsiExternalTypeDetailTransferData
+(
+ ExternalTypeDetailData ExternalDetailData,
+ IEnumerable SsiDetailData
+);
+
+public record CompanySsiDetailTransferData
+(
+ Guid CredentialId,
+ CompanySsiDetailStatusId ParticipationStatus,
+ DateTimeOffset? ExpiryDate,
+ IEnumerable Documents
+);
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/CompanySsiDetailsRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/CompanySsiDetailsRepository.cs
new file mode 100644
index 00000000..9f6bffa7
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/CompanySsiDetailsRepository.cs
@@ -0,0 +1,285 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.EntityFrameworkCore;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.Text.Json;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories;
+
+public class CompanySsiDetailsRepository : ICompanySsiDetailsRepository
+{
+ private readonly IssuerDbContext _context;
+
+ ///
+ /// Constructor.
+ ///
+ /// DB context.
+ public CompanySsiDetailsRepository(IssuerDbContext dbContext)
+ {
+ _context = dbContext;
+ }
+
+ ///
+ public IAsyncEnumerable GetUseCaseParticipationForCompany(string bpnl, DateTimeOffset minExpiry) =>
+ _context.VerifiedCredentialTypes
+ .Where(t => t.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId == VerifiedCredentialTypeKindId.FRAMEWORK)
+ .Select(t => new
+ {
+ UseCase = t.VerifiedCredentialTypeAssignedUseCase!.UseCase,
+ TypeId = t.Id,
+ ExternalTypeDetails = t.VerifiedCredentialTypeAssignedExternalType!.VerifiedCredentialExternalType!.VerifiedCredentialExternalTypeDetailVersions
+ })
+ .Select(x => new UseCaseParticipationTransferData(
+ x.UseCase!.Name,
+ x.UseCase.Shortname,
+ x.TypeId,
+ x.ExternalTypeDetails
+ .Select(e =>
+ new CompanySsiExternalTypeDetailTransferData(
+ new ExternalTypeDetailData(
+ e.Id,
+ e.VerifiedCredentialExternalTypeId,
+ e.Version,
+ e.Template,
+ e.ValidFrom,
+ e.Expiry),
+ e.CompanySsiDetails
+ .Where(ssi =>
+ ssi.Bpnl == bpnl &&
+ ssi.VerifiedCredentialTypeId == x.TypeId &&
+ ssi.CompanySsiDetailStatusId != CompanySsiDetailStatusId.INACTIVE &&
+ ssi.VerifiedCredentialExternalTypeDetailVersionId == e.Id &&
+ ssi.ExpiryDate > minExpiry)
+ .Select(ssi =>
+ new CompanySsiDetailTransferData(
+ ssi.Id,
+ ssi.CompanySsiDetailStatusId,
+ ssi.ExpiryDate,
+ ssi.Documents.Select(d => new DocumentData(
+ d.Id,
+ d.DocumentName,
+ d.DocumentTypeId))))
+ .Take(2)
+ ))
+ ))
+ .ToAsyncEnumerable();
+
+ ///
+ public IAsyncEnumerable GetSsiCertificates(string bpnl, DateTimeOffset minExpiry) =>
+ _context.VerifiedCredentialTypes
+ .Where(types => types.VerifiedCredentialTypeAssignedKind != null && types.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId != VerifiedCredentialTypeKindId.FRAMEWORK)
+ .Select(t => new
+ {
+ TypeId = t.Id,
+ ExternalTypeDetails = t.VerifiedCredentialTypeAssignedExternalType!.VerifiedCredentialExternalType!.VerifiedCredentialExternalTypeDetailVersions
+ })
+ .Select(x => new SsiCertificateTransferData(
+ x.TypeId,
+ x.ExternalTypeDetails
+ .Select(e =>
+ new SsiCertificateExternalTypeDetailTransferData(
+ new ExternalTypeDetailData(
+ e.Id,
+ e.VerifiedCredentialExternalTypeId,
+ e.Version,
+ e.Template,
+ e.ValidFrom,
+ e.Expiry),
+ e.CompanySsiDetails
+ .Where(ssi =>
+ ssi.Bpnl == bpnl &&
+ ssi.VerifiedCredentialTypeId == x.TypeId &&
+ ssi.CompanySsiDetailStatusId != CompanySsiDetailStatusId.INACTIVE &&
+ ssi.ExpiryDate > minExpiry)
+ .Select(ssi =>
+ new CompanySsiDetailTransferData(
+ ssi.Id,
+ ssi.CompanySsiDetailStatusId,
+ ssi.ExpiryDate,
+ ssi.Documents.Select(d => new DocumentData(
+ d.Id,
+ d.DocumentName,
+ d.DocumentTypeId))))
+ .Take(2)
+ ))
+ ))
+ .ToAsyncEnumerable();
+
+ ///
+ public CompanySsiDetail CreateSsiDetails(string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, Guid docId, CompanySsiDetailStatusId companySsiDetailStatusId, Guid userId, Action? setOptionalFields)
+ {
+ var detail = new CompanySsiDetail(Guid.NewGuid(), bpnl, verifiedCredentialTypeId, companySsiDetailStatusId, userId, DateTimeOffset.UtcNow);
+ setOptionalFields?.Invoke(detail);
+ return _context.CompanySsiDetails.Add(detail).Entity;
+ }
+
+ ///
+ public Task CheckSsiDetailsExistsForCompany(string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, VerifiedCredentialTypeKindId kindId, Guid? verifiedCredentialExternalTypeUseCaseDetailId) =>
+ _context.CompanySsiDetails
+ .AnyAsync(x =>
+ x.Bpnl == bpnl &&
+ x.VerifiedCredentialTypeId == verifiedCredentialTypeId &&
+ x.VerifiedCredentialType!.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId == kindId &&
+ x.CompanySsiDetailStatusId != CompanySsiDetailStatusId.INACTIVE &&
+ (verifiedCredentialExternalTypeUseCaseDetailId == null || x.VerifiedCredentialExternalTypeDetailVersionId == verifiedCredentialExternalTypeUseCaseDetailId));
+
+ ///
+ public Task<(bool Exists, string? Version, string? Template, IEnumerable UseCase, DateTimeOffset Expiry)> CheckCredentialTypeIdExistsForExternalTypeDetailVersionId(Guid verifiedCredentialExternalTypeUseCaseDetailId, VerifiedCredentialTypeId verifiedCredentialTypeId) =>
+ _context.VerifiedCredentialExternalTypeDetailVersions
+ .Where(x =>
+ x.Id == verifiedCredentialExternalTypeUseCaseDetailId &&
+ x.VerifiedCredentialExternalType!.VerifiedCredentialTypeAssignedExternalTypes.Any(y => y.VerifiedCredentialTypeId == verifiedCredentialTypeId))
+ .Select(x => new ValueTuple, DateTimeOffset>(
+ true,
+ x.Version,
+ x.Template,
+ x.VerifiedCredentialExternalType!.VerifiedCredentialTypeAssignedExternalTypes.Select(y => y.VerifiedCredentialType!.VerifiedCredentialTypeAssignedUseCase!.UseCase!.Shortname),
+ x.Expiry))
+ .SingleOrDefaultAsync();
+
+ ///
+ public Task<(bool Exists, IEnumerable DetailVersionIds)> CheckSsiCertificateType(VerifiedCredentialTypeId credentialTypeId) =>
+ _context.VerifiedCredentialTypeAssignedKinds
+ .Where(x =>
+ x.VerifiedCredentialTypeId == credentialTypeId &&
+ x.VerifiedCredentialTypeKindId != VerifiedCredentialTypeKindId.FRAMEWORK)
+ .Select(x => new ValueTuple>(
+ true,
+ x.VerifiedCredentialType!.VerifiedCredentialTypeAssignedExternalType!.VerifiedCredentialExternalType!.VerifiedCredentialExternalTypeDetailVersions.Select(x => x.Id)
+ ))
+ .SingleOrDefaultAsync();
+
+ ///
+ public IQueryable GetAllCredentialDetails(CompanySsiDetailStatusId? companySsiDetailStatusId, VerifiedCredentialTypeId? credentialTypeId) =>
+ _context.CompanySsiDetails.AsNoTracking()
+ .Where(c =>
+ (!companySsiDetailStatusId.HasValue || c.CompanySsiDetailStatusId == companySsiDetailStatusId.Value) &&
+ (!credentialTypeId.HasValue || c.VerifiedCredentialTypeId == credentialTypeId));
+
+ ///
+ public Task<(bool exists, SsiApprovalData data)> GetSsiApprovalData(Guid credentialId) =>
+ _context.CompanySsiDetails
+ .Where(x => x.Id == credentialId)
+ .Select(x => new ValueTuple(
+ true,
+ new SsiApprovalData(
+ x.CompanySsiDetailStatusId,
+ x.VerifiedCredentialTypeId,
+ x.VerifiedCredentialType!.VerifiedCredentialTypeAssignedKind == null ? null : x.VerifiedCredentialType!.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId,
+ x.Bpnl,
+ x.VerifiedCredentialExternalTypeDetailVersion == null ?
+ null :
+ new DetailData(
+ x.VerifiedCredentialExternalTypeDetailVersion!.VerifiedCredentialExternalTypeId,
+ x.VerifiedCredentialExternalTypeDetailVersion.Template,
+ x.VerifiedCredentialExternalTypeDetailVersion.Version,
+ x.VerifiedCredentialExternalTypeDetailVersion.Expiry
+ )
+ )
+ ))
+ .SingleOrDefaultAsync();
+
+ ///
+ public Task<(bool Exists, CompanySsiDetailStatusId Status, VerifiedCredentialTypeId Type)> GetSsiRejectionData(Guid credentialId) =>
+ _context.CompanySsiDetails
+ .Where(x => x.Id == credentialId)
+ .Select(x => new ValueTuple(
+ true,
+ x.CompanySsiDetailStatusId,
+ x.VerifiedCredentialTypeId
+ ))
+ .SingleOrDefaultAsync();
+
+ ///
+ public void AttachAndModifyCompanySsiDetails(Guid id, Action? initialize, Action updateFields)
+ {
+ var entity = new CompanySsiDetail(id, null!, default, default, Guid.Empty, default);
+ initialize?.Invoke(entity);
+ _context.Attach(entity);
+ updateFields.Invoke(entity);
+ }
+
+ ///
+ public IAsyncEnumerable GetCertificateTypes(string bpnl) =>
+ _context.VerifiedCredentialTypes
+ .Where(x =>
+ x.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId != VerifiedCredentialTypeKindId.FRAMEWORK &&
+ !x.CompanySsiDetails.Any(ssi =>
+ ssi.Bpnl == bpnl &&
+ (ssi.CompanySsiDetailStatusId == CompanySsiDetailStatusId.PENDING || ssi.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE)))
+ .Select(x => x.Id)
+ .ToAsyncEnumerable();
+
+ public IAsyncEnumerable GetExpiryData(DateTimeOffset now, DateTimeOffset inactiveVcsToDelete, DateTimeOffset expiredVcsToDelete)
+ {
+ var oneDay = now.AddDays(1);
+ var twoWeeks = now.AddDays(14);
+ var oneMonth = now.AddMonths(2);
+
+ return _context.CompanySsiDetails
+ .Select(x => new
+ {
+ Details = x,
+ IsVcToDecline = x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.PENDING && x.VerifiedCredentialExternalTypeDetailVersion!.Expiry < now,
+ IsVcToDelete = x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.INACTIVE && x.DateCreated < inactiveVcsToDelete || (x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE || x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.INACTIVE) && x.ExpiryDate < expiredVcsToDelete,
+ IsOneDayNotification = x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE && x.ExpiryDate <= oneDay && (x.ExpiryCheckTypeId == ExpiryCheckTypeId.TWO_WEEKS || x.ExpiryCheckTypeId == ExpiryCheckTypeId.ONE_MONTH || x.ExpiryCheckTypeId == null),
+ IsTwoWeeksNotification = x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE && x.ExpiryDate > oneDay && x.ExpiryDate <= twoWeeks && (x.ExpiryCheckTypeId == ExpiryCheckTypeId.ONE_MONTH || x.ExpiryCheckTypeId == null),
+ IsOneMonthNotification = x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE && x.ExpiryDate > twoWeeks && x.ExpiryDate <= oneMonth && x.ExpiryCheckTypeId == null
+ })
+ .Where(x => x.IsVcToDecline || x.IsVcToDelete || x.IsOneDayNotification || x.IsTwoWeeksNotification || x.IsOneMonthNotification)
+ .Select(x => new CredentialExpiryData(
+ x.Details.Id,
+ x.Details.ExpiryDate,
+ x.Details.ExpiryCheckTypeId,
+ x.Details.VerifiedCredentialExternalTypeDetailVersion!.Version,
+ x.Details.Bpnl,
+ x.Details.CompanySsiDetailStatusId,
+ x.Details.VerifiedCredentialTypeId,
+ new CredentialScheduleData(
+ x.IsVcToDelete,
+ x.IsOneDayNotification,
+ x.IsTwoWeeksNotification,
+ x.IsOneMonthNotification,
+ x.IsVcToDecline
+ )))
+ .ToAsyncEnumerable();
+ }
+
+ public void RemoveSsiDetail(Guid companySsiDetailId) =>
+ _context.CompanySsiDetails.Remove(new CompanySsiDetail(companySsiDetailId, null!, default, default, Guid.Empty, default));
+
+ public void CreateProcessData(Guid companySsiDetailId, JsonDocument schema, VerifiedCredentialTypeKindId credentialTypeKindId, Action? setOptionalFields)
+ {
+ var companySsiDetailData = new CompanySsiProcessData(companySsiDetailId, schema, credentialTypeKindId);
+ _context.CompanySsiProcessData.Add(companySsiDetailData);
+ setOptionalFields?.Invoke(companySsiDetailData);
+ }
+
+ public void AttachAndModifyProcessData(Guid companySsiDetailId, Action? initialize, Action setOptionalFields)
+ {
+ var companySsiDetailData = new CompanySsiProcessData(companySsiDetailId, null!, default);
+ initialize?.Invoke(companySsiDetailData);
+ _context.CompanySsiProcessData.Attach(companySsiDetailData);
+ setOptionalFields(companySsiDetailData);
+ }
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/CredentialRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/CredentialRepository.cs
new file mode 100644
index 00000000..735d77d9
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/CredentialRepository.cs
@@ -0,0 +1,68 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.EntityFrameworkCore;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.Text.Json;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories;
+
+public class CredentialRepository : ICredentialRepository
+{
+ private readonly IssuerDbContext _dbContext;
+
+ public CredentialRepository(IssuerDbContext dbContext)
+ {
+ _dbContext = dbContext;
+ }
+
+ public Task GetWalletCredentialId(Guid credentialId) =>
+ _dbContext.CompanySsiDetails.Where(x => x.Id == credentialId)
+ .Select(x => x.ExternalCredentialId)
+ .SingleOrDefaultAsync();
+
+ public Task<(HolderWalletData HolderWalletData, string? Credential, EncryptionTransformationData EncryptionInformation)> GetCredentialData(Guid credentialId) =>
+ _dbContext.CompanySsiDetails
+ .Where(x => x.Id == credentialId)
+ .Select(x => new ValueTuple(
+ new HolderWalletData(x.CompanySsiProcessData!.HolderWalletUrl, x.CompanySsiProcessData.ClientId),
+ x.Credential,
+ new EncryptionTransformationData(x.CompanySsiProcessData!.ClientSecret, x.CompanySsiProcessData.InitializationVector, x.CompanySsiProcessData.EncryptionMode)))
+ .SingleOrDefaultAsync();
+
+ public Task<(bool Exists, Guid CredentialId)> GetDataForProcessId(Guid processId) =>
+ _dbContext.CompanySsiDetails
+ .Where(c => c.ProcessId == processId)
+ .Select(c => new ValueTuple(true, c.Id))
+ .SingleOrDefaultAsync();
+
+ public Task<(VerifiedCredentialTypeKindId CredentialTypeKindId, JsonDocument Schema)> GetCredentialStorageInformationById(Guid credentialId) =>
+ _dbContext.CompanySsiDetails
+ .Where(c => c.Id == credentialId)
+ .Select(c => new ValueTuple(c.CompanySsiProcessData!.CredentialTypeKindId, c.CompanySsiProcessData.Schema))
+ .SingleOrDefaultAsync();
+
+ public Task<(Guid? ExternalCredentialId, VerifiedCredentialTypeKindId KindId)> GetExternalCredentialAndKindId(Guid credentialId) =>
+ _dbContext.CompanySsiDetails
+ .Where(c => c.Id == credentialId)
+ .Select(c => new ValueTuple(c.ExternalCredentialId, c.VerifiedCredentialType!.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId))
+ .SingleOrDefaultAsync();
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/DocumentRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/DocumentRepository.cs
new file mode 100644
index 00000000..b6bf1b6d
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/DocumentRepository.cs
@@ -0,0 +1,63 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories;
+
+/// Implementation of accessing database with EF Core.
+public class DocumentRepository : IDocumentRepository
+{
+ private readonly IssuerDbContext _dbContext;
+
+ ///
+ /// Constructor.
+ ///
+ /// PortalDb context.
+ public DocumentRepository(IssuerDbContext dbContext)
+ {
+ this._dbContext = dbContext;
+ }
+
+ ///
+ public Document CreateDocument(string documentName, byte[] documentContent, byte[] hash, MediaTypeId mediaTypeId, DocumentTypeId documentTypeId, Action? setupOptionalFields)
+ {
+ var document = new Document(
+ Guid.NewGuid(),
+ documentContent,
+ hash,
+ documentName,
+ mediaTypeId,
+ DateTimeOffset.UtcNow,
+ DocumentStatusId.ACTIVE,
+ documentTypeId);
+
+ setupOptionalFields?.Invoke(document);
+ return _dbContext.Documents.Add(document).Entity;
+ }
+
+ ///
+ public void AssignDocumentToCompanySsiDetails(Guid documentId, Guid companySsiDetailId)
+ {
+ var document = new CompanySsiDetailAssignedDocument(documentId, companySsiDetailId);
+ _dbContext.CompanySsiDetailAssignedDocuments.Add(document);
+ }
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICompanySsiDetailsRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICompanySsiDetailsRepository.cs
new file mode 100644
index 00000000..d8240733
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICompanySsiDetailsRepository.cs
@@ -0,0 +1,99 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.Text.Json;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories;
+
+public interface ICompanySsiDetailsRepository
+{
+ ///
+ /// Gets the company credential details for the given company id
+ ///
+ /// Bpnl of the company
+ /// The minimum datetime the expiry date should have
+ /// AsyncEnumerable of UseCaseParticipation
+ IAsyncEnumerable GetUseCaseParticipationForCompany(string bpnl, DateTimeOffset minExpiry);
+
+ ///
+ /// Gets the company credential details for the given company id
+ ///
+ /// Bpnl of the company
+ /// The minimum datetime the expiry date should have
+ /// AsyncEnumerable of SsiCertificateData
+ IAsyncEnumerable GetSsiCertificates(string bpnl, DateTimeOffset minExpiry);
+
+ ///
+ /// Creates the credential details
+ ///
+ /// Id of the company
+ /// Id of the credential types
+ /// id of the document
+ /// id of detail status
+ /// Id of the creator
+ /// Id of the linked Process
+ /// sets the optional fields
+ /// The created entity
+ CompanySsiDetail CreateSsiDetails(string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, Guid docId, CompanySsiDetailStatusId companySsiDetailStatusId, Guid userId, Action? setOptionalFields);
+
+ ///
+ /// Checks whether the credential details are already exists for the company and the given version
+ ///
+ /// Bpnl of the company
+ /// Id of the verifiedCredentialType
+ /// Id of the credentialTypeKind
+ /// Id of the verifiedCredentialExternalType Detail Id
+ /// true if the details already exists, otherwise false
+ Task CheckSsiDetailsExistsForCompany(string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, VerifiedCredentialTypeKindId kindId, Guid? verifiedCredentialExternalTypeUseCaseDetailId);
+
+ ///
+ /// Checks whether the given externalTypeDetail exists and returns the CredentialTypeId
+ ///
+ /// Id of vc external type use case detail id
+ /// Id of the vc type
+ /// Returns a valueTuple with identifiers if the externalTypeUseCaseDetailId exists and the corresponding credentialTypeId
+ Task<(bool Exists, string? Version, string? Template, IEnumerable UseCase, DateTimeOffset Expiry)> CheckCredentialTypeIdExistsForExternalTypeDetailVersionId(Guid verifiedCredentialExternalTypeUseCaseDetailId, VerifiedCredentialTypeId verifiedCredentialTypeId);
+
+ ///
+ /// Checks whether the given credentialTypeId is a Certificate
+ ///
+ /// Id of the credentialTypeId
+ /// true if the tpye is a certificate, otherwise false
+ Task<(bool Exists, IEnumerable DetailVersionIds)> CheckSsiCertificateType(VerifiedCredentialTypeId credentialTypeId);
+
+ ///
+ /// Gets all credential details
+ ///
+ /// The status of the details
+ /// OPTIONAL: The type of the credential that should be returned
+ /// Returns data to create the pagination
+ IQueryable GetAllCredentialDetails(CompanySsiDetailStatusId? companySsiDetailStatusId, VerifiedCredentialTypeId? credentialTypeId);
+
+ Task<(bool exists, SsiApprovalData data)> GetSsiApprovalData(Guid credentialId);
+ Task<(bool Exists, CompanySsiDetailStatusId Status, VerifiedCredentialTypeId Type)> GetSsiRejectionData(Guid credentialId);
+ void AttachAndModifyCompanySsiDetails(Guid id, Action? initialize, Action updateFields);
+ IAsyncEnumerable GetCertificateTypes(string bpnl);
+ IAsyncEnumerable GetExpiryData(DateTimeOffset now, DateTimeOffset inactiveVcsToDelete, DateTimeOffset expiredVcsToDelete);
+ void RemoveSsiDetail(Guid companySsiDetailId);
+ void CreateProcessData(Guid companySsiDetailId, JsonDocument schema, VerifiedCredentialTypeKindId credentialTypeKindId, Action? setOptionalFields);
+ void AttachAndModifyProcessData(Guid companySsiDetailId, Action? initialize, Action setOptionalFields);
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICredentialRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICredentialRepository.cs
new file mode 100644
index 00000000..9af61ddc
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICredentialRepository.cs
@@ -0,0 +1,33 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.Text.Json;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories;
+
+public interface ICredentialRepository
+{
+ Task GetWalletCredentialId(Guid credentialId);
+ Task<(HolderWalletData HolderWalletData, string? Credential, EncryptionTransformationData EncryptionInformation)> GetCredentialData(Guid credentialId);
+ Task<(bool Exists, Guid CredentialId)> GetDataForProcessId(Guid processId);
+ Task<(VerifiedCredentialTypeKindId CredentialTypeKindId, JsonDocument Schema)> GetCredentialStorageInformationById(Guid credentialId);
+ Task<(Guid? ExternalCredentialId, VerifiedCredentialTypeKindId KindId)> GetExternalCredentialAndKindId(Guid credentialId);
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/IDocumentRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/IDocumentRepository.cs
new file mode 100644
index 00000000..5b5c105b
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/IDocumentRepository.cs
@@ -0,0 +1,43 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories;
+
+///
+/// Repository for writing documents on persistence layer.
+///
+public interface IDocumentRepository
+{
+ ///
+ /// Creates a document in the persistence layer.
+ ///
+ /// The documents name
+ /// The document itself
+ /// Hash of the document
+ /// The documents mediaType
+ /// the document type id
+ /// Action to setup the additional fields
+ /// Returns the created document
+ Document CreateDocument(string documentName, byte[] documentContent, byte[] hash, MediaTypeId mediaTypeId, DocumentTypeId documentTypeId, Action? setupOptionalFields);
+
+ void AssignDocumentToCompanySsiDetails(Guid documentId, Guid companySsiDetailId);
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/IProcessStepRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/IProcessStepRepository.cs
new file mode 100644
index 00000000..3e1419f9
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/IProcessStepRepository.cs
@@ -0,0 +1,37 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories;
+
+///
+/// Repository for accessing and creating processSteps on persistence layer.
+///
+public interface IProcessStepRepository
+{
+ Process CreateProcess(ProcessTypeId processTypeId);
+ ProcessStep CreateProcessStep(ProcessStepTypeId processStepTypeId, ProcessStepStatusId processStepStatusId, Guid processId);
+ IEnumerable CreateProcessStepRange(IEnumerable<(ProcessStepTypeId ProcessStepTypeId, ProcessStepStatusId ProcessStepStatusId, Guid ProcessId)> processStepTypeStatus);
+ void AttachAndModifyProcessStep(Guid processStepId, Action? initialize, Action modify);
+ void AttachAndModifyProcessSteps(IEnumerable<(Guid ProcessStepId, Action? Initialize, Action Modify)> processStepIdsInitializeModifyData);
+ IAsyncEnumerable GetActiveProcesses(IEnumerable processTypeIds, IEnumerable processStepTypeIds, DateTimeOffset lockExpiryDate);
+ IAsyncEnumerable<(Guid ProcessStepId, ProcessStepTypeId ProcessStepTypeId)> GetProcessStepData(Guid processId);
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/ProcessStepRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/ProcessStepRepository.cs
new file mode 100644
index 00000000..177eddf3
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/ProcessStepRepository.cs
@@ -0,0 +1,100 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.EntityFrameworkCore;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using ProcessTypeId = Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums.ProcessTypeId;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories;
+
+public class ProcessStepRepository : IProcessStepRepository
+{
+ private readonly IssuerDbContext _context;
+
+ ///
+ /// Constructor
+ ///
+ /// PortalDb context.
+ public ProcessStepRepository(IssuerDbContext portalDbContext)
+ {
+ _context = portalDbContext;
+ }
+
+ public Process CreateProcess(ProcessTypeId processTypeId) =>
+ _context.Add(new Process(Guid.NewGuid(), processTypeId, Guid.NewGuid())).Entity;
+
+ public ProcessStep CreateProcessStep(ProcessStepTypeId processStepTypeId, ProcessStepStatusId processStepStatusId, Guid processId) =>
+ _context.Add(new ProcessStep(Guid.NewGuid(), processStepTypeId, processStepStatusId, processId, DateTimeOffset.UtcNow)).Entity;
+
+ public IEnumerable CreateProcessStepRange(IEnumerable<(ProcessStepTypeId ProcessStepTypeId, ProcessStepStatusId ProcessStepStatusId, Guid ProcessId)> processStepTypeStatus)
+ {
+ var processSteps = processStepTypeStatus.Select(x => new ProcessStep(Guid.NewGuid(), x.ProcessStepTypeId, x.ProcessStepStatusId, x.ProcessId, DateTimeOffset.UtcNow)).ToList();
+ _context.AddRange(processSteps);
+ return processSteps;
+ }
+
+ public void AttachAndModifyProcessStep(Guid processStepId, Action? initialize, Action modify)
+ {
+ var step = new ProcessStep(processStepId, default, default, Guid.Empty, default);
+ initialize?.Invoke(step);
+ _context.Attach(step);
+ step.DateLastChanged = DateTimeOffset.UtcNow;
+ modify(step);
+ }
+
+ public void AttachAndModifyProcessSteps(IEnumerable<(Guid ProcessStepId, Action? Initialize, Action Modify)> processStepIdsInitializeModifyData)
+ {
+ var stepModifyData = processStepIdsInitializeModifyData.Select(data =>
+ {
+ var step = new ProcessStep(data.ProcessStepId, default, default, Guid.Empty, default);
+ data.Initialize?.Invoke(step);
+ return (Step: step, data.Modify);
+ }).ToList();
+ _context.AttachRange(stepModifyData.Select(data => data.Step));
+ stepModifyData.ForEach(data =>
+ {
+ data.Step.DateLastChanged = DateTimeOffset.UtcNow;
+ data.Modify(data.Step);
+ });
+ }
+
+ public IAsyncEnumerable GetActiveProcesses(IEnumerable processTypeIds, IEnumerable processStepTypeIds, DateTimeOffset lockExpiryDate) =>
+ _context.Processes
+ .AsNoTracking()
+ .Where(process =>
+ processTypeIds.Contains(process.ProcessTypeId) &&
+ process.ProcessSteps.Any(step => processStepTypeIds.Contains(step.ProcessStepTypeId) && step.ProcessStepStatusId == ProcessStepStatusId.TODO) &&
+ (process.LockExpiryDate == null || process.LockExpiryDate < lockExpiryDate))
+ .AsAsyncEnumerable();
+
+ public IAsyncEnumerable<(Guid ProcessStepId, ProcessStepTypeId ProcessStepTypeId)> GetProcessStepData(Guid processId) =>
+ _context.ProcessSteps
+ .AsNoTracking()
+ .Where(step =>
+ step.ProcessId == processId &&
+ step.ProcessStepStatusId == ProcessStepStatusId.TODO)
+ .OrderBy(step => step.ProcessStepTypeId)
+ .Select(step =>
+ new ValueTuple(
+ step.Id,
+ step.ProcessStepTypeId))
+ .AsAsyncEnumerable();
+}
diff --git a/src/database/SsiCredentialIssuer.DbAccess/SsiCredentialIssuer.DbAccess.csproj b/src/database/SsiCredentialIssuer.DbAccess/SsiCredentialIssuer.DbAccess.csproj
new file mode 100644
index 00000000..6cb5fa65
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.DbAccess/SsiCredentialIssuer.DbAccess.csproj
@@ -0,0 +1,42 @@
+
+
+
+
+ Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess
+ Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess
+ net7.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditCompanySsiDetail20240228.cs b/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditCompanySsiDetail20240228.cs
new file mode 100644
index 00000000..2697cae5
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditCompanySsiDetail20240228.cs
@@ -0,0 +1,59 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Enums;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+using System.Diagnostics.CodeAnalysis;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities;
+
+[ExcludeFromCodeCoverage]
+public class AuditCompanySsiDetail20240228 : IAuditEntityV1
+{
+ ///
+ [Key]
+ public Guid AuditV1Id { get; set; }
+
+ public Guid Id { get; set; }
+ public string Bpnl { get; set; } = null!;
+ public VerifiedCredentialTypeId VerifiedCredentialTypeId { get; set; }
+ public CompanySsiDetailStatusId CompanySsiDetailStatusId { get; set; }
+ public DateTimeOffset DateCreated { get; private set; }
+ public Guid CreatorUserId { get; set; }
+ public DateTimeOffset? ExpiryDate { get; set; }
+ public Guid? VerifiedCredentialExternalTypeDetailVersionId { get; set; }
+
+ public ExpiryCheckTypeId? ExpiryCheckTypeId { get; set; }
+ public Guid? ProcessId { get; set; }
+ public Guid? ExternalCredentialId { get; set; }
+ public string? Credential { get; set; }
+ public DateTimeOffset? DateLastChanged { get; set; }
+ public Guid? LastEditorId { get; set; }
+
+ ///
+ public Guid? AuditV1LastEditorId { get; set; }
+
+ ///
+ public AuditOperationId AuditV1OperationId { get; set; }
+
+ ///
+ public DateTimeOffset AuditV1DateLastChanged { get; set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditDocument20240305.cs b/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditDocument20240305.cs
new file mode 100644
index 00000000..bbfe37ae
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditDocument20240305.cs
@@ -0,0 +1,63 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Enums;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+using System.Diagnostics.CodeAnalysis;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities;
+
+[ExcludeFromCodeCoverage]
+public class AuditDocument20240305 : IAuditEntityV1
+{
+ ///
+ [Key]
+ public Guid AuditV1Id { get; set; }
+
+ public Guid Id { get; private set; }
+
+ public DateTimeOffset? DateCreated { get; private set; }
+
+ public byte[]? DocumentHash { get; set; }
+
+ public byte[]? DocumentContent { get; set; }
+
+ public string? DocumentName { get; set; }
+
+ public MediaTypeId? MediaTypeId { get; set; }
+
+ public DocumentTypeId? DocumentTypeId { get; set; }
+
+ public DocumentStatusId? DocumentStatusId { get; set; }
+
+ public Guid? CompanyUserId { get; set; }
+ public DateTimeOffset? DateLastChanged { get; set; }
+ public Guid? LastEditorId { get; private set; }
+
+ ///
+ public DateTimeOffset AuditV1DateLastChanged { get; set; }
+
+ ///
+ public Guid? AuditV1LastEditorId { get; set; }
+
+ ///
+ public AuditOperationId AuditV1OperationId { get; set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditEntityV1Attribute.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditEntityV1Attribute.cs
new file mode 100644
index 00000000..b9d84ea4
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditEntityV1Attribute.cs
@@ -0,0 +1,43 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes;
+
+///
+/// Attribute to Provide the needed methods to setup an audit trigger
+///
+///
+/// The implementation of this Attribute must not be changed.
+/// When changes are needed create a V2 of it.
+///
+[AttributeUsage(AttributeTargets.Class)]
+public class AuditEntityV1Attribute : Attribute
+{
+ public AuditEntityV1Attribute(Type auditEntityType)
+ {
+ if (!typeof(IAuditEntityV1).IsAssignableFrom(auditEntityType))
+ {
+ throw new ArgumentException($"Entity must derive from {nameof(IAuditEntityV1)}", nameof(auditEntityType));
+ }
+
+ AuditEntityType = auditEntityType;
+ }
+
+ public virtual Type AuditEntityType { get; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditInsertEditorV1Attribute.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditInsertEditorV1Attribute.cs
new file mode 100644
index 00000000..4ccebc8b
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditInsertEditorV1Attribute.cs
@@ -0,0 +1,34 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes;
+
+///
+/// Attribute to mark the creators id in the base class.
+/// The usage is optional. If not set
+/// is being used to determine the creators id.
+///
+///
+/// The implementation of this Attribute must not be changed.
+/// When changes are needed create a V2 of it.
+///
+[AttributeUsage(AttributeTargets.Property)]
+public class AuditInsertEditorV1Attribute : Attribute
+{
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastChangedV1Attribute.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastChangedV1Attribute.cs
new file mode 100644
index 00000000..8028d45e
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastChangedV1Attribute.cs
@@ -0,0 +1,32 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes;
+
+///
+/// Attribute to mark the last editor id in the base class
+///
+///
+/// The implementation of this Attribute must not be changed.
+/// When changes are needed create a V2 of it.
+///
+[AttributeUsage(AttributeTargets.Property)]
+public class LastChangedV1Attribute : Attribute
+{
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastEditorV1Attribute.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastEditorV1Attribute.cs
new file mode 100644
index 00000000..6af18970
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastEditorV1Attribute.cs
@@ -0,0 +1,32 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes;
+
+///
+/// Attribute to mark the last editor id in the base class
+///
+///
+/// The implementation of this Attribute must not be changed.
+/// When changes are needed create a V2 of it.
+///
+[AttributeUsage(AttributeTargets.Property)]
+public class LastEditorV1Attribute : Attribute
+{
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/DependencyInjection/AuditingDependencyInjection.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/DependencyInjection/AuditingDependencyInjection.cs
new file mode 100644
index 00000000..ba3e0698
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/DependencyInjection/AuditingDependencyInjection.cs
@@ -0,0 +1,33 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.Extensions.DependencyInjection;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.DateTimeProvider;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Handler;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.DependencyInjection;
+
+public static class AuditingDependencyInjection
+{
+ public static IServiceCollection AddDbAuditing(this IServiceCollection services)
+ {
+ return services.AddTransient()
+ .AddTransient();
+ }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditOperationId.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditOperationId.cs
new file mode 100644
index 00000000..975bb728
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditOperationId.cs
@@ -0,0 +1,41 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Enums;
+
+///
+/// Possible operations for the audit table
+///
+public enum AuditOperationId
+{
+ ///
+ /// The entity has been inserted
+ ///
+ INSERT = 1,
+
+ ///
+ /// The entity has been updated
+ ///
+ UPDATE = 2,
+
+ ///
+ /// The entity has been deleted
+ ///
+ DELETE = 3,
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditPropertyV1Names.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditPropertyV1Names.cs
new file mode 100644
index 00000000..ea04951b
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditPropertyV1Names.cs
@@ -0,0 +1,28 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Enums;
+
+public enum AuditPropertyV1Names
+{
+ AuditV1Id,
+ AuditV1OperationId,
+ AuditV1DateLastChanged,
+ AuditV1LastEditorId
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/AuditExtensions.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/AuditExtensions.cs
new file mode 100644
index 00000000..e881df0c
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/AuditExtensions.cs
@@ -0,0 +1,86 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.EntityFrameworkCore;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Linq;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Enums;
+using System.Collections.Immutable;
+using System.Reflection;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Extensions;
+
+public static class AuditExtensions
+{
+ public record AuditPropertyInformation
+ (
+ Type AuditEntityType,
+ IEnumerable SourceProperties,
+ IEnumerable AuditProperties,
+ IEnumerable TargetProperties
+ );
+
+ public static AuditOperationId ToAuditOperation(this EntityState state) =>
+ state switch
+ {
+ EntityState.Added => AuditOperationId.INSERT,
+ EntityState.Deleted => AuditOperationId.DELETE,
+ EntityState.Modified => AuditOperationId.UPDATE,
+ _ => throw new ConflictException($"Entries with state {state} should not be audited")
+ };
+
+ public static AuditPropertyInformation? GetAuditPropertyInformation(this Type auditableEntityType)
+ {
+ var auditEntityAttribute =
+ (AuditEntityV1Attribute?)Attribute.GetCustomAttribute(auditableEntityType, typeof(AuditEntityV1Attribute));
+ if (auditEntityAttribute == null)
+ {
+ return null;
+ }
+
+ var auditEntityType = auditEntityAttribute.AuditEntityType;
+ if (!typeof(IAuditEntityV1).IsAssignableFrom(auditEntityType))
+ {
+ throw new ConflictException($"{auditEntityType} must inherit from {nameof(IAuditEntityV1)}");
+ }
+
+ var sourceProperties = (typeof(IBaseEntity).IsAssignableFrom(auditableEntityType)
+ ? typeof(IBaseEntity).GetProperties()
+ : Enumerable.Empty())
+ .Concat(auditableEntityType
+ .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
+ .Where(p => !(p.GetGetMethod()?.IsVirtual ?? false)))
+ .ToImmutableList();
+ var auditProperties = typeof(IAuditEntityV1).GetProperties();
+ var targetProperties = auditEntityType.GetProperties().ExceptBy(auditProperties.Select(x => x.Name), p => p.Name).ToImmutableList();
+
+ targetProperties
+ .ExceptBy(Enumerable.Repeat(nameof(IBaseEntity.Id), 1), p => p.Name)
+ .Where(x => x.PropertyType == typeof(Nullable<>))
+ .IfAny(notNullableProperties =>
+ throw new ConfigurationException($"Properties {string.Join(",", notNullableProperties.Select(x => x.Name))} of type {auditEntityType.Name} are not nullable"));
+
+ return new AuditPropertyInformation(
+ auditEntityType,
+ sourceProperties,
+ auditProperties,
+ targetProperties);
+ }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/EntityTypeBuilderV1Extension.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/EntityTypeBuilderV1Extension.cs
new file mode 100644
index 00000000..8d3270b8
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/EntityTypeBuilderV1Extension.cs
@@ -0,0 +1,129 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Laraue.EfCoreTriggers.Common.Extensions;
+using Laraue.EfCoreTriggers.Common.TriggerBuilders.TableRefs;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Linq;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Enums;
+using System.ComponentModel.DataAnnotations;
+using System.Linq.Expressions;
+using System.Reflection;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Extensions;
+
+public static class EntityTypeBuilderV1Extension
+{
+ public static EntityTypeBuilder HasAuditV1Triggers(this EntityTypeBuilder builder) where TEntity : class, IAuditableV1 where TAuditEntity : class, IAuditEntityV1
+ {
+ var (auditEntityType, sourceProperties, auditProperties, targetProperties) = typeof(TEntity).GetAuditPropertyInformation() ?? throw new ConfigurationException($"{typeof(TEntity)} must be annotated with {nameof(AuditEntityV1Attribute)}");
+ if (typeof(TAuditEntity) != auditEntityType)
+ {
+ throw new ConfigurationException($"{typeof(TEntity).Name} is annotated with {nameof(AuditEntityV1Attribute)} referring to a different audit entity type {auditEntityType.Name} then {typeof(TAuditEntity).Name}");
+ }
+
+ sourceProperties.IntersectBy(auditProperties.Select(x => x.Name), p => p.Name).IfAny(
+ illegalProperties => throw new ConfigurationException($"{typeof(TEntity).Name} is must not declare any of the following properties: {string.Join(", ", illegalProperties.Select(x => x.Name))}"));
+
+ sourceProperties.ExceptBy(targetProperties.Select(x => x.Name), p => p.Name).IfAny(
+ missingProperties => throw new ArgumentException($"{typeof(TAuditEntity).Name} is missing the following properties: {string.Join(", ", missingProperties.Select(x => x.Name))}"));
+
+ if (!Array.Exists(
+ typeof(TAuditEntity).GetProperties(),
+ p => p.Name == AuditPropertyV1Names.AuditV1Id.ToString() && p.CustomAttributes.Any(a => a.AttributeType == typeof(KeyAttribute))))
+ {
+ throw new ConfigurationException($"{typeof(TAuditEntity).Name}.{AuditPropertyV1Names.AuditV1Id} must be marked as primary key by attribute {typeof(KeyAttribute).Name}");
+ }
+
+ var insertEditorProperty = sourceProperties.SingleOrDefault(p => p.CustomAttributes.Any(a => a.AttributeType == typeof(AuditInsertEditorV1Attribute)));
+ var lastEditorProperty = sourceProperties.SingleOrDefault(p => p.CustomAttributes.Any(a => a.AttributeType == typeof(LastEditorV1Attribute)));
+
+ return builder
+ .AfterInsert(trigger =>
+ trigger.Action(action =>
+ action.Insert(CreateNewAuditEntityExpression(sourceProperties, insertEditorProperty ?? lastEditorProperty))))
+ .AfterUpdate(trigger =>
+ trigger.Action(action =>
+ action.Insert(CreateUpdateAuditEntityExpression(sourceProperties, lastEditorProperty))));
+ }
+
+ private static Expression, TAuditEntity>> CreateNewAuditEntityExpression(IEnumerable sourceProperties, PropertyInfo? lastEditorProperty) where TEntity : class
+ {
+ var entity = Expression.Parameter(typeof(NewTableRef), "entity");
+
+ var newPropertyInfo = typeof(NewTableRef).GetProperty("New");
+ if (newPropertyInfo == null)
+ {
+ throw new UnexpectedConditionException($"{nameof(NewTableRef)} must have property New");
+ }
+
+ var propertyExpression = Expression.Property(entity, newPropertyInfo);
+ return Expression.Lambda, TAuditEntity>>(
+ CreateAuditEntityExpression(sourceProperties, AuditOperationId.INSERT, propertyExpression, lastEditorProperty),
+ entity);
+ }
+
+ private static Expression, TAuditEntity>> CreateUpdateAuditEntityExpression(IEnumerable sourceProperties, PropertyInfo? lastEditorProperty) where TEntity : class
+ {
+ var entity = Expression.Parameter(typeof(OldAndNewTableRefs), "entity");
+
+ var newPropertyInfo = typeof(OldAndNewTableRefs).GetProperty("New");
+ if (newPropertyInfo == null)
+ {
+ throw new UnexpectedConditionException($"{nameof(OldAndNewTableRefs)} must have property New");
+ }
+
+ var propertyExpression = Expression.Property(entity, newPropertyInfo);
+ return Expression.Lambda, TAuditEntity>>(
+ CreateAuditEntityExpression(sourceProperties, AuditOperationId.UPDATE, propertyExpression, lastEditorProperty),
+ entity);
+ }
+
+ private static MemberInitExpression CreateAuditEntityExpression(IEnumerable sourceProperties, AuditOperationId auditOperationId, Expression entity, PropertyInfo? lastEditorProperty)
+ {
+ var memberBindings = sourceProperties.Select(p =>
+ CreateMemberAssignment(typeof(TAuditEntity).GetMember(p.Name)[0], Expression.Property(entity, p)))
+ .Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV1Names.AuditV1Id.ToString())[0], Expression.New(typeof(Guid))))
+ .Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV1Names.AuditV1OperationId.ToString())[0], Expression.Constant(auditOperationId)))
+ .Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV1Names.AuditV1DateLastChanged.ToString())[0], Expression.New(typeof(DateTimeOffset))));
+
+ if (lastEditorProperty != null)
+ {
+ memberBindings = memberBindings.Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV1Names.AuditV1LastEditorId.ToString())[0], Expression.Property(entity, lastEditorProperty)));
+ }
+
+ return Expression.MemberInit(
+ Expression.New(typeof(TAuditEntity)),
+ memberBindings);
+ }
+
+ private static MemberAssignment CreateMemberAssignment(MemberInfo member, Expression expression)
+ {
+ try
+ {
+ return Expression.Bind(member, expression);
+ }
+ catch (Exception e)
+ {
+ throw new ArgumentException($"{member.DeclaringType?.Name}.{member.Name} is not assignable from {expression}, {e.Message}", e);
+ }
+ }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Handler/AuditHandlerV1.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Handler/AuditHandlerV1.cs
new file mode 100644
index 00000000..ce651a6e
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Handler/AuditHandlerV1.cs
@@ -0,0 +1,109 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.ChangeTracking;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.DateTimeProvider;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Extensions;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Identity;
+using System.Collections.Immutable;
+using System.Reflection;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Handler;
+
+public class AuditHandlerV1 : IAuditHandler
+{
+ private readonly IIdentityIdService _identityService;
+ private readonly IDateTimeProvider _dateTimeProvider;
+
+ public AuditHandlerV1(IIdentityIdService identityService, IDateTimeProvider dateTimeProvider)
+ {
+ _identityService = identityService;
+ _dateTimeProvider = dateTimeProvider;
+ }
+
+ public void HandleAuditForChangedEntries(IEnumerable changedEntries, DbContext context)
+ {
+ var now = _dateTimeProvider.OffsetNow;
+ foreach (var groupedEntries in changedEntries
+ .GroupBy(entry => entry.Metadata.ClrType))
+ {
+ var lastEditorNames = groupedEntries.Key.GetProperties()
+ .Where(x => Attribute.IsDefined(x, typeof(LastEditorV1Attribute)))
+ .Select(x => x.Name)
+ .ToImmutableHashSet();
+ var lastChangedNames = groupedEntries.Key.GetProperties()
+ .Where(x => Attribute.IsDefined(x, typeof(LastChangedV1Attribute)))
+ .Select(x => x.Name)
+ .ToImmutableHashSet();
+
+ foreach (var properties in groupedEntries.Where(entry => entry.State != EntityState.Deleted).Select(entry => entry.Properties))
+ {
+ foreach (var prop in properties.IntersectBy(
+ lastEditorNames,
+ property => property.Metadata.Name))
+ {
+ prop.CurrentValue = _identityService.IdentityId;
+ }
+
+ foreach (var prop in properties.IntersectBy(
+ lastChangedNames,
+ property => property.Metadata.Name))
+ {
+ prop.CurrentValue = now;
+ }
+ }
+
+ var auditPropertyInformation = groupedEntries.Key.GetAuditPropertyInformation();
+ if (auditPropertyInformation == null)
+ continue;
+ var (auditEntityType, sourceProperties, _, targetProperties) = auditPropertyInformation;
+
+ foreach (var entry in groupedEntries.Where(entry => entry.State == EntityState.Deleted))
+ {
+ AddAuditEntry(entry, entry.Metadata.ClrType, context, auditEntityType, sourceProperties, targetProperties);
+ }
+ }
+ }
+
+ private void AddAuditEntry(EntityEntry entityEntry, Type entityType, DbContext context, Type auditEntityType, IEnumerable sourceProperties, IEnumerable targetProperties)
+ {
+ if (Activator.CreateInstance(auditEntityType) is not IAuditEntityV1 newAuditEntity)
+ throw new UnexpectedConditionException($"AuditEntityV1Attribute can only be used on types implementing IAuditEntityV1 but Type {entityType} isn't");
+
+ var propertyValues = entityEntry.CurrentValues;
+ foreach (var joined in targetProperties.Join(
+ sourceProperties,
+ t => t.Name,
+ s => s.Name,
+ (t, s) => (Target: t, Value: propertyValues?[s.Name])))
+ {
+ joined.Target.SetValue(newAuditEntity, joined.Value);
+ }
+
+ newAuditEntity.AuditV1Id = Guid.NewGuid();
+ newAuditEntity.AuditV1OperationId = entityEntry.State.ToAuditOperation();
+ newAuditEntity.AuditV1DateLastChanged = _dateTimeProvider.OffsetNow;
+ newAuditEntity.AuditV1LastEditorId = _identityService.IdentityId;
+
+ context.Add(newAuditEntity);
+ }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Handler/IAuditHandler.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Handler/IAuditHandler.cs
new file mode 100644
index 00000000..02c25572
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Handler/IAuditHandler.cs
@@ -0,0 +1,28 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.ChangeTracking;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Handler;
+
+public interface IAuditHandler
+{
+ void HandleAuditForChangedEntries(IEnumerable changedEntries, DbContext context);
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditEntityV1.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditEntityV1.cs
new file mode 100644
index 00000000..18471c8e
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditEntityV1.cs
@@ -0,0 +1,52 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+
+///
+/// Marker interface to define that the entity is an audit entity
+///
+///
+/// The implementation of this Attribute must not be changed.
+/// When changes are needed create a V2 of it.
+///
+public interface IAuditEntityV1
+{
+ ///
+ /// Id of the audited entity
+ ///
+ Guid AuditV1Id { get; set; }
+
+ ///
+ /// Date Time of the last change of the entity
+ ///
+ DateTimeOffset AuditV1DateLastChanged { get; set; }
+
+ ///
+ /// Reference to the that changed the entity
+ ///
+ Guid? AuditV1LastEditorId { get; set; }
+
+ ///
+ /// Id of the audit operation
+ ///
+ AuditOperationId AuditV1OperationId { get; set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditableV1.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditableV1.cs
new file mode 100644
index 00000000..99f65976
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditableV1.cs
@@ -0,0 +1,31 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+
+///
+/// Marker interface to define that a entity is auditable
+///
+///
+/// The implementation of this Attribute must not be changed.
+/// When changes are needed create a V2 of it.
+///
+public interface IAuditableV1
+{
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/IBaseEntity.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/IBaseEntity.cs
new file mode 100644
index 00000000..5ee0e0c3
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/IBaseEntity.cs
@@ -0,0 +1,28 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+
+///
+/// Marker interface
+///
+public interface IBaseEntity
+{
+ Guid Id { get; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Identity/IIdentityIdService.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Identity/IIdentityIdService.cs
new file mode 100644
index 00000000..26544541
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Identity/IIdentityIdService.cs
@@ -0,0 +1,25 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Identity;
+
+public interface IIdentityIdService
+{
+ Guid IdentityId { get; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetail.cs b/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetail.cs
new file mode 100644
index 00000000..95facf0c
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetail.cs
@@ -0,0 +1,75 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+[AuditEntityV1(typeof(AuditCompanySsiDetail20240228))]
+public class CompanySsiDetail : IAuditableV1, IBaseEntity
+{
+ private CompanySsiDetail()
+ {
+ Bpnl = null!;
+ Documents = new HashSet();
+ }
+
+ public CompanySsiDetail(Guid id, string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, CompanySsiDetailStatusId companySsiDetailStatusId, Guid creatorUserId, DateTimeOffset dateCreated)
+ : this()
+ {
+ Id = id;
+ Bpnl = bpnl;
+ VerifiedCredentialTypeId = verifiedCredentialTypeId;
+ CompanySsiDetailStatusId = companySsiDetailStatusId;
+ CreatorUserId = creatorUserId;
+ DateCreated = dateCreated;
+ }
+
+ public Guid Id { get; set; }
+ public string Bpnl { get; set; }
+ public VerifiedCredentialTypeId VerifiedCredentialTypeId { get; set; }
+ public CompanySsiDetailStatusId CompanySsiDetailStatusId { get; set; }
+ public DateTimeOffset DateCreated { get; set; }
+ public Guid CreatorUserId { get; set; }
+ public DateTimeOffset? ExpiryDate { get; set; }
+ public Guid? VerifiedCredentialExternalTypeDetailVersionId { get; set; }
+
+ public ExpiryCheckTypeId? ExpiryCheckTypeId { get; set; }
+ public Guid? ProcessId { get; set; }
+ public Guid? ExternalCredentialId { get; set; }
+ public string? Credential { get; set; }
+
+ [LastChangedV1]
+ public DateTimeOffset? DateLastChanged { get; set; }
+
+ [LastEditorV1]
+ public Guid? LastEditorId { get; private set; }
+
+ // Navigation Properties
+ public virtual VerifiedCredentialType? VerifiedCredentialType { get; set; }
+ public virtual ExpiryCheckType? ExpiryCheckType { get; set; }
+ public virtual CompanySsiDetailStatus? CompanySsiDetailStatus { get; set; }
+ public virtual Process? Process { get; set; }
+ public virtual VerifiedCredentialExternalTypeDetailVersion? VerifiedCredentialExternalTypeDetailVersion { get; set; }
+ public virtual CompanySsiProcessData? CompanySsiProcessData { get; set; }
+ public virtual ICollection Documents { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetailAssignedDocument.cs b/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetailAssignedDocument.cs
new file mode 100644
index 00000000..79f88bdf
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetailAssignedDocument.cs
@@ -0,0 +1,16 @@
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class CompanySsiDetailAssignedDocument
+{
+ public CompanySsiDetailAssignedDocument(Guid documentId, Guid companySsiDetailId)
+ {
+ DocumentId = documentId;
+ CompanySsiDetailId = companySsiDetailId;
+ }
+
+ public Guid DocumentId { get; set; }
+ public Guid CompanySsiDetailId { get; set; }
+
+ public virtual Document? Document { get; set; }
+ public virtual CompanySsiDetail? CompanySsiDetail { get; set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetailStatus.cs b/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetailStatus.cs
new file mode 100644
index 00000000..7c4be658
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetailStatus.cs
@@ -0,0 +1,47 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class CompanySsiDetailStatus
+{
+ private CompanySsiDetailStatus()
+ {
+ Label = null!;
+ CompanySsiDetails = new HashSet();
+ }
+
+ public CompanySsiDetailStatus(CompanySsiDetailStatusId companySsiDetailStatusId)
+ : this()
+ {
+ Id = companySsiDetailStatusId;
+ Label = companySsiDetailStatusId.ToString();
+ }
+
+ public CompanySsiDetailStatusId Id { get; private set; }
+
+ [MaxLength(255)]
+ public string Label { get; private set; }
+
+ // Navigation properties
+ public virtual ICollection CompanySsiDetails { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiProcessData.cs b/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiProcessData.cs
new file mode 100644
index 00000000..aa14e404
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiProcessData.cs
@@ -0,0 +1,50 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.Text.Json;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class CompanySsiProcessData
+{
+ private CompanySsiProcessData()
+ {
+ Schema = null!;
+ }
+
+ public CompanySsiProcessData(Guid companySsiDetailId, JsonDocument schema, VerifiedCredentialTypeKindId credentialTypeKindId)
+ : this()
+ {
+ CompanySsiDetailId = companySsiDetailId;
+ Schema = schema;
+ CredentialTypeKindId = credentialTypeKindId;
+ }
+
+ public Guid CompanySsiDetailId { get; set; }
+ public JsonDocument Schema { get; set; }
+ public VerifiedCredentialTypeKindId CredentialTypeKindId { get; set; }
+ public string? ClientId { get; set; }
+ public byte[]? ClientSecret { get; set; }
+ public byte[]? InitializationVector { get; set; }
+ public int EncryptionMode { get; set; }
+ public string? HolderWalletUrl { get; set; }
+ public virtual CompanySsiDetail? CompanySsiDetail { get; private set; }
+ public virtual VerifiedCredentialTypeKind? CredentialTypeKind { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/Document.cs b/src/database/SsiCredentialIssuer.Entities/Entities/Document.cs
new file mode 100644
index 00000000..ac70ee87
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/Document.cs
@@ -0,0 +1,83 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+[AuditEntityV1(typeof(AuditDocument20240305))]
+public class Document : IAuditableV1, IBaseEntity
+{
+ private Document()
+ {
+ DocumentHash = null!;
+ DocumentName = null!;
+ DocumentContent = null!;
+ CompanySsiDetails = new HashSet();
+ }
+
+ public Document(Guid id, byte[] documentContent, byte[] documentHash, string documentName, MediaTypeId mediaTypeId, DateTimeOffset dateCreated, DocumentStatusId documentStatusId, DocumentTypeId documentTypeId)
+ : this()
+ {
+ Id = id;
+ DocumentContent = documentContent;
+ DocumentHash = documentHash;
+ DocumentName = documentName;
+ DateCreated = dateCreated;
+ DocumentStatusId = documentStatusId;
+ DocumentTypeId = documentTypeId;
+ MediaTypeId = mediaTypeId;
+ }
+
+ public Guid Id { get; private set; }
+
+ public DateTimeOffset DateCreated { get; private set; }
+
+ public byte[] DocumentHash { get; set; }
+
+ public byte[] DocumentContent { get; set; }
+
+ [MaxLength(255)]
+ public string DocumentName { get; set; }
+
+ public MediaTypeId MediaTypeId { get; set; }
+
+ public DocumentTypeId DocumentTypeId { get; set; }
+
+ public DocumentStatusId DocumentStatusId { get; set; }
+
+ public Guid? CompanyUserId { get; set; }
+
+ [LastChangedV1]
+ public DateTimeOffset? DateLastChanged { get; set; }
+
+ [LastEditorV1]
+ public Guid? LastEditorId { get; private set; }
+
+ // Navigation properties
+ public virtual DocumentType? DocumentType { get; set; }
+ public virtual MediaType? MediaType { get; set; }
+ public virtual DocumentStatus? DocumentStatus { get; set; }
+
+ public virtual ICollection CompanySsiDetails { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/DocumentStatus.cs b/src/database/SsiCredentialIssuer.Entities/Entities/DocumentStatus.cs
new file mode 100644
index 00000000..425bb472
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/DocumentStatus.cs
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class DocumentStatus
+{
+ private DocumentStatus()
+ {
+ Label = null!;
+ Documents = new HashSet();
+ }
+
+ public DocumentStatus(DocumentStatusId documentStatusId) : this()
+ {
+ Id = documentStatusId;
+ Label = documentStatusId.ToString();
+ }
+
+ public DocumentStatusId Id { get; private set; }
+
+ [MaxLength(255)]
+ public string Label { get; private set; }
+
+ // Navigation properties
+ public virtual ICollection Documents { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/DocumentType.cs b/src/database/SsiCredentialIssuer.Entities/Entities/DocumentType.cs
new file mode 100644
index 00000000..602c03c9
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/DocumentType.cs
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class DocumentType
+{
+ private DocumentType()
+ {
+ Label = null!;
+ Documents = new HashSet();
+ }
+
+ public DocumentType(DocumentTypeId documentTypeId) : this()
+ {
+ Id = documentTypeId;
+ Label = documentTypeId.ToString();
+ }
+
+ public DocumentTypeId Id { get; private set; }
+
+ [MaxLength(255)]
+ public string Label { get; private set; }
+
+ // Navigation properties
+ public virtual ICollection Documents { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/ExpiryCheckType.cs b/src/database/SsiCredentialIssuer.Entities/Entities/ExpiryCheckType.cs
new file mode 100644
index 00000000..3288b6ea
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/ExpiryCheckType.cs
@@ -0,0 +1,49 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class ExpiryCheckType
+{
+ private ExpiryCheckType()
+ {
+ Label = null!;
+ CompanySsiDetails = new HashSet();
+ }
+
+ public ExpiryCheckType(ExpiryCheckTypeId expiryCheckId)
+ : this()
+ {
+ Id = expiryCheckId;
+ Label = expiryCheckId.ToString();
+ CompanySsiDetails = new HashSet();
+ }
+
+ public ExpiryCheckTypeId Id { get; private set; }
+
+ [MaxLength(255)]
+ public string Label { get; private set; }
+
+ // Navigation properties
+
+ public virtual ICollection CompanySsiDetails { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/MediaType.cs b/src/database/SsiCredentialIssuer.Entities/Entities/MediaType.cs
new file mode 100644
index 00000000..274f3881
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/MediaType.cs
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class MediaType
+{
+ private MediaType()
+ {
+ Label = null!;
+ Documents = new HashSet();
+ }
+
+ public MediaType(MediaTypeId mediaTypeId) : this()
+ {
+ Id = mediaTypeId;
+ Label = mediaTypeId.ToString();
+ }
+
+ public MediaTypeId Id { get; private set; }
+
+ [MaxLength(255)]
+ public string Label { get; private set; }
+
+ // Navigation properties
+ public virtual ICollection Documents { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/Process.cs b/src/database/SsiCredentialIssuer.Entities/Entities/Process.cs
new file mode 100644
index 00000000..41448123
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/Process.cs
@@ -0,0 +1,55 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class Process : IBaseEntity, ILockableEntity
+{
+ private Process()
+ {
+ ProcessSteps = new HashSet();
+ CompanySsiDetails = new HashSet();
+ }
+
+ public Process(Guid id, ProcessTypeId processTypeId, Guid version) : this()
+ {
+ Id = id;
+ ProcessTypeId = processTypeId;
+ Version = version;
+ }
+
+ public Guid Id { get; private set; }
+
+ public ProcessTypeId ProcessTypeId { get; set; }
+
+ public DateTimeOffset? LockExpiryDate { get; set; }
+
+ [ConcurrencyCheck]
+ public Guid Version { get; set; }
+
+ // Navigation properties
+ public virtual ProcessType? ProcessType { get; set; }
+ public virtual ICollection ProcessSteps { get; private set; }
+ public virtual ICollection CompanySsiDetails { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStep.cs b/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStep.cs
new file mode 100644
index 00000000..13da78d4
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStep.cs
@@ -0,0 +1,56 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class ProcessStep : IBaseEntity
+{
+ public ProcessStep(Guid id, ProcessStepTypeId processStepTypeId, ProcessStepStatusId processStepStatusId, Guid processId, DateTimeOffset dateCreated)
+ {
+ Id = id;
+ ProcessStepTypeId = processStepTypeId;
+ ProcessStepStatusId = processStepStatusId;
+ ProcessId = processId;
+ DateCreated = dateCreated;
+ }
+
+ public Guid Id { get; private set; }
+
+ public ProcessStepTypeId ProcessStepTypeId { get; private set; }
+
+ public ProcessStepStatusId ProcessStepStatusId { get; set; }
+
+ public Guid ProcessId { get; private set; }
+
+ public DateTimeOffset DateCreated { get; private set; }
+
+ [LastChangedV1]
+ public DateTimeOffset? DateLastChanged { get; set; }
+
+ public string? Message { get; set; }
+
+ // Navigation properties
+ public virtual ProcessStepType? ProcessStepType { get; private set; }
+ public virtual ProcessStepStatus? ProcessStepStatus { get; set; }
+ public virtual Process? Process { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStepStatus.cs b/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStepStatus.cs
new file mode 100644
index 00000000..a62480b7
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStepStatus.cs
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class ProcessStepStatus
+{
+ private ProcessStepStatus()
+ {
+ this.Label = null!;
+ this.ProcessSteps = new HashSet();
+ }
+
+ public ProcessStepStatus(ProcessStepStatusId processStepStatusId) : this()
+ {
+ Id = processStepStatusId;
+ Label = processStepStatusId.ToString();
+ }
+
+ public ProcessStepStatusId Id { get; private set; }
+
+ [MaxLength(255)]
+ public string Label { get; private set; }
+
+ // Navigation properties
+ public virtual ICollection ProcessSteps { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStepType.cs b/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStepType.cs
new file mode 100644
index 00000000..d175f667
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStepType.cs
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class ProcessStepType
+{
+ private ProcessStepType()
+ {
+ this.Label = null!;
+ this.ProcessSteps = new HashSet();
+ }
+
+ public ProcessStepType(ProcessStepTypeId processStepTypeId) : this()
+ {
+ Id = processStepTypeId;
+ Label = processStepTypeId.ToString();
+ }
+
+ public ProcessStepTypeId Id { get; private set; }
+
+ [MaxLength(255)]
+ public string Label { get; private set; }
+
+ // Navigation properties
+ public virtual ICollection ProcessSteps { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/ProcessType.cs b/src/database/SsiCredentialIssuer.Entities/Entities/ProcessType.cs
new file mode 100644
index 00000000..87c8860a
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/ProcessType.cs
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class ProcessType
+{
+ private ProcessType()
+ {
+ this.Label = null!;
+ this.Processes = new HashSet();
+ }
+
+ public ProcessType(ProcessTypeId processTypeId) : this()
+ {
+ Id = processTypeId;
+ Label = processTypeId.ToString();
+ }
+
+ public ProcessTypeId Id { get; private set; }
+
+ [MaxLength(255)]
+ public string Label { get; private set; }
+
+ // Navigation properties
+ public virtual ICollection Processes { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/UseCase.cs b/src/database/SsiCredentialIssuer.Entities/Entities/UseCase.cs
new file mode 100644
index 00000000..69be03e8
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/UseCase.cs
@@ -0,0 +1,50 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class UseCase : IBaseEntity
+{
+ private UseCase()
+ {
+ Name = null!;
+ Shortname = null!;
+ }
+
+ public UseCase(Guid id, string name, string shortname) : this()
+ {
+ Id = id;
+ Name = name;
+ Shortname = shortname;
+ }
+
+ public Guid Id { get; private set; }
+
+ [MaxLength(255)]
+ public string Name { get; set; }
+
+ [MaxLength(255)]
+ public string Shortname { get; set; }
+
+ // Navigation properties
+ public virtual VerifiedCredentialTypeAssignedUseCase? VerifiedCredentialAssignedUseCase { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialExternalType.cs b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialExternalType.cs
new file mode 100644
index 00000000..512124d7
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialExternalType.cs
@@ -0,0 +1,43 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class VerifiedCredentialExternalType
+{
+ public VerifiedCredentialExternalType(VerifiedCredentialExternalTypeId id)
+ {
+ Id = id;
+ Label = id.ToString();
+
+ VerifiedCredentialTypeAssignedExternalTypes = new HashSet();
+ VerifiedCredentialExternalTypeDetailVersions = new HashSet();
+ }
+
+ public VerifiedCredentialExternalTypeId Id { get; private set; }
+
+ public string Label { get; private set; }
+
+ // Navigation properties
+ public virtual ICollection VerifiedCredentialTypeAssignedExternalTypes { get; private set; }
+
+ public virtual ICollection VerifiedCredentialExternalTypeDetailVersions { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialExternalTypeDetailVersion.cs b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialExternalTypeDetailVersion.cs
new file mode 100644
index 00000000..f4a8f9b6
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialExternalTypeDetailVersion.cs
@@ -0,0 +1,41 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class VerifiedCredentialExternalTypeDetailVersion : IBaseEntity
+{
+ public VerifiedCredentialExternalTypeDetailVersion()
+ {
+ CompanySsiDetails = new HashSet();
+ }
+
+ public Guid Id { get; set; }
+ public VerifiedCredentialExternalTypeId VerifiedCredentialExternalTypeId { get; set; }
+ public string? Version { get; set; }
+ public string? Template { get; set; }
+ public DateTimeOffset ValidFrom { get; set; }
+ public DateTimeOffset Expiry { get; set; }
+
+ public virtual VerifiedCredentialExternalType? VerifiedCredentialExternalType { get; private set; }
+ public virtual ICollection CompanySsiDetails { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialType.cs b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialType.cs
new file mode 100644
index 00000000..863d8421
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialType.cs
@@ -0,0 +1,52 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class VerifiedCredentialType
+{
+ private VerifiedCredentialType()
+ {
+ Label = null!;
+ CompanySsiDetails = new HashSet();
+ }
+
+ public VerifiedCredentialType(VerifiedCredentialTypeId verifiedCredentialTypeId)
+ {
+ Id = verifiedCredentialTypeId;
+ Label = verifiedCredentialTypeId.ToString();
+ CompanySsiDetails = new HashSet();
+ }
+
+ public VerifiedCredentialTypeId Id { get; private set; }
+
+ [MaxLength(255)]
+ public string Label { get; private set; }
+
+ // Navigation properties
+ public virtual VerifiedCredentialTypeAssignedExternalType? VerifiedCredentialTypeAssignedExternalType { get; private set; }
+ public virtual VerifiedCredentialTypeAssignedKind? VerifiedCredentialTypeAssignedKind { get; set; }
+
+ public virtual VerifiedCredentialTypeAssignedUseCase? VerifiedCredentialTypeAssignedUseCase { get; set; }
+
+ public virtual ICollection CompanySsiDetails { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeAssignedExternalType.cs b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeAssignedExternalType.cs
new file mode 100644
index 00000000..2ae5f28b
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeAssignedExternalType.cs
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class VerifiedCredentialTypeAssignedExternalType
+{
+ public VerifiedCredentialTypeAssignedExternalType(VerifiedCredentialTypeId verifiedCredentialTypeId, VerifiedCredentialExternalTypeId verifiedCredentialExternalTypeId)
+ {
+ VerifiedCredentialTypeId = verifiedCredentialTypeId;
+ VerifiedCredentialExternalTypeId = verifiedCredentialExternalTypeId;
+ }
+
+ ///
+ /// Id of the credential type.
+ ///
+ public VerifiedCredentialTypeId VerifiedCredentialTypeId { get; private set; }
+
+ ///
+ /// Id of the credential type kind.
+ ///
+ public VerifiedCredentialExternalTypeId VerifiedCredentialExternalTypeId { get; private set; }
+
+ // Navigation properties
+ public virtual VerifiedCredentialType? VerifiedCredentialType { get; private set; }
+
+ public virtual VerifiedCredentialExternalType? VerifiedCredentialExternalType { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeAssignedKind.cs b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeAssignedKind.cs
new file mode 100644
index 00000000..b1a174d5
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeAssignedKind.cs
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class VerifiedCredentialTypeAssignedKind
+{
+ public VerifiedCredentialTypeAssignedKind(VerifiedCredentialTypeId verifiedCredentialTypeId, VerifiedCredentialTypeKindId verifiedCredentialTypeKindId)
+ {
+ VerifiedCredentialTypeId = verifiedCredentialTypeId;
+ VerifiedCredentialTypeKindId = verifiedCredentialTypeKindId;
+ }
+
+ ///
+ /// Id of the credential type.
+ ///
+ public VerifiedCredentialTypeId VerifiedCredentialTypeId { get; private set; }
+
+ ///
+ /// Id of the credential type kind.
+ ///
+ public VerifiedCredentialTypeKindId VerifiedCredentialTypeKindId { get; private set; }
+
+ // Navigation properties
+ public virtual VerifiedCredentialType? VerifiedCredentialType { get; private set; }
+
+ public virtual VerifiedCredentialTypeKind? VerifiedCredentialTypeKind { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeAssignedUseCase.cs b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeAssignedUseCase.cs
new file mode 100644
index 00000000..8924c076
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeAssignedUseCase.cs
@@ -0,0 +1,38 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class VerifiedCredentialTypeAssignedUseCase
+{
+ public VerifiedCredentialTypeAssignedUseCase(VerifiedCredentialTypeId verifiedCredentialTypeId, Guid useCaseId)
+ {
+ VerifiedCredentialTypeId = verifiedCredentialTypeId;
+ UseCaseId = useCaseId;
+ }
+
+ public VerifiedCredentialTypeId VerifiedCredentialTypeId { get; set; }
+ public Guid UseCaseId { get; set; }
+
+ // Navigation Properties
+ public virtual VerifiedCredentialType? VerifiedCredentialType { get; set; }
+ public virtual UseCase? UseCase { get; set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeKind.cs b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeKind.cs
new file mode 100644
index 00000000..0814fb02
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/VerifiedCredentialTypeKind.cs
@@ -0,0 +1,50 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public class VerifiedCredentialTypeKind
+{
+ private VerifiedCredentialTypeKind()
+ {
+ Label = null!;
+ VerifiedCredentialTypeAssignedKinds = new HashSet();
+ CompanySsiProcessData = new HashSet();
+ }
+
+ public VerifiedCredentialTypeKind(VerifiedCredentialTypeKindId verifiedCredentialTypeKindId)
+ : this()
+ {
+ Id = verifiedCredentialTypeKindId;
+ Label = verifiedCredentialTypeKindId.ToString();
+ VerifiedCredentialTypeAssignedKinds = new HashSet();
+ }
+
+ public VerifiedCredentialTypeKindId Id { get; private set; }
+
+ [MaxLength(255)]
+ public string Label { get; private set; }
+
+ // Navigation Properties
+ public virtual ICollection VerifiedCredentialTypeAssignedKinds { get; private set; }
+ public virtual ICollection CompanySsiProcessData { get; private set; }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/VerifyProcessData.cs b/src/database/SsiCredentialIssuer.Entities/Entities/VerifyProcessData.cs
new file mode 100644
index 00000000..20004488
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Entities/VerifyProcessData.cs
@@ -0,0 +1,25 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+
+public record VerifyProcessData(
+ Process? Process,
+ IEnumerable? ProcessSteps
+);
diff --git a/src/database/SsiCredentialIssuer.Entities/Enums/CompanySsiDetailStatusId.cs b/src/database/SsiCredentialIssuer.Entities/Enums/CompanySsiDetailStatusId.cs
new file mode 100644
index 00000000..ace621fc
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Enums/CompanySsiDetailStatusId.cs
@@ -0,0 +1,27 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+public enum CompanySsiDetailStatusId
+{
+ PENDING = 1,
+ ACTIVE = 2,
+ INACTIVE = 3
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Enums/DocumentStatusId.cs b/src/database/SsiCredentialIssuer.Entities/Enums/DocumentStatusId.cs
new file mode 100644
index 00000000..96d3d43a
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Enums/DocumentStatusId.cs
@@ -0,0 +1,36 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+///
+/// Possible status for documents
+///
+public enum DocumentStatusId
+{
+ ///
+ /// The document is active for changes
+ ///
+ ACTIVE = 2,
+
+ ///
+ /// The document was deleted by the user
+ ///
+ INACTIVE = 3,
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Enums/DocumentTypeId.cs b/src/database/SsiCredentialIssuer.Entities/Enums/DocumentTypeId.cs
new file mode 100644
index 00000000..d9502810
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Enums/DocumentTypeId.cs
@@ -0,0 +1,27 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+public enum DocumentTypeId
+{
+ PRESENTATION = 1,
+ CREDENTIAL = 2,
+ VERIFIED_CREDENTIAL = 3
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Enums/ExpiryCheckTypeId.cs b/src/database/SsiCredentialIssuer.Entities/Enums/ExpiryCheckTypeId.cs
new file mode 100644
index 00000000..3280b9c9
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Enums/ExpiryCheckTypeId.cs
@@ -0,0 +1,27 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+public enum ExpiryCheckTypeId
+{
+ ONE_MONTH = 1,
+ TWO_WEEKS = 2,
+ ONE_DAY = 3
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Enums/MediaTypeId.cs b/src/database/SsiCredentialIssuer.Entities/Enums/MediaTypeId.cs
new file mode 100644
index 00000000..f322bdf6
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Enums/MediaTypeId.cs
@@ -0,0 +1,35 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+public enum MediaTypeId
+{
+ JPEG = 1,
+ GIF = 2,
+ PNG = 3,
+ SVG = 4,
+ TIFF = 5,
+ PDF = 6,
+ JSON = 7,
+ PEM = 8,
+ CA_CERT = 9,
+ PKX_CER = 10,
+ OCTET = 11
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Enums/ProcessStepStatusId.cs b/src/database/SsiCredentialIssuer.Entities/Enums/ProcessStepStatusId.cs
new file mode 100644
index 00000000..9450d24b
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Enums/ProcessStepStatusId.cs
@@ -0,0 +1,29 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+public enum ProcessStepStatusId
+{
+ TODO = 1,
+ DONE = 2,
+ SKIPPED = 3,
+ FAILED = 4,
+ DUPLICATE = 5
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Enums/ProcessStepTypeId.cs b/src/database/SsiCredentialIssuer.Entities/Enums/ProcessStepTypeId.cs
new file mode 100644
index 00000000..9e65e8b5
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Enums/ProcessStepTypeId.cs
@@ -0,0 +1,29 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+public enum ProcessStepTypeId
+{
+ // ApplicationChecklist Process
+ CREATE_CREDENTIAL = 1,
+ SIGN_CREDENTIAL = 2,
+ SAVE_CREDENTIAL_DOCUMENT = 3,
+ CREATE_CREDENTIAL_FOR_HOLDER = 4
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Enums/ProcessTypeId.cs b/src/database/SsiCredentialIssuer.Entities/Enums/ProcessTypeId.cs
new file mode 100644
index 00000000..a07c1bca
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Enums/ProcessTypeId.cs
@@ -0,0 +1,25 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+public enum ProcessTypeId
+{
+ CREATE_CREDENTIAL = 1,
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Enums/VerifiedCredentialExternalTypeId.cs b/src/database/SsiCredentialIssuer.Entities/Enums/VerifiedCredentialExternalTypeId.cs
new file mode 100644
index 00000000..fbb6178c
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Enums/VerifiedCredentialExternalTypeId.cs
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using System.Runtime.Serialization;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+public enum VerifiedCredentialExternalTypeId
+{
+ [EnumMember(Value = "TraceabilityCredential")]
+ TRACEABILITY_CREDENTIAL = 1,
+
+ [EnumMember(Value = "PcfCredential")]
+ PCF_CREDENTIAL = 2,
+
+ [EnumMember(Value = "BehaviorTwinCredential")]
+ BEHAVIOR_TWIN_CREDENTIAL = 3,
+
+ [EnumMember(Value = "vehicleDismantle")]
+ VEHICLE_DISMANTLE = 4,
+
+ [EnumMember(Value = "SustainabilityCredential")]
+ SUSTAINABILITY_CREDENTIAL = 5,
+
+ [EnumMember(Value = "QualityCredential")]
+ QUALITY_CREDENTIAL = 6,
+
+ [EnumMember(Value = "BusinessPartnerCredential")]
+ BUSINESS_PARTNER_NUMBER = 7
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Enums/VerifiedCredentialTypeId.cs b/src/database/SsiCredentialIssuer.Entities/Enums/VerifiedCredentialTypeId.cs
new file mode 100644
index 00000000..725f9d22
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Enums/VerifiedCredentialTypeId.cs
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using System.Runtime.Serialization;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+public enum VerifiedCredentialTypeId
+{
+ [EnumMember(Value = "Traceability Framework")]
+ TRACEABILITY_FRAMEWORK = 1,
+
+ [EnumMember(Value = "PCF Framework")]
+ PCF_FRAMEWORK = 2,
+
+ [EnumMember(Value = "Behavior Twin Framework")]
+ BEHAVIOR_TWIN_FRAMEWORK = 3,
+
+ [EnumMember(Value = "Dismantler Certificate")]
+ DISMANTLER_CERTIFICATE = 4,
+
+ [EnumMember(Value = "Sustainability Framework")]
+ SUSTAINABILITY_FRAMEWORK = 5,
+
+ [EnumMember(Value = "frameworkAgreement.quality")]
+ FRAMEWORK_AGREEMENT_QUALITY = 6,
+
+ [EnumMember(Value = "BusinessPartnerCredential")]
+ BUSINESS_PARTNER_NUMBER = 7
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/Enums/VerifiedCredentialTypeKindId.cs b/src/database/SsiCredentialIssuer.Entities/Enums/VerifiedCredentialTypeKindId.cs
new file mode 100644
index 00000000..23581709
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/Enums/VerifiedCredentialTypeKindId.cs
@@ -0,0 +1,27 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+
+public enum VerifiedCredentialTypeKindId
+{
+ FRAMEWORK = 1,
+ MEMBERSHIP = 2,
+ BPN = 3
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/IssuerDbContext.cs b/src/database/SsiCredentialIssuer.Entities/IssuerDbContext.cs
new file mode 100644
index 00000000..65274bdc
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/IssuerDbContext.cs
@@ -0,0 +1,318 @@
+/********************************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.EntityFrameworkCore;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Extensions;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Handler;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums;
+using System.Collections.Immutable;
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities;
+
+public class IssuerDbContext : DbContext
+{
+ private readonly IAuditHandler _auditHandler;
+
+ protected IssuerDbContext()
+ {
+ throw new InvalidOperationException("IdentityService should never be null");
+ }
+
+ public IssuerDbContext(DbContextOptions options, IAuditHandler auditHandler)
+ : base(options)
+ {
+ _auditHandler = auditHandler;
+ }
+
+ public virtual DbSet AuditCompanySsiDetail20240228 { get; set; } = default!;
+ public virtual DbSet AuditDocument20240305 { get; set; } = default!;
+ public virtual DbSet CompanySsiDetails { get; set; } = default!;
+ public virtual DbSet CompanySsiDetailAssignedDocuments { get; set; } = default!;
+ public virtual DbSet CompanySsiDetailStatuses { get; set; } = default!;
+ public virtual DbSet CompanySsiProcessData { get; set; } = default!;
+ public virtual DbSet Documents { get; set; } = default!;
+ public virtual DbSet DocumentStatus { get; set; } = default!;
+ public virtual DbSet DocumentTypes { get; set; } = default!;
+ public virtual DbSet ExpiryCheckTypes { get; set; } = default!;
+ public virtual DbSet MediaTypes { get; set; } = default!;
+ public virtual DbSet Processes { get; set; } = default!;
+ public virtual DbSet ProcessSteps { get; set; } = default!;
+ public virtual DbSet ProcessStepStatuses { get; set; } = default!;
+ public virtual DbSet ProcessStepTypes { get; set; } = default!;
+ public virtual DbSet ProcessTypes { get; set; } = default!;
+ public virtual DbSet UseCases { get; set; } = default!;
+ public virtual DbSet VerifiedCredentialExternalTypes { get; set; } = default!;
+ public virtual DbSet VerifiedCredentialExternalTypeDetailVersions { get; set; } = default!;
+ public virtual DbSet VerifiedCredentialTypes { get; set; } = default!;
+ public virtual DbSet VerifiedCredentialTypeAssignedExternalTypes { get; set; } = default!;
+ public virtual DbSet VerifiedCredentialTypeAssignedKinds { get; set; } = default!;
+ public virtual DbSet VerifiedCredentialTypeAssignedUseCases { get; set; } = default!;
+ public virtual DbSet VerifiedCredentialTypeKinds { get; set; } = default!;
+
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ optionsBuilder.UseSnakeCaseNamingConvention();
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.HasAnnotation("Relational:Collation", "en_US.utf8");
+ modelBuilder.HasDefaultSchema("issuer");
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasOne(c => c.Process)
+ .WithMany(c => c.CompanySsiDetails)
+ .HasForeignKey(t => t.ProcessId)
+ .OnDelete(DeleteBehavior.ClientSetNull);
+
+ entity.HasOne(c => c.VerifiedCredentialType)
+ .WithMany(c => c.CompanySsiDetails)
+ .HasForeignKey(t => t.VerifiedCredentialTypeId)
+ .OnDelete(DeleteBehavior.ClientSetNull);
+
+ entity.HasOne(c => c.CompanySsiDetailStatus)
+ .WithMany(c => c.CompanySsiDetails)
+ .HasForeignKey(t => t.CompanySsiDetailStatusId)
+ .OnDelete(DeleteBehavior.ClientSetNull);
+
+ entity.HasOne(c => c.VerifiedCredentialExternalTypeDetailVersion)
+ .WithMany(c => c.CompanySsiDetails)
+ .HasForeignKey(t => t.VerifiedCredentialExternalTypeDetailVersionId)
+ .OnDelete(DeleteBehavior.ClientSetNull);
+
+ entity.HasMany(t => t.Documents)
+ .WithMany(o => o.CompanySsiDetails)
+ .UsingEntity(
+ j => j
+ .HasOne(d => d.Document!)
+ .WithMany()
+ .HasForeignKey(d => d.DocumentId)
+ .OnDelete(DeleteBehavior.ClientSetNull),
+ j => j
+ .HasOne(d => d.CompanySsiDetail!)
+ .WithMany()
+ .HasForeignKey(d => d.CompanySsiDetailId)
+ .OnDelete(DeleteBehavior.ClientSetNull),
+ j =>
+ {
+ j.HasKey(e => new { e.DocumentId, e.CompanySsiDetailId });
+ });
+
+ entity.HasAuditV1Triggers();
+ });
+
+ modelBuilder.Entity()
+ .HasData(
+ Enum.GetValues(typeof(CompanySsiDetailStatusId))
+ .Cast()
+ .Select(e => new CompanySsiDetailStatus(e))
+ );
+
+ modelBuilder.Entity(e =>
+ {
+ e.HasKey(x => x.CompanySsiDetailId);
+
+ e.HasOne(x => x.CompanySsiDetail)
+ .WithOne(x => x.CompanySsiProcessData)
+ .HasForeignKey(x => x.CompanySsiDetailId);
+
+ e.HasOne(x => x.CredentialTypeKind)
+ .WithMany(x => x.CompanySsiProcessData)
+ .HasForeignKey(x => x.CredentialTypeKindId);
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasAuditV1Triggers();
+ });
+
+ modelBuilder.Entity()
+ .HasData(
+ Enum.GetValues(typeof(DocumentStatusId))
+ .Cast()
+ .Select(e => new DocumentStatus(e))
+ );
+
+ modelBuilder.Entity()
+ .HasData(
+ Enum.GetValues(typeof(DocumentTypeId))
+ .Cast()
+ .Select(e => new DocumentType(e))
+ );
+
+ modelBuilder.Entity()
+ .HasData(
+ Enum.GetValues(typeof(ExpiryCheckTypeId))
+ .Cast()
+ .Select(e => new ExpiryCheckType(e))
+ );
+
+ modelBuilder.Entity()
+ .HasData(
+ Enum.GetValues(typeof(MediaTypeId))
+ .Cast()
+ .Select(e => new MediaType(e))
+ );
+
+ modelBuilder.Entity()
+ .HasOne(d => d.ProcessType)
+ .WithMany(p => p!.Processes)
+ .HasForeignKey(d => d.ProcessTypeId)
+ .OnDelete(DeleteBehavior.ClientSetNull);
+
+ modelBuilder.Entity()
+ .HasOne(d => d.Process)
+ .WithMany(p => p!.ProcessSteps)
+ .HasForeignKey(d => d.ProcessId)
+ .OnDelete(DeleteBehavior.ClientSetNull);
+
+ modelBuilder.Entity()
+ .HasData(
+ Enum.GetValues(typeof(ProcessTypeId))
+ .Cast()
+ .Select(e => new ProcessType(e))
+ );
+
+ modelBuilder.Entity()
+ .HasData(
+ Enum.GetValues(typeof(ProcessStepStatusId))
+ .Cast()
+ .Select(e => new ProcessStepStatus(e))
+ );
+
+ modelBuilder.Entity()
+ .HasData(
+ Enum.GetValues(typeof(ProcessStepTypeId))
+ .Cast()
+ .Select(e => new ProcessStepType(e))
+ );
+
+ modelBuilder.Entity();
+
+ modelBuilder.Entity()
+ .HasData(
+ Enum.GetValues(typeof(VerifiedCredentialExternalTypeId))
+ .Cast()
+ .Select(e => new VerifiedCredentialExternalType(e))
+ );
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasOne(d => d.VerifiedCredentialExternalType)
+ .WithMany(x => x.VerifiedCredentialExternalTypeDetailVersions)
+ .HasForeignKey(d => d.VerifiedCredentialExternalTypeId)
+ .OnDelete(DeleteBehavior.ClientSetNull);
+
+ entity.HasIndex(e => new { e.VerifiedCredentialExternalTypeId, e.Version })
+ .IsUnique();
+ });
+ modelBuilder.Entity()
+ .HasData(
+ Enum.GetValues(typeof(VerifiedCredentialTypeId))
+ .Cast()
+ .Select(e => new VerifiedCredentialType(e))
+ );
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => new { e.VerifiedCredentialTypeId, e.VerifiedCredentialExternalTypeId });
+
+ entity.HasOne(d => d.VerifiedCredentialType)
+ .WithOne(x => x.VerifiedCredentialTypeAssignedExternalType)
+ .HasForeignKey(d => d.VerifiedCredentialTypeId)
+ .OnDelete(DeleteBehavior.ClientSetNull);
+
+ entity.HasOne(d => d.VerifiedCredentialExternalType)
+ .WithMany(x => x.VerifiedCredentialTypeAssignedExternalTypes)
+ .HasForeignKey(d => d.VerifiedCredentialExternalTypeId)
+ .OnDelete(DeleteBehavior.ClientSetNull);
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => new { e.VerifiedCredentialTypeId, e.VerifiedCredentialTypeKindId });
+
+ entity.HasOne(d => d.VerifiedCredentialTypeKind)
+ .WithMany(x => x.VerifiedCredentialTypeAssignedKinds)
+ .HasForeignKey(d => d.VerifiedCredentialTypeKindId)
+ .OnDelete(DeleteBehavior.ClientSetNull);
+
+ entity.HasOne(d => d.VerifiedCredentialType)
+ .WithOne(x => x.VerifiedCredentialTypeAssignedKind)
+ .HasForeignKey(d => d.VerifiedCredentialTypeId)
+ .OnDelete(DeleteBehavior.ClientSetNull);
+
+ entity.HasIndex(x => x.VerifiedCredentialTypeId)
+ .IsUnique(false);
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => new { x.VerifiedCredentialTypeId, x.UseCaseId });
+
+ entity.HasOne(c => c.VerifiedCredentialType)
+ .WithOne(c => c.VerifiedCredentialTypeAssignedUseCase)
+ .HasForeignKey(c => c.VerifiedCredentialTypeId);
+
+ entity.HasOne(c => c.UseCase)
+ .WithOne(c => c.VerifiedCredentialAssignedUseCase)
+ .HasForeignKey(c => c.UseCaseId);
+ });
+
+ modelBuilder.Entity()
+ .HasData(
+ Enum.GetValues(typeof(VerifiedCredentialTypeKindId))
+ .Cast()
+ .Select(e => new VerifiedCredentialTypeKind(e))
+ );
+ }
+
+ ///
+ public override Task SaveChangesAsync(CancellationToken cancellationToken = new())
+ {
+ EnhanceChangedEntries();
+ return base.SaveChangesAsync(cancellationToken);
+ }
+
+ ///
+ public override int SaveChanges(bool acceptAllChangesOnSuccess)
+ {
+ EnhanceChangedEntries();
+ return base.SaveChanges(acceptAllChangesOnSuccess);
+ }
+
+ public override int SaveChanges()
+ {
+ EnhanceChangedEntries();
+ return base.SaveChanges();
+ }
+
+ private void EnhanceChangedEntries()
+ {
+ _auditHandler.HandleAuditForChangedEntries(
+ ChangeTracker.Entries().Where(entry =>
+ entry.State != EntityState.Unchanged && entry.State != EntityState.Detached &&
+ entry.Entity is IAuditableV1).ToImmutableList(),
+ ChangeTracker.Context);
+ }
+}
diff --git a/src/database/SsiCredentialIssuer.Entities/SsiCredentialIssuer.Entities.csproj b/src/database/SsiCredentialIssuer.Entities/SsiCredentialIssuer.Entities.csproj
new file mode 100644
index 00000000..6d397738
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Entities/SsiCredentialIssuer.Entities.csproj
@@ -0,0 +1,46 @@
+
+
+
+
+ Org.Eclipse.TractusX.SsiCredentialIssuer.Entities
+ Org.Eclipse.TractusX.SsiCredentialIssuer.Entities
+ net7.0
+ enable
+ enable
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
+
+ **/IssuerDbContext.cs
+
+
+
diff --git a/src/database/SsiCredentialIssuer.Migrations/Migrations/20240308143713_0.1.0-rc.1.Designer.cs b/src/database/SsiCredentialIssuer.Migrations/Migrations/20240308143713_0.1.0-rc.1.Designer.cs
new file mode 100644
index 00000000..507f1af5
--- /dev/null
+++ b/src/database/SsiCredentialIssuer.Migrations/Migrations/20240308143713_0.1.0-rc.1.Designer.cs
@@ -0,0 +1,1403 @@
+/********************************************************************************
+// * Copyright (c) 2024 Contributors to the Eclipse Foundation
+// *
+// * See the NOTICE file(s) distributed with this work for additional
+// * information regarding copyright ownership.
+// *
+// * This program and the accompanying materials are made available under the
+// * terms of the Apache License, Version 2.0 which is available at
+// * https://www.apache.org/licenses/LICENSE-2.0.
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// * License for the specific language governing permissions and limitations
+// * under the License.
+// *
+// * SPDX-License-Identifier: Apache-2.0
+// ********************************************************************************/
+
+//
+using System;
+using System.Text.Json;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities;
+
+#nullable disable
+
+namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Migrations.Migrations
+{
+ [DbContext(typeof(IssuerDbContext))]
+ [Migration("20240308143713_0.1.0-rc.1")]
+ partial class _010rc1
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasDefaultSchema("issuer")
+ .UseCollation("en_US.utf8")
+ .HasAnnotation("ProductVersion", "7.0.13")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities.AuditCompanySsiDetail20240228", b =>
+ {
+ b.Property("AuditV1Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid")
+ .HasColumnName("audit_v1id");
+
+ b.Property("AuditV1DateLastChanged")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("audit_v1date_last_changed");
+
+ b.Property("AuditV1LastEditorId")
+ .HasColumnType("uuid")
+ .HasColumnName("audit_v1last_editor_id");
+
+ b.Property("AuditV1OperationId")
+ .HasColumnType("integer")
+ .HasColumnName("audit_v1operation_id");
+
+ b.Property("Bpnl")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("bpnl");
+
+ b.Property("CompanySsiDetailStatusId")
+ .HasColumnType("integer")
+ .HasColumnName("company_ssi_detail_status_id");
+
+ b.Property("CreatorUserId")
+ .HasColumnType("uuid")
+ .HasColumnName("creator_user_id");
+
+ b.Property("Credential")
+ .HasColumnType("text")
+ .HasColumnName("credential");
+
+ b.Property("DateCreated")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("date_created");
+
+ b.Property("DateLastChanged")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("date_last_changed");
+
+ b.Property("ExpiryCheckTypeId")
+ .HasColumnType("integer")
+ .HasColumnName("expiry_check_type_id");
+
+ b.Property("ExpiryDate")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("expiry_date");
+
+ b.Property("ExternalCredentialId")
+ .HasColumnType("uuid")
+ .HasColumnName("external_credential_id");
+
+ b.Property("Id")
+ .HasColumnType("uuid")
+ .HasColumnName("id");
+
+ b.Property("LastEditorId")
+ .HasColumnType("uuid")
+ .HasColumnName("last_editor_id");
+
+ b.Property("ProcessId")
+ .HasColumnType("uuid")
+ .HasColumnName("process_id");
+
+ b.Property("VerifiedCredentialExternalTypeDetailVersionId")
+ .HasColumnType("uuid")
+ .HasColumnName("verified_credential_external_type_detail_version_id");
+
+ b.Property("VerifiedCredentialTypeId")
+ .HasColumnType("integer")
+ .HasColumnName("verified_credential_type_id");
+
+ b.HasKey("AuditV1Id")
+ .HasName("pk_audit_company_ssi_detail20240228");
+
+ b.ToTable("audit_company_ssi_detail20240228", "issuer");
+ });
+
+ modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities.AuditDocument20240305", b =>
+ {
+ b.Property("AuditV1Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid")
+ .HasColumnName("audit_v1id");
+
+ b.Property("AuditV1DateLastChanged")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("audit_v1date_last_changed");
+
+ b.Property("AuditV1LastEditorId")
+ .HasColumnType("uuid")
+ .HasColumnName("audit_v1last_editor_id");
+
+ b.Property("AuditV1OperationId")
+ .HasColumnType("integer")
+ .HasColumnName("audit_v1operation_id");
+
+ b.Property("CompanyUserId")
+ .HasColumnType("uuid")
+ .HasColumnName("company_user_id");
+
+ b.Property("DateCreated")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("date_created");
+
+ b.Property