diff --git a/.github/workflows/trivy-dev.yml b/.github/workflows/trivy-dev.yml index c731d72b..da715a5b 100644 --- a/.github/workflows/trivy-dev.yml +++ b/.github/workflows/trivy-dev.yml @@ -53,7 +53,7 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Run Trivy vulnerability scanner in repo mode - uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0 + uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # v0.19.0 with: scan-type: "config" hide-progress: false @@ -86,7 +86,7 @@ jobs: # For public images, no ENV vars must be set. - name: Run Trivy vulnerability scanner if: always() - uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0 + uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # v0.19.0 with: # Path to Docker image image-ref: "${{ env.IMAGE_NAMESPACE }}/ssi-credential-issuer-service:dev" @@ -118,7 +118,7 @@ jobs: # For public images, no ENV vars must be set. - name: Run Trivy vulnerability scanner if: always() - uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0 + uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # v0.19.0 with: # Path to Docker image image-ref: "${{ env.IMAGE_NAMESPACE }}/ssi-credential-issuer-migrations:dev" @@ -151,7 +151,7 @@ jobs: # For public images, no ENV vars must be set. - name: Run Trivy vulnerability scanner if: always() - uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0 + uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # v0.19.0 with: # Path to Docker image image-ref: "${{ env.IMAGE_NAMESPACE }}/ssi-credential-expiry-app:dev" @@ -184,7 +184,7 @@ jobs: # For public images, no ENV vars must be set. - name: Run Trivy vulnerability scanner if: always() - uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0 + uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # v0.19.0 with: # Path to Docker image image-ref: "${{ env.IMAGE_NAMESPACE }}/ssi-credential-issuer-processes-worker:dev" diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index a6b1f060..1688ba06 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -53,7 +53,7 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Run Trivy vulnerability scanner in repo mode - uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0 + uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # v0.19.0 with: scan-type: "config" hide-progress: false @@ -87,7 +87,7 @@ jobs: # For public images, no ENV vars must be set. - name: Run Trivy vulnerability scanner if: always() - uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0 + uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # v0.19.0 with: # Path to Docker image image-ref: "${{ env.IMAGE_NAMESPACE }}/ssi-credential-issuer-service:latest" @@ -119,7 +119,7 @@ jobs: # For public images, no ENV vars must be set. - name: Run Trivy vulnerability scanner if: always() - uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0 + uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # v0.19.0 with: # Path to Docker image image-ref: "${{ env.IMAGE_NAMESPACE }}/ssi-credential-issuer-migrations:latest" @@ -151,7 +151,7 @@ jobs: # For public images, no ENV vars must be set. - name: Run Trivy vulnerability scanner if: always() - uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0 + uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # v0.19.0 with: # Path to Docker image image-ref: "${{ env.IMAGE_NAMESPACE }}/ssi-credential-expiry-app:latest" @@ -183,7 +183,7 @@ jobs: # For public images, no ENV vars must be set. - name: Run Trivy vulnerability scanner if: always() - uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0 + uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # v0.19.0 with: # Path to Docker image image-ref: "${{ env.IMAGE_NAMESPACE }}/ssi-credential-issuer-processes-worker:latest" diff --git a/charts/ssi-credential-issuer/Chart.yaml b/charts/ssi-credential-issuer/Chart.yaml index 4a92b2df..1cd37b2d 100644 --- a/charts/ssi-credential-issuer/Chart.yaml +++ b/charts/ssi-credential-issuer/Chart.yaml @@ -20,8 +20,8 @@ apiVersion: v2 name: ssi-credential-issuer type: application -version: 1.0.0-rc.1 -appVersion: 1.0.0-rc.1 +version: 1.0.0-rc.2 +appVersion: 1.0.0-rc.2 description: Helm chart for SSI Credential Issuer home: https://github.com/eclipse-tractusx/ssi-credential-issuer dependencies: diff --git a/charts/ssi-credential-issuer/README.md b/charts/ssi-credential-issuer/README.md index fd3ef803..4ff2e5f2 100644 --- a/charts/ssi-credential-issuer/README.md +++ b/charts/ssi-credential-issuer/README.md @@ -1,4 +1,4 @@ -# Helm chart for Catena-X SSI Credential Issuer +# Helm chart for SSI Credential Issuer This helm chart installs the Catena-X SSI Credential Issuer application. @@ -27,7 +27,7 @@ To use the helm chart as a dependency: dependencies: - name: ssi-credential-issuer repository: https://eclipse-tractusx.github.io/charts/dev - version: 1.0.0-rc.1 + version: 1.0.0-rc.2 ``` ## Requirements @@ -40,6 +40,9 @@ dependencies: | Key | Type | Default | Description | |-----|------|---------|-------------| +| portalBackendAddress | string | `"https://portal-backend.example.org"` | Provide portal-backend base address. | +| walletAddress | string | `"https://wallet.example.org"` | | +| walletTokenAddress | string | `"https://wallet.example.org/oauth/token"` | | | issuer.image.name | string | `"docker.io/tractusx/ssi-credential-issuer-service"` | | | issuer.image.tag | string | `""` | | | issuer.imagePullPolicy | string | `"IfNotPresent"` | | @@ -56,9 +59,9 @@ dependencies: | issuer.portal.grantType | string | `"client_credentials"` | | | issuer.portal.clientId | string | `"portal-client-id"` | Provide portal client-id from CX IAM centralidp. | | issuer.portal.clientSecret | string | `""` | Client-secret for portal client-id. Secret-key 'portal-client-secret'. | -| issuer.credential.issuerDid | string | `""` | | -| issuer.credential.issuerBpn | string | `""` | | -| issuer.credential.statusListUrl | string | `""` | | +| issuer.credential.issuerDid | string | `"did:web:example"` | | +| issuer.credential.issuerBpn | string | `"BPNL00000001TEST"` | | +| issuer.credential.statusListUrl | string | `"https://example.org/statuslist"` | | | issuer.credential.encryptionConfigIndex | int | `0` | | | issuer.credential.encryptionConfigs.index0.index | int | `0` | | | issuer.credential.encryptionConfigs.index0.cipherMode | string | `"CBC"` | | @@ -68,7 +71,7 @@ dependencies: | issuermigrations.image.name | string | `"docker.io/tractusx/ssi-credential-issuer-migrations"` | | | issuermigrations.image.tag | string | `""` | | | issuermigrations.imagePullPolicy | string | `"IfNotPresent"` | | -| issuermigrations.resources | object | `{"limits":{"cpu":"45m","memory":"105M"},"requests":{"cpu":"15m","memory":"105M"}}` | We recommend to review the default resource limits as this should a conscious choice. | +| issuermigrations.resources | object | `{"limits":{"cpu":"45m","memory":"200M"},"requests":{"cpu":"15m","memory":"200M"}}` | We recommend to review the default resource limits as this should a conscious choice. | | issuermigrations.seeding.testDataEnvironments | string | `""` | | | issuermigrations.seeding.testDataPaths | string | `"Seeder/Data"` | | | issuermigrations.logging.default | string | `"Information"` | | @@ -77,7 +80,7 @@ dependencies: | processesworker.image.name | string | `"docker.io/tractusx/ssi-credential-issuer-processes-worker"` | | | processesworker.image.tag | string | `""` | | | processesworker.imagePullPolicy | string | `"IfNotPresent"` | | -| processesworker.resources | object | `{"limits":{"cpu":"45m","memory":"105M"},"requests":{"cpu":"15m","memory":"105M"}}` | We recommend to review the default resource limits as this should a conscious choice. | +| processesworker.resources | object | `{"limits":{"cpu":"45m","memory":"200M"},"requests":{"cpu":"15m","memory":"200M"}}` | We recommend to review the default resource limits as this should a conscious choice. | | processesworker.logging.default | string | `"Information"` | | | processesworker.portal.scope | string | `"openid"` | | | processesworker.portal.grantType | string | `"client_credentials"` | | @@ -127,7 +130,6 @@ dependencies: | externalDatabase.database | string | `"issuer"` | Database name. | | externalDatabase.password | string | `""` | Password for the non-root username (default 'issuer'). Secret-key 'password'. | | externalDatabase.existingSecret | string | `"issuer-external-db"` | Secret containing the password non-root username, (default 'issuer'). | -| externalDatabase.existingSecretPasswordKey | string | `"password"` | Name of an existing secret key containing the database credentials. | | centralidp | object | `{"address":"https://centralidp.example.org","authRealm":"CX-Central","jwtBearerOptions":{"metadataPath":"/auth/realms/CX-Central/.well-known/openid-configuration","refreshInterval":"00:00:30","requireHttpsMetadata":"true","tokenValidationParameters":{"validAudience":"Cl24-CX-SSI-CredentialIssuer","validIssuerPath":"/auth/realms/CX-Central"}},"tokenPath":"/auth/realms/CX-Central/protocol/openid-connect/token","useAuthTrail":true}` | Provide details about centralidp (CX IAM) Keycloak instance. | | centralidp.address | string | `"https://centralidp.example.org"` | Provide centralidp base address (CX IAM), without trailing '/auth'. | | centralidp.useAuthTrail | bool | `true` | Flag if the api should be used with an leading /auth path | diff --git a/charts/ssi-credential-issuer/templates/cronjob-issuer-processes.yaml b/charts/ssi-credential-issuer/templates/cronjob-issuer-processes.yaml index a9b72ee0..46d92ca3 100644 --- a/charts/ssi-credential-issuer/templates/cronjob-issuer-processes.yaml +++ b/charts/ssi-credential-issuer/templates/cronjob-issuer-processes.yaml @@ -66,6 +66,8 @@ spec: - name: "CONNECTIONSTRINGS__ISSUERDB" value: "Server={{ .Values.externalDatabase.host }};Database={{ .Values.externalDatabase.database }};Port={{ .Values.externalDatabase.port }};User Id={{ .Values.externalDatabase.username }};Password=$(ISSUER_PASSWORD);Ssl Mode={{ .Values.dbConnection.sslMode }};" {{- end }} + - name: "PORTAL__CLIENTID" + value: "{{ .Values.issuer.portal.clientId }}" - name: "PORTAL__CLIENTSECRET" valueFrom: secretKeyRef: @@ -75,12 +77,33 @@ spec: value: "{{ .Values.processesworker.portal.grantType }}" - name: "PORTAL__TOKENADDRESS" value: "{{ .Values.centralidp.address }}{{ .Values.centralidp.tokenPath }}" + - name: "PORTAL__BASEADDRESS" + value: "{{ .Values.portalBackendAddress }}" - name: "PORTAL__PASSWORD" value: "empty" - name: "PORTAL__SCOPE" value: "{{ .Values.processesworker.portal.scope }}" - name: "PORTAL__USERNAME" value: "empty" + - name: "CALLBACK__CLIENTID" + value: "{{ .Values.issuer.portal.clientId }}" + - name: "CALLBACK__CLIENTSECRET" + valueFrom: + secretKeyRef: + name: "{{ template "issuer.secretName" . }}" + key: "portal-client-secret" + - name: "CALLBACK__GRANTTYPE" + value: "{{ .Values.processesworker.portal.grantType }}" + - name: "CALLBACK__TOKENADDRESS" + value: "{{ .Values.centralidp.address }}{{ .Values.centralidp.tokenPath }}" + - name: "CALLBACK__BASEADDRESS" + value: "{{ .Values.portalBackendAddress }}" + - name: "CALLBACK__PASSWORD" + value: "empty" + - name: "CALLBACK__SCOPE" + value: "{{ .Values.processesworker.portal.scope }}" + - name: "CALLBACK__USERNAME" + value: "empty" - name: "WALLET__BASEADDRESS" value: "{{ .Values.walletAddress }}" - name: "WALLET__CLIENTID" diff --git a/charts/ssi-credential-issuer/templates/deployment-issuer-service.yaml b/charts/ssi-credential-issuer/templates/deployment-issuer-service.yaml index 6409468f..2bb435ef 100644 --- a/charts/ssi-credential-issuer/templates/deployment-issuer-service.yaml +++ b/charts/ssi-credential-issuer/templates/deployment-issuer-service.yaml @@ -93,6 +93,8 @@ spec: value: "{{ .Values.issuer.logging.businessLogic }}" - name: "SWAGGERENABLED" value: "{{ .Values.issuer.swaggerEnabled }}" + - name: "PORTAL__CLIENTID" + value: "{{ .Values.issuer.portal.clientId }}" - name: "PORTAL__CLIENTSECRET" valueFrom: secretKeyRef: @@ -102,6 +104,8 @@ spec: value: "{{ .Values.issuer.portal.grantType }}" - name: "PORTAL__TOKENADDRESS" value: "{{ .Values.centralidp.address }}{{ .Values.centralidp.tokenPath }}" + - name: "PORTAL__BASEADDRESS" + value: "{{ .Values.portalBackendAddress }}" - name: "PORTAL__PASSWORD" value: "empty" - name: "PORTAL__SCOPE" diff --git a/charts/ssi-credential-issuer/values.yaml b/charts/ssi-credential-issuer/values.yaml index 3e84ee0a..80940f40 100644 --- a/charts/ssi-credential-issuer/values.yaml +++ b/charts/ssi-credential-issuer/values.yaml @@ -17,6 +17,11 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### +# -- Provide portal-backend base address. +portalBackendAddress: "https://portal-backend.example.org" +walletAddress: "https://wallet.example.org" +walletTokenAddress: "https://wallet.example.org/oauth/token" + issuer: image: name: "docker.io/tractusx/ssi-credential-issuer-service" @@ -52,9 +57,9 @@ issuer: # -- Client-secret for portal client-id. Secret-key 'portal-client-secret'. clientSecret: "" credential: - issuerDid: "" - issuerBpn: "" - statusListUrl: "" + issuerDid: "did:web:example" + issuerBpn: "BPNL00000001TEST" + statusListUrl: "https://example.org/statuslist" encryptionConfigIndex: 0 encryptionConfigs: index0: @@ -75,10 +80,10 @@ issuermigrations: resources: requests: cpu: 15m - memory: 105M + memory: 200M limits: cpu: 45m - memory: 105M + memory: 200M seeding: testDataEnvironments: "" testDataPaths: "Seeder/Data" @@ -97,10 +102,10 @@ processesworker: resources: requests: cpu: 15m - memory: 105M + memory: 200M limits: cpu: 45m - memory: 105M + memory: 200M logging: default: "Information" portal: diff --git a/consortia/argocd-app-templates/appsetup-int.yaml b/consortia/argocd-app-templates/appsetup-int.yaml index 45a42a45..f1695f2b 100644 --- a/consortia/argocd-app-templates/appsetup-int.yaml +++ b/consortia/argocd-app-templates/appsetup-int.yaml @@ -28,7 +28,7 @@ spec: source: path: charts/ssi-credential-issuer repoURL: 'https://github.com/eclipse-tractusx/ssi-credential-issuer.git' - targetRevision: ssi-credential-issuer-1.0.0-rc.1 + targetRevision: ssi-credential-issuer-1.0.0-rc.2 plugin: env: - name: AVP_SECRET diff --git a/consortia/argocd-app-templates/appsetup-pen.yaml b/consortia/argocd-app-templates/appsetup-pen.yaml index b869af9b..d8663ab7 100644 --- a/consortia/argocd-app-templates/appsetup-pen.yaml +++ b/consortia/argocd-app-templates/appsetup-pen.yaml @@ -28,7 +28,7 @@ spec: source: path: charts/ssi-credential-issuer repoURL: 'https://github.com/eclipse-tractusx/ssi-credential-issuer.git' - targetRevision: ssi-credential-issuer-1.0.0-rc.1 + targetRevision: ssi-credential-issuer-1.0.0-2 plugin: env: - name: AVP_SECRET diff --git a/consortia/argocd-app-templates/appsetup-stable.yaml b/consortia/argocd-app-templates/appsetup-stable.yaml index 6152c557..33e28fc4 100644 --- a/consortia/argocd-app-templates/appsetup-stable.yaml +++ b/consortia/argocd-app-templates/appsetup-stable.yaml @@ -29,7 +29,7 @@ spec: source: path: '' repoURL: 'https://eclipse-tractusx.github.io/charts/dev' - targetRevision: ssi-credential-issuer-1.0.0-rc.1 + targetRevision: ssi-credential-issuer-1.0.0-rc.2 plugin: env: - name: HELM_VALUES diff --git a/consortia/environments/values-beta.yaml b/consortia/environments/values-beta.yaml index 6a6527f2..435aae17 100644 --- a/consortia/environments/values-beta.yaml +++ b/consortia/environments/values-beta.yaml @@ -17,6 +17,10 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### +portalBackendAddress: "https://portal-backend.beta.demo.catena-x.net" +walletAddress: "https://dis-integration-service-prod.eu10.dim.cloud.sap" +walletTokenAddress: "https://bpnl00000003crhk-catena-x.authentication.eu10.hana.ondemand.com/oauth/token" + ingress: enabled: true className: "nginx" @@ -39,8 +43,10 @@ ingress: issuer: swaggerEnabled: true - credential: + credential: + issuerDid: "did:web:dim-static-prod.dis-cloud-prod.cfapps.eu10-004.hana.ondemand.com:dim-hosted:2f45795c-d6cc-4038-96c9-63cedc0cd266:holder-iatp" issuerBpn: "BPNL00000003CRHK" + statusListUrl: "https://dim-static-prod.dis-cloud-prod.cfapps.eu10-004.hana.ondemand.com/credentials/status/c5f1d9bb-42d5-42b7-a80a-ccbda6891df3/3e6f1f74-56e3-443a-a75e-320c301aca07" encryptionConfigs: index0: encryptionKey: "" diff --git a/consortia/environments/values-dev.yaml b/consortia/environments/values-dev.yaml index 28a7ad1d..a9cfa18c 100644 --- a/consortia/environments/values-dev.yaml +++ b/consortia/environments/values-dev.yaml @@ -17,6 +17,10 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### +portalBackendAddress: "https://portal-backend.dev.demo.catena-x.net" +walletAddress: "https://dis-integration-service-prod.eu10.dim.cloud.sap" +walletTokenAddress: "https://bpnl00000003crhk-catena-x.authentication.eu10.hana.ondemand.com/oauth/token" + ingress: enabled: true className: "nginx" @@ -43,6 +47,7 @@ issuer: imagePullPolicy: "Always" swaggerEnabled: true credential: + issuerDid: "did:web:dim-static-prod.dis-cloud-prod.cfapps.eu10-004.hana.ondemand.com:dim-hosted:2f45795c-d6cc-4038-96c9-63cedc0cd266:holder-iatp" issuerBpn: "BPNL00000003CRHK" statusListUrl: "https://dim-static-prod.dis-cloud-prod.cfapps.eu10-004.hana.ondemand.com/credentials/status/c5f1d9bb-42d5-42b7-a80a-ccbda6891df3/3e6f1f74-56e3-443a-a75e-320c301aca07" encryptionConfigs: diff --git a/consortia/environments/values-int.yaml b/consortia/environments/values-int.yaml index e956121f..81c0a05b 100644 --- a/consortia/environments/values-int.yaml +++ b/consortia/environments/values-int.yaml @@ -17,6 +17,10 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### +portalBackendAddress: "https://portal-backend.int.demo.catena-x.net" +walletAddress: "https://dis-integration-service-prod.eu10.dim.cloud.sap" +walletTokenAddress: "https://bpnl00000003crhk-catena-x.authentication.eu10.hana.ondemand.com/oauth/token" + ingress: enabled: true className: "nginx" @@ -40,7 +44,9 @@ ingress: issuer: swaggerEnabled: true credential: + issuerDid: "did:web:dim-static-prod.dis-cloud-prod.cfapps.eu10-004.hana.ondemand.com:dim-hosted:2f45795c-d6cc-4038-96c9-63cedc0cd266:holder-iatp" issuerBpn: "BPNL00000003CRHK" + statusListUrl: "https://dim-static-prod.dis-cloud-prod.cfapps.eu10-004.hana.ondemand.com/credentials/status/c5f1d9bb-42d5-42b7-a80a-ccbda6891df3/3e6f1f74-56e3-443a-a75e-320c301aca07" encryptionConfigs: index0: encryptionKey: "" diff --git a/consortia/environments/values-pen.yaml b/consortia/environments/values-pen.yaml index 3460e8d4..1b747209 100644 --- a/consortia/environments/values-pen.yaml +++ b/consortia/environments/values-pen.yaml @@ -17,6 +17,10 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### +portalBackendAddress: "https://portal-backend-pen.dev.demo.catena-x.net" +walletAddress: "https://dis-integration-service-prod.eu10.dim.cloud.sap" +walletTokenAddress: "https://bpnl00000003crhk-catena-x.authentication.eu10.hana.ondemand.com/oauth/token" + ingress: enabled: true className: "nginx" @@ -28,9 +32,9 @@ ingress: tls: - secretName: "tls-secret" hosts: - - "ssi-credential-issuer-backend-pen.dev.demo.catena-x.net" + - "ssi-credential-issuer-pen.dev.demo.catena-x.net" hosts: - - host: "ssi-credential-issuer-backend-pen.dev.demo.catena-x.net" + - host: "ssi-credential-issuer-pen.dev.demo.catena-x.net" paths: - path: "/api/issuer" pathType: "Prefix" @@ -40,7 +44,9 @@ ingress: issuer: swaggerEnabled: true credential: + issuerDid: "did:web:dim-static-prod.dis-cloud-prod.cfapps.eu10-004.hana.ondemand.com:dim-hosted:2f45795c-d6cc-4038-96c9-63cedc0cd266:holder-iatp" issuerBpn: "BPNL00000003CRHK" + statusListUrl: "https://dim-static-prod.dis-cloud-prod.cfapps.eu10-004.hana.ondemand.com/credentials/status/c5f1d9bb-42d5-42b7-a80a-ccbda6891df3/3e6f1f74-56e3-443a-a75e-320c301aca07" encryptionConfigs: index0: encryptionKey: "" diff --git a/consortia/environments/values-rc.yaml b/consortia/environments/values-rc.yaml index 7753b4dd..27176150 100644 --- a/consortia/environments/values-rc.yaml +++ b/consortia/environments/values-rc.yaml @@ -17,6 +17,10 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### +portalBackendAddress: "https://portal-backend-rc.dev.demo.catena-x.net" +walletAddress: "https://dis-integration-service-prod.eu10.dim.cloud.sap" +walletTokenAddress: "https://bpnl00000003crhk-catena-x.authentication.eu10.hana.ondemand.com/oauth/token" + ingress: enabled: true className: "nginx" @@ -28,9 +32,9 @@ ingress: tls: - secretName: "tls-secret" hosts: - - "ssi-credential-issuer-backend-rc.dev.demo.catena-x.net" + - "ssi-credential-issuer-rc.dev.demo.catena-x.net" hosts: - - host: "ssi-credential-issuer-backend-rc.dev.demo.catena-x.net" + - host: "ssi-credential-issuer-rc.dev.demo.catena-x.net" paths: - path: "/api/issuer" pathType: "Prefix" @@ -43,7 +47,9 @@ issuer: imagePullPolicy: "Always" swaggerEnabled: true credential: + issuerDid: "did:web:dim-static-prod.dis-cloud-prod.cfapps.eu10-004.hana.ondemand.com:dim-hosted:2f45795c-d6cc-4038-96c9-63cedc0cd266:holder-iatp" issuerBpn: "BPNL00000003CRHK" + statusListUrl: "https://dim-static-prod.dis-cloud-prod.cfapps.eu10-004.hana.ondemand.com/credentials/status/c5f1d9bb-42d5-42b7-a80a-ccbda6891df3/3e6f1f74-56e3-443a-a75e-320c301aca07" encryptionConfigs: index0: encryptionKey: "" diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ae93adb6..ff5d3169 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -20,6 +20,6 @@ 1.0.0 - rc.1 + rc.2 diff --git a/src/credentials/SsiCredentialIssuer.Expiry.App/ExpiryCheckService.cs b/src/credentials/SsiCredentialIssuer.Expiry.App/ExpiryCheckService.cs index 729d7e4a..49649986 100644 --- a/src/credentials/SsiCredentialIssuer.Expiry.App/ExpiryCheckService.cs +++ b/src/credentials/SsiCredentialIssuer.Expiry.App/ExpiryCheckService.cs @@ -88,7 +88,7 @@ public async Task ExecuteAsync(CancellationToken stoppingToken) await foreach (var credential in credentials.WithCancellation(stoppingToken).ConfigureAwait(false)) { await ProcessCredentials(credential, companySsiDetailsRepository, repositories, portalService, - stoppingToken); + stoppingToken).ConfigureAwait(false); } } catch (Exception ex) @@ -129,8 +129,6 @@ private static async ValueTask HandleDecline( IPortalService portalService, CancellationToken cancellationToken) { - var content = JsonSerializer.Serialize(new { Type = data.VerifiedCredentialTypeId, CredentialId = data.Id }, Options); - await portalService.AddNotification(content, data.RequesterId, NotificationTypeId.CREDENTIAL_REJECTED, cancellationToken); companySsiDetailsRepository.AttachAndModifyCompanySsiDetails(data.Id, c => { c.CompanySsiDetailStatusId = data.CompanySsiDetailStatusId; @@ -140,13 +138,19 @@ private static async ValueTask HandleDecline( c.CompanySsiDetailStatusId = CompanySsiDetailStatusId.INACTIVE; }); - var typeValue = data.VerifiedCredentialTypeId.GetEnumValue() ?? throw new UnexpectedConditionException($"VerifiedCredentialType {data.VerifiedCredentialTypeId} does not exists"); - var mailParameters = new Dictionary + if (Guid.TryParse(data.RequesterId, out var requesterId)) { - { "requestName", typeValue }, - { "reason", "The credential is already expired" } - }; - await portalService.TriggerMail("CredentialRejected", data.RequesterId, mailParameters, cancellationToken); + var content = JsonSerializer.Serialize(new { Type = data.VerifiedCredentialTypeId, CredentialId = data.Id }, Options); + await portalService.AddNotification(content, requesterId, NotificationTypeId.CREDENTIAL_REJECTED, cancellationToken).ConfigureAwait(false); + + 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", requesterId, mailParameters, cancellationToken).ConfigureAwait(false); + } } private static async ValueTask HandleNotification( @@ -182,15 +186,19 @@ private static async ValueTask HandleNotification( CredentialId = data.Id, ExpiryCheckTypeId = newExpiryCheckTypeId }, Options); - await portalService.AddNotification(content, data.RequesterId, NotificationTypeId.CREDENTIAL_EXPIRY, cancellationToken); - var typeValue = data.VerifiedCredentialTypeId.GetEnumValue() ?? throw new UnexpectedConditionException($"VerifiedCredentialType {data.VerifiedCredentialTypeId} does not exists"); - var mailParameters = new Dictionary + + if (Guid.TryParse(data.RequesterId, out var requesterId)) { - { "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.AddNotification(content, requesterId, NotificationTypeId.CREDENTIAL_EXPIRY, cancellationToken).ConfigureAwait(false); + 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.RequesterId, mailParameters, cancellationToken); + await portalService.TriggerMail("CredentialExpiry", requesterId, mailParameters, cancellationToken).ConfigureAwait(false); + } } } diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialExpiryData.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialExpiryData.cs index c541da4e..b04940e3 100644 --- a/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialExpiryData.cs +++ b/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialExpiryData.cs @@ -23,7 +23,7 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models; public record CredentialExpiryData( Guid Id, - Guid RequesterId, + string RequesterId, DateTimeOffset? ExpiryDate, ExpiryCheckTypeId? ExpiryCheckTypeId, string? DetailVersion, diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/CompanySsiDetailsRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/CompanySsiDetailsRepository.cs index 0f230919..baf127a3 100644 --- a/src/database/SsiCredentialIssuer.DbAccess/Repositories/CompanySsiDetailsRepository.cs +++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/CompanySsiDetailsRepository.cs @@ -126,7 +126,7 @@ public IAsyncEnumerable GetSsiCertificates(string bp .ToAsyncEnumerable(); /// - public CompanySsiDetail CreateSsiDetails(string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, CompanySsiDetailStatusId companySsiDetailStatusId, string issuerBpn, Guid userId, Action? setOptionalFields) + public CompanySsiDetail CreateSsiDetails(string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, CompanySsiDetailStatusId companySsiDetailStatusId, string issuerBpn, string userId, Action? setOptionalFields) { var detail = new CompanySsiDetail(Guid.NewGuid(), bpnl, verifiedCredentialTypeId, companySsiDetailStatusId, issuerBpn, userId, DateTimeOffset.UtcNow); setOptionalFields?.Invoke(detail); @@ -216,7 +216,7 @@ public IQueryable GetAllCredentialDetails(CompanySsiDetailStat /// public void AttachAndModifyCompanySsiDetails(Guid id, Action? initialize, Action updateFields) { - var entity = new CompanySsiDetail(id, null!, default, default, null!, Guid.Empty, DateTimeOffset.MinValue); + var entity = new CompanySsiDetail(id, null!, default, default, null!, null!, DateTimeOffset.MinValue); initialize?.Invoke(entity); _context.Attach(entity); updateFields.Invoke(entity); @@ -270,7 +270,7 @@ public IAsyncEnumerable GetExpiryData(DateTimeOffset now, } public void RemoveSsiDetail(Guid companySsiDetailId) => - _context.CompanySsiDetails.Remove(new CompanySsiDetail(companySsiDetailId, null!, default, default, null!, Guid.Empty, DateTimeOffset.MinValue)); + _context.CompanySsiDetails.Remove(new CompanySsiDetail(companySsiDetailId, null!, default, default, null!, null!, DateTimeOffset.MinValue)); public void CreateProcessData(Guid companySsiDetailId, JsonDocument schema, VerifiedCredentialTypeKindId credentialTypeKindId, Action? setOptionalFields) { diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICompanySsiDetailsRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICompanySsiDetailsRepository.cs index 225a51e0..38135954 100644 --- a/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICompanySsiDetailsRepository.cs +++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICompanySsiDetailsRepository.cs @@ -52,7 +52,7 @@ public interface ICompanySsiDetailsRepository /// Id of the creator /// sets the optional fields /// The created entity - CompanySsiDetail CreateSsiDetails(string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, CompanySsiDetailStatusId companySsiDetailStatusId, string issuerBpn, Guid userId, Action? setOptionalFields); + CompanySsiDetail CreateSsiDetails(string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, CompanySsiDetailStatusId companySsiDetailStatusId, string issuerBpn, string userId, Action? setOptionalFields); /// /// Checks whether the credential details are already exists for the company and the given version diff --git a/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditCompanySsiDetail20240419.cs b/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditCompanySsiDetail20240419.cs new file mode 100644 index 00000000..c18b24c7 --- /dev/null +++ b/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditCompanySsiDetail20240419.cs @@ -0,0 +1,58 @@ +/******************************************************************************** + * 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; + +namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities; + +public class AuditCompanySsiDetail20240419 : IAuditEntityV2 +{ + /// + [Key] + public Guid AuditV2Id { get; set; } + + public Guid Id { get; set; } + public string Bpnl { get; set; } = null!; + public string IssuerBpn { get; set; } = null!; + public VerifiedCredentialTypeId VerifiedCredentialTypeId { get; set; } + public CompanySsiDetailStatusId CompanySsiDetailStatusId { get; set; } + public DateTimeOffset DateCreated { get; private set; } + public string CreatorUserId { get; set; } = null!; + 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 string? LastEditorId { get; set; } + + /// + public string? AuditV2LastEditorId { get; set; } + + /// + public AuditOperationId AuditV2OperationId { get; set; } + + /// + public DateTimeOffset AuditV2DateLastChanged { get; set; } +} diff --git a/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditDocument20240419.cs b/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditDocument20240419.cs new file mode 100644 index 00000000..afe2b53e --- /dev/null +++ b/src/database/SsiCredentialIssuer.Entities/AuditEntities/AuditDocument20240419.cs @@ -0,0 +1,61 @@ +/******************************************************************************** + * 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; + +namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities; + +public class AuditDocument20240419 : IAuditEntityV2 +{ + /// + [Key] + public Guid AuditV2Id { 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 string? IdentityId { get; set; } + public DateTimeOffset? DateLastChanged { get; set; } + public string? LastEditorId { get; private set; } + + /// + public DateTimeOffset AuditV2DateLastChanged { get; set; } + + /// + public string? AuditV2LastEditorId { get; set; } + + /// + public AuditOperationId AuditV2OperationId { get; set; } +} diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditEntityV1Attribute.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditEntityV2Attribute.cs similarity index 81% rename from src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditEntityV1Attribute.cs rename to src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditEntityV2Attribute.cs index b9d84ea4..6cfd3a94 100644 --- a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditEntityV1Attribute.cs +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditEntityV2Attribute.cs @@ -24,20 +24,20 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes; /// /// /// The implementation of this Attribute must not be changed. -/// When changes are needed create a V2 of it. +/// When changes are needed create a V3 of it. /// [AttributeUsage(AttributeTargets.Class)] -public class AuditEntityV1Attribute : Attribute +public class AuditEntityV2Attribute : Attribute { - public AuditEntityV1Attribute(Type auditEntityType) + public AuditEntityV2Attribute(Type auditEntityType) { - if (!typeof(IAuditEntityV1).IsAssignableFrom(auditEntityType)) + if (!typeof(IAuditEntityV2).IsAssignableFrom(auditEntityType)) { - throw new ArgumentException($"Entity must derive from {nameof(IAuditEntityV1)}", nameof(auditEntityType)); + throw new ArgumentException($"Entity must derive from {nameof(IAuditEntityV2)}", nameof(auditEntityType)); } AuditEntityType = auditEntityType; } - public virtual Type AuditEntityType { get; } + public Type AuditEntityType { get; } } diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditInsertEditorV1Attribute.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditInsertEditorV2Attribute.cs similarity index 88% rename from src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditInsertEditorV1Attribute.cs rename to src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditInsertEditorV2Attribute.cs index 4ccebc8b..8dc8d82c 100644 --- a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditInsertEditorV1Attribute.cs +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/AuditInsertEditorV2Attribute.cs @@ -21,14 +21,14 @@ 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 +/// 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. +/// When changes are needed create a V3 of it. /// [AttributeUsage(AttributeTargets.Property)] -public class AuditInsertEditorV1Attribute : Attribute +public class AuditInsertEditorV2Attribute : Attribute { } diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastChangedV1Attribute.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastChangedV2Attribute.cs similarity index 92% rename from src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastChangedV1Attribute.cs rename to src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastChangedV2Attribute.cs index 8028d45e..150fe264 100644 --- a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastChangedV1Attribute.cs +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastChangedV2Attribute.cs @@ -24,9 +24,9 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes; /// /// /// The implementation of this Attribute must not be changed. -/// When changes are needed create a V2 of it. +/// When changes are needed create a V3 of it. /// [AttributeUsage(AttributeTargets.Property)] -public class LastChangedV1Attribute : Attribute +public class LastChangedV2Attribute : Attribute { } diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastEditorV1Attribute.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastEditorV2Attribute.cs similarity index 92% rename from src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastEditorV1Attribute.cs rename to src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastEditorV2Attribute.cs index 6af18970..f870b4e8 100644 --- a/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastEditorV1Attribute.cs +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Attributes/LastEditorV2Attribute.cs @@ -24,9 +24,9 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Attributes; /// /// /// The implementation of this Attribute must not be changed. -/// When changes are needed create a V2 of it. +/// When changes are needed create a V3 of it. /// [AttributeUsage(AttributeTargets.Property)] -public class LastEditorV1Attribute : Attribute +public class LastEditorV2Attribute : Attribute { } diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/DependencyInjection/AuditingDependencyInjection.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/DependencyInjection/AuditingDependencyInjection.cs index bd641eba..2f5b16ba 100644 --- a/src/database/SsiCredentialIssuer.Entities/Auditing/DependencyInjection/AuditingDependencyInjection.cs +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/DependencyInjection/AuditingDependencyInjection.cs @@ -28,7 +28,7 @@ public static class AuditingDependencyInjection public static IServiceCollection AddDbAuditing(this IServiceCollection services) { return services - .AddTransient() + .AddTransient() .AddTransient(); } } diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditPropertyV1Names.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditPropertyV2Names.cs similarity index 88% rename from src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditPropertyV1Names.cs rename to src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditPropertyV2Names.cs index ea04951b..a0e697ff 100644 --- a/src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditPropertyV1Names.cs +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Enums/AuditPropertyV2Names.cs @@ -19,10 +19,10 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Enums; -public enum AuditPropertyV1Names +public enum AuditPropertyV2Names { - AuditV1Id, - AuditV1OperationId, - AuditV1DateLastChanged, - AuditV1LastEditorId + AuditV2Id, + AuditV2OperationId, + AuditV2DateLastChanged, + AuditV2LastEditorId } diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/AuditExtensions.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/AuditExtensions.cs index e881df0c..ed1fe785 100644 --- a/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/AuditExtensions.cs +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/AuditExtensions.cs @@ -46,29 +46,29 @@ public static AuditOperationId ToAuditOperation(this EntityState state) => _ => throw new ConflictException($"Entries with state {state} should not be audited") }; - public static AuditPropertyInformation? GetAuditPropertyInformation(this Type auditableEntityType) + public static AuditPropertyInformation? GetAuditV2PropertyInformation(this Type auditableEntityType) { var auditEntityAttribute = - (AuditEntityV1Attribute?)Attribute.GetCustomAttribute(auditableEntityType, typeof(AuditEntityV1Attribute)); + (AuditEntityV2Attribute?)Attribute.GetCustomAttribute(auditableEntityType, typeof(AuditEntityV2Attribute)); if (auditEntityAttribute == null) { return null; } var auditEntityType = auditEntityAttribute.AuditEntityType; - if (!typeof(IAuditEntityV1).IsAssignableFrom(auditEntityType)) + if (!typeof(IAuditEntityV2).IsAssignableFrom(auditEntityType)) { - throw new ConflictException($"{auditEntityType} must inherit from {nameof(IAuditEntityV1)}"); + throw new ConflictException($"{auditEntityType} must inherit from {nameof(IAuditEntityV2)}"); } 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))) + ? 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 auditProperties = typeof(IAuditEntityV2).GetProperties(); var targetProperties = auditEntityType.GetProperties().ExceptBy(auditProperties.Select(x => x.Name), p => p.Name).ToImmutableList(); targetProperties diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/EntityTypeBuilderV1Extension.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/EntityTypeBuilderV2Extension.cs similarity index 87% rename from src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/EntityTypeBuilderV1Extension.cs rename to src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/EntityTypeBuilderV2Extension.cs index 8d3270b8..cc959e96 100644 --- a/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/EntityTypeBuilderV1Extension.cs +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Extensions/EntityTypeBuilderV2Extension.cs @@ -30,14 +30,14 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Extensions; -public static class EntityTypeBuilderV1Extension +public static class EntityTypeBuilderV2Extension { - public static EntityTypeBuilder HasAuditV1Triggers(this EntityTypeBuilder builder) where TEntity : class, IAuditableV1 where TAuditEntity : class, IAuditEntityV1 + public static EntityTypeBuilder HasAuditV2Triggers(this EntityTypeBuilder builder) where TEntity : class, IAuditableV2 where TAuditEntity : class, IAuditEntityV2 { - var (auditEntityType, sourceProperties, auditProperties, targetProperties) = typeof(TEntity).GetAuditPropertyInformation() ?? throw new ConfigurationException($"{typeof(TEntity)} must be annotated with {nameof(AuditEntityV1Attribute)}"); + var (auditEntityType, sourceProperties, auditProperties, targetProperties) = typeof(TEntity).GetAuditV2PropertyInformation() ?? throw new ConfigurationException($"{typeof(TEntity)} must be annotated with {nameof(AuditEntityV2Attribute)}"); 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}"); + throw new ConfigurationException($"{typeof(TEntity).Name} is annotated with {nameof(AuditEntityV2Attribute)} referring to a different audit entity type {auditEntityType.Name} then {typeof(TAuditEntity).Name}"); } sourceProperties.IntersectBy(auditProperties.Select(x => x.Name), p => p.Name).IfAny( @@ -48,13 +48,13 @@ public static EntityTypeBuilder HasAuditV1Triggers p.Name == AuditPropertyV1Names.AuditV1Id.ToString() && p.CustomAttributes.Any(a => a.AttributeType == typeof(KeyAttribute)))) + p => p.Name == AuditPropertyV2Names.AuditV2Id.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}"); + throw new ConfigurationException($"{typeof(TAuditEntity).Name}.{AuditPropertyV2Names.AuditV2Id} 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))); + var insertEditorProperty = sourceProperties.SingleOrDefault(p => p.CustomAttributes.Any(a => a.AttributeType == typeof(AuditInsertEditorV2Attribute))); + var lastEditorProperty = sourceProperties.SingleOrDefault(p => p.CustomAttributes.Any(a => a.AttributeType == typeof(LastEditorV2Attribute))); return builder .AfterInsert(trigger => @@ -101,13 +101,13 @@ private static MemberInitExpression CreateAuditEntityExpression(IE { 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)))); + .Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV2Names.AuditV2Id.ToString())[0], Expression.New(typeof(Guid)))) + .Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV2Names.AuditV2OperationId.ToString())[0], Expression.Constant(auditOperationId))) + .Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV2Names.AuditV2DateLastChanged.ToString())[0], Expression.New(typeof(DateTimeOffset)))); if (lastEditorProperty != null) { - memberBindings = memberBindings.Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV1Names.AuditV1LastEditorId.ToString())[0], Expression.Property(entity, lastEditorProperty))); + memberBindings = memberBindings.Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV2Names.AuditV2LastEditorId.ToString())[0], Expression.Property(entity, lastEditorProperty))); } return Expression.MemberInit( diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Handler/AuditHandlerV1.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Handler/AuditHandlerV2.cs similarity index 91% rename from src/database/SsiCredentialIssuer.Entities/Auditing/Handler/AuditHandlerV1.cs rename to src/database/SsiCredentialIssuer.Entities/Auditing/Handler/AuditHandlerV2.cs index ce651a6e..bea4bf26 100644 --- a/src/database/SsiCredentialIssuer.Entities/Auditing/Handler/AuditHandlerV1.cs +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Handler/AuditHandlerV2.cs @@ -29,12 +29,12 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Handler; -public class AuditHandlerV1 : IAuditHandler +public class AuditHandlerV2 : IAuditHandler { private readonly IIdentityIdService _identityService; private readonly IDateTimeProvider _dateTimeProvider; - public AuditHandlerV1(IIdentityIdService identityService, IDateTimeProvider dateTimeProvider) + public AuditHandlerV2(IIdentityIdService identityService, IDateTimeProvider dateTimeProvider) { _identityService = identityService; _dateTimeProvider = dateTimeProvider; @@ -47,11 +47,11 @@ public void HandleAuditForChangedEntries(IEnumerable changedEntries .GroupBy(entry => entry.Metadata.ClrType)) { var lastEditorNames = groupedEntries.Key.GetProperties() - .Where(x => Attribute.IsDefined(x, typeof(LastEditorV1Attribute))) + .Where(x => Attribute.IsDefined(x, typeof(LastEditorV2Attribute))) .Select(x => x.Name) .ToImmutableHashSet(); var lastChangedNames = groupedEntries.Key.GetProperties() - .Where(x => Attribute.IsDefined(x, typeof(LastChangedV1Attribute))) + .Where(x => Attribute.IsDefined(x, typeof(LastChangedV2Attribute))) .Select(x => x.Name) .ToImmutableHashSet(); @@ -72,7 +72,7 @@ public void HandleAuditForChangedEntries(IEnumerable changedEntries } } - var auditPropertyInformation = groupedEntries.Key.GetAuditPropertyInformation(); + var auditPropertyInformation = groupedEntries.Key.GetAuditV2PropertyInformation(); if (auditPropertyInformation == null) continue; var (auditEntityType, sourceProperties, _, targetProperties) = auditPropertyInformation; @@ -86,7 +86,7 @@ public void HandleAuditForChangedEntries(IEnumerable changedEntries private void AddAuditEntry(EntityEntry entityEntry, Type entityType, DbContext context, Type auditEntityType, IEnumerable sourceProperties, IEnumerable targetProperties) { - if (Activator.CreateInstance(auditEntityType) is not IAuditEntityV1 newAuditEntity) + if (Activator.CreateInstance(auditEntityType) is not IAuditEntityV2 newAuditEntity) throw new UnexpectedConditionException($"AuditEntityV1Attribute can only be used on types implementing IAuditEntityV1 but Type {entityType} isn't"); var propertyValues = entityEntry.CurrentValues; @@ -99,10 +99,10 @@ private void AddAuditEntry(EntityEntry entityEntry, Type entityType, DbContext c joined.Target.SetValue(newAuditEntity, joined.Value); } - newAuditEntity.AuditV1Id = Guid.NewGuid(); - newAuditEntity.AuditV1OperationId = entityEntry.State.ToAuditOperation(); - newAuditEntity.AuditV1DateLastChanged = _dateTimeProvider.OffsetNow; - newAuditEntity.AuditV1LastEditorId = _identityService.IdentityId; + newAuditEntity.AuditV2Id = Guid.NewGuid(); + newAuditEntity.AuditV2OperationId = entityEntry.State.ToAuditOperation(); + newAuditEntity.AuditV2DateLastChanged = _dateTimeProvider.OffsetNow; + newAuditEntity.AuditV2LastEditorId = _identityService.IdentityId; context.Add(newAuditEntity); } diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditEntityV2.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditEntityV2.cs new file mode 100644 index 00000000..509292f8 --- /dev/null +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditEntityV2.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 V3 of it. +/// +public interface IAuditEntityV2 +{ + /// + /// Id of the audited entity + /// + Guid AuditV2Id { get; set; } + + /// + /// Date Time of the last change of the entity + /// + DateTimeOffset AuditV2DateLastChanged { get; set; } + + /// + /// Reference to the that changed the entity + /// + string? AuditV2LastEditorId { get; set; } + + /// + /// Id of the audit operation + /// + AuditOperationId AuditV2OperationId { get; set; } +} diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditableV1.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditableV2.cs similarity index 93% rename from src/database/SsiCredentialIssuer.Entities/Auditing/IAuditableV1.cs rename to src/database/SsiCredentialIssuer.Entities/Auditing/IAuditableV2.cs index 99f65976..fca8a5f6 100644 --- a/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditableV1.cs +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/IAuditableV2.cs @@ -24,8 +24,8 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing; /// /// /// The implementation of this Attribute must not be changed. -/// When changes are needed create a V2 of it. +/// When changes are needed create a V3 of it. /// -public interface IAuditableV1 +public interface IAuditableV2 { } diff --git a/src/database/SsiCredentialIssuer.Entities/Auditing/Identity/IIdentityIdService.cs b/src/database/SsiCredentialIssuer.Entities/Auditing/Identity/IIdentityIdService.cs index 26544541..af5e8569 100644 --- a/src/database/SsiCredentialIssuer.Entities/Auditing/Identity/IIdentityIdService.cs +++ b/src/database/SsiCredentialIssuer.Entities/Auditing/Identity/IIdentityIdService.cs @@ -21,5 +21,5 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Identity; public interface IIdentityIdService { - Guid IdentityId { get; } + string IdentityId { get; } } diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetail.cs b/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetail.cs index 102e6776..343018d6 100644 --- a/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetail.cs +++ b/src/database/SsiCredentialIssuer.Entities/Entities/CompanySsiDetail.cs @@ -24,17 +24,18 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities; -[AuditEntityV1(typeof(AuditCompanySsiDetail20240228))] -public class CompanySsiDetail : IAuditableV1, IBaseEntity +[AuditEntityV2(typeof(AuditCompanySsiDetail20240419))] +public class CompanySsiDetail : IAuditableV2, IBaseEntity { private CompanySsiDetail() { Bpnl = null!; IssuerBpn = null!; + CreatorUserId = null!; Documents = new HashSet(); } - public CompanySsiDetail(Guid id, string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, CompanySsiDetailStatusId companySsiDetailStatusId, string issuerBpn, Guid creatorUserId, DateTimeOffset dateCreated) + public CompanySsiDetail(Guid id, string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, CompanySsiDetailStatusId companySsiDetailStatusId, string issuerBpn, string creatorUserId, DateTimeOffset dateCreated) : this() { Id = id; @@ -52,7 +53,7 @@ public CompanySsiDetail(Guid id, string bpnl, VerifiedCredentialTypeId verifiedC public VerifiedCredentialTypeId VerifiedCredentialTypeId { get; set; } public CompanySsiDetailStatusId CompanySsiDetailStatusId { get; set; } public DateTimeOffset DateCreated { get; set; } - public Guid CreatorUserId { get; set; } + public string CreatorUserId { get; set; } public DateTimeOffset? ExpiryDate { get; set; } public Guid? VerifiedCredentialExternalTypeDetailVersionId { get; set; } @@ -61,11 +62,11 @@ public CompanySsiDetail(Guid id, string bpnl, VerifiedCredentialTypeId verifiedC public Guid? ExternalCredentialId { get; set; } public string? Credential { get; set; } - [LastChangedV1] + [LastChangedV2] public DateTimeOffset? DateLastChanged { get; set; } - [LastEditorV1] - public Guid? LastEditorId { get; private set; } + [LastEditorV2] + public string? LastEditorId { get; private set; } // Navigation Properties public virtual VerifiedCredentialType? VerifiedCredentialType { get; set; } diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/Document.cs b/src/database/SsiCredentialIssuer.Entities/Entities/Document.cs index ac70ee87..e10e474c 100644 --- a/src/database/SsiCredentialIssuer.Entities/Entities/Document.cs +++ b/src/database/SsiCredentialIssuer.Entities/Entities/Document.cs @@ -25,8 +25,8 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities; -[AuditEntityV1(typeof(AuditDocument20240305))] -public class Document : IAuditableV1, IBaseEntity +[AuditEntityV2(typeof(AuditDocument20240419))] +public class Document : IAuditableV2, IBaseEntity { private Document() { @@ -66,13 +66,13 @@ public Document(Guid id, byte[] documentContent, byte[] documentHash, string doc public DocumentStatusId DocumentStatusId { get; set; } - public Guid? CompanyUserId { get; set; } + public string? IdentityId { get; set; } - [LastChangedV1] + [LastChangedV2] public DateTimeOffset? DateLastChanged { get; set; } - [LastEditorV1] - public Guid? LastEditorId { get; private set; } + [LastEditorV2] + public string? LastEditorId { get; private set; } // Navigation properties public virtual DocumentType? DocumentType { get; set; } diff --git a/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStep.cs b/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStep.cs index 13da78d4..29f06801 100644 --- a/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStep.cs +++ b/src/database/SsiCredentialIssuer.Entities/Entities/ProcessStep.cs @@ -44,7 +44,7 @@ public ProcessStep(Guid id, ProcessStepTypeId processStepTypeId, ProcessStepStat public DateTimeOffset DateCreated { get; private set; } - [LastChangedV1] + [LastChangedV2] public DateTimeOffset? DateLastChanged { get; set; } public string? Message { get; set; } diff --git a/src/database/SsiCredentialIssuer.Entities/IssuerDbContext.cs b/src/database/SsiCredentialIssuer.Entities/IssuerDbContext.cs index 65274bdc..529a769d 100644 --- a/src/database/SsiCredentialIssuer.Entities/IssuerDbContext.cs +++ b/src/database/SsiCredentialIssuer.Entities/IssuerDbContext.cs @@ -45,6 +45,8 @@ public IssuerDbContext(DbContextOptions options, IAuditHandler public virtual DbSet AuditCompanySsiDetail20240228 { get; set; } = default!; public virtual DbSet AuditDocument20240305 { get; set; } = default!; + public virtual DbSet AuditCompanySsiDetail20240419 { get; set; } = default!; + public virtual DbSet AuditDocument20240419 { get; set; } = default!; public virtual DbSet CompanySsiDetails { get; set; } = default!; public virtual DbSet CompanySsiDetailAssignedDocuments { get; set; } = default!; public virtual DbSet CompanySsiDetailStatuses { get; set; } = default!; @@ -118,7 +120,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) j.HasKey(e => new { e.DocumentId, e.CompanySsiDetailId }); }); - entity.HasAuditV1Triggers(); + entity.HasAuditV2Triggers(); }); modelBuilder.Entity() @@ -143,7 +145,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - entity.HasAuditV1Triggers(); + entity.HasAuditV2Triggers(); }); modelBuilder.Entity() @@ -312,7 +314,7 @@ private void EnhanceChangedEntries() _auditHandler.HandleAuditForChangedEntries( ChangeTracker.Entries().Where(entry => entry.State != EntityState.Unchanged && entry.State != EntityState.Detached && - entry.Entity is IAuditableV1).ToImmutableList(), + entry.Entity is IAuditableV2).ToImmutableList(), ChangeTracker.Context); } } diff --git a/src/database/SsiCredentialIssuer.Migrations/Migrations/20240321135530_1.0.0-rc.1.Designer.cs b/src/database/SsiCredentialIssuer.Migrations/Migrations/20240321135530_1.0.0-rc.1.Designer.cs index 2b3c68d7..7880f348 100644 --- a/src/database/SsiCredentialIssuer.Migrations/Migrations/20240321135530_1.0.0-rc.1.Designer.cs +++ b/src/database/SsiCredentialIssuer.Migrations/Migrations/20240321135530_1.0.0-rc.1.Designer.cs @@ -18,14 +18,11 @@ // ********************************************************************************/ // -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; +using System.Text.Json; #nullable disable diff --git a/src/database/SsiCredentialIssuer.Migrations/Migrations/20240321135530_1.0.0-rc.1.cs b/src/database/SsiCredentialIssuer.Migrations/Migrations/20240321135530_1.0.0-rc.1.cs index 2a110962..21f1eaf4 100644 --- a/src/database/SsiCredentialIssuer.Migrations/Migrations/20240321135530_1.0.0-rc.1.cs +++ b/src/database/SsiCredentialIssuer.Migrations/Migrations/20240321135530_1.0.0-rc.1.cs @@ -18,7 +18,6 @@ ********************************************************************************/ using Microsoft.EntityFrameworkCore.Migrations; -using System; using System.Text.Json; #nullable disable diff --git a/src/database/SsiCredentialIssuer.Migrations/Migrations/20240422084019_1.0.0-rc.2.Designer.cs b/src/database/SsiCredentialIssuer.Migrations/Migrations/20240422084019_1.0.0-rc.2.Designer.cs new file mode 100644 index 00000000..ea391e1a --- /dev/null +++ b/src/database/SsiCredentialIssuer.Migrations/Migrations/20240422084019_1.0.0-rc.2.Designer.cs @@ -0,0 +1,1587 @@ +/******************************************************************************** + * 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.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities; +using System.Text.Json; + +#nullable disable + +namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Migrations.Migrations +{ + [DbContext(typeof(IssuerDbContext))] + [Migration("20240422084019_1.0.0-rc.2")] + partial class _100rc2 + { + /// + 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("IssuerBpn") + .IsRequired() + .HasColumnType("text") + .HasColumnName("issuer_bpn"); + + 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.AuditCompanySsiDetail20240419", b => + { + b.Property("AuditV2Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v2id"); + + b.Property("AuditV2DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v2date_last_changed"); + + b.Property("AuditV2LastEditorId") + .HasColumnType("text") + .HasColumnName("audit_v2last_editor_id"); + + b.Property("AuditV2OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v2operation_id"); + + b.Property("Bpnl") + .IsRequired() + .HasColumnType("text") + .HasColumnName("bpnl"); + + b.Property("CompanySsiDetailStatusId") + .HasColumnType("integer") + .HasColumnName("company_ssi_detail_status_id"); + + b.Property("CreatorUserId") + .IsRequired() + .HasColumnType("text") + .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("IssuerBpn") + .IsRequired() + .HasColumnType("text") + .HasColumnName("issuer_bpn"); + + b.Property("LastEditorId") + .HasColumnType("text") + .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("AuditV2Id") + .HasName("pk_audit_company_ssi_detail20240419"); + + b.ToTable("audit_company_ssi_detail20240419", "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("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("DocumentContent") + .HasColumnType("bytea") + .HasColumnName("document_content"); + + b.Property("DocumentHash") + .HasColumnType("bytea") + .HasColumnName("document_hash"); + + b.Property("DocumentName") + .HasColumnType("text") + .HasColumnName("document_name"); + + b.Property("DocumentStatusId") + .HasColumnType("integer") + .HasColumnName("document_status_id"); + + b.Property("DocumentTypeId") + .HasColumnType("integer") + .HasColumnName("document_type_id"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("MediaTypeId") + .HasColumnType("integer") + .HasColumnName("media_type_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_document20240305"); + + b.ToTable("audit_document20240305", "issuer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities.AuditDocument20240419", b => + { + b.Property("AuditV2Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v2id"); + + b.Property("AuditV2DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v2date_last_changed"); + + b.Property("AuditV2LastEditorId") + .HasColumnType("text") + .HasColumnName("audit_v2last_editor_id"); + + b.Property("AuditV2OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v2operation_id"); + + 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("DocumentContent") + .HasColumnType("bytea") + .HasColumnName("document_content"); + + b.Property("DocumentHash") + .HasColumnType("bytea") + .HasColumnName("document_hash"); + + b.Property("DocumentName") + .HasColumnType("text") + .HasColumnName("document_name"); + + b.Property("DocumentStatusId") + .HasColumnType("integer") + .HasColumnName("document_status_id"); + + b.Property("DocumentTypeId") + .HasColumnType("integer") + .HasColumnName("document_type_id"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("IdentityId") + .HasColumnType("text") + .HasColumnName("identity_id"); + + b.Property("LastEditorId") + .HasColumnType("text") + .HasColumnName("last_editor_id"); + + b.Property("MediaTypeId") + .HasColumnType("integer") + .HasColumnName("media_type_id"); + + b.HasKey("AuditV2Id") + .HasName("pk_audit_document20240419"); + + b.ToTable("audit_document20240419", "issuer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Bpnl") + .IsRequired() + .HasColumnType("text") + .HasColumnName("bpnl"); + + b.Property("CompanySsiDetailStatusId") + .HasColumnType("integer") + .HasColumnName("company_ssi_detail_status_id"); + + b.Property("CreatorUserId") + .IsRequired() + .HasColumnType("text") + .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("IssuerBpn") + .IsRequired() + .HasColumnType("text") + .HasColumnName("issuer_bpn"); + + b.Property("LastEditorId") + .HasColumnType("text") + .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("Id") + .HasName("pk_company_ssi_details"); + + b.HasIndex("CompanySsiDetailStatusId") + .HasDatabaseName("ix_company_ssi_details_company_ssi_detail_status_id"); + + b.HasIndex("ExpiryCheckTypeId") + .HasDatabaseName("ix_company_ssi_details_expiry_check_type_id"); + + b.HasIndex("ProcessId") + .HasDatabaseName("ix_company_ssi_details_process_id"); + + b.HasIndex("VerifiedCredentialExternalTypeDetailVersionId") + .HasDatabaseName("ix_company_ssi_details_verified_credential_external_type_detai"); + + b.HasIndex("VerifiedCredentialTypeId") + .HasDatabaseName("ix_company_ssi_details_verified_credential_type_id"); + + b.ToTable("company_ssi_details", "issuer", t => + { + t.HasTrigger("LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL"); + + t.HasTrigger("LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL"); + }); + + b + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_company_ssi_detail20240419\" (\"id\", \"bpnl\", \"issuer_bpn\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_detail_version_id\", \"expiry_check_type_id\", \"process_id\", \"external_credential_id\", \"credential\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"bpnl\", \r\n NEW.\"issuer_bpn\", \r\n NEW.\"verified_credential_type_id\", \r\n NEW.\"company_ssi_detail_status_id\", \r\n NEW.\"date_created\", \r\n NEW.\"creator_user_id\", \r\n NEW.\"expiry_date\", \r\n NEW.\"verified_credential_external_type_detail_version_id\", \r\n NEW.\"expiry_check_type_id\", \r\n NEW.\"process_id\", \r\n NEW.\"external_credential_id\", \r\n NEW.\"credential\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL AFTER INSERT\r\nON \"issuer\".\"company_ssi_details\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_company_ssi_detail20240419\" (\"id\", \"bpnl\", \"issuer_bpn\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_detail_version_id\", \"expiry_check_type_id\", \"process_id\", \"external_credential_id\", \"credential\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"bpnl\", \r\n NEW.\"issuer_bpn\", \r\n NEW.\"verified_credential_type_id\", \r\n NEW.\"company_ssi_detail_status_id\", \r\n NEW.\"date_created\", \r\n NEW.\"creator_user_id\", \r\n NEW.\"expiry_date\", \r\n NEW.\"verified_credential_external_type_detail_version_id\", \r\n NEW.\"expiry_check_type_id\", \r\n NEW.\"process_id\", \r\n NEW.\"external_credential_id\", \r\n NEW.\"credential\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL AFTER UPDATE\r\nON \"issuer\".\"company_ssi_details\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetailAssignedDocument", b => + { + b.Property("DocumentId") + .HasColumnType("uuid") + .HasColumnName("document_id"); + + b.Property("CompanySsiDetailId") + .HasColumnType("uuid") + .HasColumnName("company_ssi_detail_id"); + + b.HasKey("DocumentId", "CompanySsiDetailId") + .HasName("pk_company_ssi_detail_assigned_documents"); + + b.HasIndex("CompanySsiDetailId") + .HasDatabaseName("ix_company_ssi_detail_assigned_documents_company_ssi_detail_id"); + + b.ToTable("company_ssi_detail_assigned_documents", "issuer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetailStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_company_ssi_detail_statuses"); + + b.ToTable("company_ssi_detail_statuses", "issuer"); + + b.HasData( + new + { + Id = 1, + Label = "PENDING" + }, + new + { + Id = 2, + Label = "ACTIVE" + }, + new + { + Id = 3, + Label = "REVOKED" + }, + new + { + Id = 4, + Label = "INACTIVE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiProcessData", b => + { + b.Property("CompanySsiDetailId") + .HasColumnType("uuid") + .HasColumnName("company_ssi_detail_id"); + + b.Property("CallbackUrl") + .HasColumnType("text") + .HasColumnName("callback_url"); + + b.Property("ClientId") + .HasColumnType("text") + .HasColumnName("client_id"); + + b.Property("ClientSecret") + .HasColumnType("bytea") + .HasColumnName("client_secret"); + + b.Property("CredentialTypeKindId") + .HasColumnType("integer") + .HasColumnName("credential_type_kind_id"); + + b.Property("EncryptionMode") + .HasColumnType("integer") + .HasColumnName("encryption_mode"); + + b.Property("HolderWalletUrl") + .HasColumnType("text") + .HasColumnName("holder_wallet_url"); + + b.Property("InitializationVector") + .HasColumnType("bytea") + .HasColumnName("initialization_vector"); + + b.Property("Schema") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("schema"); + + b.HasKey("CompanySsiDetailId") + .HasName("pk_company_ssi_process_data"); + + b.HasIndex("CredentialTypeKindId") + .HasDatabaseName("ix_company_ssi_process_data_credential_type_kind_id"); + + b.ToTable("company_ssi_process_data", "issuer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + 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("DocumentContent") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("document_content"); + + b.Property("DocumentHash") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("document_hash"); + + b.Property("DocumentName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("document_name"); + + b.Property("DocumentStatusId") + .HasColumnType("integer") + .HasColumnName("document_status_id"); + + b.Property("DocumentTypeId") + .HasColumnType("integer") + .HasColumnName("document_type_id"); + + b.Property("IdentityId") + .HasColumnType("text") + .HasColumnName("identity_id"); + + b.Property("LastEditorId") + .HasColumnType("text") + .HasColumnName("last_editor_id"); + + b.Property("MediaTypeId") + .HasColumnType("integer") + .HasColumnName("media_type_id"); + + b.HasKey("Id") + .HasName("pk_documents"); + + b.HasIndex("DocumentStatusId") + .HasDatabaseName("ix_documents_document_status_id"); + + b.HasIndex("DocumentTypeId") + .HasDatabaseName("ix_documents_document_type_id"); + + b.HasIndex("MediaTypeId") + .HasDatabaseName("ix_documents_media_type_id"); + + b.ToTable("documents", "issuer", t => + { + t.HasTrigger("LC_TRIGGER_AFTER_INSERT_DOCUMENT"); + + t.HasTrigger("LC_TRIGGER_AFTER_UPDATE_DOCUMENT"); + }); + + b + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_DOCUMENT", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_DOCUMENT$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_document20240419\" (\"id\", \"date_created\", \"document_hash\", \"document_content\", \"document_name\", \"media_type_id\", \"document_type_id\", \"document_status_id\", \"identity_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"date_created\", \r\n NEW.\"document_hash\", \r\n NEW.\"document_content\", \r\n NEW.\"document_name\", \r\n NEW.\"media_type_id\", \r\n NEW.\"document_type_id\", \r\n NEW.\"document_status_id\", \r\n NEW.\"identity_id\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_DOCUMENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_DOCUMENT AFTER INSERT\r\nON \"issuer\".\"documents\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_DOCUMENT", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_DOCUMENT$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_document20240419\" (\"id\", \"date_created\", \"document_hash\", \"document_content\", \"document_name\", \"media_type_id\", \"document_type_id\", \"document_status_id\", \"identity_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"date_created\", \r\n NEW.\"document_hash\", \r\n NEW.\"document_content\", \r\n NEW.\"document_name\", \r\n NEW.\"media_type_id\", \r\n NEW.\"document_type_id\", \r\n NEW.\"document_status_id\", \r\n NEW.\"identity_id\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_DOCUMENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_DOCUMENT AFTER UPDATE\r\nON \"issuer\".\"documents\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.DocumentStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_document_status"); + + b.ToTable("document_status", "issuer"); + + b.HasData( + new + { + Id = 2, + Label = "ACTIVE" + }, + new + { + Id = 3, + Label = "INACTIVE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.DocumentType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_document_types"); + + b.ToTable("document_types", "issuer"); + + b.HasData( + new + { + Id = 1, + Label = "PRESENTATION" + }, + new + { + Id = 2, + Label = "CREDENTIAL" + }, + new + { + Id = 3, + Label = "VERIFIED_CREDENTIAL" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ExpiryCheckType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_expiry_check_types"); + + b.ToTable("expiry_check_types", "issuer"); + + b.HasData( + new + { + Id = 1, + Label = "ONE_MONTH" + }, + new + { + Id = 2, + Label = "TWO_WEEKS" + }, + new + { + Id = 3, + Label = "ONE_DAY" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.MediaType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_media_types"); + + b.ToTable("media_types", "issuer"); + + b.HasData( + new + { + Id = 1, + Label = "JPEG" + }, + new + { + Id = 2, + Label = "GIF" + }, + new + { + Id = 3, + Label = "PNG" + }, + new + { + Id = 4, + Label = "SVG" + }, + new + { + Id = 5, + Label = "TIFF" + }, + new + { + Id = 6, + Label = "PDF" + }, + new + { + Id = 7, + Label = "JSON" + }, + new + { + Id = 8, + Label = "PEM" + }, + new + { + Id = 9, + Label = "CA_CERT" + }, + new + { + Id = 10, + Label = "PKX_CER" + }, + new + { + Id = 11, + Label = "OCTET" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.Process", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LockExpiryDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("lock_expiry_date"); + + b.Property("ProcessTypeId") + .HasColumnType("integer") + .HasColumnName("process_type_id"); + + b.Property("Version") + .IsConcurrencyToken() + .HasColumnType("uuid") + .HasColumnName("version"); + + b.HasKey("Id") + .HasName("pk_processes"); + + b.HasIndex("ProcessTypeId") + .HasDatabaseName("ix_processes_process_type_id"); + + b.ToTable("processes", "issuer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ProcessStep", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + 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("Message") + .HasColumnType("text") + .HasColumnName("message"); + + b.Property("ProcessId") + .HasColumnType("uuid") + .HasColumnName("process_id"); + + b.Property("ProcessStepStatusId") + .HasColumnType("integer") + .HasColumnName("process_step_status_id"); + + b.Property("ProcessStepTypeId") + .HasColumnType("integer") + .HasColumnName("process_step_type_id"); + + b.HasKey("Id") + .HasName("pk_process_steps"); + + b.HasIndex("ProcessId") + .HasDatabaseName("ix_process_steps_process_id"); + + b.HasIndex("ProcessStepStatusId") + .HasDatabaseName("ix_process_steps_process_step_status_id"); + + b.HasIndex("ProcessStepTypeId") + .HasDatabaseName("ix_process_steps_process_step_type_id"); + + b.ToTable("process_steps", "issuer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ProcessStepStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_process_step_statuses"); + + b.ToTable("process_step_statuses", "issuer"); + + b.HasData( + new + { + Id = 1, + Label = "TODO" + }, + new + { + Id = 2, + Label = "DONE" + }, + new + { + Id = 3, + Label = "SKIPPED" + }, + new + { + Id = 4, + Label = "FAILED" + }, + new + { + Id = 5, + Label = "DUPLICATE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ProcessStepType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_process_step_types"); + + b.ToTable("process_step_types", "issuer"); + + b.HasData( + new + { + Id = 1, + Label = "CREATE_CREDENTIAL" + }, + new + { + Id = 2, + Label = "SIGN_CREDENTIAL" + }, + new + { + Id = 3, + Label = "SAVE_CREDENTIAL_DOCUMENT" + }, + new + { + Id = 4, + Label = "CREATE_CREDENTIAL_FOR_HOLDER" + }, + new + { + Id = 5, + Label = "TRIGGER_CALLBACK" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ProcessType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_process_types"); + + b.ToTable("process_types", "issuer"); + + b.HasData( + new + { + Id = 1, + Label = "CREATE_CREDENTIAL" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.UseCase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("Shortname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("shortname"); + + b.HasKey("Id") + .HasName("pk_use_cases"); + + b.ToTable("use_cases", "issuer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialExternalType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasColumnType("text") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_verified_credential_external_types"); + + b.ToTable("verified_credential_external_types", "issuer"); + + b.HasData( + new + { + Id = 1, + Label = "TRACEABILITY_CREDENTIAL" + }, + new + { + Id = 2, + Label = "PCF_CREDENTIAL" + }, + new + { + Id = 3, + Label = "BEHAVIOR_TWIN_CREDENTIAL" + }, + new + { + Id = 4, + Label = "VEHICLE_DISMANTLE" + }, + new + { + Id = 5, + Label = "SUSTAINABILITY_CREDENTIAL" + }, + new + { + Id = 6, + Label = "QUALITY_CREDENTIAL" + }, + new + { + Id = 7, + Label = "BUSINESS_PARTNER_NUMBER" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialExternalTypeDetailVersion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Expiry") + .HasColumnType("timestamp with time zone") + .HasColumnName("expiry"); + + b.Property("Template") + .HasColumnType("text") + .HasColumnName("template"); + + b.Property("ValidFrom") + .HasColumnType("timestamp with time zone") + .HasColumnName("valid_from"); + + b.Property("VerifiedCredentialExternalTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_external_type_id"); + + b.Property("Version") + .HasColumnType("text") + .HasColumnName("version"); + + b.HasKey("Id") + .HasName("pk_verified_credential_external_type_detail_versions"); + + b.HasIndex("VerifiedCredentialExternalTypeId", "Version") + .IsUnique() + .HasDatabaseName("ix_verified_credential_external_type_detail_versions_verified_"); + + b.ToTable("verified_credential_external_type_detail_versions", "issuer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_verified_credential_types"); + + b.ToTable("verified_credential_types", "issuer"); + + b.HasData( + new + { + Id = 1, + Label = "TRACEABILITY_FRAMEWORK" + }, + new + { + Id = 2, + Label = "PCF_FRAMEWORK" + }, + new + { + Id = 3, + Label = "BEHAVIOR_TWIN_FRAMEWORK" + }, + new + { + Id = 4, + Label = "DISMANTLER_CERTIFICATE" + }, + new + { + Id = 5, + Label = "SUSTAINABILITY_FRAMEWORK" + }, + new + { + Id = 6, + Label = "FRAMEWORK_AGREEMENT_QUALITY" + }, + new + { + Id = 7, + Label = "BUSINESS_PARTNER_NUMBER" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeAssignedExternalType", b => + { + b.Property("VerifiedCredentialTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_type_id"); + + b.Property("VerifiedCredentialExternalTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_external_type_id"); + + b.HasKey("VerifiedCredentialTypeId", "VerifiedCredentialExternalTypeId") + .HasName("pk_verified_credential_type_assigned_external_types"); + + b.HasIndex("VerifiedCredentialExternalTypeId") + .HasDatabaseName("ix_verified_credential_type_assigned_external_types_verified_c"); + + b.HasIndex("VerifiedCredentialTypeId") + .IsUnique() + .HasDatabaseName("ix_verified_credential_type_assigned_external_types_verified_c1"); + + b.ToTable("verified_credential_type_assigned_external_types", "issuer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeAssignedKind", b => + { + b.Property("VerifiedCredentialTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_type_id"); + + b.Property("VerifiedCredentialTypeKindId") + .HasColumnType("integer") + .HasColumnName("verified_credential_type_kind_id"); + + b.HasKey("VerifiedCredentialTypeId", "VerifiedCredentialTypeKindId") + .HasName("pk_verified_credential_type_assigned_kinds"); + + b.HasIndex("VerifiedCredentialTypeId") + .HasDatabaseName("ix_verified_credential_type_assigned_kinds_verified_credential"); + + b.HasIndex("VerifiedCredentialTypeKindId") + .HasDatabaseName("ix_verified_credential_type_assigned_kinds_verified_credential1"); + + b.ToTable("verified_credential_type_assigned_kinds", "issuer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeAssignedUseCase", b => + { + b.Property("VerifiedCredentialTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_type_id"); + + b.Property("UseCaseId") + .HasColumnType("uuid") + .HasColumnName("use_case_id"); + + b.HasKey("VerifiedCredentialTypeId", "UseCaseId") + .HasName("pk_verified_credential_type_assigned_use_cases"); + + b.HasIndex("UseCaseId") + .IsUnique() + .HasDatabaseName("ix_verified_credential_type_assigned_use_cases_use_case_id"); + + b.HasIndex("VerifiedCredentialTypeId") + .IsUnique() + .HasDatabaseName("ix_verified_credential_type_assigned_use_cases_verified_creden"); + + b.ToTable("verified_credential_type_assigned_use_cases", "issuer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeKind", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_verified_credential_type_kinds"); + + b.ToTable("verified_credential_type_kinds", "issuer"); + + b.HasData( + new + { + Id = 1, + Label = "FRAMEWORK" + }, + new + { + Id = 2, + Label = "MEMBERSHIP" + }, + new + { + Id = 3, + Label = "BPN" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetail", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetailStatus", "CompanySsiDetailStatus") + .WithMany("CompanySsiDetails") + .HasForeignKey("CompanySsiDetailStatusId") + .IsRequired() + .HasConstraintName("fk_company_ssi_details_company_ssi_detail_statuses_company_ssi"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ExpiryCheckType", "ExpiryCheckType") + .WithMany("CompanySsiDetails") + .HasForeignKey("ExpiryCheckTypeId") + .HasConstraintName("fk_company_ssi_details_expiry_check_types_expiry_check_type_id"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.Process", "Process") + .WithMany("CompanySsiDetails") + .HasForeignKey("ProcessId") + .HasConstraintName("fk_company_ssi_details_processes_process_id"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialExternalTypeDetailVersion", "VerifiedCredentialExternalTypeDetailVersion") + .WithMany("CompanySsiDetails") + .HasForeignKey("VerifiedCredentialExternalTypeDetailVersionId") + .HasConstraintName("fk_company_ssi_details_verified_credential_external_type_detai"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialType", "VerifiedCredentialType") + .WithMany("CompanySsiDetails") + .HasForeignKey("VerifiedCredentialTypeId") + .IsRequired() + .HasConstraintName("fk_company_ssi_details_verified_credential_types_verified_cred"); + + b.Navigation("CompanySsiDetailStatus"); + + b.Navigation("ExpiryCheckType"); + + b.Navigation("Process"); + + b.Navigation("VerifiedCredentialExternalTypeDetailVersion"); + + b.Navigation("VerifiedCredentialType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetailAssignedDocument", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetail", "CompanySsiDetail") + .WithMany() + .HasForeignKey("CompanySsiDetailId") + .IsRequired() + .HasConstraintName("fk_company_ssi_detail_assigned_documents_company_ssi_details_c"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .IsRequired() + .HasConstraintName("fk_company_ssi_detail_assigned_documents_documents_document_id"); + + b.Navigation("CompanySsiDetail"); + + b.Navigation("Document"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiProcessData", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetail", "CompanySsiDetail") + .WithOne("CompanySsiProcessData") + .HasForeignKey("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiProcessData", "CompanySsiDetailId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_ssi_process_data_company_ssi_details_company_ssi_de"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeKind", "CredentialTypeKind") + .WithMany("CompanySsiProcessData") + .HasForeignKey("CredentialTypeKindId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_ssi_process_data_verified_credential_type_kinds_cre"); + + b.Navigation("CompanySsiDetail"); + + b.Navigation("CredentialTypeKind"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.Document", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.DocumentStatus", "DocumentStatus") + .WithMany("Documents") + .HasForeignKey("DocumentStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_documents_document_status_document_status_id"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.DocumentType", "DocumentType") + .WithMany("Documents") + .HasForeignKey("DocumentTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_documents_document_types_document_type_id"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.MediaType", "MediaType") + .WithMany("Documents") + .HasForeignKey("MediaTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_documents_media_types_media_type_id"); + + b.Navigation("DocumentStatus"); + + b.Navigation("DocumentType"); + + b.Navigation("MediaType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.Process", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ProcessType", "ProcessType") + .WithMany("Processes") + .HasForeignKey("ProcessTypeId") + .IsRequired() + .HasConstraintName("fk_processes_process_types_process_type_id"); + + b.Navigation("ProcessType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ProcessStep", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.Process", "Process") + .WithMany("ProcessSteps") + .HasForeignKey("ProcessId") + .IsRequired() + .HasConstraintName("fk_process_steps_processes_process_id"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ProcessStepStatus", "ProcessStepStatus") + .WithMany("ProcessSteps") + .HasForeignKey("ProcessStepStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_process_steps_process_step_statuses_process_step_status_id"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ProcessStepType", "ProcessStepType") + .WithMany("ProcessSteps") + .HasForeignKey("ProcessStepTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_process_steps_process_step_types_process_step_type_id"); + + b.Navigation("Process"); + + b.Navigation("ProcessStepStatus"); + + b.Navigation("ProcessStepType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialExternalTypeDetailVersion", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialExternalType", "VerifiedCredentialExternalType") + .WithMany("VerifiedCredentialExternalTypeDetailVersions") + .HasForeignKey("VerifiedCredentialExternalTypeId") + .IsRequired() + .HasConstraintName("fk_verified_credential_external_type_detail_versions_verified_"); + + b.Navigation("VerifiedCredentialExternalType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeAssignedExternalType", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialExternalType", "VerifiedCredentialExternalType") + .WithMany("VerifiedCredentialTypeAssignedExternalTypes") + .HasForeignKey("VerifiedCredentialExternalTypeId") + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_external_types_verified_c"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialType", "VerifiedCredentialType") + .WithOne("VerifiedCredentialTypeAssignedExternalType") + .HasForeignKey("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeAssignedExternalType", "VerifiedCredentialTypeId") + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_external_types_verified_c1"); + + b.Navigation("VerifiedCredentialExternalType"); + + b.Navigation("VerifiedCredentialType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeAssignedKind", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialType", "VerifiedCredentialType") + .WithOne("VerifiedCredentialTypeAssignedKind") + .HasForeignKey("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeAssignedKind", "VerifiedCredentialTypeId") + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_kinds_verified_credential"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeKind", "VerifiedCredentialTypeKind") + .WithMany("VerifiedCredentialTypeAssignedKinds") + .HasForeignKey("VerifiedCredentialTypeKindId") + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_kinds_verified_credential1"); + + b.Navigation("VerifiedCredentialType"); + + b.Navigation("VerifiedCredentialTypeKind"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeAssignedUseCase", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.UseCase", "UseCase") + .WithOne("VerifiedCredentialAssignedUseCase") + .HasForeignKey("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeAssignedUseCase", "UseCaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_use_cases_use_cases_use_c"); + + b.HasOne("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialType", "VerifiedCredentialType") + .WithOne("VerifiedCredentialTypeAssignedUseCase") + .HasForeignKey("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeAssignedUseCase", "VerifiedCredentialTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_use_cases_verified_creden"); + + b.Navigation("UseCase"); + + b.Navigation("VerifiedCredentialType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetail", b => + { + b.Navigation("CompanySsiProcessData"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetailStatus", b => + { + b.Navigation("CompanySsiDetails"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.DocumentStatus", b => + { + b.Navigation("Documents"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.DocumentType", b => + { + b.Navigation("Documents"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ExpiryCheckType", b => + { + b.Navigation("CompanySsiDetails"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.MediaType", b => + { + b.Navigation("Documents"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.Process", b => + { + b.Navigation("CompanySsiDetails"); + + b.Navigation("ProcessSteps"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ProcessStepStatus", b => + { + b.Navigation("ProcessSteps"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ProcessStepType", b => + { + b.Navigation("ProcessSteps"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.ProcessType", b => + { + b.Navigation("Processes"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.UseCase", b => + { + b.Navigation("VerifiedCredentialAssignedUseCase"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialExternalType", b => + { + b.Navigation("VerifiedCredentialExternalTypeDetailVersions"); + + b.Navigation("VerifiedCredentialTypeAssignedExternalTypes"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialExternalTypeDetailVersion", b => + { + b.Navigation("CompanySsiDetails"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialType", b => + { + b.Navigation("CompanySsiDetails"); + + b.Navigation("VerifiedCredentialTypeAssignedExternalType"); + + b.Navigation("VerifiedCredentialTypeAssignedKind"); + + b.Navigation("VerifiedCredentialTypeAssignedUseCase"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.VerifiedCredentialTypeKind", b => + { + b.Navigation("CompanySsiProcessData"); + + b.Navigation("VerifiedCredentialTypeAssignedKinds"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/database/SsiCredentialIssuer.Migrations/Migrations/20240422084019_1.0.0-rc.2.cs b/src/database/SsiCredentialIssuer.Migrations/Migrations/20240422084019_1.0.0-rc.2.cs new file mode 100644 index 00000000..10a61883 --- /dev/null +++ b/src/database/SsiCredentialIssuer.Migrations/Migrations/20240422084019_1.0.0-rc.2.cs @@ -0,0 +1,223 @@ +/******************************************************************************** + * 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.Migrations; + +#nullable disable + +namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Migrations.Migrations +{ + /// + public partial class _100rc2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DROP FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"() CASCADE;"); + + migrationBuilder.Sql("DROP FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"() CASCADE;"); + + migrationBuilder.Sql("DROP FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"() CASCADE;"); + + migrationBuilder.Sql("DROP FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"() CASCADE;"); + + migrationBuilder.RenameColumn( + name: "company_user_id", + newName: "identity_id", + schema: "issuer", + table: "documents"); + + migrationBuilder.AlterColumn( + name: "last_editor_id", + schema: "issuer", + table: "documents", + type: "text", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "identity_id", + schema: "issuer", + table: "documents", + type: "text", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "last_editor_id", + schema: "issuer", + table: "company_ssi_details", + type: "text", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "creator_user_id", + schema: "issuer", + table: "company_ssi_details", + type: "text", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.CreateTable( + name: "audit_company_ssi_detail20240419", + schema: "issuer", + columns: table => new + { + audit_v2id = table.Column(type: "uuid", nullable: false), + id = table.Column(type: "uuid", nullable: false), + bpnl = table.Column(type: "text", nullable: false), + issuer_bpn = table.Column(type: "text", nullable: false), + verified_credential_type_id = table.Column(type: "integer", nullable: false), + company_ssi_detail_status_id = table.Column(type: "integer", nullable: false), + date_created = table.Column(type: "timestamp with time zone", nullable: false), + creator_user_id = table.Column(type: "text", nullable: false), + expiry_date = table.Column(type: "timestamp with time zone", nullable: true), + verified_credential_external_type_detail_version_id = table.Column(type: "uuid", nullable: true), + expiry_check_type_id = table.Column(type: "integer", nullable: true), + process_id = table.Column(type: "uuid", nullable: true), + external_credential_id = table.Column(type: "uuid", nullable: true), + credential = table.Column(type: "text", nullable: true), + date_last_changed = table.Column(type: "timestamp with time zone", nullable: true), + last_editor_id = table.Column(type: "text", nullable: true), + audit_v2last_editor_id = table.Column(type: "text", nullable: true), + audit_v2operation_id = table.Column(type: "integer", nullable: false), + audit_v2date_last_changed = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_audit_company_ssi_detail20240419", x => x.audit_v2id); + }); + + migrationBuilder.CreateTable( + name: "audit_document20240419", + schema: "issuer", + columns: table => new + { + audit_v2id = table.Column(type: "uuid", nullable: false), + id = table.Column(type: "uuid", nullable: false), + date_created = table.Column(type: "timestamp with time zone", nullable: true), + document_hash = table.Column(type: "bytea", nullable: true), + document_content = table.Column(type: "bytea", nullable: true), + document_name = table.Column(type: "text", nullable: true), + media_type_id = table.Column(type: "integer", nullable: true), + document_type_id = table.Column(type: "integer", nullable: true), + document_status_id = table.Column(type: "integer", nullable: true), + identity_id = table.Column(type: "text", nullable: true), + date_last_changed = table.Column(type: "timestamp with time zone", nullable: true), + last_editor_id = table.Column(type: "text", nullable: true), + audit_v2date_last_changed = table.Column(type: "timestamp with time zone", nullable: false), + audit_v2last_editor_id = table.Column(type: "text", nullable: true), + audit_v2operation_id = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_audit_document20240419", x => x.audit_v2id); + }); + + migrationBuilder.Sql("CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_company_ssi_detail20240419\" (\"id\", \"bpnl\", \"issuer_bpn\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_detail_version_id\", \"expiry_check_type_id\", \"process_id\", \"external_credential_id\", \"credential\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"bpnl\", \r\n NEW.\"issuer_bpn\", \r\n NEW.\"verified_credential_type_id\", \r\n NEW.\"company_ssi_detail_status_id\", \r\n NEW.\"date_created\", \r\n NEW.\"creator_user_id\", \r\n NEW.\"expiry_date\", \r\n NEW.\"verified_credential_external_type_detail_version_id\", \r\n NEW.\"expiry_check_type_id\", \r\n NEW.\"process_id\", \r\n NEW.\"external_credential_id\", \r\n NEW.\"credential\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL AFTER INSERT\r\nON \"issuer\".\"company_ssi_details\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"();"); + + migrationBuilder.Sql("CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_company_ssi_detail20240419\" (\"id\", \"bpnl\", \"issuer_bpn\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_detail_version_id\", \"expiry_check_type_id\", \"process_id\", \"external_credential_id\", \"credential\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"bpnl\", \r\n NEW.\"issuer_bpn\", \r\n NEW.\"verified_credential_type_id\", \r\n NEW.\"company_ssi_detail_status_id\", \r\n NEW.\"date_created\", \r\n NEW.\"creator_user_id\", \r\n NEW.\"expiry_date\", \r\n NEW.\"verified_credential_external_type_detail_version_id\", \r\n NEW.\"expiry_check_type_id\", \r\n NEW.\"process_id\", \r\n NEW.\"external_credential_id\", \r\n NEW.\"credential\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL AFTER UPDATE\r\nON \"issuer\".\"company_ssi_details\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"();"); + + migrationBuilder.Sql("CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_DOCUMENT$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_document20240419\" (\"id\", \"date_created\", \"document_hash\", \"document_content\", \"document_name\", \"media_type_id\", \"document_type_id\", \"document_status_id\", \"identity_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"date_created\", \r\n NEW.\"document_hash\", \r\n NEW.\"document_content\", \r\n NEW.\"document_name\", \r\n NEW.\"media_type_id\", \r\n NEW.\"document_type_id\", \r\n NEW.\"document_status_id\", \r\n NEW.\"identity_id\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_DOCUMENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_DOCUMENT AFTER INSERT\r\nON \"issuer\".\"documents\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"();"); + + migrationBuilder.Sql("CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_DOCUMENT$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_document20240419\" (\"id\", \"date_created\", \"document_hash\", \"document_content\", \"document_name\", \"media_type_id\", \"document_type_id\", \"document_status_id\", \"identity_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"date_created\", \r\n NEW.\"document_hash\", \r\n NEW.\"document_content\", \r\n NEW.\"document_name\", \r\n NEW.\"media_type_id\", \r\n NEW.\"document_type_id\", \r\n NEW.\"document_status_id\", \r\n NEW.\"identity_id\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_DOCUMENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_DOCUMENT AFTER UPDATE\r\nON \"issuer\".\"documents\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"();"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DROP FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"() CASCADE;"); + + migrationBuilder.Sql("DROP FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"() CASCADE;"); + + migrationBuilder.Sql("DROP FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"() CASCADE;"); + + migrationBuilder.Sql("DROP FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"() CASCADE;"); + + migrationBuilder.DropTable( + name: "audit_company_ssi_detail20240419", + schema: "issuer"); + + migrationBuilder.DropTable( + name: "audit_document20240419", + schema: "issuer"); + + migrationBuilder.RenameColumn( + name: "identity_id", + newName: "company_user_id", + schema: "issuer", + table: "documents"); + + migrationBuilder.AlterColumn( + name: "last_editor_id", + schema: "issuer", + table: "documents", + type: "uuid", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "company_user_id", + schema: "issuer", + table: "documents", + type: "uuid", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "last_editor_id", + schema: "issuer", + table: "company_ssi_details", + type: "uuid", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "creator_user_id", + schema: "issuer", + table: "company_ssi_details", + type: "uuid", + nullable: false, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.Sql("CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_company_ssi_detail20240228\" (\"id\", \"bpnl\", \"issuer_bpn\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_detail_version_id\", \"expiry_check_type_id\", \"process_id\", \"external_credential_id\", \"credential\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"bpnl\", \r\n NEW.\"issuer_bpn\", \r\n NEW.\"verified_credential_type_id\", \r\n NEW.\"company_ssi_detail_status_id\", \r\n NEW.\"date_created\", \r\n NEW.\"creator_user_id\", \r\n NEW.\"expiry_date\", \r\n NEW.\"verified_credential_external_type_detail_version_id\", \r\n NEW.\"expiry_check_type_id\", \r\n NEW.\"process_id\", \r\n NEW.\"external_credential_id\", \r\n NEW.\"credential\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL AFTER INSERT\r\nON \"issuer\".\"company_ssi_details\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"();"); + + migrationBuilder.Sql("CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_company_ssi_detail20240228\" (\"id\", \"bpnl\", \"issuer_bpn\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_detail_version_id\", \"expiry_check_type_id\", \"process_id\", \"external_credential_id\", \"credential\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"bpnl\", \r\n NEW.\"issuer_bpn\", \r\n NEW.\"verified_credential_type_id\", \r\n NEW.\"company_ssi_detail_status_id\", \r\n NEW.\"date_created\", \r\n NEW.\"creator_user_id\", \r\n NEW.\"expiry_date\", \r\n NEW.\"verified_credential_external_type_detail_version_id\", \r\n NEW.\"expiry_check_type_id\", \r\n NEW.\"process_id\", \r\n NEW.\"external_credential_id\", \r\n NEW.\"credential\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL AFTER UPDATE\r\nON \"issuer\".\"company_ssi_details\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"();"); + + migrationBuilder.Sql("CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_DOCUMENT$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_document20240305\" (\"id\", \"date_created\", \"document_hash\", \"document_content\", \"document_name\", \"media_type_id\", \"document_type_id\", \"document_status_id\", \"company_user_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"date_created\", \r\n NEW.\"document_hash\", \r\n NEW.\"document_content\", \r\n NEW.\"document_name\", \r\n NEW.\"media_type_id\", \r\n NEW.\"document_type_id\", \r\n NEW.\"document_status_id\", \r\n NEW.\"company_user_id\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_DOCUMENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_DOCUMENT AFTER INSERT\r\nON \"issuer\".\"documents\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"();"); + + migrationBuilder.Sql("CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_DOCUMENT$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_document20240305\" (\"id\", \"date_created\", \"document_hash\", \"document_content\", \"document_name\", \"media_type_id\", \"document_type_id\", \"document_status_id\", \"company_user_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"date_created\", \r\n NEW.\"document_hash\", \r\n NEW.\"document_content\", \r\n NEW.\"document_name\", \r\n NEW.\"media_type_id\", \r\n NEW.\"document_type_id\", \r\n NEW.\"document_status_id\", \r\n NEW.\"company_user_id\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_DOCUMENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_DOCUMENT AFTER UPDATE\r\nON \"issuer\".\"documents\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"();"); + } + } +} diff --git a/src/database/SsiCredentialIssuer.Migrations/Migrations/IssuerDbContextModelSnapshot.cs b/src/database/SsiCredentialIssuer.Migrations/Migrations/IssuerDbContextModelSnapshot.cs index bf3c8653..d55dec90 100644 --- a/src/database/SsiCredentialIssuer.Migrations/Migrations/IssuerDbContextModelSnapshot.cs +++ b/src/database/SsiCredentialIssuer.Migrations/Migrations/IssuerDbContextModelSnapshot.cs @@ -1,28 +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 -// ********************************************************************************/ + * 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; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities; +using System.Text.Json; + +#nullable disable namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Migrations.Migrations { @@ -127,6 +128,94 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("audit_company_ssi_detail20240228", "issuer"); }); + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities.AuditCompanySsiDetail20240419", b => + { + b.Property("AuditV2Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v2id"); + + b.Property("AuditV2DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v2date_last_changed"); + + b.Property("AuditV2LastEditorId") + .HasColumnType("text") + .HasColumnName("audit_v2last_editor_id"); + + b.Property("AuditV2OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v2operation_id"); + + b.Property("Bpnl") + .IsRequired() + .HasColumnType("text") + .HasColumnName("bpnl"); + + b.Property("CompanySsiDetailStatusId") + .HasColumnType("integer") + .HasColumnName("company_ssi_detail_status_id"); + + b.Property("CreatorUserId") + .IsRequired() + .HasColumnType("text") + .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("IssuerBpn") + .IsRequired() + .HasColumnType("text") + .HasColumnName("issuer_bpn"); + + b.Property("LastEditorId") + .HasColumnType("text") + .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("AuditV2Id") + .HasName("pk_audit_company_ssi_detail20240419"); + + b.ToTable("audit_company_ssi_detail20240419", "issuer"); + }); + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities.AuditDocument20240305", b => { b.Property("AuditV1Id") @@ -196,6 +285,75 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("audit_document20240305", "issuer"); }); + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.AuditEntities.AuditDocument20240419", b => + { + b.Property("AuditV2Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v2id"); + + b.Property("AuditV2DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v2date_last_changed"); + + b.Property("AuditV2LastEditorId") + .HasColumnType("text") + .HasColumnName("audit_v2last_editor_id"); + + b.Property("AuditV2OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v2operation_id"); + + 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("DocumentContent") + .HasColumnType("bytea") + .HasColumnName("document_content"); + + b.Property("DocumentHash") + .HasColumnType("bytea") + .HasColumnName("document_hash"); + + b.Property("DocumentName") + .HasColumnType("text") + .HasColumnName("document_name"); + + b.Property("DocumentStatusId") + .HasColumnType("integer") + .HasColumnName("document_status_id"); + + b.Property("DocumentTypeId") + .HasColumnType("integer") + .HasColumnName("document_type_id"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("IdentityId") + .HasColumnType("text") + .HasColumnName("identity_id"); + + b.Property("LastEditorId") + .HasColumnType("text") + .HasColumnName("last_editor_id"); + + b.Property("MediaTypeId") + .HasColumnType("integer") + .HasColumnName("media_type_id"); + + b.HasKey("AuditV2Id") + .HasName("pk_audit_document20240419"); + + b.ToTable("audit_document20240419", "issuer"); + }); + modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetail", b => { b.Property("Id") @@ -212,8 +370,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("integer") .HasColumnName("company_ssi_detail_status_id"); - b.Property("CreatorUserId") - .HasColumnType("uuid") + b.Property("CreatorUserId") + .IsRequired() + .HasColumnType("text") .HasColumnName("creator_user_id"); b.Property("Credential") @@ -245,8 +404,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("text") .HasColumnName("issuer_bpn"); - b.Property("LastEditorId") - .HasColumnType("uuid") + b.Property("LastEditorId") + .HasColumnType("text") .HasColumnName("last_editor_id"); b.Property("ProcessId") @@ -287,8 +446,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) }); b - .HasAnnotation("LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_company_ssi_detail20240228\" (\"id\", \"bpnl\", \"issuer_bpn\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_detail_version_id\", \"expiry_check_type_id\", \"process_id\", \"external_credential_id\", \"credential\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"bpnl\", \r\n NEW.\"issuer_bpn\", \r\n NEW.\"verified_credential_type_id\", \r\n NEW.\"company_ssi_detail_status_id\", \r\n NEW.\"date_created\", \r\n NEW.\"creator_user_id\", \r\n NEW.\"expiry_date\", \r\n NEW.\"verified_credential_external_type_detail_version_id\", \r\n NEW.\"expiry_check_type_id\", \r\n NEW.\"process_id\", \r\n NEW.\"external_credential_id\", \r\n NEW.\"credential\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL AFTER INSERT\r\nON \"issuer\".\"company_ssi_details\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"();") - .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_company_ssi_detail20240228\" (\"id\", \"bpnl\", \"issuer_bpn\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_detail_version_id\", \"expiry_check_type_id\", \"process_id\", \"external_credential_id\", \"credential\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"bpnl\", \r\n NEW.\"issuer_bpn\", \r\n NEW.\"verified_credential_type_id\", \r\n NEW.\"company_ssi_detail_status_id\", \r\n NEW.\"date_created\", \r\n NEW.\"creator_user_id\", \r\n NEW.\"expiry_date\", \r\n NEW.\"verified_credential_external_type_detail_version_id\", \r\n NEW.\"expiry_check_type_id\", \r\n NEW.\"process_id\", \r\n NEW.\"external_credential_id\", \r\n NEW.\"credential\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL AFTER UPDATE\r\nON \"issuer\".\"company_ssi_details\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"();"); + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_company_ssi_detail20240419\" (\"id\", \"bpnl\", \"issuer_bpn\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_detail_version_id\", \"expiry_check_type_id\", \"process_id\", \"external_credential_id\", \"credential\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"bpnl\", \r\n NEW.\"issuer_bpn\", \r\n NEW.\"verified_credential_type_id\", \r\n NEW.\"company_ssi_detail_status_id\", \r\n NEW.\"date_created\", \r\n NEW.\"creator_user_id\", \r\n NEW.\"expiry_date\", \r\n NEW.\"verified_credential_external_type_detail_version_id\", \r\n NEW.\"expiry_check_type_id\", \r\n NEW.\"process_id\", \r\n NEW.\"external_credential_id\", \r\n NEW.\"credential\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL AFTER INSERT\r\nON \"issuer\".\"company_ssi_details\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL\"();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_company_ssi_detail20240419\" (\"id\", \"bpnl\", \"issuer_bpn\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_detail_version_id\", \"expiry_check_type_id\", \"process_id\", \"external_credential_id\", \"credential\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"bpnl\", \r\n NEW.\"issuer_bpn\", \r\n NEW.\"verified_credential_type_id\", \r\n NEW.\"company_ssi_detail_status_id\", \r\n NEW.\"date_created\", \r\n NEW.\"creator_user_id\", \r\n NEW.\"expiry_date\", \r\n NEW.\"verified_credential_external_type_detail_version_id\", \r\n NEW.\"expiry_check_type_id\", \r\n NEW.\"process_id\", \r\n NEW.\"external_credential_id\", \r\n NEW.\"credential\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL AFTER UPDATE\r\nON \"issuer\".\"company_ssi_details\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL\"();"); }); modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.CompanySsiDetailAssignedDocument", b => @@ -405,10 +564,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("uuid") .HasColumnName("id"); - b.Property("CompanyUserId") - .HasColumnType("uuid") - .HasColumnName("company_user_id"); - b.Property("DateCreated") .HasColumnType("timestamp with time zone") .HasColumnName("date_created"); @@ -441,8 +596,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("integer") .HasColumnName("document_type_id"); - b.Property("LastEditorId") - .HasColumnType("uuid") + b.Property("IdentityId") + .HasColumnType("text") + .HasColumnName("identity_id"); + + b.Property("LastEditorId") + .HasColumnType("text") .HasColumnName("last_editor_id"); b.Property("MediaTypeId") @@ -469,8 +628,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) }); b - .HasAnnotation("LC_TRIGGER_AFTER_INSERT_DOCUMENT", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_DOCUMENT$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_document20240305\" (\"id\", \"date_created\", \"document_hash\", \"document_content\", \"document_name\", \"media_type_id\", \"document_type_id\", \"document_status_id\", \"company_user_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"date_created\", \r\n NEW.\"document_hash\", \r\n NEW.\"document_content\", \r\n NEW.\"document_name\", \r\n NEW.\"media_type_id\", \r\n NEW.\"document_type_id\", \r\n NEW.\"document_status_id\", \r\n NEW.\"company_user_id\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_DOCUMENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_DOCUMENT AFTER INSERT\r\nON \"issuer\".\"documents\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"();") - .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_DOCUMENT", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_DOCUMENT$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_document20240305\" (\"id\", \"date_created\", \"document_hash\", \"document_content\", \"document_name\", \"media_type_id\", \"document_type_id\", \"document_status_id\", \"company_user_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"date_created\", \r\n NEW.\"document_hash\", \r\n NEW.\"document_content\", \r\n NEW.\"document_name\", \r\n NEW.\"media_type_id\", \r\n NEW.\"document_type_id\", \r\n NEW.\"document_status_id\", \r\n NEW.\"company_user_id\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_DOCUMENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_DOCUMENT AFTER UPDATE\r\nON \"issuer\".\"documents\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"();"); + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_DOCUMENT", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_DOCUMENT$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_document20240419\" (\"id\", \"date_created\", \"document_hash\", \"document_content\", \"document_name\", \"media_type_id\", \"document_type_id\", \"document_status_id\", \"identity_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"date_created\", \r\n NEW.\"document_hash\", \r\n NEW.\"document_content\", \r\n NEW.\"document_name\", \r\n NEW.\"media_type_id\", \r\n NEW.\"document_type_id\", \r\n NEW.\"document_status_id\", \r\n NEW.\"identity_id\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_DOCUMENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_DOCUMENT AFTER INSERT\r\nON \"issuer\".\"documents\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_INSERT_DOCUMENT\"();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_DOCUMENT", "CREATE FUNCTION \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_DOCUMENT$\r\nBEGIN\r\n INSERT INTO \"issuer\".\"audit_document20240419\" (\"id\", \"date_created\", \"document_hash\", \"document_content\", \"document_name\", \"media_type_id\", \"document_type_id\", \"document_status_id\", \"identity_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v2id\", \"audit_v2operation_id\", \"audit_v2date_last_changed\", \"audit_v2last_editor_id\") SELECT NEW.\"id\", \r\n NEW.\"date_created\", \r\n NEW.\"document_hash\", \r\n NEW.\"document_content\", \r\n NEW.\"document_name\", \r\n NEW.\"media_type_id\", \r\n NEW.\"document_type_id\", \r\n NEW.\"document_status_id\", \r\n NEW.\"identity_id\", \r\n NEW.\"date_last_changed\", \r\n NEW.\"last_editor_id\", \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.\"last_editor_id\";\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_DOCUMENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_DOCUMENT AFTER UPDATE\r\nON \"issuer\".\"documents\"\r\nFOR EACH ROW EXECUTE PROCEDURE \"issuer\".\"LC_TRIGGER_AFTER_UPDATE_DOCUMENT\"();"); }); modelBuilder.Entity("Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities.DocumentStatus", b => diff --git a/src/externalservices/Callback.Service/Callback.Service.csproj b/src/externalservices/Callback.Service/Callback.Service.csproj index 3fbe75c7..6f0c33d9 100644 --- a/src/externalservices/Callback.Service/Callback.Service.csproj +++ b/src/externalservices/Callback.Service/Callback.Service.csproj @@ -29,6 +29,7 @@ + diff --git a/src/externalservices/Callback.Service/DependencyInjection/ServiceCollectionExtensions.cs b/src/externalservices/Callback.Service/DependencyInjection/ServiceCollectionExtensions.cs index 9e9dff45..c49024bc 100644 --- a/src/externalservices/Callback.Service/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/externalservices/Callback.Service/DependencyInjection/ServiceCollectionExtensions.cs @@ -30,6 +30,7 @@ public static IServiceCollection AddCallbackService(this IServiceCollection serv { services.AddOptions() .Bind(section) + .ValidateDataAnnotations() .ValidateOnStart(); services.AddTransient>(); diff --git a/src/externalservices/Portal.Service/DependencyInjection/ServiceCollectionExtensions.cs b/src/externalservices/Portal.Service/DependencyInjection/ServiceCollectionExtensions.cs index 8bfe6921..08fb8573 100644 --- a/src/externalservices/Portal.Service/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/externalservices/Portal.Service/DependencyInjection/ServiceCollectionExtensions.cs @@ -31,6 +31,7 @@ public static IServiceCollection AddPortalService(this IServiceCollection servic { services.AddOptions() .Bind(section) + .ValidateDataAnnotations() .ValidateOnStart(); services.AddTransient>(); diff --git a/src/externalservices/Portal.Service/Portal.Service.csproj b/src/externalservices/Portal.Service/Portal.Service.csproj index 894c46d8..76ede424 100644 --- a/src/externalservices/Portal.Service/Portal.Service.csproj +++ b/src/externalservices/Portal.Service/Portal.Service.csproj @@ -29,6 +29,7 @@ + diff --git a/src/externalservices/Wallet.Service/DependencyInjection/ServiceCollectionExtensions.cs b/src/externalservices/Wallet.Service/DependencyInjection/ServiceCollectionExtensions.cs index d8e011c0..9264d155 100644 --- a/src/externalservices/Wallet.Service/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/externalservices/Wallet.Service/DependencyInjection/ServiceCollectionExtensions.cs @@ -32,6 +32,7 @@ public static IServiceCollection AddWalletService(this IServiceCollection servic { services.AddOptions() .Bind(config.GetSection("Wallet")) + .ValidateDataAnnotations() .ValidateOnStart(); services.AddTransient>(); diff --git a/src/externalservices/Wallet.Service/Schemas/BPNCredential.schema.json b/src/externalservices/Wallet.Service/Schemas/BPNCredential.schema.json index f7fd53c7..ba43ad65 100644 --- a/src/externalservices/Wallet.Service/Schemas/BPNCredential.schema.json +++ b/src/externalservices/Wallet.Service/Schemas/BPNCredential.schema.json @@ -6,36 +6,48 @@ "id": { "type": "string" }, - "@context": { + "type": { "type": "array", "items": { "type": "string" - }, - "const": [ - "https://www.w3.org/2018/credentials/v1", - "https://w3id.org/catenax/credentials/v1.0.0" - ] + } }, - "type": { + "issuer": { + "type": "string" + }, + "@context": { "type": "array", "items": { - "type": "string", - "enum": [ - "VerifiableCredential", - "BpnCredential" - ] + "type": "string" } - }, + }, "issuanceDate": { "type": "string", - "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(.\\d{6})?(Z|\\+\\d{2}:\\d{2})?$" + "format": "date-time" }, "expirationDate": { "type": "string", - "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(.\\d{6})?(Z|\\+\\d{2}:\\d{2})?$" + "format": "date-time" }, - "issuer": { - "type": "string" + "credentialStatus": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "type": "string" + }, + "statusPurpose": { + "type": "string" + }, + "statusListIndex": { + "type": "string" + }, + "statusListCredential": { + "type": "string" + } + } }, "credentialSubject": { "type": "object", @@ -43,17 +55,15 @@ "id": { "type": "string" }, - "holderIdentifier": { + "bpn": { "type": "string" }, - "bpn": { + "holderIndentifier": { "type": "string" } }, - "required": ["id", "holderIdentifier", "bpn"], - "additionalProperties": false + "required": ["id", "bpn", "holderIndentifier"] } }, - "required": ["id", "@context", "type", "issuanceDate", "expirationDate", "issuer", "credentialSubject"], - "additionalProperties": true + "required": ["id", "@context", "type", "issuanceDate", "expirationDate", "issuer", "credentialSubject"] } diff --git a/src/externalservices/Wallet.Service/Schemas/FRAMEWORKCredential.schema.json b/src/externalservices/Wallet.Service/Schemas/FRAMEWORKCredential.schema.json index 915bc138..024ebff5 100644 --- a/src/externalservices/Wallet.Service/Schemas/FRAMEWORKCredential.schema.json +++ b/src/externalservices/Wallet.Service/Schemas/FRAMEWORKCredential.schema.json @@ -6,17 +6,16 @@ "id": { "type": "string" }, - "@context": { + "type": { "type": "array", "items": { "type": "string" - }, - "const": [ - "https://www.w3.org/2018/credentials/v1", - "https://w3id.org/catenax/credentials/v1.0.0" - ] + } }, - "type": { + "issuer": { + "type": "string" + }, + "@context": { "type": "array", "items": { "type": "string" @@ -24,14 +23,31 @@ }, "issuanceDate": { "type": "string", - "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(.\\d{6})?(Z|\\+\\d{2}:\\d{2})?$" + "format": "date-time" }, "expirationDate": { "type": "string", - "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(.\\d{6})?(Z|\\+\\d{2}:\\d{2})?$" + "format": "date-time" }, - "issuer": { - "type": "string" + "credentialStatus": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "type": "string" + }, + "statusPurpose": { + "type": "string" + }, + "statusListIndex": { + "type": "string" + }, + "statusListCredential": { + "type": "string" + } + } }, "credentialSubject": { "type": "object", @@ -56,10 +72,8 @@ "type": "string" } }, - "required": ["id", "holderIdentifier", "group", "useCase", "contractTemplate", "contractVersion"], - "additionalProperties": false + "required": ["id", "holderIdentifier", "group", "useCase", "contractTemplate", "contractVersion"] } }, - "required": ["id", "@context", "type", "issuanceDate", "expirationDate", "issuer", "credentialSubject"], - "additionalProperties": true + "required": ["id", "@context", "type", "issuanceDate", "expirationDate", "issuer", "credentialSubject"] } diff --git a/src/externalservices/Wallet.Service/Schemas/MEMBERSHIPCredential.schema.json b/src/externalservices/Wallet.Service/Schemas/MEMBERSHIPCredential.schema.json index 18091e88..1e453e87 100644 --- a/src/externalservices/Wallet.Service/Schemas/MEMBERSHIPCredential.schema.json +++ b/src/externalservices/Wallet.Service/Schemas/MEMBERSHIPCredential.schema.json @@ -3,39 +3,52 @@ "$id": "https://eclipse-tractusx.github.io/MembershipCredential.schema.json", "type": "object", "properties": { + "id": { "type": "string" }, - "@context": { + "type": { "type": "array", "items": { "type": "string" - }, - "const": [ - "https://www.w3.org/2018/credentials/v1", - "https://w3id.org/catenax/credentials/v1.0.0" - ] + } }, - "type": { + "issuer": { + "type": "string" + }, + "@context": { "type": "array", "items": { - "type": "string", - "enum": [ - "VerifiableCredential", - "MembershipCredential" - ] + "type": "string" } }, "issuanceDate": { "type": "string", - "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(.\\d{6})?(Z|\\+\\d{2}:\\d{2})?$" + "format": "date-time" }, "expirationDate": { "type": "string", - "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(.\\d{6})?(Z|\\+\\d{2}:\\d{2})?$" + "format": "date-time" }, - "issuer": { - "type": "string" + "credentialStatus": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "type": "string" + }, + "statusPurpose": { + "type": "string" + }, + "statusListIndex": { + "type": "string" + }, + "statusListCredential": { + "type": "string" + } + } }, "credentialSubject": { "type": "object", @@ -50,10 +63,8 @@ "type": "string" } }, - "required": ["id", "holderIdentifier", "memberOf"], - "additionalProperties": false + "required": ["id", "holderIdentifier", "memberOf"] } }, - "required": ["id", "@context", "type", "issuanceDate", "expirationDate", "issuer", "credentialSubject"], - "additionalProperties": true + "required": ["id", "@context", "type", "issuanceDate", "expirationDate", "issuer", "credentialSubject"] } diff --git a/src/externalservices/Wallet.Service/Wallet.Service.csproj b/src/externalservices/Wallet.Service/Wallet.Service.csproj index c37e3a95..64436a01 100644 --- a/src/externalservices/Wallet.Service/Wallet.Service.csproj +++ b/src/externalservices/Wallet.Service/Wallet.Service.csproj @@ -32,6 +32,7 @@ + diff --git a/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerBusinessLogic.cs b/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerBusinessLogic.cs index 8dd4b588..63999d76 100644 --- a/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerBusinessLogic.cs +++ b/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerBusinessLogic.cs @@ -176,6 +176,11 @@ await _repositories /// public async Task ApproveCredential(Guid credentialId, CancellationToken cancellationToken) { + if (_identity.IsServiceAccount || _identity.CompanyUserId == null) + { + throw UnexpectedConditionException.Create(CredentialErrors.USER_MUST_NOT_BE_TECHNICAL_USER, new ErrorParameter[] { new("identityId", _identity.IdentityId) }); + } + var companySsiRepository = _repositories.GetInstance(); var (exists, data) = await companySsiRepository.GetSsiApprovalData(credentialId).ConfigureAwait(false); ValidateApprovalData(credentialId, exists, data); @@ -198,14 +203,14 @@ public async Task ApproveCredential(Guid credentialId, CancellationToken cancell }); var typeValue = data.Type.GetEnumValue() ?? throw UnexpectedConditionException.Create(CredentialErrors.CREDENTIAL_TYPE_NOT_FOUND, new ErrorParameter[] { new("verifiedCredentialType", data.Type.ToString()) }); var content = JsonSerializer.Serialize(new { data.Type, CredentialId = credentialId }, Options); - await _portalService.AddNotification(content, _identity.IdentityId, NotificationTypeId.CREDENTIAL_APPROVAL, cancellationToken).ConfigureAwait(false); + await _portalService.AddNotification(content, _identity.CompanyUserId.Value, NotificationTypeId.CREDENTIAL_APPROVAL, cancellationToken).ConfigureAwait(false); var mailParameters = new Dictionary { { "requestName", typeValue }, { "credentialType", typeValue }, { "expiryDate", expiry.ToString("o", CultureInfo.InvariantCulture) } }; - await _portalService.TriggerMail("CredentialApproval", _identity.IdentityId, mailParameters, cancellationToken).ConfigureAwait(false); + await _portalService.TriggerMail("CredentialApproval", _identity.CompanyUserId.Value, mailParameters, cancellationToken).ConfigureAwait(false); await _repositories.SaveAsync().ConfigureAwait(false); } @@ -272,6 +277,11 @@ private DateTimeOffset GetExpiryDate(DateTimeOffset? expiryDate) /// public async Task RejectCredential(Guid credentialId, CancellationToken cancellationToken) { + if (_identity.IsServiceAccount || _identity.CompanyUserId == null) + { + throw UnexpectedConditionException.Create(CredentialErrors.USER_MUST_NOT_BE_TECHNICAL_USER, new ErrorParameter[] { new("identityId", _identity.IdentityId) }); + } + var companySsiRepository = _repositories.GetInstance(); var (exists, status, type, processId, processStepIds) = await companySsiRepository.GetSsiRejectionData(credentialId).ConfigureAwait(false); if (!exists) @@ -286,7 +296,7 @@ public async Task RejectCredential(Guid credentialId, CancellationToken cancella var typeValue = type.GetEnumValue() ?? throw UnexpectedConditionException.Create(CredentialErrors.CREDENTIAL_TYPE_NOT_FOUND, new ErrorParameter[] { new("verifiedCredentialType", type.ToString()) }); var content = JsonSerializer.Serialize(new { Type = type, CredentialId = credentialId }, Options); - await _portalService.AddNotification(content, _identity.IdentityId, NotificationTypeId.CREDENTIAL_REJECTED, cancellationToken).ConfigureAwait(false); + await _portalService.AddNotification(content, _identity.CompanyUserId.Value, NotificationTypeId.CREDENTIAL_REJECTED, cancellationToken).ConfigureAwait(false); var mailParameters = new Dictionary { @@ -294,7 +304,7 @@ public async Task RejectCredential(Guid credentialId, CancellationToken cancella { "reason", "Declined by the Operator" } }; - await _portalService.TriggerMail("CredentialRejected", _identity.IdentityId, mailParameters, cancellationToken).ConfigureAwait(false); + await _portalService.TriggerMail("CredentialRejected", _identity.CompanyUserId.Value, mailParameters, cancellationToken).ConfigureAwait(false); companySsiRepository.AttachAndModifyCompanySsiDetails(credentialId, c => { @@ -429,7 +439,7 @@ public async Task CreateFrameworkCredential(CreateFrameworkCredentialReque StatusList) ); var schema = JsonSerializer.Serialize(schemaData, Options); - return await HandleCredentialProcessCreation(_identity.Bpnl, VerifiedCredentialTypeKindId.FRAMEWORK, requestData.UseCaseFrameworkId, schema, requestData.TechnicalUserDetails, requestData.UseCaseFrameworkVersionId, requestData.CallbackUrl, companyCredentialDetailsRepository); + return await HandleCredentialProcessCreation(requestData.HolderBpn, VerifiedCredentialTypeKindId.FRAMEWORK, requestData.UseCaseFrameworkId, schema, requestData.TechnicalUserDetails, requestData.UseCaseFrameworkVersionId, requestData.CallbackUrl, companyCredentialDetailsRepository); } private async Task GetHolderInformation(string didDocumentLocation, CancellationToken cancellationToken) @@ -467,7 +477,7 @@ private async Task HandleCredentialProcessCreation( var docId = documentRepository.CreateDocument("schema.json", documentContent, hash, MediaTypeId.JSON, DocumentTypeId.PRESENTATION, x => { - x.CompanyUserId = _identity.IdentityId; + x.IdentityId = _identity.IdentityId; x.DocumentStatusId = DocumentStatusId.ACTIVE; }).Id; @@ -506,6 +516,7 @@ private async Task HandleCredentialProcessCreation( c.ClientId = technicalUserDetails.ClientId; c.ClientSecret = secret; c.InitializationVector = initializationVector; + c.EncryptionMode = _settings.EncrptionConfigIndex; c.HolderWalletUrl = technicalUserDetails.WalletUrl; c.CallbackUrl = callbackUrl; }); diff --git a/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerSettings.cs b/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerSettings.cs index fda6d5c9..367ad9f0 100644 --- a/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerSettings.cs +++ b/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerSettings.cs @@ -57,6 +57,7 @@ public static IServiceCollection ConfigureCredentialSettings( { services.AddOptions() .Bind(section) + .ValidateDataAnnotations() .ValidateDistinctValues(section) .ValidateEnumEnumeration(section) .ValidateOnStart(); diff --git a/src/issuer/SsiCredentialIssuer.Service/Controllers/IssuerController.cs b/src/issuer/SsiCredentialIssuer.Service/Controllers/IssuerController.cs index 62fd8f06..0f685e6d 100644 --- a/src/issuer/SsiCredentialIssuer.Service/Controllers/IssuerController.cs +++ b/src/issuer/SsiCredentialIssuer.Service/Controllers/IssuerController.cs @@ -124,7 +124,6 @@ public static RouteGroupBuilder MapIssuerApi(this RouteGroupBuilder group) .RequireAuthorization(r => { r.RequireRole(RequestSsiRole); - r.AddRequirements(new MandatoryIdentityClaimRequirement(PolicyTypeId.ValidBpn)); r.AddRequirements(new MandatoryIdentityClaimRequirement(PolicyTypeId.ValidIdentity)); }) .WithDefaultResponses() diff --git a/src/issuer/SsiCredentialIssuer.Service/ErrorHandling/CredentialErrorMessageContainer.cs b/src/issuer/SsiCredentialIssuer.Service/ErrorHandling/CredentialErrorMessageContainer.cs index 8168311f..86015c51 100644 --- a/src/issuer/SsiCredentialIssuer.Service/ErrorHandling/CredentialErrorMessageContainer.cs +++ b/src/issuer/SsiCredentialIssuer.Service/ErrorHandling/CredentialErrorMessageContainer.cs @@ -54,6 +54,7 @@ public class CredentialErrorMessageContainer : IErrorMessageContainer { CredentialErrors.DID_NOT_SET, "Did must not be null" }, { CredentialErrors.ALREADY_LINKED_PROCESS, "Credential should not already be linked to a process" }, { CredentialErrors.INVALID_DID_LOCATION, "The did url location must be a valid url" }, + { CredentialErrors.USER_MUST_NOT_BE_TECHNICAL_USER, "The endpoint can not be called by a technical user" }, }.ToImmutableDictionary(x => (int)x.Key, x => x.Value); public Type Type { get => typeof(CredentialErrors); } @@ -88,5 +89,6 @@ public enum CredentialErrors MULTIPLE_USE_CASES, DID_NOT_SET, ALREADY_LINKED_PROCESS, - INVALID_DID_LOCATION + INVALID_DID_LOCATION, + USER_MUST_NOT_BE_TECHNICAL_USER } diff --git a/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimTypes.cs b/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimTypes.cs index 1dc65bea..6f251550 100644 --- a/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimTypes.cs +++ b/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimTypes.cs @@ -22,5 +22,6 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Service.Identity; public static class ClaimTypes { public const string PreferredUserName = "preferred_username"; + public const string ClientId = "client_id"; public const string Bpn = "bpn"; } diff --git a/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimsIdentityDataBuilder.cs b/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimsIdentityDataBuilder.cs index 8924ed10..8f6c321b 100644 --- a/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimsIdentityDataBuilder.cs +++ b/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimsIdentityDataBuilder.cs @@ -23,21 +23,35 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Service.Identity; public class ClaimsIdentityDataBuilder : IClaimsIdentityDataBuilder { - private Guid? _identityId; + private string? _identityId; + private Guid? _companyUserId; private string? _bpnl; + private bool? _isServiceAccount; - public Guid IdentityId { get => _identityId ?? throw new UnexpectedConditionException("userId should never be null here (endpoint must be annotated with an identity policy)"); } + public string IdentityId { get => _identityId ?? throw new UnexpectedConditionException("userId should never be null here (endpoint must be annotated with an identity policy)"); } + public Guid? CompanyUserId { get => _companyUserId; } public string Bpnl { get => _bpnl ?? throw new UnexpectedConditionException("bpnl should never be null here (endpoint must be annotated with an identity policy)"); } + public bool IsServiceAccount { get => _isServiceAccount ?? throw new UnexpectedConditionException("isServiceAccount should never be null here (endpoint must be annotated with an isServiceACcount"); } - public void AddIdentityId(Guid identityId) + public void AddIdentityId(string identityId) { _identityId = identityId; } + public void AddCompanyUserId(Guid companyUserId) + { + _companyUserId = companyUserId; + } + public void AddBpnl(string bpnl) { _bpnl = bpnl; } + public void AddIsServiceAccount(bool isServiceAccount) + { + _isServiceAccount = isServiceAccount; + } + public IClaimsIdentityDataBuilderStatus Status { get; set; } = IClaimsIdentityDataBuilderStatus.Initial; } diff --git a/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimsIdentityService.cs b/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimsIdentityService.cs index 615f4d01..8e55c3c9 100644 --- a/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimsIdentityService.cs +++ b/src/issuer/SsiCredentialIssuer.Service/Identity/ClaimsIdentityService.cs @@ -32,5 +32,5 @@ public ClaimsIdentityService(IClaimsIdentityDataBuilder claimsIdentityDataBuilde public IIdentityData IdentityData => _identityData; - public Guid IdentityId => _identityData.IdentityId; + public string IdentityId => _identityData.IdentityId; } diff --git a/src/issuer/SsiCredentialIssuer.Service/Identity/IClaimsIdentityDataBuilder.cs b/src/issuer/SsiCredentialIssuer.Service/Identity/IClaimsIdentityDataBuilder.cs index fa683915..01711c63 100644 --- a/src/issuer/SsiCredentialIssuer.Service/Identity/IClaimsIdentityDataBuilder.cs +++ b/src/issuer/SsiCredentialIssuer.Service/Identity/IClaimsIdentityDataBuilder.cs @@ -21,7 +21,9 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Service.Identity; public interface IClaimsIdentityDataBuilder : IIdentityData { - void AddIdentityId(Guid identityId); + void AddIdentityId(string identityId); + void AddCompanyUserId(Guid companyUserId); + void AddIsServiceAccount(bool isServiceAccount); void AddBpnl(string bpnl); IClaimsIdentityDataBuilderStatus Status { get; set; } } diff --git a/src/issuer/SsiCredentialIssuer.Service/Identity/IIdentityData.cs b/src/issuer/SsiCredentialIssuer.Service/Identity/IIdentityData.cs index 70184a6c..e10a734e 100644 --- a/src/issuer/SsiCredentialIssuer.Service/Identity/IIdentityData.cs +++ b/src/issuer/SsiCredentialIssuer.Service/Identity/IIdentityData.cs @@ -21,6 +21,8 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Service.Identity; public interface IIdentityData { - Guid IdentityId { get; } + string IdentityId { get; } + Guid? CompanyUserId { get; } string Bpnl { get; } + bool IsServiceAccount { get; } } diff --git a/src/issuer/SsiCredentialIssuer.Service/Identity/IdentityIdService.cs b/src/issuer/SsiCredentialIssuer.Service/Identity/IdentityIdService.cs deleted file mode 100644 index ebfa998e..00000000 --- a/src/issuer/SsiCredentialIssuer.Service/Identity/IdentityIdService.cs +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************** - * 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.Auditing.Identity; - -namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Service.Identity; - -public class IdentityIdService : IIdentityIdService -{ - private readonly IHttpContextAccessor _httpContextAccessor; - - public IdentityIdService(IHttpContextAccessor httpContextAccessor) - { - _httpContextAccessor = httpContextAccessor; - } - - public Guid IdentityId => GetIdentityId(); - - private Guid GetIdentityId() - { - var preferredUserName = _httpContextAccessor?.HttpContext?.User.Claims.SingleOrDefault(x => x.Type == ClaimTypes.PreferredUserName)?.Value ?? - throw new UnexpectedConditionException("Username must be set here"); - if (Guid.TryParse(preferredUserName, out var identityId)) - { - return identityId; - } - - throw new UnexpectedConditionException("Username must be a uuid"); - } -} diff --git a/src/issuer/SsiCredentialIssuer.Service/Identity/MandatoryIdentityClaimHandler.cs b/src/issuer/SsiCredentialIssuer.Service/Identity/MandatoryIdentityClaimHandler.cs index 8d8ccca6..2bc6efdc 100644 --- a/src/issuer/SsiCredentialIssuer.Service/Identity/MandatoryIdentityClaimHandler.cs +++ b/src/issuer/SsiCredentialIssuer.Service/Identity/MandatoryIdentityClaimHandler.cs @@ -59,7 +59,7 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte if (requirement.PolicyTypeId switch { - PolicyTypeId.ValidIdentity => _identityDataBuilder.IdentityId != Guid.Empty, + PolicyTypeId.ValidIdentity => _identityDataBuilder.IdentityId != string.Empty, PolicyTypeId.ValidBpn => !string.IsNullOrWhiteSpace(_identityDataBuilder.Bpnl), _ => throw new UnexpectedConditionException($"unexpected PolicyTypeId {requirement.PolicyTypeId}") }) @@ -77,23 +77,27 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte private void InitializeClaims(ClaimsPrincipal principal) { var preferredUserName = principal.Claims.SingleOrDefault(x => x.Type == ClaimTypes.PreferredUserName)?.Value; - if (!Guid.TryParse(preferredUserName, out var identityId)) + var clientId = principal.Claims.SingleOrDefault(x => x.Type == ClaimTypes.ClientId)?.Value; + if (preferredUserName == null && clientId == null) { - _logger.LogInformation("Preferred user name {PreferredUserName} couldn't be parsed to uuid", preferredUserName); + _logger.LogInformation("Both preferred_user_name and client_id are null"); _identityDataBuilder.Status = IClaimsIdentityDataBuilderStatus.Empty; return; } var bpnl = principal.Claims.SingleOrDefault(x => x.Type == ClaimTypes.Bpn)?.Value; - if (string.IsNullOrWhiteSpace(bpnl)) + if (!string.IsNullOrWhiteSpace(bpnl)) // we only set the bpn if available, technical users don't have the bpn in the claims { - _logger.LogInformation("Bpn must be set for user {PreferredUserName}", preferredUserName); - _identityDataBuilder.Status = IClaimsIdentityDataBuilderStatus.Empty; - return; + _identityDataBuilder.AddBpnl(bpnl); } - _identityDataBuilder.AddIdentityId(identityId); - _identityDataBuilder.AddBpnl(bpnl); + _identityDataBuilder.AddIdentityId(preferredUserName ?? clientId!); + bool isCompanyUser; + if (isCompanyUser = Guid.TryParse(preferredUserName, out var companyUserId)) + { + _identityDataBuilder.AddCompanyUserId(companyUserId); + } + _identityDataBuilder.AddIsServiceAccount(!isCompanyUser); _identityDataBuilder.Status = IClaimsIdentityDataBuilderStatus.Complete; } } diff --git a/src/processes/Processes.Worker.Library/DependencyInjection/ServiceCollectionExtensions.cs b/src/processes/Processes.Worker.Library/DependencyInjection/ServiceCollectionExtensions.cs index 2f560c87..a2b642ca 100644 --- a/src/processes/Processes.Worker.Library/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/processes/Processes.Worker.Library/DependencyInjection/ServiceCollectionExtensions.cs @@ -27,7 +27,11 @@ public static class ServiceCollectionExtensions { public static IServiceCollection AddProcessIdentity(this IServiceCollection services, IConfigurationSection section) { - services.AddOptions().Bind(section); + services.AddOptions() + .Bind(section) + .ValidateDataAnnotations() + .ValidateOnStart(); + return services .AddTransient(); } diff --git a/src/processes/Processes.Worker.Library/ProcessExecutionServiceSettings.cs b/src/processes/Processes.Worker.Library/ProcessExecutionServiceSettings.cs index ae00657c..9d3642f6 100644 --- a/src/processes/Processes.Worker.Library/ProcessExecutionServiceSettings.cs +++ b/src/processes/Processes.Worker.Library/ProcessExecutionServiceSettings.cs @@ -27,5 +27,5 @@ public class ProcessExecutionServiceSettings public int LockExpirySeconds { get; set; } [Required] - public Guid IdentityId { get; set; } + public string IdentityId { get; set; } = null!; } diff --git a/src/processes/Processes.Worker.Library/ProcessIdentityIdService.cs b/src/processes/Processes.Worker.Library/ProcessIdentityIdService.cs index f553f834..7583853b 100644 --- a/src/processes/Processes.Worker.Library/ProcessIdentityIdService.cs +++ b/src/processes/Processes.Worker.Library/ProcessIdentityIdService.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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.Options; using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Auditing.Identity; @@ -12,5 +31,5 @@ public ProcessIdentityIdService(IOptions option _settings = options.Value; } - public Guid IdentityId => _settings.IdentityId; + public string IdentityId => _settings.IdentityId; } diff --git a/src/processes/Processes.Worker.Library/Processes.Worker.Library.csproj b/src/processes/Processes.Worker.Library/Processes.Worker.Library.csproj index d2867026..be16ad8b 100644 --- a/src/processes/Processes.Worker.Library/Processes.Worker.Library.csproj +++ b/src/processes/Processes.Worker.Library/Processes.Worker.Library.csproj @@ -29,8 +29,10 @@ + + diff --git a/tests/Tests.Shared/FakeIdentity.cs b/tests/Tests.Shared/FakeIdentity.cs index 32df8a14..8c2da458 100644 --- a/tests/Tests.Shared/FakeIdentity.cs +++ b/tests/Tests.Shared/FakeIdentity.cs @@ -23,6 +23,8 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Tests.Shared; public class FakeIdentity : IIdentityData { - public Guid IdentityId => new("ac1cf001-7fbc-1f2f-817f-bce058020001"); + public string IdentityId => "ac1cf001-7fbc-1f2f-817f-bce058020001"; + public Guid? CompanyUserId => new Guid("ac1cf001-7fbc-1f2f-817f-bce058020001"); public string Bpnl => "BPNL00000003AYRE"; + public bool IsServiceAccount => false; } diff --git a/tests/Tests.Shared/FakeIdentityIdService.cs b/tests/Tests.Shared/FakeIdentityIdService.cs index 75a45577..57ef9a06 100644 --- a/tests/Tests.Shared/FakeIdentityIdService.cs +++ b/tests/Tests.Shared/FakeIdentityIdService.cs @@ -23,7 +23,5 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Tests.Shared; public class FakeIdentityIdService : IIdentityIdService { - private readonly Guid _identityId = new("ac1cf001-7fbc-1f2f-817f-bce058020001"); - - public Guid IdentityId => _identityId; + public string IdentityId => "ac1cf001-7fbc-1f2f-817f-bce058020001"; } diff --git a/tests/Tests.Shared/FakeIdentityService.cs b/tests/Tests.Shared/FakeIdentityService.cs index cc887a6c..d929b05b 100644 --- a/tests/Tests.Shared/FakeIdentityService.cs +++ b/tests/Tests.Shared/FakeIdentityService.cs @@ -23,6 +23,6 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Tests.Shared; public class FakeIdentityService : IIdentityService { - public Guid IdentityId => IdentityData.IdentityId; + public string IdentityId => IdentityData.IdentityId; public IIdentityData IdentityData { get; } = new FakeIdentity(); } diff --git a/tests/credentials/SsiCredentialIssuer.Expiry.App.Tests/ExpiryCheckServiceTests.cs b/tests/credentials/SsiCredentialIssuer.Expiry.App.Tests/ExpiryCheckServiceTests.cs index ffa94ee0..f454e8a4 100644 --- a/tests/credentials/SsiCredentialIssuer.Expiry.App.Tests/ExpiryCheckServiceTests.cs +++ b/tests/credentials/SsiCredentialIssuer.Expiry.App.Tests/ExpiryCheckServiceTests.cs @@ -92,7 +92,7 @@ public async Task ExecuteAsync_WithInactiveAndEligibleForDeletion_RemovesEntry() .Create(); var data = new CredentialExpiryData[] { - new(credentialId, Guid.NewGuid(), inactiveVcsToDelete.AddDays(-1), null, null, Bpnl, CompanySsiDetailStatusId.INACTIVE, VerifiedCredentialTypeId.DISMANTLER_CERTIFICATE, credentialScheduleData) + new(credentialId, Guid.NewGuid().ToString(), inactiveVcsToDelete.AddDays(-1), null, null, Bpnl, CompanySsiDetailStatusId.INACTIVE, VerifiedCredentialTypeId.DISMANTLER_CERTIFICATE, credentialScheduleData) }; A.CallTo(() => _dateTimeProvider.OffsetNow).Returns(now); A.CallTo(() => _companySsiDetailsRepository.GetExpiryData(A._, A._, A._)) @@ -112,10 +112,11 @@ public async Task ExecuteAsync_WithPendingAndExpiryBeforeNow_DeclinesRequest() // Arrange var now = DateTimeOffset.UtcNow; var expiredVcsToDeleteInMonth = now.AddMonths(-_settings.ExpiredVcsToDeleteInMonth); - var ssiDetail = new CompanySsiDetail(Guid.NewGuid(), Bpnl, VerifiedCredentialTypeId.DISMANTLER_CERTIFICATE, CompanySsiDetailStatusId.PENDING, IssuerBpnl, Guid.NewGuid(), now) + var creatorUserId = Guid.NewGuid(); + var ssiDetail = new CompanySsiDetail(Guid.NewGuid(), Bpnl, VerifiedCredentialTypeId.DISMANTLER_CERTIFICATE, CompanySsiDetailStatusId.PENDING, IssuerBpnl, creatorUserId.ToString(), now) { ExpiryDate = expiredVcsToDeleteInMonth.AddDays(-2), - CreatorUserId = Guid.NewGuid() + CreatorUserId = creatorUserId.ToString() }; var credentialScheduleData = _fixture.Build() .With(x => x.IsVcToDecline, true) @@ -141,8 +142,8 @@ public async Task ExecuteAsync_WithPendingAndExpiryBeforeNow_DeclinesRequest() // Assert A.CallTo(() => _companySsiDetailsRepository.RemoveSsiDetail(ssiDetail.Id)).MustNotHaveHappened(); A.CallTo(() => _issuerRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); - A.CallTo(() => _portalService.AddNotification(A._, ssiDetail.CreatorUserId, NotificationTypeId.CREDENTIAL_REJECTED, A._)).MustHaveHappenedOnceExactly(); - A.CallTo(() => _portalService.TriggerMail("CredentialRejected", ssiDetail.CreatorUserId, A>._, A._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _portalService.AddNotification(A._, creatorUserId, NotificationTypeId.CREDENTIAL_REJECTED, A._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _portalService.TriggerMail("CredentialRejected", creatorUserId, A>._, A._)).MustHaveHappenedOnceExactly(); ssiDetail.CompanySsiDetailStatusId.Should().Be(CompanySsiDetailStatusId.INACTIVE); } @@ -155,11 +156,12 @@ public async Task ExecuteAsync_WithActiveCloseToExpiry_NotifiesCreator(int days, { // Arrange var now = DateTimeOffset.UtcNow; - var ssiDetail = new CompanySsiDetail(Guid.NewGuid(), Bpnl, VerifiedCredentialTypeId.DISMANTLER_CERTIFICATE, CompanySsiDetailStatusId.ACTIVE, IssuerBpnl, Guid.NewGuid(), now) + var creatorUserId = Guid.NewGuid(); + var ssiDetail = new CompanySsiDetail(Guid.NewGuid(), Bpnl, VerifiedCredentialTypeId.DISMANTLER_CERTIFICATE, CompanySsiDetailStatusId.ACTIVE, IssuerBpnl, creatorUserId.ToString(), now) { ExpiryDate = now.AddDays(-days), ExpiryCheckTypeId = currentExpiryCheckTypeId, - CreatorUserId = Guid.NewGuid() + CreatorUserId = creatorUserId.ToString() }; var credentialScheduleData = _fixture.Build() .With(x => x.IsVcToDecline, false) @@ -188,8 +190,8 @@ public async Task ExecuteAsync_WithActiveCloseToExpiry_NotifiesCreator(int days, // Assert A.CallTo(() => _companySsiDetailsRepository.RemoveSsiDetail(ssiDetail.Id)).MustNotHaveHappened(); A.CallTo(() => _issuerRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); - A.CallTo(() => _portalService.AddNotification(A._, ssiDetail.CreatorUserId, NotificationTypeId.CREDENTIAL_EXPIRY, A._)).MustHaveHappenedOnceExactly(); - A.CallTo(() => _portalService.TriggerMail("CredentialExpiry", ssiDetail.CreatorUserId, A>._, A._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _portalService.AddNotification(A._, creatorUserId, NotificationTypeId.CREDENTIAL_EXPIRY, A._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _portalService.TriggerMail("CredentialExpiry", creatorUserId, A>._, A._)).MustHaveHappenedOnceExactly(); ssiDetail.ExpiryCheckTypeId.Should().Be(expiryCheckTypeId); } diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/CompanySsiDetailsRepositoryTests.cs b/tests/database/SsiCredentialIssuer.DbAccess.Tests/CompanySsiDetailsRepositoryTests.cs index 09e18438..0674bd99 100644 --- a/tests/database/SsiCredentialIssuer.DbAccess.Tests/CompanySsiDetailsRepositoryTests.cs +++ b/tests/database/SsiCredentialIssuer.DbAccess.Tests/CompanySsiDetailsRepositoryTests.cs @@ -35,7 +35,7 @@ public class CompanySsiDetailsRepositoryTests { private const string ValidBpnl = "BPNL00000003AYRE"; private readonly TestDbFixture _dbTestDbFixture; - private readonly Guid _userId = new("ac1cf001-7fbc-1f2f-817f-bce058020006"); + private readonly string _userId = "ac1cf001-7fbc-1f2f-817f-bce058020006"; public CompanySsiDetailsRepositoryTests(TestDbFixture testDbFixture) { diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/IssuerDbContextTests.cs b/tests/database/SsiCredentialIssuer.DbAccess.Tests/IssuerDbContextTests.cs index 35ec7098..502354e9 100644 --- a/tests/database/SsiCredentialIssuer.DbAccess.Tests/IssuerDbContextTests.cs +++ b/tests/database/SsiCredentialIssuer.DbAccess.Tests/IssuerDbContextTests.cs @@ -61,7 +61,7 @@ public async Task SaveCreatedAuditableEntity_SetsLastEditorId() var before = now.AddDays(-1); var id = Guid.NewGuid(); - var ca = new CompanySsiDetail(id, "BPNL00000001TEST", VerifiedCredentialTypeId.BUSINESS_PARTNER_NUMBER, CompanySsiDetailStatusId.ACTIVE, "BPNL0001ISSUER", new Guid("ac1cf001-7fbc-1f2f-817f-bce058020001"), before); + var ca = new CompanySsiDetail(id, "BPNL00000001TEST", VerifiedCredentialTypeId.BUSINESS_PARTNER_NUMBER, CompanySsiDetailStatusId.ACTIVE, "BPNL0001ISSUER", "ac1cf001-7fbc-1f2f-817f-bce058020001", before); var sut = await CreateContext().ConfigureAwait(false); using var trans = await sut.Database.BeginTransactionAsync().ConfigureAwait(false); @@ -71,11 +71,11 @@ public async Task SaveCreatedAuditableEntity_SetsLastEditorId() await sut.SaveChangesAsync().ConfigureAwait(false); // Assert - ca.LastEditorId.Should().NotBeNull().And.Be(new Guid("ac1cf001-7fbc-1f2f-817f-bce058020001")); + ca.LastEditorId.Should().NotBeNull().And.Be("ac1cf001-7fbc-1f2f-817f-bce058020001"); ca.DateLastChanged.Should().Be(now); - var auditEntries = await sut.AuditCompanySsiDetail20240228.Where(x => x.Id == id).ToListAsync(); - auditEntries.Should().ContainSingle().Which.Should().Match( - x => x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE && (x.DateCreated - before) < TimeSpan.FromSeconds(1) && x.AuditV1OperationId == AuditOperationId.INSERT && (x.AuditV1DateLastChanged - now) < TimeSpan.FromSeconds(1) && x.LastEditorId == new Guid("ac1cf001-7fbc-1f2f-817f-bce058020001")); + var auditEntries = await sut.AuditCompanySsiDetail20240419.Where(x => x.Id == id).ToListAsync(); + auditEntries.Should().ContainSingle().Which.Should().Match( + x => x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE && (x.DateCreated - before) < TimeSpan.FromSeconds(1) && x.AuditV2OperationId == AuditOperationId.INSERT && (x.AuditV2DateLastChanged - now) < TimeSpan.FromSeconds(1) && x.LastEditorId == "ac1cf001-7fbc-1f2f-817f-bce058020001"); await trans.RollbackAsync().ConfigureAwait(false); } @@ -89,7 +89,7 @@ public async Task SaveDeletedAuditableEntity_SetsLastEditorId() var before = now.AddDays(-1); var id = Guid.NewGuid(); - var ca = new CompanySsiDetail(id, "BPNL00000001TEST", VerifiedCredentialTypeId.BUSINESS_PARTNER_NUMBER, CompanySsiDetailStatusId.ACTIVE, "BPNL0001ISSUER", new Guid("ac1cf001-7fbc-1f2f-817f-bce058020001"), before); + var ca = new CompanySsiDetail(id, "BPNL00000001TEST", VerifiedCredentialTypeId.BUSINESS_PARTNER_NUMBER, CompanySsiDetailStatusId.ACTIVE, "BPNL0001ISSUER", "ac1cf001-7fbc-1f2f-817f-bce058020001", before); var sut = await CreateContext().ConfigureAwait(false); using var trans = await sut.Database.BeginTransactionAsync().ConfigureAwait(false); @@ -101,12 +101,12 @@ public async Task SaveDeletedAuditableEntity_SetsLastEditorId() await sut.SaveChangesAsync().ConfigureAwait(false); // Assert - ca.LastEditorId.Should().NotBeNull().And.Be(new Guid("ac1cf001-7fbc-1f2f-817f-bce058020001")); + ca.LastEditorId.Should().NotBeNull().And.Be("ac1cf001-7fbc-1f2f-817f-bce058020001"); ca.DateLastChanged.Should().Be(later); - var auditEntries = await sut.AuditCompanySsiDetail20240228.Where(x => x.Id == id).ToListAsync(); + var auditEntries = await sut.AuditCompanySsiDetail20240419.Where(x => x.Id == id).ToListAsync(); auditEntries.Should().HaveCount(2).And.Satisfy( - x => x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE && (x.DateCreated - before) < TimeSpan.FromSeconds(1) && x.AuditV1OperationId == AuditOperationId.INSERT && x.LastEditorId == new Guid("ac1cf001-7fbc-1f2f-817f-bce058020001"), - x => x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE && (x.DateCreated - before) < TimeSpan.FromSeconds(1) && x.AuditV1OperationId == AuditOperationId.DELETE && (x.AuditV1DateLastChanged - later) < TimeSpan.FromSeconds(1) && x.LastEditorId == new Guid("ac1cf001-7fbc-1f2f-817f-bce058020001")); + x => x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE && (x.DateCreated - before) < TimeSpan.FromSeconds(1) && x.AuditV2OperationId == AuditOperationId.INSERT && x.LastEditorId == "ac1cf001-7fbc-1f2f-817f-bce058020001", + x => x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE && (x.DateCreated - before) < TimeSpan.FromSeconds(1) && x.AuditV2OperationId == AuditOperationId.DELETE && (x.AuditV2DateLastChanged - later) < TimeSpan.FromSeconds(1) && x.LastEditorId == "ac1cf001-7fbc-1f2f-817f-bce058020001"); await trans.RollbackAsync().ConfigureAwait(false); } diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Setup/TestDbFixture.cs b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Setup/TestDbFixture.cs index 742d9c28..9095640a 100644 --- a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Setup/TestDbFixture.cs +++ b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Setup/TestDbFixture.cs @@ -61,7 +61,7 @@ public async Task GetDbContext(IDateTimeProvider? dateTimeProvi x => x.MigrationsAssembly(typeof(BatchInsertSeeder).Assembly.GetName().Name) .MigrationsHistoryTable("__efmigrations_history_issuer") ); - var context = new IssuerDbContext(optionsBuilder.Options, new AuditHandlerV1(new FakeIdentityIdService(), dateTimeProvider ?? new UtcDateTimeProvider())); + var context = new IssuerDbContext(optionsBuilder.Options, new AuditHandlerV2(new FakeIdentityIdService(), dateTimeProvider ?? new UtcDateTimeProvider())); await context.Database.EnsureCreatedAsync().ConfigureAwait(false); foreach (var seedAction in seedActions) { @@ -87,7 +87,7 @@ await _container.StartAsync() x => x.MigrationsAssembly(typeof(BatchInsertSeeder).Assembly.GetName().Name) .MigrationsHistoryTable("__efmigrations_history_issuer") ); - var context = new IssuerDbContext(optionsBuilder.Options, new AuditHandlerV1(new FakeIdentityIdService(), new UtcDateTimeProvider())); + var context = new IssuerDbContext(optionsBuilder.Options, new AuditHandlerV2(new FakeIdentityIdService(), new UtcDateTimeProvider())); await context.Database.MigrateAsync(); var seederOptions = Options.Create(new SeederSettings diff --git a/tests/externalservices/Wallet.Service.Tests/BusinessLogic/WalletBusinessLogicTests.cs b/tests/externalservices/Wallet.Service.Tests/BusinessLogic/WalletBusinessLogicTests.cs index a35049f1..1ed9d7db 100644 --- a/tests/externalservices/Wallet.Service.Tests/BusinessLogic/WalletBusinessLogicTests.cs +++ b/tests/externalservices/Wallet.Service.Tests/BusinessLogic/WalletBusinessLogicTests.cs @@ -74,7 +74,7 @@ public async Task CreateCredential_CallsExpected() var id = Guid.NewGuid(); var externalId = Guid.NewGuid(); var schema = JsonDocument.Parse("{}"); - var ssiDetail = new CompanySsiDetail(id, null!, VerifiedCredentialTypeId.BUSINESS_PARTNER_NUMBER, CompanySsiDetailStatusId.ACTIVE, IssuerBpnl, Guid.NewGuid(), DateTimeOffset.UtcNow); + var ssiDetail = new CompanySsiDetail(id, null!, VerifiedCredentialTypeId.BUSINESS_PARTNER_NUMBER, CompanySsiDetailStatusId.ACTIVE, IssuerBpnl, Guid.NewGuid().ToString(), DateTimeOffset.UtcNow); A.CallTo(() => _companySsiDetailRepository.AttachAndModifyCompanySsiDetails(A._, A>._, A>._)) .Invokes((Guid _, Action? initialize, Action setupOptionalFields) => { @@ -105,7 +105,7 @@ public async Task SignCredential_CallsExpected() // Arrange var id = Guid.NewGuid(); var credentialId = Guid.NewGuid(); - var ssiDetail = new CompanySsiDetail(id, null!, VerifiedCredentialTypeId.BUSINESS_PARTNER_NUMBER, CompanySsiDetailStatusId.ACTIVE, IssuerBpnl, Guid.NewGuid(), DateTimeOffset.UtcNow); + var ssiDetail = new CompanySsiDetail(id, null!, VerifiedCredentialTypeId.BUSINESS_PARTNER_NUMBER, CompanySsiDetailStatusId.ACTIVE, IssuerBpnl, Guid.NewGuid().ToString(), DateTimeOffset.UtcNow); A.CallTo(() => _companySsiDetailRepository.AttachAndModifyCompanySsiDetails(A._, A>._, A>._)) .Invokes((Guid _, Action? initialize, Action setupOptionalFields) => { @@ -166,22 +166,29 @@ public async Task GetCredential_CallsExpected() // Arrange const string data = """ { - "id": "2e70ee49-5fae-438a-9435-0cce3854650d", - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://w3id.org/catenax/credentials/v1.0.0" - ], + "id": "f2ee21e938e217f362d3e7edac9e59a2b17d34017ef0f842e1f48513", "type": [ "VerifiableCredential", "BpnCredential" ], - "issuanceDate": "2022-06-16T18:56:59Z", - "expirationDate": "2022-06-16T18:56:59Z", - "issuer": "2e70ee49-5fae-438a-9435-0cce3854650d", + "issuer": "did:web:example.org:dim-hosted:2f45795c-d6cc-4038-96c9-63cedc0cd266:holder-iatp", + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://w3id.org/catenax/credentials/v1.0.0" + ], + "issuanceDate": "2024-04-22T17:02:33.568629+00:00", + "expirationDate": "2025-04-22T17:02:33.568629+00:00", + "credentialStatus": { + "id": "https://example.org/credentials/status/c5f1d9bb-42d5-42b7-a80a-ccbda6891df3/3e6f1f74-56e3-443a-a75e-320c301aca07#10", + "type": "StatusList2021Entry", + "statusPurpose": "revocation", + "statusListIndex": "10", + "statusListCredential": "https://example.org/credentials/status/c5f1d9bb-42d5-42b7-a80a-ccbda6891df3/3e6f1f74-56e3-443a-a75e-320c301aca07" + }, "credentialSubject": { - "id": "2e70ee49-5fae-438a-9435-0cce3854650d", - "holderIdentifier": "2e70ee49-5fae-438a-9435-0cce3854650d", - "bpn": "2e70ee49-5fae-438a-9435-0cce3854650d" + "id": "did:web:example.org:api:administration:staticdata:did:BPNL000001PS0000", + "bpn": "BPNL000001PS0000", + "holderIndentifier": "BPNL000001PS0000" } } """; diff --git a/tests/issuer/SsiCredentialIssuer.Service.Tests/BusinessLogic/IssuerBusinessLogicTests.cs b/tests/issuer/SsiCredentialIssuer.Service.Tests/BusinessLogic/IssuerBusinessLogicTests.cs index 4f35795d..add24e71 100644 --- a/tests/issuer/SsiCredentialIssuer.Service.Tests/BusinessLogic/IssuerBusinessLogicTests.cs +++ b/tests/issuer/SsiCredentialIssuer.Service.Tests/BusinessLogic/IssuerBusinessLogicTests.cs @@ -32,7 +32,6 @@ using Org.Eclipse.TractusX.SsiCredentialIssuer.Service.ErrorHandling; using Org.Eclipse.TractusX.SsiCredentialIssuer.Service.Identity; using Org.Eclipse.TractusX.SsiCredentialIssuer.Service.Models; -using Org.Eclipse.TractusX.SsiCredentialIssuer.Service.Tests.Setup; using System.Net; using System.Security.Cryptography; using System.Text.Json; @@ -80,7 +79,11 @@ public IssuerBusinessLogicTests() A.CallTo(() => _issuerRepositories.GetInstance()).Returns(_documentRepository); A.CallTo(() => _issuerRepositories.GetInstance()).Returns(_processStepRepository); - A.CallTo(() => _identity.IdentityId).Returns(Guid.NewGuid()); + var identityId = Guid.NewGuid(); + + A.CallTo(() => _identity.IdentityId).Returns(identityId.ToString()); + A.CallTo(() => _identity.CompanyUserId).Returns(identityId); + A.CallTo(() => _identity.IsServiceAccount).Returns(false); A.CallTo(() => _identity.Bpnl).Returns(Bpnl); A.CallTo(() => _identityService.IdentityData).Returns(_identity); @@ -365,7 +368,7 @@ public async Task ApproveCredential_WithValid_ReturnsExpected(VerifiedCredential detailData ); - var detail = new CompanySsiDetail(CredentialId, _identity.Bpnl, typeId, CompanySsiDetailStatusId.PENDING, "", Guid.NewGuid(), DateTimeOffset.Now); + var detail = new CompanySsiDetail(CredentialId, _identity.Bpnl, typeId, CompanySsiDetailStatusId.PENDING, "", Guid.NewGuid().ToString(), DateTimeOffset.Now); A.CallTo(() => _dateTimeProvider.OffsetNow).Returns(now); A.CallTo(() => _companySsiDetailsRepository.GetSsiApprovalData(CredentialId)) .Returns(new ValueTuple(true, data)); @@ -443,7 +446,7 @@ public async Task RejectCredential_WithValidRequest_ReturnsExpected() { // Arrange var now = DateTimeOffset.UtcNow; - var detail = new CompanySsiDetail(CredentialId, _identity.Bpnl, VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK, CompanySsiDetailStatusId.PENDING, IssuerBpnl, Guid.NewGuid(), DateTimeOffset.Now); + var detail = new CompanySsiDetail(CredentialId, _identity.Bpnl, VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK, CompanySsiDetailStatusId.PENDING, IssuerBpnl, Guid.NewGuid().ToString(), DateTimeOffset.Now); A.CallTo(() => _dateTimeProvider.OffsetNow).Returns(now); A.CallTo(() => _companySsiDetailsRepository.GetSsiRejectionData(CredentialId)) .Returns(new ValueTuple>( @@ -476,7 +479,7 @@ public async Task RejectCredential_WithValidRequestAndPendingProcessStepIds_Retu { // Arrange var now = DateTimeOffset.UtcNow; - var detail = new CompanySsiDetail(CredentialId, _identity.Bpnl, VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK, CompanySsiDetailStatusId.PENDING, IssuerBpnl, Guid.NewGuid(), DateTimeOffset.Now); + var detail = new CompanySsiDetail(CredentialId, _identity.Bpnl, VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK, CompanySsiDetailStatusId.PENDING, IssuerBpnl, Guid.NewGuid().ToString(), DateTimeOffset.Now); A.CallTo(() => _dateTimeProvider.OffsetNow).Returns(now); A.CallTo(() => _companySsiDetailsRepository.GetSsiRejectionData(CredentialId)) .Returns(new ValueTuple>( diff --git a/tests/issuer/SsiCredentialIssuer.Service.Tests/Identity/MandatoryIdentityClaimHandlerTests.cs b/tests/issuer/SsiCredentialIssuer.Service.Tests/Identity/MandatoryIdentityClaimHandlerTests.cs index 767614d6..e2f973d4 100644 --- a/tests/issuer/SsiCredentialIssuer.Service.Tests/Identity/MandatoryIdentityClaimHandlerTests.cs +++ b/tests/issuer/SsiCredentialIssuer.Service.Tests/Identity/MandatoryIdentityClaimHandlerTests.cs @@ -51,10 +51,7 @@ public MandatoryIdentityClaimHandlerTests() public async Task HandleValidRequirement_WithoutUsername_ReturnsExpected() { // Arrange - var principal = new ClaimsPrincipal(new ClaimsIdentity[] - { - new(new[] { new Claim("preferred_username", "00000000-0000-0000-0000-000000000000") }) - }); + var principal = new ClaimsPrincipal(Array.Empty()); var context = new AuthorizationHandlerContext(Enumerable.Repeat(new MandatoryIdentityClaimRequirement(PolicyTypeId.ValidIdentity), 1), principal, null); var sut = new MandatoryIdentityClaimHandler(_claimsIdentityDataBuilder, _logger); @@ -72,31 +69,6 @@ public async Task HandleValidRequirement_WithoutUsername_ReturnsExpected() .MustHaveHappenedOnceExactly(); } - [Fact] - public async Task HandleValidRequirement_WithUsernameWithoutBpn_ReturnsExpected() - { - // Arrange - var principal = new ClaimsPrincipal(new ClaimsIdentity[] - { - new(new[] - { - new Claim("preferred_username", "eb4f6b1d-cde2-4e7b-86d5-e678421c0bd3"), - }) - }); - - var context = new AuthorizationHandlerContext(Enumerable.Repeat(new MandatoryIdentityClaimRequirement(PolicyTypeId.ValidIdentity), 1), principal, null); - var sut = new MandatoryIdentityClaimHandler(_claimsIdentityDataBuilder, _logger); - - // Act - await sut.HandleAsync(context).ConfigureAwait(false); - - // Assert - context.HasSucceeded.Should().Be(false); - _claimsIdentityDataBuilder.Status.Should().Be(IClaimsIdentityDataBuilderStatus.Empty); - - Assert.Throws(() => _claimsIdentityDataBuilder.Bpnl); - } - [Fact] public async Task HandleValidRequirement_WithAllSet_ReturnsExpected() { @@ -120,7 +92,7 @@ public async Task HandleValidRequirement_WithAllSet_ReturnsExpected() context.HasSucceeded.Should().Be(true); _claimsIdentityDataBuilder.Status.Should().Be(IClaimsIdentityDataBuilderStatus.Complete); - _claimsIdentityDataBuilder.IdentityId.Should().Be(new Guid("eb4f6b1d-cde2-4e7b-86d5-e678421c0bd3")); + _claimsIdentityDataBuilder.IdentityId.Should().Be("eb4f6b1d-cde2-4e7b-86d5-e678421c0bd3"); _claimsIdentityDataBuilder.Bpnl.Should().Be(Bpnl); A.CallTo(() => _mockLogger.Log(A._, A._, A._)) .MustNotHaveHappened(); diff --git a/tests/issuer/SsiCredentialIssuer.Service.Tests/Setup/IntegrationTestFactory.cs b/tests/issuer/SsiCredentialIssuer.Service.Tests/Setup/IntegrationTestFactory.cs index db8ae172..3e9a9929 100644 --- a/tests/issuer/SsiCredentialIssuer.Service.Tests/Setup/IntegrationTestFactory.cs +++ b/tests/issuer/SsiCredentialIssuer.Service.Tests/Setup/IntegrationTestFactory.cs @@ -58,12 +58,8 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) var projectDir = Directory.GetCurrentDirectory(); var configPath = Path.Combine(projectDir, "appsettings.IntegrationTests.json"); - builder.ConfigureAppConfiguration((_, conf) => - { - conf.AddJsonFile(configPath, true) - .AddUserSecrets(Assembly.GetExecutingAssembly(), true) - .AddEnvironmentVariables(); - }); + var config = new ConfigurationBuilder().AddJsonFile(configPath, true).Build(); + builder.UseConfiguration(config); builder.ConfigureTestServices(services => { var identityService = services.SingleOrDefault(d => d.ServiceType.GetInterfaces().Contains(typeof(IIdentityService))); diff --git a/tests/issuer/SsiCredentialIssuer.Service.Tests/appsettings.IntegrationTests.json b/tests/issuer/SsiCredentialIssuer.Service.Tests/appsettings.IntegrationTests.json index 107e7db0..32a29359 100644 --- a/tests/issuer/SsiCredentialIssuer.Service.Tests/appsettings.IntegrationTests.json +++ b/tests/issuer/SsiCredentialIssuer.Service.Tests/appsettings.IntegrationTests.json @@ -1,19 +1,4 @@ { - "Serilog": { - "Using": [ "Serilog.Sinks.Console" ], - "MinimumLevel": { - "Default": "Debug" - }, - "WriteTo": [ - { "Name": "Console" } - ], - "Enrich": [ - "WithCorrelationId" - ], - "Properties": { - "Application": "PolicyHub" - } - }, "SwaggerEnabled": true, "HealthChecks": [], "Cors": { @@ -35,5 +20,29 @@ "ValidateLifetime": true, "ClockSkew": 600000 } + }, + "Portal": { + "Username": "empty", + "Password": "empty", + "ClientId": "sa-test", + "GrantType": "client_credentials", + "ClientSecret": "test", + "Scope": "openid", + "TokenAddress": "https://centralidp.example.org/auth/realms/test/protocol/openid-connect/token", + "BaseAddress": "https://localhost:5001" + }, + "Credential": { + "IssuerDid": "did:web:example.org:dim-hosted:2f45795c-d6cc-4038-96c9-63cedc0cd266:holder-iatp", + "IssuerBpn": "BPNL00000003CRHK", + "StatusListUrl": "https://example.org/credentials/status/c5f1d9bb-42d5-42b7-a80a-ccbda6891df3", + "EncryptionConfigIndex": 0, + "EncryptionConfigs": [ + { + "Index": 0, + "EncryptionKey": "9b1503084ab5638260079cb61b8ed2d1fde462b5a7608556516a1659aeb3f541", + "CipherMode": "CBC", + "PaddingMode": "PKCS7" + } + ] } }