diff --git a/.github/workflows/iam-seeding.yml b/.github/workflows/iam-seeding.yml
new file mode 100644
index 0000000000..4659e343bc
--- /dev/null
+++ b/.github/workflows/iam-seeding.yml
@@ -0,0 +1,85 @@
+###############################################################
+# Copyright (c) 2021, 2023 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
+###############################################################
+
+name: IAM Seeding
+
+on:
+ push:
+ paths:
+ # service and transitive paths
+ - 'src/framework/**'
+ - 'src/keycloak/**'
+ # workflow file
+ - '.github/workflows/iam-seeding.yml'
+ # dockerfile
+ - 'docker/Dockerfile-iam-seeding'
+
+ branches:
+ - 'dev'
+ workflow_dispatch:
+
+env:
+ IMAGE_NAMESPACE: "tractusx"
+ IMAGE_NAME: "portal-iam-seeding"
+
+jobs:
+ build-and-push-image:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Login to DockerHub
+ if: github.event_name != 'pull_request'
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKER_HUB_USER }}
+ password: ${{ secrets.DOCKER_HUB_TOKEN }}
+
+ - name: Docker meta
+ id: meta
+ uses: docker/metadata-action@v4
+ with:
+ images: ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}
+ tags: |
+ type=raw,value=dev
+ type=raw,value=${{ github.sha }}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v4
+ with:
+ context: .
+ file: docker/Dockerfile-iam-seeding
+ pull: true
+ push: ${{ github.event_name != 'pull_request' }}
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+
+ # https://github.com/peter-evans/dockerhub-description
+ - name: Update Docker Hub description
+ if: github.event_name != 'pull_request'
+ uses: peter-evans/dockerhub-description@v3
+ with:
+ username: ${{ secrets.DOCKER_HUB_USER }}
+ password: ${{ secrets.DOCKER_HUB_TOKEN }}
+ repository: ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}
+ readme-filepath: "./docker/notice-iam-seeding.md"
diff --git a/.github/workflows/release_iam-seeding.yml b/.github/workflows/release_iam-seeding.yml
new file mode 100644
index 0000000000..12b2b990e6
--- /dev/null
+++ b/.github/workflows/release_iam-seeding.yml
@@ -0,0 +1,76 @@
+###############################################################
+# Copyright (c) 2021, 2023 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
+###############################################################
+
+name: Release IAM Seeding
+
+on:
+ push:
+ tags:
+ - 'iam-v*.*.*'
+ workflow_dispatch:
+
+env:
+ IMAGE_NAMESPACE: "tractusx"
+ IMAGE_NAME: "portal-iam-seeding"
+
+jobs:
+ iam-seeding-release:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Login to DockerHub
+ if: github.event_name != 'pull_request'
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKER_HUB_USER }}
+ password: ${{ secrets.DOCKER_HUB_TOKEN }}
+
+ - name: Docker meta
+ id: meta
+ uses: docker/metadata-action@v4
+ with:
+ images: ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME}}
+ tags: |
+ type=raw,value=latest
+ type=raw,value=${{ github.ref_name }}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v4
+ with:
+ context: .
+ file: docker/Dockerfile-iam-seeding
+ pull: true
+ push: ${{ github.event_name != 'pull_request' }}
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+
+ # https://github.com/peter-evans/dockerhub-description
+ - name: Update Docker Hub description
+ if: github.event_name != 'pull_request'
+ uses: peter-evans/dockerhub-description@v3
+ with:
+ username: ${{ secrets.DOCKER_HUB_USER }}
+ password: ${{ secrets.DOCKER_HUB_TOKEN }}
+ repository: ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}
+ readme-filepath: "./docker/notice-iam-seeding.md"
diff --git a/.github/workflows/trivy-dev.yml b/.github/workflows/trivy-dev.yml
index 521ee1b415..2eb4b3cfe6 100644
--- a/.github/workflows/trivy-dev.yml
+++ b/.github/workflows/trivy-dev.yml
@@ -368,3 +368,36 @@ jobs:
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results11.sarif"
+
+ analyze-portal-iam_seeding:
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ # It's also possible to scan your private registry with Trivy's built-in image scan.
+ # All you have to do is set ENV vars.
+ # Docker Hub needs TRIVY_USERNAME and TRIVY_PASSWORD.
+ # You don't need to set ENV vars when downloading from a public repository.
+ # For public images, no ENV vars must be set.
+ - name: Run Trivy vulnerability scanner
+ if: always()
+ uses: aquasecurity/trivy-action@master
+ with:
+ # Path to Docker image
+ image-ref: "${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}-iam-seeding:dev"
+ format: "sarif"
+ output: "trivy-results12.sarif"
+ exit-code: "1"
+ severity: "CRITICAL,HIGH"
+
+ - name: Upload Trivy scan results to GitHub Security tab
+ if: always()
+ uses: github/codeql-action/upload-sarif@v2
+ with:
+ sarif_file: "trivy-results12.sarif"
diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml
index 48c1dd18e7..ae4abb2415 100644
--- a/.github/workflows/trivy.yml
+++ b/.github/workflows/trivy.yml
@@ -368,3 +368,36 @@ jobs:
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results11.sarif"
+
+ analyze-portal-iam_seeding:
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ # It's also possible to scan your private registry with Trivy's built-in image scan.
+ # All you have to do is set ENV vars.
+ # Docker Hub needs TRIVY_USERNAME and TRIVY_PASSWORD.
+ # You don't need to set ENV vars when downloading from a public repository.
+ # For public images, no ENV vars must be set.
+ - name: Run Trivy vulnerability scanner
+ if: always()
+ uses: aquasecurity/trivy-action@master
+ with:
+ # Path to Docker image
+ image-ref: "${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}-iam-seeding:latest"
+ format: "sarif"
+ output: "trivy-results12.sarif"
+ exit-code: "1"
+ severity: "CRITICAL,HIGH"
+
+ - name: Upload Trivy scan results to GitHub Security tab
+ if: always()
+ uses: github/codeql-action/upload-sarif@v2
+ with:
+ sarif_file: "trivy-results12.sarif"
diff --git a/.github/workflows/veracode.yaml b/.github/workflows/veracode.yaml
index 1012f62bfb..571af10a37 100644
--- a/.github/workflows/veracode.yaml
+++ b/.github/workflows/veracode.yaml
@@ -435,3 +435,46 @@ jobs:
vid: "${{ secrets.ORG_VERACODE_API_ID }}"
vkey: "${{ secrets.ORG_VERACODE_API_KEY }}"
include: 'Org.Eclipse.TractusX.Portal.Backend.Processes.Worker.dll'
+
+ analyze-iam-seeding:
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: ${{ env.DOTNET_VERSION }}
+
+ - name: Install dependencies
+ run: dotnet restore src/keycloak/Keycloak.Seeding
+
+ - name: Build and publish
+ run: |
+ cd src/keycloak/Keycloak.Seeding
+ dotnet build --no-restore
+ dotnet publish -c Debug -p:PublishDir=.\publish
+
+ - name: "Bundle files to scan"
+ run: >
+ zip -r portal-iam-seeding.zip
+ src/keycloak/Keycloak.Seeding/.publish
+
+ - name: Run Veracode Upload And Scan
+ uses: veracode/veracode-uploadandscan-action@0.2.1
+ with:
+ # Specify Veracode application name
+ appname: "Portal-IAM_Seeding"
+ createprofile: true
+ teams: 'portal'
+ # Specify path to upload
+ filepath: "portal-iam-seeding.zip"
+ vid: "${{ secrets.ORG_VERACODE_API_ID }}"
+ vkey: "${{ secrets.ORG_VERACODE_API_KEY }}"
+ include: 'Org.Eclipse.TractusX.Portal.Backend.Keycloak.Seeding.dll'
diff --git a/.tractusx b/.tractusx
index 516454ab19..b52629dca6 100644
--- a/.tractusx
+++ b/.tractusx
@@ -1 +1,20 @@
+###############################################################
+# Copyright (c) 2021, 2023 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
+###############################################################
+
leadingRepository: "https://github.com/eclipse-tractusx/portal-cd"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20dc91a695..7a3832c3cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,45 @@
New features, fixed bugs, known defects and other noteworthy changes to each release of the Catena-X Portal Backend.
+## 1.6.0-RC7
+
+### Change
+* All Services
+ * add an /api/info endpoint to retrieve specific api endpoints which can be used publicly for external services
+* Keycloak Seeding
+ * add seeding for keycloak realm-data from a json-file
+* Marketplace Service
+ * Removed PUT: /api/apps/appreleaseprocess/updateapp/{appId}
+* Process Worker:
+ * add error handling for BPDM Pull Process Steps
+
+### Technical Support
+* Logging
+ * removed machine name, processId, threadId from the logging message
+* TRG
+ * changed license notice for images
+ * add second license
+ * add file header to .tractusx
+
+### Bugfix
+* Administration Service
+ * fixed Get: api/administration/companydata/certificates when multiple certificates are in the database for a specific company
+ * add check for active offerSubscriptions when deleting a connector
+ * fixed api/administration/serviceaccount/owncompany/serviceaccounts
+* Company Service Accounts
+ * set identityTypeId when creating service accounts to company service account instead of company user
+ * change client_id of service accounts in seeding data
+ * add service accounts from cx-central base
+ * remove service account for daps
+* Marketplace Service
+ * fixed validation for /api/apps/AppReleaseProcess/instance-type/{appId} to only be executable for apps in state CREATED
+* Mail Templates
+ * fixed bpn display in the welcome email
+* Registration Service
+ * fixed Get: /api/registration/legalEntityAddress/{bpn}
+* Seeding
+ * TestDataEnvironments set to optional
+
## 1.6.0-RC6
### Change
diff --git a/LICENSES/CC-BY-4.0.txt b/LICENSES/CC-BY-4.0.txt
new file mode 100644
index 0000000000..4ea99c213c
--- /dev/null
+++ b/LICENSES/CC-BY-4.0.txt
@@ -0,0 +1,395 @@
+Attribution 4.0 International
+
+=======================================================================
+
+Creative Commons Corporation ("Creative Commons") is not a law firm and
+does not provide legal services or legal advice. Distribution of
+Creative Commons public licenses does not create a lawyer-client or
+other relationship. Creative Commons makes its licenses and related
+information available on an "as-is" basis. Creative Commons gives no
+warranties regarding its licenses, any material licensed under their
+terms and conditions, or any related information. Creative Commons
+disclaims all liability for damages resulting from their use to the
+fullest extent possible.
+
+Using Creative Commons Public Licenses
+
+Creative Commons public licenses provide a standard set of terms and
+conditions that creators and other rights holders may use to share
+original works of authorship and other material subject to copyright
+and certain other rights specified in the public license below. The
+following considerations are for informational purposes only, are not
+exhaustive, and do not form part of our licenses.
+
+ Considerations for licensors: Our public licenses are
+ intended for use by those authorized to give the public
+ permission to use material in ways otherwise restricted by
+ copyright and certain other rights. Our licenses are
+ irrevocable. Licensors should read and understand the terms
+ and conditions of the license they choose before applying it.
+ Licensors should also secure all rights necessary before
+ applying our licenses so that the public can reuse the
+ material as expected. Licensors should clearly mark any
+ material not subject to the license. This includes other CC-
+ licensed material, or material used under an exception or
+ limitation to copyright. More considerations for licensors:
+ wiki.creativecommons.org/Considerations_for_licensors
+
+ Considerations for the public: By using one of our public
+ licenses, a licensor grants the public permission to use the
+ licensed material under specified terms and conditions. If
+ the licensor's permission is not necessary for any reason--for
+ example, because of any applicable exception or limitation to
+ copyright--then that use is not regulated by the license. Our
+ licenses grant only permissions under copyright and certain
+ other rights that a licensor has authority to grant. Use of
+ the licensed material may still be restricted for other
+ reasons, including because others have copyright or other
+ rights in the material. A licensor may make special requests,
+ such as asking that all changes be marked or described.
+ Although not required by our licenses, you are encouraged to
+ respect those requests where reasonable. More considerations
+ for the public:
+ wiki.creativecommons.org/Considerations_for_licensees
+
+=======================================================================
+
+Creative Commons Attribution 4.0 International Public License
+
+By exercising the Licensed Rights (defined below), You accept and agree
+to be bound by the terms and conditions of this Creative Commons
+Attribution 4.0 International Public License ("Public License"). To the
+extent this Public License may be interpreted as a contract, You are
+granted the Licensed Rights in consideration of Your acceptance of
+these terms and conditions, and the Licensor grants You such rights in
+consideration of benefits the Licensor receives from making the
+Licensed Material available under these terms and conditions.
+
+
+Section 1 -- Definitions.
+
+ a. Adapted Material means material subject to Copyright and Similar
+ Rights that is derived from or based upon the Licensed Material
+ and in which the Licensed Material is translated, altered,
+ arranged, transformed, or otherwise modified in a manner requiring
+ permission under the Copyright and Similar Rights held by the
+ Licensor. For purposes of this Public License, where the Licensed
+ Material is a musical work, performance, or sound recording,
+ Adapted Material is always produced where the Licensed Material is
+ synched in timed relation with a moving image.
+
+ b. Adapter's License means the license You apply to Your Copyright
+ and Similar Rights in Your contributions to Adapted Material in
+ accordance with the terms and conditions of this Public License.
+
+ c. Copyright and Similar Rights means copyright and/or similar rights
+ closely related to copyright including, without limitation,
+ performance, broadcast, sound recording, and Sui Generis Database
+ Rights, without regard to how the rights are labeled or
+ categorized. For purposes of this Public License, the rights
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
+ Rights.
+
+ d. Effective Technological Measures means those measures that, in the
+ absence of proper authority, may not be circumvented under laws
+ fulfilling obligations under Article 11 of the WIPO Copyright
+ Treaty adopted on December 20, 1996, and/or similar international
+ agreements.
+
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
+ any other exception or limitation to Copyright and Similar Rights
+ that applies to Your use of the Licensed Material.
+
+ f. Licensed Material means the artistic or literary work, database,
+ or other material to which the Licensor applied this Public
+ License.
+
+ g. Licensed Rights means the rights granted to You subject to the
+ terms and conditions of this Public License, which are limited to
+ all Copyright and Similar Rights that apply to Your use of the
+ Licensed Material and that the Licensor has authority to license.
+
+ h. Licensor means the individual(s) or entity(ies) granting rights
+ under this Public License.
+
+ i. Share means to provide material to the public by any means or
+ process that requires permission under the Licensed Rights, such
+ as reproduction, public display, public performance, distribution,
+ dissemination, communication, or importation, and to make material
+ available to the public including in ways that members of the
+ public may access the material from a place and at a time
+ individually chosen by them.
+
+ j. Sui Generis Database Rights means rights other than copyright
+ resulting from Directive 96/9/EC of the European Parliament and of
+ the Council of 11 March 1996 on the legal protection of databases,
+ as amended and/or succeeded, as well as other essentially
+ equivalent rights anywhere in the world.
+
+ k. You means the individual or entity exercising the Licensed Rights
+ under this Public License. Your has a corresponding meaning.
+
+
+Section 2 -- Scope.
+
+ a. License grant.
+
+ 1. Subject to the terms and conditions of this Public License,
+ the Licensor hereby grants You a worldwide, royalty-free,
+ non-sublicensable, non-exclusive, irrevocable license to
+ exercise the Licensed Rights in the Licensed Material to:
+
+ a. reproduce and Share the Licensed Material, in whole or
+ in part; and
+
+ b. produce, reproduce, and Share Adapted Material.
+
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
+ Exceptions and Limitations apply to Your use, this Public
+ License does not apply, and You do not need to comply with
+ its terms and conditions.
+
+ 3. Term. The term of this Public License is specified in Section
+ 6(a).
+
+ 4. Media and formats; technical modifications allowed. The
+ Licensor authorizes You to exercise the Licensed Rights in
+ all media and formats whether now known or hereafter created,
+ and to make technical modifications necessary to do so. The
+ Licensor waives and/or agrees not to assert any right or
+ authority to forbid You from making technical modifications
+ necessary to exercise the Licensed Rights, including
+ technical modifications necessary to circumvent Effective
+ Technological Measures. For purposes of this Public License,
+ simply making modifications authorized by this Section 2(a)
+ (4) never produces Adapted Material.
+
+ 5. Downstream recipients.
+
+ a. Offer from the Licensor -- Licensed Material. Every
+ recipient of the Licensed Material automatically
+ receives an offer from the Licensor to exercise the
+ Licensed Rights under the terms and conditions of this
+ Public License.
+
+ b. No downstream restrictions. You may not offer or impose
+ any additional or different terms or conditions on, or
+ apply any Effective Technological Measures to, the
+ Licensed Material if doing so restricts exercise of the
+ Licensed Rights by any recipient of the Licensed
+ Material.
+
+ 6. No endorsement. Nothing in this Public License constitutes or
+ may be construed as permission to assert or imply that You
+ are, or that Your use of the Licensed Material is, connected
+ with, or sponsored, endorsed, or granted official status by,
+ the Licensor or others designated to receive attribution as
+ provided in Section 3(a)(1)(A)(i).
+
+ b. Other rights.
+
+ 1. Moral rights, such as the right of integrity, are not
+ licensed under this Public License, nor are publicity,
+ privacy, and/or other similar personality rights; however, to
+ the extent possible, the Licensor waives and/or agrees not to
+ assert any such rights held by the Licensor to the limited
+ extent necessary to allow You to exercise the Licensed
+ Rights, but not otherwise.
+
+ 2. Patent and trademark rights are not licensed under this
+ Public License.
+
+ 3. To the extent possible, the Licensor waives any right to
+ collect royalties from You for the exercise of the Licensed
+ Rights, whether directly or through a collecting society
+ under any voluntary or waivable statutory or compulsory
+ licensing scheme. In all other cases the Licensor expressly
+ reserves any right to collect such royalties.
+
+
+Section 3 -- License Conditions.
+
+Your exercise of the Licensed Rights is expressly made subject to the
+following conditions.
+
+ a. Attribution.
+
+ 1. If You Share the Licensed Material (including in modified
+ form), You must:
+
+ a. retain the following if it is supplied by the Licensor
+ with the Licensed Material:
+
+ i. identification of the creator(s) of the Licensed
+ Material and any others designated to receive
+ attribution, in any reasonable manner requested by
+ the Licensor (including by pseudonym if
+ designated);
+
+ ii. a copyright notice;
+
+ iii. a notice that refers to this Public License;
+
+ iv. a notice that refers to the disclaimer of
+ warranties;
+
+ v. a URI or hyperlink to the Licensed Material to the
+ extent reasonably practicable;
+
+ b. indicate if You modified the Licensed Material and
+ retain an indication of any previous modifications; and
+
+ c. indicate the Licensed Material is licensed under this
+ Public License, and include the text of, or the URI or
+ hyperlink to, this Public License.
+
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
+ reasonable manner based on the medium, means, and context in
+ which You Share the Licensed Material. For example, it may be
+ reasonable to satisfy the conditions by providing a URI or
+ hyperlink to a resource that includes the required
+ information.
+
+ 3. If requested by the Licensor, You must remove any of the
+ information required by Section 3(a)(1)(A) to the extent
+ reasonably practicable.
+
+ 4. If You Share Adapted Material You produce, the Adapter's
+ License You apply must not prevent recipients of the Adapted
+ Material from complying with this Public License.
+
+
+Section 4 -- Sui Generis Database Rights.
+
+Where the Licensed Rights include Sui Generis Database Rights that
+apply to Your use of the Licensed Material:
+
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
+ to extract, reuse, reproduce, and Share all or a substantial
+ portion of the contents of the database;
+
+ b. if You include all or a substantial portion of the database
+ contents in a database in which You have Sui Generis Database
+ Rights, then the database in which You have Sui Generis Database
+ Rights (but not its individual contents) is Adapted Material; and
+
+ c. You must comply with the conditions in Section 3(a) if You Share
+ all or a substantial portion of the contents of the database.
+
+For the avoidance of doubt, this Section 4 supplements and does not
+replace Your obligations under this Public License where the Licensed
+Rights include other Copyright and Similar Rights.
+
+
+Section 5 -- Disclaimer of Warranties and Limitation of Liability.
+
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
+
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
+
+ c. The disclaimer of warranties and limitation of liability provided
+ above shall be interpreted in a manner that, to the extent
+ possible, most closely approximates an absolute disclaimer and
+ waiver of all liability.
+
+
+Section 6 -- Term and Termination.
+
+ a. This Public License applies for the term of the Copyright and
+ Similar Rights licensed here. However, if You fail to comply with
+ this Public License, then Your rights under this Public License
+ terminate automatically.
+
+ b. Where Your right to use the Licensed Material has terminated under
+ Section 6(a), it reinstates:
+
+ 1. automatically as of the date the violation is cured, provided
+ it is cured within 30 days of Your discovery of the
+ violation; or
+
+ 2. upon express reinstatement by the Licensor.
+
+ For the avoidance of doubt, this Section 6(b) does not affect any
+ right the Licensor may have to seek remedies for Your violations
+ of this Public License.
+
+ c. For the avoidance of doubt, the Licensor may also offer the
+ Licensed Material under separate terms or conditions or stop
+ distributing the Licensed Material at any time; however, doing so
+ will not terminate this Public License.
+
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
+ License.
+
+
+Section 7 -- Other Terms and Conditions.
+
+ a. The Licensor shall not be bound by any additional or different
+ terms or conditions communicated by You unless expressly agreed.
+
+ b. Any arrangements, understandings, or agreements regarding the
+ Licensed Material not stated herein are separate from and
+ independent of the terms and conditions of this Public License.
+
+
+Section 8 -- Interpretation.
+
+ a. For the avoidance of doubt, this Public License does not, and
+ shall not be interpreted to, reduce, limit, restrict, or impose
+ conditions on any use of the Licensed Material that could lawfully
+ be made without permission under this Public License.
+
+ b. To the extent possible, if any provision of this Public License is
+ deemed unenforceable, it shall be automatically reformed to the
+ minimum extent necessary to make it enforceable. If the provision
+ cannot be reformed, it shall be severed from this Public License
+ without affecting the enforceability of the remaining terms and
+ conditions.
+
+ c. No term or condition of this Public License will be waived and no
+ failure to comply consented to unless expressly agreed to by the
+ Licensor.
+
+ d. Nothing in this Public License constitutes or may be interpreted
+ as a limitation upon, or waiver of, any privileges and immunities
+ that apply to the Licensor or You, including from the legal
+ processes of any jurisdiction or authority.
+
+
+=======================================================================
+
+Creative Commons is not a party to its public
+licenses. Notwithstanding, Creative Commons may elect to apply one of
+its public licenses to material it publishes and in those instances
+will be considered the “Licensor.” The text of the Creative Commons
+public licenses is dedicated to the public domain under the CC0 Public
+Domain Dedication. Except for the limited purpose of indicating that
+material is shared under a Creative Commons public license or as
+otherwise permitted by the Creative Commons policies published at
+creativecommons.org/policies, Creative Commons does not authorize the
+use of the trademark "Creative Commons" or any other trademark or logo
+of Creative Commons without its prior written consent including,
+without limitation, in connection with any unauthorized modifications
+to any of its public licenses or any other arrangements,
+understandings, or agreements concerning use of licensed material. For
+the avoidance of doubt, this paragraph does not form part of the
+public licenses.
+
+Creative Commons may be contacted at creativecommons.org.
diff --git a/docker/Dockerfile-iam-seeding b/docker/Dockerfile-iam-seeding
new file mode 100644
index 0000000000..a22f369aca
--- /dev/null
+++ b/docker/Dockerfile-iam-seeding
@@ -0,0 +1,45 @@
+###############################################################
+# Copyright (c) 2021, 2023 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
+###############################################################
+
+FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base
+
+FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
+WORKDIR /
+COPY LICENSE NOTICE.md DEPENDENCIES /
+COPY /src/framework/Framework.Async /src/framework/Framework.Async
+COPY /src/framework/Framework.ErrorHandling.Library /src/framework/Framework.ErrorHandling.Library
+COPY /src/framework/Framework.Linq /src/framework/Framework.Linq
+COPY /src/framework/Framework.Logging /src/framework/Framework.Logging
+COPY /src/framework/Framework.Models /src/framework/Framework.Models
+COPY /src/keycloak/Keycloak.ErrorHandling /src/keycloak/Keycloak.ErrorHandling
+COPY /src/keycloak/Keycloak.Factory /src/keycloak/Keycloak.Factory
+COPY /src/keycloak/Keycloak.Library /src/keycloak/Keycloak.Library
+COPY /src/keycloak/Keycloak.Seeding /src/keycloak/Keycloak.Seeding
+WORKDIR /src/keycloak/Keycloak.Seeding
+RUN dotnet build "Keycloak.Seeding.csproj" -c Release -o /app/build
+
+FROM build AS publish
+RUN dotnet publish "Keycloak.Seeding.csproj" -c Release -o /app/publish
+
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
+RUN chown -R 1000:3000 /app
+USER 1000:3000
+ENTRYPOINT ["dotnet", "Org.Eclipse.TractusX.Portal.Backend.Keycloak.Seeding.dll"]
diff --git a/docker/notice-iam-seeding.md b/docker/notice-iam-seeding.md
new file mode 100644
index 0000000000..cf19ebf822
--- /dev/null
+++ b/docker/notice-iam-seeding.md
@@ -0,0 +1,22 @@
+## Notice for Docker image
+
+DockerHub: [https://hub.docker.com/r/tractusx/portal-iam-seeding](https://hub.docker.com/r/tractusx/portal-iam-seeding)
+
+Eclipse Tractus-X product(s) installed within the image:
+
+__Portal Checklist Worker__
+
+- GitHub: https://github.com/eclipse-tractusx/portal-backend
+- Project home: https://projects.eclipse.org/projects/automotive.tractusx
+- Dockerfile: https://github.com/eclipse-tractusx/portal-backend/blob/main/docker/Dockerfile-iam-seeding
+- Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/portal-backend/blob/main/LICENSE)
+
+__Used base images__
+
+- Dockerfile: [mcr.microsoft.com/dotnet/runtime:6.0-alpine](https://github.com/dotnet/dotnet-docker/blob/main/src/runtime/6.0/alpine3.17/amd64/Dockerfile)
+- GitHub project: [https://github.com/dotnet/dotnet-docker](https://github.com/dotnet/dotnet-docker)
+- DockerHub: [https://hub.docker.com/_/microsoft-dotnet-runtime](https://hub.docker.com/_/microsoft-dotnet-runtime)
+
+As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
+
+As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 2efc185599..d0671e5510 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -21,6 +21,6 @@
1.6.0
- RC6
+ RC7
diff --git a/src/Portal.Backend.sln b/src/Portal.Backend.sln
index 3e625d207a..1f7093b921 100644
--- a/src/Portal.Backend.sln
+++ b/src/Portal.Backend.sln
@@ -206,6 +206,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework.Models.Tests", ".
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework.ProcessIdentity", "framework\Framework.ProcessIdentity\Framework.ProcessIdentity.csproj", "{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework.PublicInfos", "framework\Framework.PublicInfos\Framework.PublicInfos.csproj", "{47E089E3-E875-4045-9E58-C1223BE899E9}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework.PublicInfos.Tests", "..\tests\framework\Framework.PublicInfos.Tests\Framework.PublicInfos.Tests.csproj", "{9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Keycloak.Seeding", "keycloak\Keycloak.Seeding\Keycloak.Seeding.csproj", "{E1D41A07-F468-4D13-8185-35F127230B17}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Keycloak.Seeding.Tests", "..\tests\keycloak\Keycloak.Seeding.Tests\Keycloak.Seeding.Tests.csproj", "{A5BEDD89-7280-466E-8D14-EC5E177AAD07}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -1284,6 +1292,54 @@ Global
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Release|x64.Build.0 = Release|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Release|x86.ActiveCfg = Release|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Release|x86.Build.0 = Release|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Debug|x64.Build.0 = Debug|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Debug|x86.Build.0 = Debug|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Release|x64.ActiveCfg = Release|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Release|x64.Build.0 = Release|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Release|x86.ActiveCfg = Release|Any CPU
+ {47E089E3-E875-4045-9E58-C1223BE899E9}.Release|x86.Build.0 = Release|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Debug|x64.Build.0 = Debug|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Debug|x86.Build.0 = Debug|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Release|x64.ActiveCfg = Release|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Release|x64.Build.0 = Release|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Release|x86.ActiveCfg = Release|Any CPU
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3}.Release|x86.Build.0 = Release|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Debug|x64.Build.0 = Debug|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Debug|x86.Build.0 = Debug|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Release|x64.ActiveCfg = Release|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Release|x64.Build.0 = Release|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Release|x86.ActiveCfg = Release|Any CPU
+ {E1D41A07-F468-4D13-8185-35F127230B17}.Release|x86.Build.0 = Release|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Debug|x64.Build.0 = Debug|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Debug|x86.Build.0 = Debug|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Release|x64.ActiveCfg = Release|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Release|x64.Build.0 = Release|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Release|x86.ActiveCfg = Release|Any CPU
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1292,6 +1348,7 @@ Global
SolutionGuid = {2EB6265F-323A-4BF3-969E-003D64A14B64}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
+ {A5BEDD89-7280-466E-8D14-EC5E177AAD07} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{EA9BA26E-83F6-47C4-BA3B-880AF1AD6A82} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{4B40193E-2C67-4DC4-8EF4-3286DAA01D8B} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{5E80DEEA-B254-425C-8220-27EEF47C10BD} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
@@ -1381,5 +1438,8 @@ Global
{031237BF-7B2A-4B37-9E37-4D4C575FDD22} = {23500169-FC01-4D2B-A997-E7FAE2169FC0}
{CB9FFDD9-7F41-44DA-BFA8-C157A96D51F6} = {23500169-FC01-4D2B-A997-E7FAE2169FC0}
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A} = {23500169-FC01-4D2B-A997-E7FAE2169FC0}
+ {47E089E3-E875-4045-9E58-C1223BE899E9} = {23500169-FC01-4D2B-A997-E7FAE2169FC0}
+ {9D574E57-75A6-4965-AF23-ACE0BB9CD0B3} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
+ {E1D41A07-F468-4D13-8185-35F127230B17} = {46383371-8252-4598-9350-A97692851408}
EndGlobalSection
EndGlobal
diff --git a/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs
index 4e1d8ad0db..c99bc613b8 100644
--- a/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs
@@ -34,6 +34,7 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities;
using System.Globalization;
using System.Text.Json;
@@ -47,6 +48,7 @@ public class CompanyDataBusinessLogic : ICompanyDataBusinessLogic
private readonly IMailingService _mailingService;
private readonly ICustodianService _custodianService;
private readonly IDateTimeProvider _dateTimeProvider;
+ private readonly IIdentityService _identityService;
private readonly CompanyDataSettings _settings;
///
@@ -56,19 +58,22 @@ public class CompanyDataBusinessLogic : ICompanyDataBusinessLogic
///
///
///
+ ///
///
- public CompanyDataBusinessLogic(IPortalRepositories portalRepositories, IMailingService mailingService, ICustodianService custodianService, IDateTimeProvider dateTimeProvider, IOptions options)
+ public CompanyDataBusinessLogic(IPortalRepositories portalRepositories, IMailingService mailingService, ICustodianService custodianService, IDateTimeProvider dateTimeProvider, IIdentityService identityService, IOptions options)
{
_portalRepositories = portalRepositories;
_mailingService = mailingService;
_custodianService = custodianService;
_dateTimeProvider = dateTimeProvider;
+ _identityService = identityService;
_settings = options.Value;
}
///
- public async Task GetCompanyDetailsAsync(Guid companyId)
+ public async Task GetCompanyDetailsAsync()
{
+ var companyId = _identityService.IdentityData.CompanyId;
var result = await _portalRepositories.GetInstance().GetCompanyDetailsAsync(companyId).ConfigureAwait(false);
if (result == null)
{
@@ -78,12 +83,13 @@ public async Task GetCompanyDetailsAsync(Guid companyI
}
///
- public IAsyncEnumerable GetCompanyAssigendUseCaseDetailsAsync(Guid companyId) =>
- _portalRepositories.GetInstance().GetCompanyAssigendUseCaseDetailsAsync(companyId);
+ public IAsyncEnumerable GetCompanyAssigendUseCaseDetailsAsync() =>
+ _portalRepositories.GetInstance().GetCompanyAssigendUseCaseDetailsAsync(_identityService.IdentityData.CompanyId);
///
- public async Task CreateCompanyAssignedUseCaseDetailsAsync(Guid companyId, Guid useCaseId)
+ public async Task CreateCompanyAssignedUseCaseDetailsAsync(Guid useCaseId)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var companyRepositories = _portalRepositories.GetInstance();
var useCaseDetails = await companyRepositories.GetCompanyStatusAndUseCaseIdAsync(companyId, useCaseId).ConfigureAwait(false);
if (!useCaseDetails.IsActiveCompanyStatus)
@@ -100,8 +106,9 @@ public async Task CreateCompanyAssignedUseCaseDetailsAsync(Guid companyId,
}
///
- public async Task RemoveCompanyAssignedUseCaseDetailsAsync(Guid companyId, Guid useCaseId)
+ public async Task RemoveCompanyAssignedUseCaseDetailsAsync(Guid useCaseId)
{
+ var companyId = _identityService.IdentityData.CompanyId;
var companyRepositories = _portalRepositories.GetInstance();
var useCaseDetails = await companyRepositories.GetCompanyStatusAndUseCaseIdAsync(companyId, useCaseId).ConfigureAwait(false);
if (!useCaseDetails.IsActiveCompanyStatus)
@@ -116,8 +123,9 @@ public async Task RemoveCompanyAssignedUseCaseDetailsAsync(Guid companyId, Guid
await _portalRepositories.SaveAsync().ConfigureAwait(false);
}
- public async IAsyncEnumerable GetCompanyRoleAndConsentAgreementDetailsAsync(Guid companyId, string? languageShortName)
+ public async IAsyncEnumerable GetCompanyRoleAndConsentAgreementDetailsAsync(string? languageShortName)
{
+ var companyId = _identityService.IdentityData.CompanyId;
if (languageShortName != null && !await _portalRepositories.GetInstance().IsValidLanguageCode(languageShortName).ConfigureAwait(false))
{
throw new ControllerArgumentException($"language {languageShortName} is not a valid languagecode");
@@ -152,12 +160,14 @@ public async IAsyncEnumerable GetCompanyRoleAndConse
}
///
- public async Task CreateCompanyRoleAndConsentAgreementDetailsAsync((Guid UserId, Guid CompanyId) identity, IEnumerable companyRoleConsentDetails)
+ public async Task CreateCompanyRoleAndConsentAgreementDetailsAsync(IEnumerable companyRoleConsentDetails)
{
if (!companyRoleConsentDetails.Any())
{
return;
}
+
+ var identity = _identityService.IdentityData;
var companyRepositories = _portalRepositories.GetInstance();
var result = await companyRepositories.GetCompanyRolesDataAsync(identity.CompanyId, companyRoleConsentDetails.Select(x => x.CompanyRole)).ConfigureAwait(false);
if (!result.IsValidCompany)
@@ -221,10 +231,10 @@ public async Task CreateCompanyRoleAndConsentAgreementDetailsAsync((Guid UserId,
}
///
- public async Task> GetUseCaseParticipationAsync(Guid companyId, string? language) =>
+ public async Task> GetUseCaseParticipationAsync(string? language) =>
await _portalRepositories
.GetInstance()
- .GetUseCaseParticipationForCompany(companyId, language ?? Constants.DefaultLanguage)
+ .GetUseCaseParticipationForCompany(_identityService.IdentityData.CompanyId, language ?? Constants.DefaultLanguage)
.Select(x => new UseCaseParticipationData(
x.UseCase,
x.Description,
@@ -247,27 +257,23 @@ await _portalRepositories
.ConfigureAwait(false);
///
- public async Task> GetSsiCertificatesAsync(Guid companyId) =>
+ public async Task> GetSsiCertificatesAsync() =>
await _portalRepositories
.GetInstance()
- .GetSsiCertificates(companyId)
+ .GetSsiCertificates(_identityService.IdentityData.CompanyId)
.Select(x => new SsiCertificateData(
x.CredentialType,
- x.SsiDetailData.CatchingInto(
- data => data
- .Select(d => new CompanySsiDetailData(
+ x.SsiDetailData.Select(d => new CompanySsiDetailData(
d.CredentialId,
d.ParticipationStatus,
d.ExpiryDate,
- d.Document))
- .SingleOrDefault(),
- (InvalidOperationException _) => new ConflictException("There should only be one pending or active ssi detail be assigned")
+ d.Document)
)))
.ToListAsync()
.ConfigureAwait(false);
///
- public async Task CreateUseCaseParticipation((Guid UserId, Guid CompanyId) identity, UseCaseParticipationCreationData data, CancellationToken cancellationToken)
+ public async Task CreateUseCaseParticipation(UseCaseParticipationCreationData data, CancellationToken cancellationToken)
{
var (verifiedCredentialExternalTypeDetailId, credentialTypeId, document) = data;
var documentContentType = document.ContentType.ParseMediaTypeId();
@@ -279,11 +285,11 @@ public async Task CreateUseCaseParticipation((Guid UserId, Guid CompanyId) ident
throw new ControllerArgumentException($"VerifiedCredentialExternalTypeDetail {verifiedCredentialExternalTypeDetailId} does not exist");
}
- await HandleSsiCreationAsync(identity, new(credentialTypeId, VerifiedCredentialTypeKindId.USE_CASE, verifiedCredentialExternalTypeDetailId, document, documentContentType), companyCredentialDetailsRepository, cancellationToken).ConfigureAwait(false);
+ await HandleSsiCreationAsync(credentialTypeId, VerifiedCredentialTypeKindId.USE_CASE, verifiedCredentialExternalTypeDetailId, document, documentContentType, companyCredentialDetailsRepository, cancellationToken).ConfigureAwait(false);
}
///
- public async Task CreateSsiCertificate((Guid UserId, Guid CompanyId) identity, SsiCertificateCreationData data, CancellationToken cancellationToken)
+ public async Task CreateSsiCertificate(SsiCertificateCreationData data, CancellationToken cancellationToken)
{
var (credentialTypeId, document) = data;
var documentContentType = document.ContentType.ParseMediaTypeId();
@@ -295,16 +301,15 @@ public async Task CreateSsiCertificate((Guid UserId, Guid CompanyId) identity, S
throw new ControllerArgumentException($"{credentialTypeId} is not assigned to a certificate");
}
- await HandleSsiCreationAsync(identity, new(credentialTypeId, VerifiedCredentialTypeKindId.CERTIFICATE, null, document, documentContentType), companyCredentialDetailsRepository, cancellationToken).ConfigureAwait(false);
+ await HandleSsiCreationAsync(credentialTypeId, VerifiedCredentialTypeKindId.CERTIFICATE, null, document, documentContentType, companyCredentialDetailsRepository, cancellationToken).ConfigureAwait(false);
}
private async Task HandleSsiCreationAsync(
- (Guid UserId, Guid CompanyId) identity,
- (VerifiedCredentialTypeId CredentialTypeId, VerifiedCredentialTypeKindId kindId, Guid? VerifiedCredentialExternalTypeDetailId, IFormFile Document, MediaTypeId MediaTypeId) creationData,
+ VerifiedCredentialTypeId credentialTypeId, VerifiedCredentialTypeKindId kindId, Guid? verifiedCredentialExternalTypeDetailId, IFormFile document, MediaTypeId mediaTypeId,
ICompanySsiDetailsRepository companyCredentialDetailsRepository,
CancellationToken cancellationToken)
{
- var (credentialTypeId, kindId, verifiedCredentialExternalTypeDetailId, document, mediaTypeId) = creationData;
+ var identity = _identityService.IdentityData;
if (await companyCredentialDetailsRepository.CheckSsiDetailsExistsForCompany(identity.CompanyId, credentialTypeId, kindId, verifiedCredentialExternalTypeDetailId).ConfigureAwait(false))
{
throw new ControllerArgumentException("Credential request already existing");
@@ -372,9 +377,10 @@ private async Task HandleSsiCreationAsync(
}
///
- public async Task ApproveCredential(Guid userId, Guid credentialId, CancellationToken cancellationToken)
+ public async Task ApproveCredential(Guid credentialId, CancellationToken cancellationToken)
{
var companySsiRepository = _portalRepositories.GetInstance();
+ var userId = _identityService.IdentityData.UserId;
var (exists, data) = await companySsiRepository.GetSsiApprovalData(credentialId).ConfigureAwait(false);
if (!exists)
{
@@ -445,9 +451,10 @@ public async Task ApproveCredential(Guid userId, Guid credentialId, Cancellation
}
///
- public async Task RejectCredential(Guid userId, Guid credentialId)
+ public async Task RejectCredential(Guid credentialId)
{
var companySsiRepository = _portalRepositories.GetInstance();
+ var userId = _identityService.IdentityData.UserId;
var (exists, status, type, requesterId, requesterEmail, requesterFirstname, requesterLastname) = await companySsiRepository.GetSsiRejectionData(credentialId).ConfigureAwait(false);
if (!exists)
{
diff --git a/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs
index 4c3ed29a6e..6ee9f00dd1 100644
--- a/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs
@@ -272,41 +272,35 @@ public async Task DeleteConnectorAsync(Guid connectorId)
{
var companyId = _identityService.IdentityData.CompanyId;
var connectorsRepository = _portalRepositories.GetInstance();
- var (isValidConnectorId, isProvidingOrHostCompany, selfDescriptionDocumentId, documentStatusId, connectorStatus, assignedOfferSubscriptions) = await connectorsRepository.GetConnectorDeleteDataAsync(connectorId, companyId).ConfigureAwait(false);
-
- if (!isValidConnectorId)
- {
- throw new NotFoundException($"Connector {connectorId} does not exist");
- }
-
- if (!isProvidingOrHostCompany)
+ var result = await connectorsRepository.GetConnectorDeleteDataAsync(connectorId, companyId).ConfigureAwait(false) ?? throw new NotFoundException($"Connector {connectorId} does not exist");
+ if (!result.IsProvidingOrHostCompany)
{
throw new ForbiddenException($"company {companyId} is neither provider nor host-company of connector {connectorId}");
}
- switch (connectorStatus)
+ switch (result.ConnectorStatus)
{
- case ConnectorStatusId.PENDING when selfDescriptionDocumentId == null:
- await DeleteConnectorWithoutDocuments(connectorId, assignedOfferSubscriptions, connectorsRepository);
+ case ConnectorStatusId.PENDING when result.SelfDescriptionDocumentId == null:
+ await DeleteConnectorWithoutDocuments(connectorId, result.ConnectorOfferSubscriptions, connectorsRepository);
break;
case ConnectorStatusId.PENDING:
- await DeleteConnectorWithDocuments(connectorId, assignedOfferSubscriptions, selfDescriptionDocumentId.Value, connectorsRepository);
+ await DeleteConnectorWithDocuments(connectorId, result.SelfDescriptionDocumentId.Value, result.ConnectorOfferSubscriptions, connectorsRepository);
break;
- case ConnectorStatusId.ACTIVE when selfDescriptionDocumentId != null && documentStatusId != null:
- await DeleteConnector(connectorId, assignedOfferSubscriptions, selfDescriptionDocumentId.Value, documentStatusId.Value, connectorsRepository);
+ case ConnectorStatusId.ACTIVE when result.SelfDescriptionDocumentId != null && result.DocumentStatusId != null:
+ await DeleteConnector(connectorId, result.ConnectorOfferSubscriptions, result.SelfDescriptionDocumentId.Value, result.DocumentStatusId.Value, connectorsRepository);
break;
default:
throw new ConflictException("Connector status does not match a deletion scenario. Deletion declined");
}
}
- private async Task DeleteConnector(Guid connectorId, IEnumerable assignedOfferSubscriptions, Guid selfDescriptionDocumentId, DocumentStatusId documentStatus, IConnectorsRepository connectorsRepository)
+ private async Task DeleteConnector(Guid connectorId, IEnumerable connectorOfferSubscriptions, Guid selfDescriptionDocumentId, DocumentStatusId documentStatus, IConnectorsRepository connectorsRepository)
{
_portalRepositories.GetInstance().AttachAndModifyDocument(
selfDescriptionDocumentId,
a => { a.DocumentStatusId = documentStatus; },
a => { a.DocumentStatusId = DocumentStatusId.INACTIVE; });
- RemoveConnectorAssignedOfferSubscriptions(connectorId, assignedOfferSubscriptions, connectorsRepository);
+ RemoveConnectorAssignedOfferSubscriptions(connectorId, connectorOfferSubscriptions, connectorsRepository);
await DeleteUpdateConnectorDetail(connectorId, connectorsRepository);
}
@@ -320,23 +314,30 @@ private async Task DeleteUpdateConnectorDetail(Guid connectorId, IConnectorsRepo
await _portalRepositories.SaveAsync();
}
- private async Task DeleteConnectorWithDocuments(Guid connectorId, IEnumerable assignedOfferSubscriptions, Guid selfDescriptionDocumentId, IConnectorsRepository connectorsRepository)
+ private async Task DeleteConnectorWithDocuments(Guid connectorId, Guid selfDescriptionDocumentId, IEnumerable connectorOfferSubscriptions, IConnectorsRepository connectorsRepository)
{
_portalRepositories.GetInstance().RemoveDocument(selfDescriptionDocumentId);
- RemoveConnectorAssignedOfferSubscriptions(connectorId, assignedOfferSubscriptions, connectorsRepository);
+ RemoveConnectorAssignedOfferSubscriptions(connectorId, connectorOfferSubscriptions, connectorsRepository);
connectorsRepository.DeleteConnector(connectorId);
await _portalRepositories.SaveAsync();
}
- private async Task DeleteConnectorWithoutDocuments(Guid connectorId, IEnumerable assignedOfferSubscriptions, IConnectorsRepository connectorsRepository)
+ private async Task DeleteConnectorWithoutDocuments(Guid connectorId, IEnumerable connectorOfferSubscriptions, IConnectorsRepository connectorsRepository)
{
- RemoveConnectorAssignedOfferSubscriptions(connectorId, assignedOfferSubscriptions, connectorsRepository);
+ RemoveConnectorAssignedOfferSubscriptions(connectorId, connectorOfferSubscriptions, connectorsRepository);
connectorsRepository.DeleteConnector(connectorId);
await _portalRepositories.SaveAsync();
}
- private static void RemoveConnectorAssignedOfferSubscriptions(Guid connectorId, IEnumerable assignedOfferSubscriptions, IConnectorsRepository connectorsRepository)
+ private static void RemoveConnectorAssignedOfferSubscriptions(Guid connectorId, IEnumerable connectorOfferSubscriptions, IConnectorsRepository connectorsRepository)
{
+ var activeConnectorOfferSubscription = connectorOfferSubscriptions.Where(cos => cos.OfferSubscriptionStatus == OfferSubscriptionStatusId.ACTIVE)
+ .Select(cos => cos.AssignedOfferSubscriptionIds);
+ if (activeConnectorOfferSubscription.Any())
+ {
+ throw new ForbiddenException($"Deletion Failed. Connector {connectorId} connected to an active offer subscription [{string.Join(",", activeConnectorOfferSubscription)}]");
+ }
+ var assignedOfferSubscriptions = connectorOfferSubscriptions.Select(cos => cos.AssignedOfferSubscriptionIds);
if (assignedOfferSubscriptions.Any())
{
connectorsRepository.DeleteConnectorAssignedSubscriptions(connectorId, assignedOfferSubscriptions);
diff --git a/src/administration/Administration.Service/BusinessLogic/ICompanyDataBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/ICompanyDataBusinessLogic.cs
index 270d7eac33..861e04ef51 100644
--- a/src/administration/Administration.Service/BusinessLogic/ICompanyDataBusinessLogic.cs
+++ b/src/administration/Administration.Service/BusinessLogic/ICompanyDataBusinessLogic.cs
@@ -27,29 +27,30 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLog
public interface ICompanyDataBusinessLogic
{
- Task GetCompanyDetailsAsync(Guid companyId);
+ Task GetCompanyDetailsAsync();
- IAsyncEnumerable GetCompanyAssigendUseCaseDetailsAsync(Guid companyId);
+ IAsyncEnumerable GetCompanyAssigendUseCaseDetailsAsync();
- Task CreateCompanyAssignedUseCaseDetailsAsync(Guid companyId, Guid useCaseId);
+ Task CreateCompanyAssignedUseCaseDetailsAsync(Guid useCaseId);
- Task RemoveCompanyAssignedUseCaseDetailsAsync(Guid companyId, Guid useCaseId);
+ Task RemoveCompanyAssignedUseCaseDetailsAsync(Guid useCaseId);
- IAsyncEnumerable GetCompanyRoleAndConsentAgreementDetailsAsync(Guid companyId, string? languageShortName);
+ IAsyncEnumerable GetCompanyRoleAndConsentAgreementDetailsAsync(string? languageShortName);
- Task CreateCompanyRoleAndConsentAgreementDetailsAsync((Guid UserId, Guid CompanyId) identity, IEnumerable companyRoleConsentDetails);
+ Task CreateCompanyRoleAndConsentAgreementDetailsAsync(IEnumerable companyRoleConsentDetails);
- Task> GetUseCaseParticipationAsync(Guid companyId, string? language);
+ Task> GetUseCaseParticipationAsync(string? language);
- Task> GetSsiCertificatesAsync(Guid companyId);
+ Task> GetSsiCertificatesAsync();
- Task CreateUseCaseParticipation((Guid UserId, Guid CompanyId) identity, UseCaseParticipationCreationData data, CancellationToken cancellationToken);
- Task CreateSsiCertificate((Guid UserId, Guid CompanyId) identity, SsiCertificateCreationData data, CancellationToken cancellationToken);
+ Task CreateUseCaseParticipation(UseCaseParticipationCreationData data, CancellationToken cancellationToken);
+ Task CreateSsiCertificate(SsiCertificateCreationData data, CancellationToken cancellationToken);
Task> GetCredentials(int page, int size, CompanySsiDetailStatusId? companySsiDetailStatusId, VerifiedCredentialTypeId? credentialTypeId, string? companyName, CompanySsiDetailSorting? sorting);
- Task ApproveCredential(Guid userId, Guid credentialId, CancellationToken cancellationToken);
+ Task ApproveCredential(Guid credentialId, CancellationToken cancellationToken);
+
+ Task RejectCredential(Guid credentialId);
- Task RejectCredential(Guid userId, Guid credentialId);
IAsyncEnumerable GetCertificateTypes();
}
diff --git a/src/administration/Administration.Service/Controllers/CompanyDataController.cs b/src/administration/Administration.Service/Controllers/CompanyDataController.cs
index 251db9a4bc..e7b8ac8280 100644
--- a/src/administration/Administration.Service/Controllers/CompanyDataController.cs
+++ b/src/administration/Administration.Service/Controllers/CompanyDataController.cs
@@ -65,7 +65,7 @@ public CompanyDataController(ICompanyDataBusinessLogic logic)
[ProducesResponseType(typeof(CompanyAddressDetailData), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public Task GetOwnCompanyDetailsAsync() =>
- this.WithCompanyId(companyId => _logic.GetCompanyDetailsAsync(companyId));
+ _logic.GetCompanyDetailsAsync();
///
/// Gets the CompanyAssigned UseCase details
@@ -79,7 +79,7 @@ public Task GetOwnCompanyDetailsAsync() =>
[Route("preferredUseCases")]
[ProducesResponseType(typeof(CompanyAssignedUseCaseData), StatusCodes.Status200OK)]
public IAsyncEnumerable GetCompanyAssigendUseCaseDetailsAsync() =>
- this.WithCompanyId(companyId => _logic.GetCompanyAssigendUseCaseDetailsAsync(companyId));
+ _logic.GetCompanyAssigendUseCaseDetailsAsync();
///
/// Create the CompanyAssigned UseCase details
@@ -96,7 +96,7 @@ public IAsyncEnumerable GetCompanyAssigendUseCaseDet
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public async Task CreateCompanyAssignedUseCaseDetailsAsync([FromBody] UseCaseIdDetails data) =>
- await this.WithCompanyId(companyId => _logic.CreateCompanyAssignedUseCaseDetailsAsync(companyId, data.useCaseId)).ConfigureAwait(false)
+ await _logic.CreateCompanyAssignedUseCaseDetailsAsync(data.useCaseId).ConfigureAwait(false)
? StatusCode((int)HttpStatusCode.Created)
: NoContent();
@@ -115,7 +115,7 @@ await this.WithCompanyId(companyId => _logic.CreateCompanyAssignedUseCaseDetails
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public async Task RemoveCompanyAssignedUseCaseDetailsAsync([FromBody] UseCaseIdDetails data)
{
- await this.WithCompanyId(companyId => _logic.RemoveCompanyAssignedUseCaseDetailsAsync(companyId, data.useCaseId)).ConfigureAwait(false);
+ await _logic.RemoveCompanyAssignedUseCaseDetailsAsync(data.useCaseId).ConfigureAwait(false);
return NoContent();
}
@@ -134,7 +134,7 @@ public async Task RemoveCompanyAssignedUseCaseDetailsAsync([Fro
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public IAsyncEnumerable GetCompanyRoleAndConsentAgreementDetailsAsync([FromQuery] string? languageShortName = null) =>
- this.WithCompanyId(companyId => _logic.GetCompanyRoleAndConsentAgreementDetailsAsync(companyId, languageShortName));
+ _logic.GetCompanyRoleAndConsentAgreementDetailsAsync(languageShortName);
///
/// Post the companyrole and Consent Details
@@ -153,7 +153,7 @@ public IAsyncEnumerable GetCompanyRoleAndConsentAgre
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public async Task CreateCompanyRoleAndConsentAgreementDetailsAsync([FromBody] IEnumerable companyRoleConsentDetails)
{
- await this.WithUserIdAndCompanyId(identity => _logic.CreateCompanyRoleAndConsentAgreementDetailsAsync(identity, companyRoleConsentDetails));
+ await _logic.CreateCompanyRoleAndConsentAgreementDetailsAsync(companyRoleConsentDetails);
return NoContent();
}
@@ -169,7 +169,7 @@ public async Task CreateCompanyRoleAndConsentAgreementDetailsAs
[Route("useCaseParticipation")]
[ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
public Task> GetUseCaseParticipation([FromQuery] string? language) =>
- this.WithCompanyId(companyId => _logic.GetUseCaseParticipationAsync(companyId, language));
+ _logic.GetUseCaseParticipationAsync(language);
///
/// Gets the Ssi certifications for the own company
@@ -183,7 +183,7 @@ public Task> GetUseCaseParticipation([From
[Route("certificates")]
[ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
public Task> GetSsiCertificationData() =>
- this.WithCompanyId(companyId => _logic.GetSsiCertificatesAsync(companyId));
+ _logic.GetSsiCertificatesAsync();
///
/// Gets the Ssi certifications for the own company
@@ -214,7 +214,7 @@ public IAsyncEnumerable GetCertificateTypes() =>
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task CreateUseCaseParticipation([FromForm] UseCaseParticipationCreationData data, CancellationToken cancellationToken)
{
- await this.WithUserIdAndCompanyId(identity => _logic.CreateUseCaseParticipation(identity, data, cancellationToken)).ConfigureAwait(false);
+ await _logic.CreateUseCaseParticipation(data, cancellationToken).ConfigureAwait(false);
return NoContent();
}
@@ -234,7 +234,7 @@ public async Task CreateUseCaseParticipation([FromForm] UseCase
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task CreateSsiCertificate([FromForm] SsiCertificateCreationData data, CancellationToken cancellationToken)
{
- await this.WithUserIdAndCompanyId(identity => _logic.CreateSsiCertificate(identity, data, cancellationToken)).ConfigureAwait(false);
+ await _logic.CreateSsiCertificate(data, cancellationToken).ConfigureAwait(false);
return NoContent();
}
@@ -278,7 +278,7 @@ public async Task CreateSsiCertificate([FromForm] SsiCertificat
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task ApproveCredential([FromRoute] Guid credentialId, CancellationToken cts)
{
- await this.WithUserId(userId => _logic.ApproveCredential(userId, credentialId, cts)).ConfigureAwait(false);
+ await _logic.ApproveCredential(credentialId, cts).ConfigureAwait(false);
return NoContent();
}
@@ -296,7 +296,7 @@ public async Task ApproveCredential([FromRoute] Guid credential
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task RejectCredential([FromRoute] Guid credentialId)
{
- await this.WithUserId(userId => _logic.RejectCredential(userId, credentialId)).ConfigureAwait(false);
+ await _logic.RejectCredential(credentialId).ConfigureAwait(false);
return NoContent();
}
}
diff --git a/src/administration/Administration.Service/Controllers/ConnectorsController.cs b/src/administration/Administration.Service/Controllers/ConnectorsController.cs
index d7cb8d9ad8..cc75341eab 100644
--- a/src/administration/Administration.Service/Controllers/ConnectorsController.cs
+++ b/src/administration/Administration.Service/Controllers/ConnectorsController.cs
@@ -24,8 +24,10 @@
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Library;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos;
using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Authentication;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
@@ -84,6 +86,7 @@ public ConnectorsController(IConnectorsBusinessLogic connectorsBusinessLogic)
[Authorize(Roles = "view_connectors")]
[Authorize(Policy = PolicyTypes.ValidCompany)]
[ProducesResponseType(typeof(Pagination.Response), StatusCodes.Status200OK)]
+ [PublicUrl(CompanyRoleId.APP_PROVIDER, CompanyRoleId.SERVICE_PROVIDER)]
public Task> GetManagedConnectorsForCurrentUserAsync([FromQuery] int page = 0, [FromQuery] int size = 15) =>
_businessLogic.GetManagedConnectorForCompany(page, size);
@@ -145,6 +148,7 @@ public async Task CreateConnectorAsync([FromForm] Connecto
[ProducesResponseType(typeof(Guid), StatusCodes.Status201Created)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status503ServiceUnavailable)]
+ [PublicUrl(CompanyRoleId.APP_PROVIDER, CompanyRoleId.SERVICE_PROVIDER)]
public async Task CreateManagedConnectorAsync([FromForm] ManagedConnectorInputModel connectorInputModel, CancellationToken cancellationToken)
{
var connectorId = await _businessLogic.CreateManagedConnectorAsync(connectorInputModel, cancellationToken).ConfigureAwait(false);
@@ -182,6 +186,7 @@ public async Task DeleteConnectorAsync([FromRoute] Guid connector
[Route("discovery")]
[Authorize(Roles = "view_connectors")]
[ProducesResponseType(typeof(IAsyncEnumerable), StatusCodes.Status200OK)]
+ [PublicUrl(CompanyRoleId.APP_PROVIDER, CompanyRoleId.SERVICE_PROVIDER, CompanyRoleId.ACTIVE_PARTICIPANT)]
public IAsyncEnumerable GetCompanyConnectorEndPointAsync([FromBody] IEnumerable bpns) =>
_businessLogic.GetCompanyConnectorEndPointAsync(bpns);
diff --git a/src/administration/Administration.Service/Controllers/DocumentsController.cs b/src/administration/Administration.Service/Controllers/DocumentsController.cs
index 05bea4d640..9e3c564d90 100644
--- a/src/administration/Administration.Service/Controllers/DocumentsController.cs
+++ b/src/administration/Administration.Service/Controllers/DocumentsController.cs
@@ -23,8 +23,10 @@
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Library;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos;
using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Authentication;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
@@ -85,6 +87,7 @@ public async Task GetDocumentContentFileAsync([FromRoute] Guid doc
[Authorize(Roles = "view_documents")]
[ProducesResponseType(typeof(FileContentResult), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
+ [PublicUrl(CompanyRoleId.SERVICE_PROVIDER, CompanyRoleId.APP_PROVIDER)]
public async Task GetSelfDescriptionDocumentsAsync([FromRoute] Guid documentId)
{
var (fileName, content, mediaType) = await _businessLogic.GetSelfDescriptionDocumentAsync(documentId).ConfigureAwait(false);
diff --git a/src/administration/Administration.Service/Controllers/PartnerNetworkController.cs b/src/administration/Administration.Service/Controllers/PartnerNetworkController.cs
index a48e7b13aa..b4d38b4b42 100644
--- a/src/administration/Administration.Service/Controllers/PartnerNetworkController.cs
+++ b/src/administration/Administration.Service/Controllers/PartnerNetworkController.cs
@@ -21,6 +21,8 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
@@ -53,6 +55,7 @@ public PartnerNetworkController(IPartnerNetworkBusinessLogic logic)
[Authorize(Roles = "view_membership")]
[Route("memberCompanies")]
[ProducesResponseType(StatusCodes.Status200OK)]
+ [PublicUrl(CompanyRoleId.ACTIVE_PARTICIPANT, CompanyRoleId.SERVICE_PROVIDER, CompanyRoleId.APP_PROVIDER)]
public IAsyncEnumerable GetAllMemberCompaniesBPNAsync() =>
_logic.GetAllMemberCompaniesBPNAsync();
}
diff --git a/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs b/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs
index ed5fc4b456..dba22e0a8c 100644
--- a/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs
+++ b/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs
@@ -23,8 +23,10 @@
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Library;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos;
using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Authentication;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
@@ -65,6 +67,7 @@ public SubscriptionConfigurationController(ISubscriptionConfigurationBusinessLog
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
+ [PublicUrl(CompanyRoleId.SERVICE_PROVIDER, CompanyRoleId.APP_PROVIDER)]
public Task GetServiceProviderCompanyDetail() =>
this.WithCompanyId(companyId => _businessLogic.GetProviderCompanyDetailsAsync(companyId));
@@ -107,6 +110,7 @@ public async Task SetProviderCompanyDetail([FromBody] ProviderD
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
+ [PublicUrl(CompanyRoleId.SERVICE_PROVIDER, CompanyRoleId.APP_PROVIDER)]
public IAsyncEnumerable GetProcessStepsForSubscription([FromRoute] Guid offerSubscriptionId) =>
_businessLogic.GetProcessStepsForSubscription(offerSubscriptionId);
@@ -188,6 +192,7 @@ public async Task RetriggerCreateTechnicalUser([FromRoute] Guid
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
+ [PublicUrl(CompanyRoleId.SERVICE_PROVIDER, CompanyRoleId.APP_PROVIDER)]
public async Task RetriggerProviderCallback([FromRoute] Guid offerSubscriptionId)
{
await _businessLogic.RetriggerProviderCallback(offerSubscriptionId).ConfigureAwait(false);
diff --git a/src/administration/Administration.Service/Controllers/UserController.cs b/src/administration/Administration.Service/Controllers/UserController.cs
index 5fc2f4e2ca..d456c42f2b 100644
--- a/src/administration/Administration.Service/Controllers/UserController.cs
+++ b/src/administration/Administration.Service/Controllers/UserController.cs
@@ -36,8 +36,6 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers
[Consumes("application/json")]
public class UserController : ControllerBase
{
-
- private readonly ILogger _logger;
private readonly IUserBusinessLogic _logic;
private readonly IUserUploadBusinessLogic _uploadLogic;
private readonly IUserRolesBusinessLogic _rolesLogic;
@@ -45,13 +43,11 @@ public class UserController : ControllerBase
///
/// Creates a new instance of
///
- /// The logger
/// The User Business Logic
/// The User Upload Business Logic
/// The User Roles Management Business Logic
- public UserController(ILogger logger, IUserBusinessLogic logic, IUserUploadBusinessLogic uploadLogic, IUserRolesBusinessLogic rolesLogic)
+ public UserController(IUserBusinessLogic logic, IUserUploadBusinessLogic uploadLogic, IUserRolesBusinessLogic rolesLogic)
{
- _logger = logger;
_logic = logic;
_uploadLogic = uploadLogic;
_rolesLogic = rolesLogic;
diff --git a/src/administration/Administration.Service/Models/SsiCertificateData.cs b/src/administration/Administration.Service/Models/SsiCertificateData.cs
index 83163ffdf8..6678259b73 100644
--- a/src/administration/Administration.Service/Models/SsiCertificateData.cs
+++ b/src/administration/Administration.Service/Models/SsiCertificateData.cs
@@ -5,5 +5,5 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
public record SsiCertificateData
(
VerifiedCredentialTypeId CredentialType,
- CompanySsiDetailData? SsiDetailData
+ IEnumerable SsiDetailData
);
diff --git a/src/administration/Administration.Service/appsettings.json b/src/administration/Administration.Service/appsettings.json
index 303206eff5..bd9933c541 100644
--- a/src/administration/Administration.Service/appsettings.json
+++ b/src/administration/Administration.Service/appsettings.json
@@ -5,6 +5,7 @@
"Default": "Information",
"Override": {
"Microsoft": "Warning",
+ "Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware": "Warning",
"System": "Information",
"Microsoft.Hosting.Lifetime": "Information",
"Org.Eclipse.TractusX.Portal.Backend": "Information"
@@ -14,10 +15,6 @@
{ "Name": "Console" }
],
"Enrich": [
- "FromLogContext",
- "WithMachineName",
- "WithProcessId",
- "WithThreadId",
"WithCorrelationId"
],
"Properties": {
diff --git a/src/externalsystems/Bpdm.Library/BpdmService.cs b/src/externalsystems/Bpdm.Library/BpdmService.cs
index 391a68373c..54ef384863 100644
--- a/src/externalsystems/Bpdm.Library/BpdmService.cs
+++ b/src/externalsystems/Bpdm.Library/BpdmService.cs
@@ -77,7 +77,7 @@ public async Task PutInputLegalEntity(BpdmTransferData data, CancellationT
data.AlphaCode2, // Country
data.ZipCode, // PostalCode
data.City, // City
- new BpdmStreet(
+ new BpdmLegalEntityStreet(
null, // NamePrefix
null, // AdditionalNamePrefix
data.StreetName, // Name
@@ -132,4 +132,29 @@ public async Task FetchInputLegalEntity(string extern
throw new ServiceException($"Access to external system bpdm did not return a valid json response: {je.Message}");
}
}
+
+ public async Task GetSharingState(Guid applicationId, CancellationToken cancellationToken)
+ {
+ var httpClient = await _tokenService.GetAuthorizedClient(_settings, cancellationToken).ConfigureAwait(false);
+
+ var url = $"/companies/test-company/api/catena/sharing-state?externalIds={applicationId}&businessPartnerType={BpdmSharingStateBusinessPartnerType.LEGAL_ENTITY}";
+ var result = await httpClient.GetAsync(url, cancellationToken)
+ .CatchingIntoServiceExceptionFor("bpdm-sharing-state", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE).ConfigureAwait(false);
+ try
+ {
+ var response = await result.Content
+ .ReadFromJsonAsync(Options, cancellationToken)
+ .ConfigureAwait(false);
+ if (response?.Content?.Count() != 1)
+ {
+ throw new ServiceException("Access to sharing state did not return a valid legal entity response", true);
+ }
+
+ return response.Content.Single();
+ }
+ catch (JsonException je)
+ {
+ throw new ServiceException($"Access to sharing state did not return a valid json response: {je.Message}");
+ }
+ }
}
diff --git a/src/externalsystems/Bpdm.Library/BusinessLogic/BpdmBusinessLogic.cs b/src/externalsystems/Bpdm.Library/BusinessLogic/BpdmBusinessLogic.cs
index b16f21fbd0..a197ddf291 100644
--- a/src/externalsystems/Bpdm.Library/BusinessLogic/BpdmBusinessLogic.cs
+++ b/src/externalsystems/Bpdm.Library/BusinessLogic/BpdmBusinessLogic.cs
@@ -21,6 +21,7 @@
using Org.Eclipse.TractusX.Portal.Backend.Bpdm.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.Processes.ApplicationChecklist.Library;
@@ -98,16 +99,33 @@ public BpdmBusinessLogic(IPortalRepositories portalRepositories, IBpdmService bp
public async Task HandlePullLegalEntity(IApplicationChecklistService.WorkerChecklistProcessStepData context, CancellationToken cancellationToken)
{
- var result = await _portalRepositories.GetInstance().GetBpdmDataForApplicationAsync(context.ApplicationId).ConfigureAwait(false);
+ var result = await _portalRepositories.GetInstance()
+ .GetBpdmDataForApplicationAsync(context.ApplicationId).ConfigureAwait(false);
if (result == default)
{
throw new UnexpectedConditionException($"CompanyApplication {context.ApplicationId} does not exist");
}
- var (companyId, data) = result;
+ var sharingState = await _bpdmService.GetSharingState(context.ApplicationId, cancellationToken).ConfigureAwait(false);
+ return sharingState.SharingStateType switch
+ {
+ BpdmSharingStateType.Success =>
+ await HandlePullLegalEntityInternal(context, result.CompanyId, result.BpdmData, cancellationToken),
+ BpdmSharingStateType.Error =>
+ throw new ServiceException($"ErrorCode: {sharingState.SharingErrorCode}, ErrorMessage: {sharingState.SharingErrorMessage}"),
+ _ => new IApplicationChecklistService.WorkerChecklistProcessStepExecutionResult(ProcessStepStatusId.TODO, null, null, null, false, null)
+ };
+ }
- var legalEntity = await _bpdmService.FetchInputLegalEntity(context.ApplicationId.ToString(), cancellationToken).ConfigureAwait(false);
+ private async Task HandlePullLegalEntityInternal(
+ IApplicationChecklistService.WorkerChecklistProcessStepData context,
+ Guid companyId,
+ BpdmData data,
+ CancellationToken cancellationToken)
+ {
+ var legalEntity = await _bpdmService.FetchInputLegalEntity(context.ApplicationId.ToString(), cancellationToken)
+ .ConfigureAwait(false);
if (string.IsNullOrEmpty(legalEntity.Bpn))
{
diff --git a/src/externalsystems/Bpdm.Library/IBpdmService.cs b/src/externalsystems/Bpdm.Library/IBpdmService.cs
index f7e451cf85..b79ae9028a 100644
--- a/src/externalsystems/Bpdm.Library/IBpdmService.cs
+++ b/src/externalsystems/Bpdm.Library/IBpdmService.cs
@@ -35,4 +35,5 @@ public interface IBpdmService
/// Returns true if the service call was successful, otherwise false
Task PutInputLegalEntity(BpdmTransferData data, CancellationToken cancellationToken);
Task FetchInputLegalEntity(string externalId, CancellationToken cancellationToken);
+ Task GetSharingState(Guid applicationId, CancellationToken cancellationToken);
}
diff --git a/src/externalsystems/Bpdm.Library/Models/BpdmLegalEntityData.cs b/src/externalsystems/Bpdm.Library/Models/BpdmLegalEntityData.cs
index 28274d2a15..7f8c4797b6 100644
--- a/src/externalsystems/Bpdm.Library/Models/BpdmLegalEntityData.cs
+++ b/src/externalsystems/Bpdm.Library/Models/BpdmLegalEntityData.cs
@@ -79,7 +79,7 @@ public record BpdmAddressPhysicalPostalAddress(
string? Country,
string? PostalCode,
string? City,
- BpdmStreet? Street,
+ BpdmLegalEntityStreet? Street,
string? AdministrativeAreaLevel1,
string? AdministrativeAreaLevel2,
string? AdministrativeAreaLevel3,
@@ -101,3 +101,14 @@ public record BpdmAddressAlternativePostalAddress(
string? DeliveryServiceType,
string? DeliveryServiceQualifier
);
+
+public record BpdmLegalEntityStreet(
+ string? NamePrefix,
+ string? AdditionalNamePrefix,
+ string Name,
+ string? NameSuffix,
+ string? AdditionalNameSuffix,
+ string? HouseNumber,
+ string? Milestone,
+ string? Direction
+);
diff --git a/src/externalsystems/Bpdm.Library/Models/BpdmLegalEntityDto.cs b/src/externalsystems/Bpdm.Library/Models/BpdmLegalEntityDto.cs
index cc337c73c6..65b190edfe 100644
--- a/src/externalsystems/Bpdm.Library/Models/BpdmLegalEntityDto.cs
+++ b/src/externalsystems/Bpdm.Library/Models/BpdmLegalEntityDto.cs
@@ -29,37 +29,37 @@ public record BpdmLegalEntityDto(
[property: JsonPropertyName("currentness")] DateTimeOffset Currentness,
[property: JsonPropertyName("createdAt")] DateTimeOffset CreatedAt,
[property: JsonPropertyName("updatedAt")] DateTimeOffset UpdatedAt,
- IEnumerable Identifiers,
- BpdmLegalFormDto? LegalForm,
- IEnumerable Status,
- IEnumerable ProfileClassifications,
- IEnumerable Relations,
- BpdmLegalEntityAddress LegalEntityAddress
+ [property: JsonPropertyName("identifiers")] IEnumerable Identifiers,
+ [property: JsonPropertyName("legalForm")] BpdmLegalFormDto? LegalForm,
+ [property: JsonPropertyName("states")] IEnumerable States,
+ [property: JsonPropertyName("classifications")] IEnumerable Classifications,
+ [property: JsonPropertyName("relations")] IEnumerable Relations,
+ [property: JsonPropertyName("legalAddress")] BpdmLegalEntityAddress? LegalEntityAddress
);
public record BpdmIdentifierDto(
string Value,
BpdmTechnicalKey Type,
- string IssuingBody
+ string? IssuingBody
);
public record BpdmLegalFormDto(
- string TechnicalKey,
- string Name,
- string Abbreviation
+ string? TechnicalKey,
+ string? Name,
+ string? Abbreviation
);
public record BpdmStatusDto(
- string OfficialDenotation,
+ string? OfficialDenotation,
DateTimeOffset ValidFrom,
DateTimeOffset ValidUntil,
BpdmTechnicalKey Type
);
public record BpdmProfileClassificationDto(
- string Value,
- string Code,
- BpdmTechnicalKey Type
+ string? Value,
+ string? Code,
+ BpdmTechnicalKey? Type
);
public record BpdmDataDto(
@@ -74,18 +74,18 @@ string Name
public record BpdmRelationDto(
BpdmTechnicalKey Type,
- string StartBpn,
- string EndBpn,
+ string? StartBpn,
+ string? EndBpn,
DateTimeOffset ValidFrom,
DateTimeOffset ValidTo
);
public record BpdmLegalEntityAddress
(
- string Bpnl,
- string Name,
- string BpnLegalEntity,
- string BpnSite,
+ string? Bpna,
+ string? Name,
+ string? BpnLegalEntity,
+ string? BpnSite,
DateTimeOffset CreatedAt,
DateTimeOffset UpdatedAt,
bool IsLegalAddress,
@@ -98,7 +98,7 @@ public record BpdmLegalEntityAddress
public record BpdmLegalEntityAddressState
(
- string Description,
+ string? Description,
DateTimeOffset ValidFrom,
DateTimeOffset ValidTo,
BpdmTechnicalKey Type
@@ -106,7 +106,7 @@ BpdmTechnicalKey Type
public record BpdmLegalEntityAddressIdentifier
(
- string Value,
+ string? Value,
BpdmTechnicalKey Type
);
@@ -139,16 +139,13 @@ public record BpdmAlternativePostalAddress(
);
public record BpdmAdministrativeAreaLevel(
- string? Name,
+ string? CountryCode,
+ string? RegionName,
string? RegionCode
);
public record BpdmStreet(
- string? NamePrefix,
- string? AdditionalNamePrefix,
- string Name,
- string? NameSuffix,
- string? AdditionalNameSuffix,
+ string? Name,
string? HouseNumber,
string? Milestone,
string? Direction
diff --git a/src/externalsystems/Bpdm.Library/Models/BpdmSharingState.cs b/src/externalsystems/Bpdm.Library/Models/BpdmSharingState.cs
new file mode 100644
index 0000000000..78da8a3c0c
--- /dev/null
+++ b/src/externalsystems/Bpdm.Library/Models/BpdmSharingState.cs
@@ -0,0 +1,30 @@
+namespace Org.Eclipse.TractusX.Portal.Backend.Bpdm.Library.Models;
+
+public record BpdmPaginationSharingStateOutput(
+ IEnumerable? Content
+);
+
+public record BpdmSharingState(
+ BpdmSharingStateBusinessPartnerType BusinessPartnerType,
+ Guid ExternalId,
+ BpdmSharingStateType SharingStateType,
+ string? SharingErrorCode,
+ string? SharingErrorMessage,
+ string? Bpn,
+ DateTimeOffset SharingProcessStarted
+);
+
+public enum BpdmSharingStateType
+{
+ Pending = 1,
+ Success = 2,
+ Error = 3,
+ Initial = 4
+}
+
+public enum BpdmSharingStateBusinessPartnerType
+{
+ LEGAL_ENTITY = 1,
+ SITE = 2,
+ ADDRESS = 3
+}
diff --git a/src/framework/Framework.Linq/NullOrSequenceEqualExtension.cs b/src/framework/Framework.Linq/NullOrSequenceEqualExtension.cs
new file mode 100644
index 0000000000..b7a5412bbc
--- /dev/null
+++ b/src/framework/Framework.Linq/NullOrSequenceEqualExtension.cs
@@ -0,0 +1,58 @@
+/********************************************************************************
+ * Copyright (c) 2021, 2023 BMW Group AG
+ * Copyright (c) 2021, 2023 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.Diagnostics.CodeAnalysis;
+
+namespace Org.Eclipse.TractusX.Portal.Backend.Framework.Linq;
+
+public static class NullOrSequenceEqualExtensions
+{
+ public static bool NullOrContentEqual(this IEnumerable? items, IEnumerable? others, IEqualityComparer? comparer = null) where T : IComparable =>
+ items == null && others == null ||
+ items != null && others != null &&
+ items.OrderBy(x => x).SequenceEqual(others.OrderBy(x => x), comparer);
+
+ public static bool NullOrContentEqual(this IEnumerable>? items, IEnumerable>? others, IEqualityComparer>? comparer = null) where K : IComparable where V : IComparable =>
+ items == null && others == null ||
+ items != null && others != null &&
+ items.OrderBy(x => x.Key).SequenceEqual(others.OrderBy(x => x.Key), comparer ?? new KeyValuePairEqualityComparer());
+
+ public static bool NullOrContentEqual(this IEnumerable>>? items, IEnumerable>>? others, IEqualityComparer>>? comparer = null) where V : IComparable =>
+ items == null && others == null ||
+ items != null && others != null &&
+ items.OrderBy(x => x.Key).SequenceEqual(others.OrderBy(x => x.Key), comparer ?? new EnumerableValueKeyValuePairEqualityComparer());
+}
+
+public class KeyValuePairEqualityComparer : IEqualityComparer> where K : IComparable where V : IComparable
+{
+ public bool Equals(KeyValuePair x, KeyValuePair y) =>
+ x.Key.Equals(y.Key) && x.Value.Equals(y.Value);
+ public int GetHashCode([DisallowNull] KeyValuePair obj) => throw new NotImplementedException();
+}
+
+public class EnumerableValueKeyValuePairEqualityComparer : IEqualityComparer>> where V : IComparable
+{
+ public bool Equals(KeyValuePair> source, KeyValuePair> other) =>
+ (source.Key == null && other.Key == null ||
+ source.Key != null && source.Key.Equals(other.Key)) &&
+ source.Value.NullOrContentEqual(other.Value);
+
+ public int GetHashCode([DisallowNull] KeyValuePair> obj) => throw new NotImplementedException();
+}
diff --git a/src/framework/Framework.Logging/LoggingExtensions.cs b/src/framework/Framework.Logging/LoggingExtensions.cs
index f401a0511f..060e636493 100644
--- a/src/framework/Framework.Logging/LoggingExtensions.cs
+++ b/src/framework/Framework.Logging/LoggingExtensions.cs
@@ -38,9 +38,9 @@ public static IHostBuilder AddLogging(this IHostBuilder host, Action
{
configuration
- .WriteTo.Console(new JsonFormatter())
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
- .ReadFrom.Configuration(context.Configuration);
+ .ReadFrom.Configuration(context.Configuration)
+ .WriteTo.Console(new JsonFormatter(renderMessage: true));
extendLogging?.Invoke(configuration, context.Configuration);
});
@@ -58,8 +58,7 @@ public static void EnsureInitialized()
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
- .Enrich.FromLogContext()
- .WriteTo.Console(new JsonFormatter())
+ .WriteTo.Console(new JsonFormatter(renderMessage: true))
.CreateBootstrapLogger();
}
}
diff --git a/src/framework/Framework.Models/HasNextEnumeratorExtensions.cs b/src/framework/Framework.Models/HasNextEnumeratorExtensions.cs
new file mode 100644
index 0000000000..a878e9ae48
--- /dev/null
+++ b/src/framework/Framework.Models/HasNextEnumeratorExtensions.cs
@@ -0,0 +1,64 @@
+/********************************************************************************
+ * Copyright (c) 2021, 2023 BMW Group AG
+ * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
+
+public static class HasNextEnumeratorExtensions
+{
+ private sealed class HasNextEnumeratorWrapper : IHasNextEnumerator
+ {
+ private readonly IEnumerator _enumerator;
+ private bool _hasNext;
+
+ public HasNextEnumeratorWrapper(IEnumerable enumerable)
+ {
+ _enumerator = enumerable.GetEnumerator();
+ _hasNext = _enumerator.MoveNext();
+ }
+
+ public void Advance()
+ {
+ _hasNext = _enumerator.MoveNext();
+ }
+
+ public bool HasNext
+ {
+ get => _hasNext;
+ }
+
+ public T Current
+ {
+ get => _enumerator.Current;
+ }
+
+ public void Dispose() => _enumerator.Dispose();
+ }
+
+ public static IHasNextEnumerator GetHasNextEnumerator(this IEnumerable source) => new HasNextEnumeratorWrapper(source);
+}
+
+public interface IHasNextEnumerator : IDisposable
+{
+ void Advance();
+
+ bool HasNext { get; }
+
+ T Current { get; }
+}
diff --git a/src/framework/Framework.PublicInfos/DependencyInjection/PublicInfosServiceCollectionExtensions.cs b/src/framework/Framework.PublicInfos/DependencyInjection/PublicInfosServiceCollectionExtensions.cs
new file mode 100644
index 0000000000..f6287cd1b7
--- /dev/null
+++ b/src/framework/Framework.PublicInfos/DependencyInjection/PublicInfosServiceCollectionExtensions.cs
@@ -0,0 +1,34 @@
+/********************************************************************************
+ * Copyright (c) 2021, 2023 BMW Group AG
+ * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos.DependencyInjection;
+
+public static class PublicInfosServiceCollectionExtensions
+{
+ public static IServiceCollection AddPublicInfos(this IServiceCollection services)
+ {
+ services
+ .AddTransient();
+
+ return services;
+ }
+}
diff --git a/src/framework/Framework.PublicInfos/Framework.PublicInfos.csproj b/src/framework/Framework.PublicInfos/Framework.PublicInfos.csproj
new file mode 100644
index 0000000000..b9e249136d
--- /dev/null
+++ b/src/framework/Framework.PublicInfos/Framework.PublicInfos.csproj
@@ -0,0 +1,44 @@
+
+
+
+ Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos
+ Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/framework/Framework.PublicInfos/IPublicInformationBusinessLogic.cs b/src/framework/Framework.PublicInfos/IPublicInformationBusinessLogic.cs
new file mode 100644
index 0000000000..e0d118c4a4
--- /dev/null
+++ b/src/framework/Framework.PublicInfos/IPublicInformationBusinessLogic.cs
@@ -0,0 +1,26 @@
+/********************************************************************************
+ * Copyright (c) 2021, 2023 BMW Group AG
+ * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+namespace Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos;
+
+public interface IPublicInformationBusinessLogic
+{
+ Task> GetPublicUrls();
+}
diff --git a/src/framework/Framework.PublicInfos/OpenInformationController.cs b/src/framework/Framework.PublicInfos/OpenInformationController.cs
new file mode 100644
index 0000000000..3720b11135
--- /dev/null
+++ b/src/framework/Framework.PublicInfos/OpenInformationController.cs
@@ -0,0 +1,56 @@
+/********************************************************************************
+ * Copyright (c) 2021, 2023 BMW Group AG
+ * Copyright (c) 2021, 2023 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.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
+using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Authentication;
+
+namespace Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos;
+
+[ApiController]
+[Route("api/info")]
+public class OpenInformationController : ControllerBase
+{
+ private readonly IPublicInformationBusinessLogic _publicInformationBusinessLogic;
+
+ ///
+ /// Creates a new instance of
+ ///
+ /// The business logic
+ public OpenInformationController(IPublicInformationBusinessLogic publicInformationBusinessLogic)
+ {
+ _publicInformationBusinessLogic = publicInformationBusinessLogic;
+ }
+
+ ///
+ /// Gets all open information based on the
+ ///
+ ///
+ /// Example: GET: api/info
+ ///
+ /// Successfully executed the invitation.
+ [HttpGet]
+ [Authorize(Policy = PolicyTypes.ValidCompany)]
+ [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
+ public Task> GetOpenUrls() =>
+ _publicInformationBusinessLogic.GetPublicUrls();
+}
diff --git a/src/framework/Framework.PublicInfos/PublicInformationBusinessLogic.cs b/src/framework/Framework.PublicInfos/PublicInformationBusinessLogic.cs
new file mode 100644
index 0000000000..378d317431
--- /dev/null
+++ b/src/framework/Framework.PublicInfos/PublicInformationBusinessLogic.cs
@@ -0,0 +1,63 @@
+/********************************************************************************
+ * Copyright (c) 2021, 2023 BMW Group AG
+ * Copyright (c) 2021, 2023 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.AspNetCore.Mvc.ActionConstraints;
+using Microsoft.AspNetCore.Mvc.Controllers;
+using Microsoft.AspNetCore.Mvc.Infrastructure;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
+using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities;
+using System.Reflection;
+
+namespace Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos;
+
+public class PublicInformationBusinessLogic : IPublicInformationBusinessLogic
+{
+ private readonly IActionDescriptorCollectionProvider _actionDescriptorCollectionProvider;
+ private readonly IPortalRepositories _portalRepositories;
+ private readonly IIdentityService _identityService;
+
+ ///
+ /// Creates a new instance of
+ ///
+ /// The actionDescriptorCollectionProvider
+ ///
+ ///
+ public PublicInformationBusinessLogic(IActionDescriptorCollectionProvider actionDescriptorCollectionProvider, IPortalRepositories portalRepositories, IIdentityService identityService)
+ {
+ _actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
+ _portalRepositories = portalRepositories;
+ _identityService = identityService;
+ }
+
+ public async Task> GetPublicUrls()
+ {
+ var companyRoleIds = await _portalRepositories.GetInstance().GetOwnCompanyRolesAsync(_identityService.IdentityData.CompanyId).ToArrayAsync().ConfigureAwait(false);
+ return _actionDescriptorCollectionProvider.ActionDescriptors.Items
+ .Where(item => item.ActionConstraints != null && item.ActionConstraints.OfType().Any())
+ .OfType()
+ .Where(item => item.MethodInfo.GetCustomAttribute()?.CompanyRoleIds.Intersect(companyRoleIds).Any() ?? false)
+ .Select(item =>
+ new UrlInformation(
+ string.Join(", ", item.ActionConstraints!.OfType().SelectMany(x => x.HttpMethods).Distinct()),
+ (item.AttributeRouteInfo?.Template ?? throw new ConflictException($"There must be an url for {item.DisplayName}")).ToLower()));
+ }
+}
diff --git a/src/framework/Framework.PublicInfos/PublicUrlAttribute.cs b/src/framework/Framework.PublicInfos/PublicUrlAttribute.cs
new file mode 100644
index 0000000000..7c16bde307
--- /dev/null
+++ b/src/framework/Framework.PublicInfos/PublicUrlAttribute.cs
@@ -0,0 +1,34 @@
+/********************************************************************************
+ * Copyright (c) 2021, 2023 BMW Group AG
+ * Copyright (c) 2021, 2023 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.PortalBackend.PortalEntities.Enums;
+
+namespace Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos;
+
+[AttributeUsage(AttributeTargets.Method)]
+public class PublicUrlAttribute : Attribute
+{
+ public PublicUrlAttribute(params CompanyRoleId[] companyRoleIds)
+ {
+ CompanyRoleIds = companyRoleIds;
+ }
+
+ public IEnumerable CompanyRoleIds { get; set; }
+}
diff --git a/src/framework/Framework.PublicInfos/UrlInformation.cs b/src/framework/Framework.PublicInfos/UrlInformation.cs
new file mode 100644
index 0000000000..e1d4e5b2f6
--- /dev/null
+++ b/src/framework/Framework.PublicInfos/UrlInformation.cs
@@ -0,0 +1,28 @@
+/********************************************************************************
+ * Copyright (c) 2021, 2023 BMW Group AG
+ * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+
+using System.Text.Json.Serialization;
+
+namespace Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos;
+
+public record UrlInformation(
+ [property: JsonPropertyName("httpMethods")] string HttpMethods,
+ [property: JsonPropertyName("url")] string Url
+);
diff --git a/src/framework/Framework.Seeding/SeederSettings.cs b/src/framework/Framework.Seeding/SeederSettings.cs
index 60cc165ea2..8b5b8c1770 100644
--- a/src/framework/Framework.Seeding/SeederSettings.cs
+++ b/src/framework/Framework.Seeding/SeederSettings.cs
@@ -27,23 +27,16 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Framework.Seeding;
public class SeederSettings
{
- public SeederSettings()
- {
- TestDataEnvironments = null!;
- DataPaths = null!;
- }
-
///
/// Configurable paths where to check for the seeding data
///
[Required]
- public IEnumerable DataPaths { get; set; }
+ public IEnumerable DataPaths { get; set; } = null!;
///
/// Configurable environments for the testdata
///
- [Required]
- public IEnumerable TestDataEnvironments { get; set; }
+ public IEnumerable? TestDataEnvironments { get; set; }
}
public static class SeederSettingsExtensions
diff --git a/src/framework/Framework.Web/Framework.Web.csproj b/src/framework/Framework.Web/Framework.Web.csproj
index d1b6ffea9b..daa8adbaab 100644
--- a/src/framework/Framework.Web/Framework.Web.csproj
+++ b/src/framework/Framework.Web/Framework.Web.csproj
@@ -32,6 +32,7 @@
+
diff --git a/src/framework/Framework.Web/StartupServiceExtensions.cs b/src/framework/Framework.Web/StartupServiceExtensions.cs
index ed8bcf868b..5cde1fb78f 100644
--- a/src/framework/Framework.Web/StartupServiceExtensions.cs
+++ b/src/framework/Framework.Web/StartupServiceExtensions.cs
@@ -27,6 +27,7 @@
using Org.Eclipse.TractusX.Portal.Backend.Framework.Cors;
using Org.Eclipse.TractusX.Portal.Backend.Framework.DateTimeProvider.DependencyInjection;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos.DependencyInjection;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Swagger;
using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Authentication;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
@@ -104,6 +105,7 @@ public static IServiceCollection AddDefaultServices(this IServiceColle
services.AddScoped();
services.AddDateTimeProvider();
+ services.AddPublicInfos();
return services;
}
}
diff --git a/src/keycloak/Keycloak.Library/AuthenticationManagement/KeycloakClient.cs b/src/keycloak/Keycloak.Library/AuthenticationManagement/KeycloakClient.cs
index 920b840d0a..aeaed96a15 100644
--- a/src/keycloak/Keycloak.Library/AuthenticationManagement/KeycloakClient.cs
+++ b/src/keycloak/Keycloak.Library/AuthenticationManagement/KeycloakClient.cs
@@ -53,31 +53,31 @@ public async Task GetAuthenticatorProviderConfiguration
.GetJsonAsync()
.ConfigureAwait(false);
- [Obsolete("Not working yet")]
- public async Task GetAuthenticatorConfigurationAsync(string realm, string configurationId) => await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
- .AppendPathSegment("/admin/realms/")
- .AppendPathSegment(realm, true)
- .AppendPathSegment("/authentication/config/")
- .AppendPathSegment(configurationId, true)
- .GetJsonAsync()
- .ConfigureAwait(false);
+ public async Task GetAuthenticatorConfigurationAsync(string realm, string configurationId, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
+ .AppendPathSegment("/admin/realms/")
+ .AppendPathSegment(realm, true)
+ .AppendPathSegment("/authentication/config/")
+ .AppendPathSegment(configurationId, true)
+ .GetJsonAsync(cancellationToken)
+ .ConfigureAwait(false);
- public async Task UpdateAuthenticatorConfigurationAsync(string realm, string configurationId, AuthenticatorConfig authenticatorConfig) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task UpdateAuthenticatorConfigurationAsync(string realm, string configurationId, AuthenticatorConfig authenticatorConfig, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/config/")
.AppendPathSegment(configurationId, true)
- .PutJsonAsync(authenticatorConfig)
+ .PutJsonAsync(authenticatorConfig, cancellationToken)
.ConfigureAwait(false);
- public async Task DeleteAuthenticatorConfigurationAsync(string realm, string configurationId) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task DeleteAuthenticatorConfigurationAsync(string realm, string configurationId, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/config/")
.AppendPathSegment(configurationId, true)
- .DeleteAsync()
+ .DeleteAsync(cancellationToken)
.ConfigureAwait(false);
public async Task AddAuthenticationExecutionAsync(string realm, AuthenticationExecution authenticationExecution) =>
@@ -97,23 +97,23 @@ public async Task GetAuthenticationExecutionAsync(s
.GetJsonAsync()
.ConfigureAwait(false);
- public async Task DeleteAuthenticationExecutionAsync(string realm, string executionId) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task DeleteAuthenticationExecutionAsync(string realm, string executionId, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/executions/")
.AppendPathSegment(executionId, true)
- .DeleteAsync()
+ .DeleteAsync(cancellationToken)
.ConfigureAwait(false);
- public async Task UpdateAuthenticationExecutionConfigurationAsync(string realm, string executionId, AuthenticatorConfig authenticatorConfig) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task CreateAuthenticationExecutionConfigurationAsync(string realm, string executionId, AuthenticatorConfig authenticatorConfig, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/executions/")
.AppendPathSegment(executionId, true)
.AppendPathSegment("/config")
- .PostJsonAsync(authenticatorConfig)
+ .PostJsonAsync(authenticatorConfig, cancellationToken)
.ConfigureAwait(false);
public async Task LowerAuthenticationExecutionPriorityAsync(string realm, string executionId) =>
@@ -136,20 +136,20 @@ public async Task RaiseAuthenticationExecutionPriorityAsync(string realm, string
.PostAsync(new StringContent(""))
.ConfigureAwait(false);
- public async Task CreateAuthenticationFlowAsync(string realm, AuthenticationFlow authenticationFlow) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task CreateAuthenticationFlowAsync(string realm, AuthenticationFlow authenticationFlow, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/flows")
- .PostJsonAsync(authenticationFlow)
+ .PostJsonAsync(authenticationFlow, cancellationToken)
.ConfigureAwait(false);
- public async Task> GetAuthenticationFlowsAsync(string realm) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task> GetAuthenticationFlowsAsync(string realm, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/flows")
- .GetJsonAsync>()
+ .GetJsonAsync>(cancellationToken)
.ConfigureAwait(false);
public async Task DuplicateAuthenticationFlowAsync(string realm, string flowAlias, string newName) =>
@@ -162,44 +162,64 @@ public async Task DuplicateAuthenticationFlowAsync(string realm, string flowAlia
.PostJsonAsync(new Dictionary { [nameof(newName)] = newName })
.ConfigureAwait(false);
- public async Task> GetAuthenticationFlowExecutionsAsync(string realm, string flowAlias) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task> GetAuthenticationFlowExecutionsAsync(string realm, string flowAlias, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/flows/")
.AppendPathSegment(flowAlias, true)
.AppendPathSegment("/executions")
- .GetJsonAsync>()
+ .GetJsonAsync>(cancellationToken)
.ConfigureAwait(false);
- public async Task UpdateAuthenticationFlowExecutionsAsync(string realm, string flowAlias, AuthenticationExecutionInfo authenticationExecutionInfo) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task UpdateAuthenticationFlowExecutionsAsync(string realm, string flowAlias, AuthenticationExecutionInfo authenticationExecutionInfo, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/flows/")
.AppendPathSegment(flowAlias, true)
.AppendPathSegment("/executions")
- .PutJsonAsync(authenticationExecutionInfo)
+ .PutJsonAsync(authenticationExecutionInfo, cancellationToken)
.ConfigureAwait(false);
- public async Task AddAuthenticationFlowExecutionAsync(string realm, string flowAlias, IDictionary dataWithProvider) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public Task AddAuthenticationFlowExecutionAsync(string realm, string flowAlias, IDictionary dataWithProvider, CancellationToken cancellationToken = default) =>
+ InternalAddAuthenticationFlowExecutionAsync(realm, flowAlias, dataWithProvider, cancellationToken);
+
+ public async Task AddAndRetrieveAuthenticationFlowExecutionIdAsync(string realm, string flowAlias, IDictionary dataWithProvider, CancellationToken cancellationToken = default)
+ {
+ var response = await InternalAddAuthenticationFlowExecutionAsync(realm, flowAlias, dataWithProvider, cancellationToken).ConfigureAwait(false);
+ var locationPathAndQuery = response.ResponseMessage.Headers.Location?.PathAndQuery;
+ return locationPathAndQuery != null ? locationPathAndQuery.Substring(locationPathAndQuery.LastIndexOf("/", StringComparison.Ordinal) + 1) : null;
+ }
+
+ private async Task InternalAddAuthenticationFlowExecutionAsync(string realm, string flowAlias, IDictionary dataWithProvider, CancellationToken cancellationToken) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/flows/")
.AppendPathSegment(flowAlias, true)
.AppendPathSegment("/executions/execution")
- .PostJsonAsync(dataWithProvider)
+ .PostJsonAsync(dataWithProvider, cancellationToken)
.ConfigureAwait(false);
- public async Task AddAuthenticationFlowAndExecutionToAuthenticationFlowAsync(string realm, string flowAlias, IDictionary dataWithAliasTypeProviderDescription) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public Task AddAuthenticationFlowAndExecutionToAuthenticationFlowAsync(string realm, string flowAlias, IDictionary dataWithAliasTypeProviderDescription, CancellationToken cancellationToken = default) =>
+ InternalAddAuthenticationFlowAndExecutionToAuthenticationFlowAsync(realm, flowAlias, dataWithAliasTypeProviderDescription, cancellationToken);
+
+ public async Task AddAndRetrieveAuthenticationFlowAndExecutionToAuthenticationFlowIdAsync(string realm, string flowAlias, IDictionary dataWithAliasTypeProviderDescription, CancellationToken cancellationToken)
+ {
+ var response = await InternalAddAuthenticationFlowAndExecutionToAuthenticationFlowAsync(realm, flowAlias, dataWithAliasTypeProviderDescription, cancellationToken).ConfigureAwait(false);
+ var locationPathAndQuery = response.ResponseMessage.Headers.Location?.PathAndQuery;
+ return locationPathAndQuery != null ? locationPathAndQuery.Substring(locationPathAndQuery.LastIndexOf("/", StringComparison.Ordinal) + 1) : null;
+ }
+
+ private async Task InternalAddAuthenticationFlowAndExecutionToAuthenticationFlowAsync(string realm, string flowAlias, IDictionary dataWithAliasTypeProviderDescription, CancellationToken cancellationToken) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/flows/")
.AppendPathSegment(flowAlias, true)
.AppendPathSegment("/executions/flow")
- .PostJsonAsync(dataWithAliasTypeProviderDescription)
+ .PostJsonAsync(dataWithAliasTypeProviderDescription, cancellationToken)
.ConfigureAwait(false);
public async Task GetAuthenticationFlowByIdAsync(string realm, string flowId) =>
@@ -211,22 +231,22 @@ public async Task GetAuthenticationFlowByIdAsync(string real
.GetJsonAsync()
.ConfigureAwait(false);
- public async Task UpdateAuthenticationFlowAsync(string realm, string flowId, AuthenticationFlow authenticationFlow) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task UpdateAuthenticationFlowAsync(string realm, string flowId, AuthenticationFlow authenticationFlow, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/flows/")
.AppendPathSegment(flowId, true)
- .PutJsonAsync(authenticationFlow)
+ .PutJsonAsync(authenticationFlow, cancellationToken)
.ConfigureAwait(false);
- public async Task DeleteAuthenticationFlowAsync(string realm, string flowId) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task DeleteAuthenticationFlowAsync(string realm, string flowId, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/authentication/flows/")
.AppendPathSegment(flowId, true)
- .DeleteAsync()
+ .DeleteAsync(cancellationToken)
.ConfigureAwait(false);
public async Task>> GetFormActionProvidersAsync(string realm) =>
diff --git a/src/keycloak/Keycloak.Library/ClientRoleMappings/KeycloakClient.cs b/src/keycloak/Keycloak.Library/ClientRoleMappings/KeycloakClient.cs
index 4f8dc57e7a..f66cb98c5b 100644
--- a/src/keycloak/Keycloak.Library/ClientRoleMappings/KeycloakClient.cs
+++ b/src/keycloak/Keycloak.Library/ClientRoleMappings/KeycloakClient.cs
@@ -88,37 +88,37 @@ public async Task> GetEffectiveClientRoleMappingsForGroupAsync
.GetJsonAsync>()
.ConfigureAwait(false);
- public async Task AddClientRoleMappingsToUserAsync(string realm, string userId, string clientId, IEnumerable roles) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task AddClientRoleMappingsToUserAsync(string realm, string userId, string clientId, IEnumerable roles, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/users/")
.AppendPathSegment(userId, true)
.AppendPathSegment("/role-mappings/clients/")
.AppendPathSegment(clientId, true)
- .PostJsonAsync(roles)
+ .PostJsonAsync(roles, cancellationToken)
.ConfigureAwait(false);
- public async Task> GetClientRoleMappingsForUserAsync(string realm, string userId, string clientId) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task> GetClientRoleMappingsForUserAsync(string realm, string userId, string clientId, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/users/")
.AppendPathSegment(userId, true)
.AppendPathSegment("/role-mappings/clients/")
.AppendPathSegment(clientId, true)
- .GetJsonAsync>()
+ .GetJsonAsync>(cancellationToken)
.ConfigureAwait(false);
- public async Task DeleteClientRoleMappingsFromUserAsync(string realm, string userId, string clientId, IEnumerable roles) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task DeleteClientRoleMappingsFromUserAsync(string realm, string userId, string clientId, IEnumerable roles, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/users/")
.AppendPathSegment(userId, true)
.AppendPathSegment("/role-mappings/clients/")
.AppendPathSegment(clientId, true)
- .SendJsonAsync(HttpMethod.Delete, roles)
+ .SendJsonAsync(HttpMethod.Delete, roles, cancellationToken)
.ConfigureAwait(false);
public async Task> GetAvailableClientRoleMappingsForUserAsync(string realm, string userId, string clientId) =>
diff --git a/src/keycloak/Keycloak.Library/ClientScopes/KeycloakClient.cs b/src/keycloak/Keycloak.Library/ClientScopes/KeycloakClient.cs
index 690a308ac6..9fcba4326b 100644
--- a/src/keycloak/Keycloak.Library/ClientScopes/KeycloakClient.cs
+++ b/src/keycloak/Keycloak.Library/ClientScopes/KeycloakClient.cs
@@ -31,20 +31,20 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Keycloak.Library;
public partial class KeycloakClient
{
- public async Task CreateClientScopeAsync(string realm, ClientScope clientScope) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task CreateClientScopeAsync(string realm, ClientScope clientScope, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/client-scopes")
- .PostJsonAsync(clientScope)
+ .PostJsonAsync(clientScope, cancellationToken)
.ConfigureAwait(false);
- public async Task> GetClientScopesAsync(string realm) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task> GetClientScopesAsync(string realm, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/client-scopes")
- .GetJsonAsync>()
+ .GetJsonAsync>(cancellationToken)
.ConfigureAwait(false);
public async Task GetClientScopeAsync(string realm, string clientScopeId) =>
@@ -56,21 +56,21 @@ public async Task GetClientScopeAsync(string realm, string clientSc
.GetJsonAsync()
.ConfigureAwait(false);
- public async Task UpdateClientScopeAsync(string realm, string clientScopeId, ClientScope clientScope) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task UpdateClientScopeAsync(string realm, string clientScopeId, ClientScope clientScope, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/client-scopes/")
.AppendPathSegment(clientScopeId, true)
- .PutJsonAsync(clientScope)
+ .PutJsonAsync(clientScope, cancellationToken)
.ConfigureAwait(false);
- public async Task DeleteClientScopeAsync(string realm, string clientScopeId) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task DeleteClientScopeAsync(string realm, string clientScopeId, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/client-scopes/")
.AppendPathSegment(clientScopeId, true)
- .DeleteAsync()
+ .DeleteAsync(cancellationToken)
.ConfigureAwait(false);
}
diff --git a/src/keycloak/Keycloak.Library/Clients/KeycloakClient.cs b/src/keycloak/Keycloak.Library/Clients/KeycloakClient.cs
index e22f490f24..47f5306eed 100644
--- a/src/keycloak/Keycloak.Library/Clients/KeycloakClient.cs
+++ b/src/keycloak/Keycloak.Library/Clients/KeycloakClient.cs
@@ -36,26 +36,26 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Keycloak.Library;
public partial class KeycloakClient
{
- public async Task CreateClientAsync(string realm, Client client) =>
- await InternalCreateClientAsync(realm, client).ConfigureAwait(false);
+ public async Task CreateClientAsync(string realm, Client client, CancellationToken cancellationToken = default) =>
+ await InternalCreateClientAsync(realm, client, cancellationToken).ConfigureAwait(false);
- public async Task CreateClientAndRetrieveClientIdAsync(string realm, Client client)
+ public async Task CreateClientAndRetrieveClientIdAsync(string realm, Client client, CancellationToken cancellationToken = default)
{
- var response = await InternalCreateClientAsync(realm, client).ConfigureAwait(false);
+ var response = await InternalCreateClientAsync(realm, client, cancellationToken).ConfigureAwait(false);
var locationPathAndQuery = response.ResponseMessage.Headers.Location?.PathAndQuery;
return locationPathAndQuery?.Substring(locationPathAndQuery.LastIndexOf("/", StringComparison.Ordinal) + 1);
}
- private async Task InternalCreateClientAsync(string realm, Client client) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ private async Task InternalCreateClientAsync(string realm, Client client, CancellationToken cancellationToken) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/clients")
- .PostJsonAsync(client)
+ .PostJsonAsync(client, cancellationToken)
.ConfigureAwait(false);
- public async Task> GetClientsAsync(string realm, string? clientId = null, bool? viewableOnly = null)
+ public async Task> GetClientsAsync(string realm, string? clientId = null, bool? viewableOnly = null, CancellationToken cancellationToken = default)
{
var queryParams = new Dictionary
{
@@ -63,12 +63,12 @@ public async Task> GetClientsAsync(string realm, string? cli
[nameof(viewableOnly)] = viewableOnly
};
- return await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ return await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/clients")
.SetQueryParams(queryParams)
- .GetJsonAsync>()
+ .GetJsonAsync>(cancellationToken)
.ConfigureAwait(false);
}
@@ -81,13 +81,13 @@ public async Task GetClientAsync(string realm, string clientId) =>
.GetJsonAsync()
.ConfigureAwait(false);
- public async Task UpdateClientAsync(string realm, string clientId, Client client) =>
- await (await GetBaseUrlAsync(realm).ConfigureAwait(false))
+ public async Task UpdateClientAsync(string realm, string clientId, Client client, CancellationToken cancellationToken = default) =>
+ await (await GetBaseUrlAsync(realm, cancellationToken).ConfigureAwait(false))
.AppendPathSegment("/admin/realms/")
.AppendPathSegment(realm, true)
.AppendPathSegment("/clients/")
.AppendPathSegment(clientId, true)
- .PutJsonAsync(client)
+ .PutJsonAsync(client, cancellationToken)
.ConfigureAwait(false);
public async Task DeleteClientAsync(string realm, string clientId) =>
diff --git a/src/keycloak/Keycloak.Library/Common/Extensions/FlurlRequestExtensions.cs b/src/keycloak/Keycloak.Library/Common/Extensions/FlurlRequestExtensions.cs
index f9b193da5b..016362b766 100644
--- a/src/keycloak/Keycloak.Library/Common/Extensions/FlurlRequestExtensions.cs
+++ b/src/keycloak/Keycloak.Library/Common/Extensions/FlurlRequestExtensions.cs
@@ -31,7 +31,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Keycloak.Library.Common.Extensions
public static class FlurlRequestExtensions
{
- private static async Task GetAccessTokenAsync(string url, string realm, string userName, string password)
+ private static async Task GetAccessTokenAsync(string url, string realm, string userName, string password, CancellationToken cancellationToken)
{
var result = await url
.AppendPathSegment($"/auth/realms/{realm}/protocol/openid-connect/token")
@@ -42,7 +42,8 @@ private static async Task GetAccessTokenAsync(string url, string realm,
new KeyValuePair("username", userName),
new KeyValuePair("password", password),
new KeyValuePair("client_id", "admin-cli")
- })
+ },
+ cancellationToken)
.ReceiveJson().ConfigureAwait(false);
string accessToken = result
@@ -51,7 +52,7 @@ private static async Task GetAccessTokenAsync(string url, string realm,
return accessToken;
}
- private static async Task GetAccessTokenWithClientIdAsync(string url, string realm, string clientSecret, string? clientId)
+ private static async Task GetAccessTokenWithClientIdAsync(string url, string realm, string clientSecret, string? clientId, CancellationToken cancellationToken)
{
var result = await url
.AppendPathSegment($"/auth/realms/{realm}/protocol/openid-connect/token")
@@ -61,7 +62,8 @@ private static async Task GetAccessTokenWithClientIdAsync(string url, st
new KeyValuePair("grant_type", "client_credentials"),
new KeyValuePair("client_secret", clientSecret),
new KeyValuePair