From b3af6d4bfa785090ceef330b575358635b2c9601 Mon Sep 17 00:00:00 2001 From: "Amol.Dashwant" Date: Tue, 21 May 2024 15:55:22 +0530 Subject: [PATCH 1/8] Dependabot reported security issues fixed --- CHANGELOG.md | 3 ++- DEPENDENCIES | 30 +++++++++++++++--------------- pom.xml | 12 ++++++------ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28471cdb..14c20fe6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] - +### Fixed +- Dependabot reported security issues fixed. ## [1.5.5] - 2024-05-13 ### Changed diff --git a/DEPENDENCIES b/DEPENDENCIES index d14e278b..ca644453 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -13,9 +13,9 @@ maven/mavencentral/com.fasterxml/classmate/1.6.0, Apache-2.0, approved, clearlyd maven/mavencentral/com.github.stephenc.jcip/jcip-annotations/1.0-1, Apache-2.0, approved, CQ21949 maven/mavencentral/com.google.code.findbugs/jsr305/3.0.2, Apache-2.0, approved, #20 maven/mavencentral/com.google.code.gson/gson/2.10.1, Apache-2.0, approved, #6159 -maven/mavencentral/com.google.errorprone/error_prone_annotations/2.18.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.google.guava/failureaccess/1.0.1, Apache-2.0, approved, CQ22654 -maven/mavencentral/com.google.guava/guava/32.0.1-jre, Apache-2.0 AND CC0-1.0 AND CC-PDDC, approved, #8772 +maven/mavencentral/com.google.errorprone/error_prone_annotations/2.23.0, Apache-2.0, approved, #11083 +maven/mavencentral/com.google.guava/failureaccess/1.0.2, Apache-2.0, approved, CQ22654 +maven/mavencentral/com.google.guava/guava/33.0.0-jre, Apache-2.0 AND CC0-1.0, approved, #12173 maven/mavencentral/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava, Apache-2.0, approved, CQ22657 maven/mavencentral/com.google.j2objc/j2objc-annotations/2.8, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/content-type/2.2, Apache-2.0, approved, clearlydefined @@ -36,11 +36,11 @@ maven/mavencentral/io.github.openfeign/feign-core/13.2.1, Apache-2.0, approved, maven/mavencentral/io.github.openfeign/feign-slf4j/13.2.1, Apache-2.0, approved, clearlydefined maven/mavencentral/io.micrometer/micrometer-commons/1.12.5, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #11679 maven/mavencentral/io.micrometer/micrometer-observation/1.12.5, Apache-2.0, approved, #11680 -maven/mavencentral/io.minio/minio-admin/8.5.6, Apache-2.0, approved, clearlydefined -maven/mavencentral/io.minio/minio/8.5.6, Apache-2.0, approved, #9097 -maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.19, Apache-2.0, approved, #5947 -maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.19, Apache-2.0, approved, #5929 -maven/mavencentral/io.swagger.core.v3/swagger-models-jakarta/2.2.19, Apache-2.0, approved, #5919 +maven/mavencentral/io.minio/minio-admin/8.5.10, , restricted, clearlydefined +maven/mavencentral/io.minio/minio/8.5.10, Apache-2.0, approved, #9097 +maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.21, Apache-2.0, approved, #5947 +maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.21, Apache-2.0, approved, #5929 +maven/mavencentral/io.swagger.core.v3/swagger-models-jakarta/2.2.21, Apache-2.0, approved, #5919 maven/mavencentral/jakarta.activation/jakarta.activation-api/2.1.2, EPL-2.0 OR BSD-3-Clause OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jaf maven/mavencentral/jakarta.annotation/jakarta.annotation-api/2.1.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.ca maven/mavencentral/jakarta.persistence/jakarta.persistence-api/3.1.0, EPL-2.0 OR BSD-3-Clause, approved, ee4j.jpa @@ -51,9 +51,9 @@ maven/mavencentral/javax.activation/activation/1.1, CDDL-1.0, approved, CQ134 maven/mavencentral/net.minidev/accessors-smart/2.5.1, Apache-2.0, approved, clearlydefined maven/mavencentral/net.minidev/json-smart/2.5.1, Apache-2.0, approved, clearlydefined maven/mavencentral/org.antlr/antlr4-runtime/4.13.0, BSD-3-Clause, approved, #10767 -maven/mavencentral/org.apache.commons/commons-compress/1.26.0, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #13288 +maven/mavencentral/org.apache.commons/commons-compress/1.26.1, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #13288 maven/mavencentral/org.apache.commons/commons-lang3/3.13.0, Apache-2.0, approved, #9820 -maven/mavencentral/org.apache.commons/commons-text/1.11.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.apache.commons/commons-text/1.12.0, Apache-2.0, approved, #14414 maven/mavencentral/org.apache.logging.log4j/log4j-api/2.17.1, Apache-2.0, approved, clearlydefined maven/mavencentral/org.apache.logging.log4j/log4j-to-slf4j/2.17.1, Apache-2.0, approved, #2163 maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-core/10.1.20, Apache-2.0 AND (EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0) AND (CDDL-1.0 OR GPL-2.0-only WITH Classpath-exception-2.0) AND W3C AND CC0-1.0, approved, #5949 @@ -77,13 +77,13 @@ maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib/1.9.23, Apache-2.0, approv maven/mavencentral/org.jetbrains/annotations/13.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.mapstruct/mapstruct/1.4.2.Final, Apache-2.0, approved, #2483 maven/mavencentral/org.ow2.asm/asm/9.6, BSD-3-Clause, approved, #10776 -maven/mavencentral/org.postgresql/postgresql/42.7.2, BSD-2-Clause AND Apache-2.0, approved, #11681 +maven/mavencentral/org.postgresql/postgresql/42.7.3, BSD-2-Clause AND Apache-2.0, approved, #11681 maven/mavencentral/org.projectlombok/lombok/1.18.32, MIT AND LicenseRef-Public-Domain, approved, CQ23907 maven/mavencentral/org.slf4j/jul-to-slf4j/2.0.13, MIT, approved, #7698 maven/mavencentral/org.slf4j/slf4j-api/2.0.13, MIT, approved, #5915 -maven/mavencentral/org.springdoc/springdoc-openapi-starter-common/2.3.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-api/2.3.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-ui/2.3.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.springdoc/springdoc-openapi-starter-common/2.5.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-api/2.5.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-ui/2.5.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.springframework.boot/spring-boot-autoconfigure/3.2.5, Apache-2.0, approved, #11751 maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.2.5, Apache-2.0, approved, #12915 maven/mavencentral/org.springframework.boot/spring-boot-starter-aop/3.2.5, Apache-2.0, approved, #11928 @@ -130,6 +130,6 @@ maven/mavencentral/org.springframework/spring-orm/6.1.6, Apache-2.0, approved, # maven/mavencentral/org.springframework/spring-tx/6.1.6, Apache-2.0, approved, #11901 maven/mavencentral/org.springframework/spring-web/6.1.6, Apache-2.0, approved, #11748 maven/mavencentral/org.springframework/spring-webmvc/6.1.6, Apache-2.0, approved, #11879 -maven/mavencentral/org.webjars/swagger-ui/5.10.3, Apache-2.0, approved, #12068 +maven/mavencentral/org.webjars/swagger-ui/5.13.0, Apache-2.0, approved, #14547 maven/mavencentral/org.xerial.snappy/snappy-java/1.1.10.5, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #9098 maven/mavencentral/org.yaml/snakeyaml/2.2, Apache-2.0 AND (Apache-2.0 OR BSD-3-Clause OR EPL-1.0 OR GPL-2.0-or-later OR LGPL-2.1-or-later), approved, #10232 diff --git a/pom.xml b/pom.xml index 62472987..d80b54fb 100644 --- a/pom.xml +++ b/pom.xml @@ -201,7 +201,7 @@ org.springdoc springdoc-openapi-starter-webmvc-ui - 2.3.0 + 2.5.0 org.springframework.cloud @@ -231,7 +231,7 @@ org.apache.commons commons-compress - 1.26.0 + 1.26.1 commons-io @@ -241,7 +241,7 @@ org.apache.commons commons-text - 1.11.0 + 1.12.0 org.xerial.snappy @@ -261,7 +261,7 @@ org.postgresql postgresql - 42.7.2 + 42.7.3 jakarta.activation @@ -276,12 +276,12 @@ io.minio minio - 8.5.6 + 8.5.10 io.minio minio-admin - 8.5.6 + 8.5.10 From e78d8e88e2f01ab3e6ab0d5f51fb1a6f797bbdea Mon Sep 17 00:00:00 2001 From: "Amol.Dashwant" Date: Tue, 21 May 2024 16:30:07 +0530 Subject: [PATCH 2/8] Removed unnecessary libraries --- DEPENDENCIES | 20 -------------------- pom.xml | 18 ------------------ 2 files changed, 38 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index ca644453..7a9a4685 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,6 +1,5 @@ maven/mavencentral/ch.qos.logback/logback-classic/1.4.14, EPL-1.0 OR LGPL-2.1-only, approved, #3435 maven/mavencentral/ch.qos.logback/logback-core/1.4.14, EPL-1.0 OR LGPL-2.1-only, approved, #3373 -maven/mavencentral/com.carrotsearch.thirdparty/simple-xml-safe/2.7.1, Apache-2.0, approved, clearlydefined maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.4, Apache-2.0, approved, #7947 maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.15.4, MIT AND Apache-2.0, approved, #7932 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.4, Apache-2.0, approved, #7934 @@ -11,20 +10,11 @@ maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.15.4 maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.15.4, Apache-2.0, approved, #8803 maven/mavencentral/com.fasterxml/classmate/1.6.0, Apache-2.0, approved, clearlydefined maven/mavencentral/com.github.stephenc.jcip/jcip-annotations/1.0-1, Apache-2.0, approved, CQ21949 -maven/mavencentral/com.google.code.findbugs/jsr305/3.0.2, Apache-2.0, approved, #20 maven/mavencentral/com.google.code.gson/gson/2.10.1, Apache-2.0, approved, #6159 -maven/mavencentral/com.google.errorprone/error_prone_annotations/2.23.0, Apache-2.0, approved, #11083 -maven/mavencentral/com.google.guava/failureaccess/1.0.2, Apache-2.0, approved, CQ22654 -maven/mavencentral/com.google.guava/guava/33.0.0-jre, Apache-2.0 AND CC0-1.0, approved, #12173 -maven/mavencentral/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava, Apache-2.0, approved, CQ22657 -maven/mavencentral/com.google.j2objc/j2objc-annotations/2.8, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/content-type/2.2, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/lang-tag/1.7, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.24.4, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/oauth2-oidc-sdk/9.43.3, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.squareup.okhttp3/okhttp/4.12.0, Apache-2.0, approved, #11156 -maven/mavencentral/com.squareup.okio/okio-jvm/3.6.0, Apache-2.0, approved, #11158 -maven/mavencentral/com.squareup.okio/okio/3.6.0, Apache-2.0, approved, #11155 maven/mavencentral/com.sun.mail/javax.mail/1.6.2, CDDL-1.0 AND Apache-2.0, approved, CQ18739 maven/mavencentral/com.zaxxer/HikariCP/5.0.1, Apache-2.0, approved, clearlydefined maven/mavencentral/commons-codec/commons-codec/1.16.1, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #9157 @@ -36,8 +26,6 @@ maven/mavencentral/io.github.openfeign/feign-core/13.2.1, Apache-2.0, approved, maven/mavencentral/io.github.openfeign/feign-slf4j/13.2.1, Apache-2.0, approved, clearlydefined maven/mavencentral/io.micrometer/micrometer-commons/1.12.5, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #11679 maven/mavencentral/io.micrometer/micrometer-observation/1.12.5, Apache-2.0, approved, #11680 -maven/mavencentral/io.minio/minio-admin/8.5.10, , restricted, clearlydefined -maven/mavencentral/io.minio/minio/8.5.10, Apache-2.0, approved, #9097 maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.21, Apache-2.0, approved, #5947 maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.21, Apache-2.0, approved, #5929 maven/mavencentral/io.swagger.core.v3/swagger-models-jakarta/2.2.21, Apache-2.0, approved, #5919 @@ -51,7 +39,6 @@ maven/mavencentral/javax.activation/activation/1.1, CDDL-1.0, approved, CQ134 maven/mavencentral/net.minidev/accessors-smart/2.5.1, Apache-2.0, approved, clearlydefined maven/mavencentral/net.minidev/json-smart/2.5.1, Apache-2.0, approved, clearlydefined maven/mavencentral/org.antlr/antlr4-runtime/4.13.0, BSD-3-Clause, approved, #10767 -maven/mavencentral/org.apache.commons/commons-compress/1.26.1, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #13288 maven/mavencentral/org.apache.commons/commons-lang3/3.13.0, Apache-2.0, approved, #9820 maven/mavencentral/org.apache.commons/commons-text/1.12.0, Apache-2.0, approved, #14414 maven/mavencentral/org.apache.logging.log4j/log4j-api/2.17.1, Apache-2.0, approved, clearlydefined @@ -63,18 +50,12 @@ maven/mavencentral/org.aspectj/aspectjweaver/1.9.22, Apache-2.0 AND BSD-3-Clause maven/mavencentral/org.bouncycastle/bcpkix-jdk18on/1.77, MIT, approved, #11593 maven/mavencentral/org.bouncycastle/bcprov-jdk18on/1.77, MIT AND CC0-1.0, approved, #11595 maven/mavencentral/org.bouncycastle/bcutil-jdk18on/1.77, MIT, approved, #11596 -maven/mavencentral/org.checkerframework/checker-qual/3.42.0, MIT, approved, clearlydefined maven/mavencentral/org.eclipse.persistence/eclipselink/3.0.3, EPL-2.0 OR BSD-3-Clause, approved, ee4j.eclipselink maven/mavencentral/org.flywaydb/flyway-core/9.22.3, Apache-2.0, approved, #10349 maven/mavencentral/org.freemarker/freemarker/2.3.32, Apache-2.0, approved, #6764 maven/mavencentral/org.hibernate.orm/hibernate-core/6.4.4.Final, LGPL-2.1-or-later AND (EPL-2.0 OR BSD-3-Clause) AND MIT, approved, #12490 maven/mavencentral/org.hibernate.validator/hibernate-validator/8.0.1.Final, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jboss.logging/jboss-logging/3.5.3.Final, Apache-2.0, approved, #9471 -maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-common/1.9.23, Apache-2.0, approved, #14186 -maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.9.23, Apache-2.0, approved, #14188 -maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.9.23, Apache-2.0, approved, #14185 -maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib/1.9.23, Apache-2.0, approved, #11827 -maven/mavencentral/org.jetbrains/annotations/13.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.mapstruct/mapstruct/1.4.2.Final, Apache-2.0, approved, #2483 maven/mavencentral/org.ow2.asm/asm/9.6, BSD-3-Clause, approved, #10776 maven/mavencentral/org.postgresql/postgresql/42.7.3, BSD-2-Clause AND Apache-2.0, approved, #11681 @@ -131,5 +112,4 @@ maven/mavencentral/org.springframework/spring-tx/6.1.6, Apache-2.0, approved, #1 maven/mavencentral/org.springframework/spring-web/6.1.6, Apache-2.0, approved, #11748 maven/mavencentral/org.springframework/spring-webmvc/6.1.6, Apache-2.0, approved, #11879 maven/mavencentral/org.webjars/swagger-ui/5.13.0, Apache-2.0, approved, #14547 -maven/mavencentral/org.xerial.snappy/snappy-java/1.1.10.5, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #9098 maven/mavencentral/org.yaml/snakeyaml/2.2, Apache-2.0 AND (Apache-2.0 OR BSD-3-Clause OR EPL-1.0 OR GPL-2.0-or-later OR LGPL-2.1-or-later), approved, #10232 diff --git a/pom.xml b/pom.xml index d80b54fb..28f10489 100644 --- a/pom.xml +++ b/pom.xml @@ -182,14 +182,6 @@ h2 test - - io.minio - minio - - - io.minio - minio-admin - org.bouncycastle bcpkix-jdk18on @@ -273,16 +265,6 @@ javax.mail 1.6.2 - - io.minio - minio - 8.5.10 - - - io.minio - minio-admin - 8.5.10 - From 3667bfd8beb257a39caf97c37b515269041a4cdf Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Sat, 25 May 2024 00:04:52 +0530 Subject: [PATCH 3/8] Support portal new autosetup and new app version --- CHANGELOG.md | 5 + DEPENDENCIES | 70 ++- pom.xml | 62 +-- .../autosetup/config/EmailConfiguration.java | 44 +- .../constant/EmailConfigurationProperty.java | 56 ++ .../constant/SDEConfigurationProperty.java | 8 +- .../GlobalDefaultExceptionHandler.java | 34 ++ .../ConnectorCommonUtilityManager.java | 42 +- .../manager/ConnectorRegistrationManager.java | 77 ++- .../autosetup/manager/DTRegistryManager.java | 154 +----- .../manager/PortalIntegrationManager.java | 233 +++++++-- .../autosetup/manager/SDEManager.java | 33 +- .../manager/TestConnectorServiceManager.java | 7 +- .../manager/TractusConnectorManager.java | 6 +- .../autosetup/manager/VaultManager.java | 25 +- .../model/ServiceInstanceResultResponse.java | 22 +- .../portal/model/TechnicalUserDetails.java | 46 ++ ...nicalUserInfo.java => TechnicalUsers.java} | 19 +- .../portal/proxy/PortalIntegrationProxy.java | 32 +- .../AutoSetupOrchitestratorService.java | 154 +++--- .../autosetup/service/DTAppWorkFlow.java | 9 +- .../proxy/ConnectorTestRequest.java | 2 + .../utility/JsonObjectProcessingUtility.java | 50 ++ .../utility/KeyCloakTokenProxyUtitlity.java | 55 ++ .../tractusx/autosetup/utility/LogUtil.java | 8 + src/main/resources/application.properties | 17 +- .../flyway/V10__update_app_version.sql | 481 ++++++++++++++++++ .../flyway/V9__update_app_version.sql | 316 ++++++++++++ .../templates/dt_success_template.html | 3 +- .../templates/edc_success_activate.html | 10 +- src/main/resources/templates/success.html | 4 +- .../resources/templates/success_activate.html | 12 +- .../ConnectorRegistrationManagerTest.java | 10 +- .../autosetup/manager/SDEManagerTest.java | 18 +- .../autosetup/manager/VaultManagerTest.java | 2 +- .../AutoSetupOrchitestratorServiceTest.java | 7 +- .../resources/application-test.properties | 12 +- 37 files changed, 1709 insertions(+), 436 deletions(-) create mode 100644 src/main/java/org/eclipse/tractusx/autosetup/constant/EmailConfigurationProperty.java create mode 100644 src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUserDetails.java rename src/main/java/org/eclipse/tractusx/autosetup/portal/model/{TechnicalUserInfo.java => TechnicalUsers.java} (72%) create mode 100644 src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java create mode 100644 src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java create mode 100644 src/main/resources/flyway/V10__update_app_version.sql create mode 100644 src/main/resources/flyway/V9__update_app_version.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 28471cdb..f22b1c35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Added +- Support Portal autosetup latest workflow. +- Support SDE, Digital twin, EDC 7 support 24/05 release. +### Fixed +- Dependabot reported security issues fixed. ## [1.5.5] - 2024-05-13 ### Changed diff --git a/DEPENDENCIES b/DEPENDENCIES index d14e278b..db569534 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,6 +1,5 @@ maven/mavencentral/ch.qos.logback/logback-classic/1.4.14, EPL-1.0 OR LGPL-2.1-only, approved, #3435 maven/mavencentral/ch.qos.logback/logback-core/1.4.14, EPL-1.0 OR LGPL-2.1-only, approved, #3373 -maven/mavencentral/com.carrotsearch.thirdparty/simple-xml-safe/2.7.1, Apache-2.0, approved, clearlydefined maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.4, Apache-2.0, approved, #7947 maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.15.4, MIT AND Apache-2.0, approved, #7932 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.4, Apache-2.0, approved, #7934 @@ -11,21 +10,16 @@ maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.15.4 maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.15.4, Apache-2.0, approved, #8803 maven/mavencentral/com.fasterxml/classmate/1.6.0, Apache-2.0, approved, clearlydefined maven/mavencentral/com.github.stephenc.jcip/jcip-annotations/1.0-1, Apache-2.0, approved, CQ21949 -maven/mavencentral/com.google.code.findbugs/jsr305/3.0.2, Apache-2.0, approved, #20 maven/mavencentral/com.google.code.gson/gson/2.10.1, Apache-2.0, approved, #6159 -maven/mavencentral/com.google.errorprone/error_prone_annotations/2.18.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.google.guava/failureaccess/1.0.1, Apache-2.0, approved, CQ22654 -maven/mavencentral/com.google.guava/guava/32.0.1-jre, Apache-2.0 AND CC0-1.0 AND CC-PDDC, approved, #8772 -maven/mavencentral/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava, Apache-2.0, approved, CQ22657 -maven/mavencentral/com.google.j2objc/j2objc-annotations/2.8, Apache-2.0, approved, clearlydefined +maven/mavencentral/com.h2database/h2/2.2.224, (EPL-1.0 OR MPL-2.0) AND (LGPL-3.0-or-later OR EPL-1.0 OR MPL-2.0), approved, #9322 +maven/mavencentral/com.jayway.jsonpath/json-path/2.9.0, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/content-type/2.2, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/lang-tag/1.7, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.24.4, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/oauth2-oidc-sdk/9.43.3, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.squareup.okhttp3/okhttp/4.12.0, Apache-2.0, approved, #11156 -maven/mavencentral/com.squareup.okio/okio-jvm/3.6.0, Apache-2.0, approved, #11158 -maven/mavencentral/com.squareup.okio/okio/3.6.0, Apache-2.0, approved, #11155 +maven/mavencentral/com.sun.istack/istack-commons-runtime/4.1.2, BSD-3-Clause, approved, #2590 maven/mavencentral/com.sun.mail/javax.mail/1.6.2, CDDL-1.0 AND Apache-2.0, approved, CQ18739 +maven/mavencentral/com.vaadin.external.google/android-json/0.0.20131108.vaadin1, Apache-2.0, approved, CQ21310 maven/mavencentral/com.zaxxer/HikariCP/5.0.1, Apache-2.0, approved, clearlydefined maven/mavencentral/commons-codec/commons-codec/1.16.1, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #9157 maven/mavencentral/commons-fileupload/commons-fileupload/1.5, Apache-2.0, approved, #7109 @@ -36,30 +30,34 @@ maven/mavencentral/io.github.openfeign/feign-core/13.2.1, Apache-2.0, approved, maven/mavencentral/io.github.openfeign/feign-slf4j/13.2.1, Apache-2.0, approved, clearlydefined maven/mavencentral/io.micrometer/micrometer-commons/1.12.5, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #11679 maven/mavencentral/io.micrometer/micrometer-observation/1.12.5, Apache-2.0, approved, #11680 -maven/mavencentral/io.minio/minio-admin/8.5.6, Apache-2.0, approved, clearlydefined -maven/mavencentral/io.minio/minio/8.5.6, Apache-2.0, approved, #9097 -maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.19, Apache-2.0, approved, #5947 -maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.19, Apache-2.0, approved, #5929 -maven/mavencentral/io.swagger.core.v3/swagger-models-jakarta/2.2.19, Apache-2.0, approved, #5919 +maven/mavencentral/io.smallrye/jandex/3.1.2, Apache-2.0, approved, clearlydefined +maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.21, Apache-2.0, approved, #5947 +maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.21, Apache-2.0, approved, #5929 +maven/mavencentral/io.swagger.core.v3/swagger-models-jakarta/2.2.21, Apache-2.0, approved, #5919 maven/mavencentral/jakarta.activation/jakarta.activation-api/2.1.2, EPL-2.0 OR BSD-3-Clause OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jaf maven/mavencentral/jakarta.annotation/jakarta.annotation-api/2.1.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.ca +maven/mavencentral/jakarta.inject/jakarta.inject-api/2.0.1, Apache-2.0, approved, ee4j.cdi maven/mavencentral/jakarta.persistence/jakarta.persistence-api/3.1.0, EPL-2.0 OR BSD-3-Clause, approved, ee4j.jpa maven/mavencentral/jakarta.transaction/jakarta.transaction-api/2.0.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jta maven/mavencentral/jakarta.validation/jakarta.validation-api/3.0.2, Apache-2.0, approved, ee4j.validation maven/mavencentral/jakarta.xml.bind/jakarta.xml.bind-api/4.0.2, BSD-3-Clause, approved, ee4j.jaxb maven/mavencentral/javax.activation/activation/1.1, CDDL-1.0, approved, CQ134 +maven/mavencentral/net.bytebuddy/byte-buddy-agent/1.14.13, Apache-2.0, approved, #7164 +maven/mavencentral/net.bytebuddy/byte-buddy/1.14.13, Apache-2.0 AND BSD-3-Clause, approved, #7163 maven/mavencentral/net.minidev/accessors-smart/2.5.1, Apache-2.0, approved, clearlydefined maven/mavencentral/net.minidev/json-smart/2.5.1, Apache-2.0, approved, clearlydefined maven/mavencentral/org.antlr/antlr4-runtime/4.13.0, BSD-3-Clause, approved, #10767 -maven/mavencentral/org.apache.commons/commons-compress/1.26.0, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #13288 maven/mavencentral/org.apache.commons/commons-lang3/3.13.0, Apache-2.0, approved, #9820 -maven/mavencentral/org.apache.commons/commons-text/1.11.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.apache.commons/commons-text/1.12.0, Apache-2.0, approved, #14414 maven/mavencentral/org.apache.logging.log4j/log4j-api/2.17.1, Apache-2.0, approved, clearlydefined maven/mavencentral/org.apache.logging.log4j/log4j-to-slf4j/2.17.1, Apache-2.0, approved, #2163 maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-core/10.1.20, Apache-2.0 AND (EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0) AND (CDDL-1.0 OR GPL-2.0-only WITH Classpath-exception-2.0) AND W3C AND CC0-1.0, approved, #5949 maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-el/10.1.20, Apache-2.0, approved, #6997 maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-websocket/10.1.20, Apache-2.0, approved, #7920 +maven/mavencentral/org.apiguardian/apiguardian-api/1.1.2, Apache-2.0, approved, clearlydefined maven/mavencentral/org.aspectj/aspectjweaver/1.9.22, Apache-2.0 AND BSD-3-Clause AND EPL-1.0 AND BSD-3-Clause AND Apache-1.1, approved, #7695 +maven/mavencentral/org.assertj/assertj-core/3.24.2, Apache-2.0, approved, #6161 +maven/mavencentral/org.awaitility/awaitility/4.2.1, Apache-2.0, approved, #14178 maven/mavencentral/org.bouncycastle/bcpkix-jdk18on/1.77, MIT, approved, #11593 maven/mavencentral/org.bouncycastle/bcprov-jdk18on/1.77, MIT AND CC0-1.0, approved, #11595 maven/mavencentral/org.bouncycastle/bcutil-jdk18on/1.77, MIT, approved, #11596 @@ -67,25 +65,37 @@ maven/mavencentral/org.checkerframework/checker-qual/3.42.0, MIT, approved, clea maven/mavencentral/org.eclipse.persistence/eclipselink/3.0.3, EPL-2.0 OR BSD-3-Clause, approved, ee4j.eclipselink maven/mavencentral/org.flywaydb/flyway-core/9.22.3, Apache-2.0, approved, #10349 maven/mavencentral/org.freemarker/freemarker/2.3.32, Apache-2.0, approved, #6764 +maven/mavencentral/org.glassfish.jaxb/jaxb-core/4.0.5, BSD-3-Clause, approved, ee4j.jaxb-impl +maven/mavencentral/org.glassfish.jaxb/jaxb-runtime/4.0.5, BSD-3-Clause, approved, ee4j.jaxb-impl +maven/mavencentral/org.glassfish.jaxb/txw2/4.0.5, BSD-3-Clause, approved, ee4j.jaxb-impl +maven/mavencentral/org.hamcrest/hamcrest/2.2, BSD-3-Clause, approved, clearlydefined +maven/mavencentral/org.hibernate.common/hibernate-commons-annotations/6.0.6.Final, LGPL-2.1-only, approved, #6962 maven/mavencentral/org.hibernate.orm/hibernate-core/6.4.4.Final, LGPL-2.1-or-later AND (EPL-2.0 OR BSD-3-Clause) AND MIT, approved, #12490 maven/mavencentral/org.hibernate.validator/hibernate-validator/8.0.1.Final, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jboss.logging/jboss-logging/3.5.3.Final, Apache-2.0, approved, #9471 -maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-common/1.9.23, Apache-2.0, approved, #14186 -maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.9.23, Apache-2.0, approved, #14188 -maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.9.23, Apache-2.0, approved, #14185 -maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib/1.9.23, Apache-2.0, approved, #11827 -maven/mavencentral/org.jetbrains/annotations/13.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.junit.jupiter/junit-jupiter-api/5.10.2, EPL-2.0, approved, #9714 +maven/mavencentral/org.junit.jupiter/junit-jupiter-engine/5.10.2, EPL-2.0, approved, #9711 +maven/mavencentral/org.junit.jupiter/junit-jupiter-params/5.10.2, EPL-2.0, approved, #9708 +maven/mavencentral/org.junit.jupiter/junit-jupiter/5.10.2, EPL-2.0, approved, #13393 +maven/mavencentral/org.junit.platform/junit-platform-commons/1.10.2, EPL-2.0, approved, #9715 +maven/mavencentral/org.junit.platform/junit-platform-engine/1.10.2, EPL-2.0, approved, #9709 maven/mavencentral/org.mapstruct/mapstruct/1.4.2.Final, Apache-2.0, approved, #2483 +maven/mavencentral/org.mockito/mockito-core/5.7.0, MIT AND (Apache-2.0 AND MIT) AND Apache-2.0, approved, #11424 +maven/mavencentral/org.mockito/mockito-junit-jupiter/5.7.0, MIT, approved, #11423 +maven/mavencentral/org.objenesis/objenesis/3.3, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.opentest4j/opentest4j/1.3.0, Apache-2.0, approved, #9713 maven/mavencentral/org.ow2.asm/asm/9.6, BSD-3-Clause, approved, #10776 -maven/mavencentral/org.postgresql/postgresql/42.7.2, BSD-2-Clause AND Apache-2.0, approved, #11681 +maven/mavencentral/org.postgresql/postgresql/42.7.3, BSD-2-Clause AND Apache-2.0, approved, #11681 maven/mavencentral/org.projectlombok/lombok/1.18.32, MIT AND LicenseRef-Public-Domain, approved, CQ23907 +maven/mavencentral/org.skyscreamer/jsonassert/1.5.1, Apache-2.0, approved, clearlydefined maven/mavencentral/org.slf4j/jul-to-slf4j/2.0.13, MIT, approved, #7698 maven/mavencentral/org.slf4j/slf4j-api/2.0.13, MIT, approved, #5915 -maven/mavencentral/org.springdoc/springdoc-openapi-starter-common/2.3.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-api/2.3.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-ui/2.3.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.springdoc/springdoc-openapi-starter-common/2.5.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-api/2.5.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-ui/2.5.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.springframework.boot/spring-boot-autoconfigure/3.2.5, Apache-2.0, approved, #11751 maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.2.5, Apache-2.0, approved, #12915 +maven/mavencentral/org.springframework.boot/spring-boot-devtools/3.2.5, Apache-2.0, approved, clearlydefined maven/mavencentral/org.springframework.boot/spring-boot-starter-aop/3.2.5, Apache-2.0, approved, #11928 maven/mavencentral/org.springframework.boot/spring-boot-starter-data-jpa/3.2.5, Apache-2.0, approved, #11926 maven/mavencentral/org.springframework.boot/spring-boot-starter-freemarker/3.1.6, Apache-2.0, approved, clearlydefined @@ -95,10 +105,13 @@ maven/mavencentral/org.springframework.boot/spring-boot-starter-logging/3.2.5, A maven/mavencentral/org.springframework.boot/spring-boot-starter-oauth2-client/3.2.5, Apache-2.0, approved, #12587 maven/mavencentral/org.springframework.boot/spring-boot-starter-oauth2-resource-server/3.2.5, Apache-2.0, approved, #11931 maven/mavencentral/org.springframework.boot/spring-boot-starter-security/3.2.5, Apache-2.0, approved, #12069 +maven/mavencentral/org.springframework.boot/spring-boot-starter-test/3.2.5, Apache-2.0, approved, #12917 maven/mavencentral/org.springframework.boot/spring-boot-starter-tomcat/3.2.5, Apache-2.0, approved, #11923 maven/mavencentral/org.springframework.boot/spring-boot-starter-validation/3.2.5, Apache-2.0, approved, #12921 maven/mavencentral/org.springframework.boot/spring-boot-starter-web/3.2.5, Apache-2.0, approved, #11916 maven/mavencentral/org.springframework.boot/spring-boot-starter/3.2.5, Apache-2.0, approved, #11935 +maven/mavencentral/org.springframework.boot/spring-boot-test-autoconfigure/3.2.5, Apache-2.0, approved, #12920 +maven/mavencentral/org.springframework.boot/spring-boot-test/3.2.5, Apache-2.0, approved, #12916 maven/mavencentral/org.springframework.boot/spring-boot/3.2.5, Apache-2.0, approved, #11752 maven/mavencentral/org.springframework.cloud/spring-cloud-commons/4.1.2, Apache-2.0, approved, #13495 maven/mavencentral/org.springframework.cloud/spring-cloud-context/4.1.2, Apache-2.0, approved, #13494 @@ -127,9 +140,10 @@ maven/mavencentral/org.springframework/spring-expression/6.1.6, Apache-2.0, appr maven/mavencentral/org.springframework/spring-jcl/6.1.6, Apache-2.0, approved, #11749 maven/mavencentral/org.springframework/spring-jdbc/6.1.6, Apache-2.0, approved, #11897 maven/mavencentral/org.springframework/spring-orm/6.1.6, Apache-2.0, approved, #11924 +maven/mavencentral/org.springframework/spring-test/6.1.6, Apache-2.0, approved, #12919 maven/mavencentral/org.springframework/spring-tx/6.1.6, Apache-2.0, approved, #11901 maven/mavencentral/org.springframework/spring-web/6.1.6, Apache-2.0, approved, #11748 maven/mavencentral/org.springframework/spring-webmvc/6.1.6, Apache-2.0, approved, #11879 -maven/mavencentral/org.webjars/swagger-ui/5.10.3, Apache-2.0, approved, #12068 -maven/mavencentral/org.xerial.snappy/snappy-java/1.1.10.5, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #9098 +maven/mavencentral/org.webjars/swagger-ui/5.13.0, Apache-2.0, approved, #14547 +maven/mavencentral/org.xmlunit/xmlunit-core/2.9.1, Apache-2.0, approved, #6272 maven/mavencentral/org.yaml/snakeyaml/2.2, Apache-2.0 AND (Apache-2.0 OR BSD-3-Clause OR EPL-1.0 OR GPL-2.0-or-later OR LGPL-2.1-or-later), approved, #10232 diff --git a/pom.xml b/pom.xml index 62472987..848a3b2b 100644 --- a/pom.xml +++ b/pom.xml @@ -182,26 +182,17 @@ h2 test - - io.minio - minio - - - io.minio - minio-admin - org.bouncycastle bcpkix-jdk18on - org.springdoc springdoc-openapi-starter-webmvc-ui - 2.3.0 + 2.5.0 org.springframework.cloud @@ -231,7 +222,7 @@ org.apache.commons commons-compress - 1.26.0 + 1.26.1 commons-io @@ -241,7 +232,7 @@ org.apache.commons commons-text - 1.11.0 + 1.12.0 org.xerial.snappy @@ -261,7 +252,7 @@ org.postgresql postgresql - 42.7.2 + 42.7.3 jakarta.activation @@ -273,16 +264,6 @@ javax.mail 1.6.2 - - io.minio - minio - 8.5.6 - - - io.minio - minio-admin - 8.5.6 - @@ -337,22 +318,25 @@ - org.eclipse.dash - license-tool-plugin - 1.0.3-SNAPSHOT - - - license-check - - license-check - - - - - automotive.tractusx - DEPENDENCIES - - + org.eclipse.dash + license-tool-plugin + 1.1.0 + + automotive.tractusx + + DEPENDENCIES + + test + + + + license-check + + license-check + + + + diff --git a/src/main/java/org/eclipse/tractusx/autosetup/config/EmailConfiguration.java b/src/main/java/org/eclipse/tractusx/autosetup/config/EmailConfiguration.java index ce5b62a1..983bb5a2 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/config/EmailConfiguration.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/config/EmailConfiguration.java @@ -1,6 +1,6 @@ /******************************************************************************** -#* Copyright (c) 2022, 2023 T-Systems International GmbH -#* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation +#* Copyright (c) 2022,2024 T-Systems International GmbH +#* Copyright (c) 2022,2024 Contributors to the Eclipse Foundation #* #* See the NOTICE file(s) distributed with this work for additional #* information regarding copyright ownership. @@ -20,36 +20,22 @@ package org.eclipse.tractusx.autosetup.config; import java.util.Properties; + import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.internet.MimeMessage; -import org.springframework.beans.factory.annotation.Value; + +import org.eclipse.tractusx.autosetup.constant.EmailConfigurationProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import lombok.RequiredArgsConstructor; + @Configuration +@RequiredArgsConstructor public class EmailConfiguration { - @Value("${mail.smtp.host}") - private String host; - - @Value("${mail.smtp.port}") - private String port; - - @Value("${mail.from.address}") - private String fromAddress; - - @Value("${mail.smtp.starttls.enable}") - private Boolean startTlsEnable; - - @Value("${mail.smtp.username}") - private String username; - - @Value("${mail.smtp.password}") - private String password; - - @Value("${mail.smtp.auth}") - private Boolean auth; + private final EmailConfigurationProperty emailConfigurationProperty; @Bean public MimeMessage mimeMessage() { @@ -57,7 +43,7 @@ public MimeMessage mimeMessage() { Session session = Session.getInstance(properties(), new javax.mail.Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); + return new PasswordAuthentication(emailConfigurationProperty.getUsername(), emailConfigurationProperty.getPassword()); } }); return new MimeMessage(session); @@ -66,11 +52,11 @@ protected PasswordAuthentication getPasswordAuthentication() { @Bean public Properties properties() { Properties props = new Properties(); - props.put("mail.smtp.user", username); - props.put("mail.smtp.host", host); - props.put("mail.smtp.port", port); - props.put("mail.smtp.starttls.enable", startTlsEnable); - props.put("mail.smtp.auth", auth); + props.put("mail.smtp.user", emailConfigurationProperty.getUsername()); + props.put("mail.smtp.host", emailConfigurationProperty.getHost()); + props.put("mail.smtp.port", emailConfigurationProperty.getPort()); + props.put("mail.smtp.starttls.enable", emailConfigurationProperty.getStartTlsEnable()); + props.put("mail.smtp.auth", emailConfigurationProperty.getAuth()); return props; } } \ No newline at end of file diff --git a/src/main/java/org/eclipse/tractusx/autosetup/constant/EmailConfigurationProperty.java b/src/main/java/org/eclipse/tractusx/autosetup/constant/EmailConfigurationProperty.java new file mode 100644 index 00000000..c04b2878 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/constant/EmailConfigurationProperty.java @@ -0,0 +1,56 @@ +/******************************************************************************** +* Copyright (c) 2024 T-Systems International GmbH +* Copyright (c) 2024 Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License, Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0. +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +package org.eclipse.tractusx.autosetup.constant; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +import lombok.Data; + +@Configuration +@Data +public class EmailConfigurationProperty { + + @Value("${mail.smtp.host}") + private String host; + + @Value("${mail.smtp.port}") + private String port; + + @Value("${mail.from.address}") + private String fromAddress; + + @Value("${mail.smtp.starttls.enable}") + private Boolean startTlsEnable; + + @Value("${mail.smtp.username}") + private String username; + + @Value("${mail.smtp.password}") + private String password; + + @Value("${mail.smtp.auth}") + private Boolean auth; + + @Value("${mail.replyto.address}") + private String replytoAddress; + +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/constant/SDEConfigurationProperty.java b/src/main/java/org/eclipse/tractusx/autosetup/constant/SDEConfigurationProperty.java index a1b0b040..5beac959 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/constant/SDEConfigurationProperty.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/constant/SDEConfigurationProperty.java @@ -1,6 +1,6 @@ /******************************************************************************** -#* Copyright (c) 2022, 2023 T-Systems International GmbH -#* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation +#* Copyright (c) 2022,2024 T-Systems International GmbH +#* Copyright (c) 2022,2024 Contributors to the Eclipse Foundation #* #* See the NOTICE file(s) distributed with this work for additional #* information regarding copyright ownership. @@ -58,4 +58,8 @@ public class SDEConfigurationProperty { private String discoveryClientId; private String discoveryClientSecret; + private String bpdmProviderEdcDataspaceApi; + private String bpdmProviderBpnl; + private String bpdmProviderEdcPublicApi; + } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java index bb77fe0c..0767be6e 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java @@ -35,6 +35,11 @@ import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import feign.FeignException; import lombok.extern.slf4j.Slf4j; @ControllerAdvice @@ -62,6 +67,29 @@ public ResponseEntity handlePSQLException(Exception ex, WebRequest reque public ResponseEntity handleValidationException(ValidationException ex, WebRequest request) { return new ResponseEntity<>(ex.getMessage(), HttpStatus.BAD_REQUEST); } + + @ExceptionHandler(FeignException.class) + public ResponseEntity> handleFeignException(FeignException ex, WebRequest request) { + log.error("FeignException: " + ex.getMessage()); + log.error("FeignException RequestBody: " + ex.request()); + log.error("FeignException ResponseBody: " + ex.contentUTF8()); + ObjectMapper objmap = new ObjectMapper(); + Map errorResponse = new HashMap<>(); + errorResponse.put("msg", "Error in remote service execution"); + try { + @SuppressWarnings("unchecked") + Map map = objmap.readValue(ex.contentUTF8(), Map.class); + Object object = map.get("errors"); + if (object != null) + errorResponse = prepareErrorResponse(object.toString()); + } catch (JsonMappingException e) { + log.error("FeignException JsonMappingException " + e.getMessage()); + } catch (JsonProcessingException e) { + log.error("FeignException JsonProcessingException " + e.getMessage()); + } + + return new ResponseEntity<>(errorResponse, HttpStatus.valueOf(ex.status())); + } @Override protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex, @@ -83,5 +111,11 @@ protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotV return new ResponseEntity<>(errors, HttpStatus.BAD_REQUEST); } + + private Map prepareErrorResponse(String errormsg) { + Map errorResponse = new HashMap<>(); + errorResponse.put("msg", errormsg); + return errorResponse; + } } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorCommonUtilityManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorCommonUtilityManager.java index 747d1020..c6d8b5d3 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorCommonUtilityManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorCommonUtilityManager.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2023 T-Systems International GmbH - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023,2024 T-Systems International GmbH + * Copyright (c) 2023,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -23,6 +23,7 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; +import org.eclipse.tractusx.autosetup.model.Customer; import org.eclipse.tractusx.autosetup.utility.PasswordGenerator; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -41,8 +42,23 @@ public class ConnectorCommonUtilityManager { @Value("${edc.ssi.authorityId:}") private String authorityId; - - public Map prepareConnectorInput(String packageName, Map inputData) { + + @Value("${edc.iatp.id}") + private String edcIatpId; + + @Value("${edc.iatp.sts.dim.url}") + private String edcIatpStsDimUrl; + + @Value("${edc.iatp.sts.oauth.token.url}") + private String edcIatpStsOauthTokenUrl; + + @Value("${edc.bdrs.server}") + private String edcBdrsServer; + + @Value("${edc.iam.trusted-issuer}") + private String edcIamTrustedIssuer; + + public Map prepareConnectorInput(Customer customerDetails, String packageName, Map inputData) { String generateRandomPassword = PasswordGenerator.generateRandomPassword(50); String dnsName = inputData.get("dnsName"); @@ -55,6 +71,8 @@ public Map prepareConnectorInput(String packageName, Map prepareConnectorInput(String packageName, Map prepareConnectorInput(String packageName, Map registerConnector(Customer customerDetails, SelectedT + "-CONNECTOR-REGISTER package creating"); file = getTestFile(inputData.get("selfsigncertificate")); + String subscriptionIdVal = inputData.get(SUBSCRIPTION_ID); MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("name", customerDetails.getOrganizationName()); + String tenantNameNamespace = triger.getAutosetupTenantName(); + body.add("name", tenantNameNamespace); body.add("connectorUrl", inputData.get("controlPlaneEndpoint")); body.add("location", customerDetails.getCountry()); - body.add("subscriptionId", inputData.get("subscriptionId")); + body.add(SUBSCRIPTION_ID, subscriptionIdVal); Map header = new HashMap<>(); - header.put("Authorization", "Bearer " + getKeycloakToken()); + header.put("Authorization", + "Bearer " + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); - String connectorId = portalIntegrationProxy.manageConnector(connectorRegistrationUrl, header, body); + String connectorId = checkSubcriptionHaveConnectorRegister(header, subscriptionIdVal); + + if (StringUtils.isNotBlank(connectorId)) { + Map updateBody = new HashMap<>(); + updateBody.put("connectorUrl", inputData.get("controlPlaneEndpoint")); + portalIntegrationProxy.updateRegisterConnectorUrl(connectorRegistrationUrl, header, updateBody); + } else { + connectorId = portalIntegrationProxy.manageConnector(connectorRegistrationUrl, header, body); + } log.info(LogUtil.encode(tenantName) + "-" + LogUtil.encode(packageName) + "-CONNECTOR-REGISTER package created"); @@ -147,6 +165,37 @@ public Map registerConnector(Customer customerDetails, SelectedT } + @SneakyThrows + private String checkSubcriptionHaveConnectorRegister(Map header, String subscriptionId) { + + try { + JsonNode subcriptionWithConnectors = portalIntegrationProxy + .getSubcriptionWithConnectors(connectorRegistrationUrl, header, true); + + if (subcriptionWithConnectors != null && subcriptionWithConnectors.isArray()) { + for (JsonNode jsonNode : subcriptionWithConnectors) { + + String remoteSubscriptionId = JsonObjectProcessingUtility.getValueFromJsonNode(jsonNode, + SUBSCRIPTION_ID); + + if (subscriptionId.equalsIgnoreCase(remoteSubscriptionId)) { + + JsonNode connectorIds = JsonObjectProcessingUtility.getArrayNodeFromJsonNode(jsonNode, + "connectorIds"); + + if (connectorIds != null && connectorIds.isArray() && connectorIds.size() > 0) + return connectorIds.get(0).asText(); + } + } + } + + } catch (Exception e) { + log.error("Error in checkSubcriptionHaveConnectorRegister or not " + e.getMessage()); + } + + return null; + } + @Retryable(retryFor = { ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) public Map deleteConnector(SelectedTools tool, Map inputData, @@ -164,11 +213,12 @@ public Map deleteConnector(SelectedTools tool, Map header = new HashMap<>(); - header.put("Authorization", "Bearer " + getKeycloakToken()); + header.put("Authorization", + "Bearer " + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); autoSetupTriggerDetails.setStatus(TriggerStatusEnum.SUCCESS.name()); portalIntegrationProxy.deleteConnector(connectorRegistrationUrl, header, connectorId); - + log.info(LogUtil.encode(orgName) + "-" + LogUtil.encode(packageName) + "-CONNECTOR-DELETE deleted"); } else @@ -191,21 +241,6 @@ public Map deleteConnector(SelectedTools tool, Map body = new LinkedMultiValueMap<>(); - body.add("grant_type", "client_credentials"); - body.add("client_id", clientId); - body.add("client_secret", clientSecret); - var resultBody = portalIntegrationProxy.readAuthToken(tokenURI, body); - - if (resultBody != null) { - return resultBody.getAccessToken(); - } - return null; - - } - public static Path getTestFile(String str) throws IOException { Path testFile = Files.createTempFile("test-file1", ".crt"); Files.write(testFile, str.getBytes()); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java index 8087824a..5fa10eb7 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java @@ -1,7 +1,7 @@ /******************************************************************************** - * Copyright (c) 2023 T-Systems International GmbH - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023,2024 T-Systems International GmbH + * Copyright (c) 2023,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -37,13 +37,13 @@ import org.eclipse.tractusx.autosetup.exception.ServiceException; import org.eclipse.tractusx.autosetup.model.Customer; import org.eclipse.tractusx.autosetup.model.SelectedTools; -import org.eclipse.tractusx.autosetup.utility.LogUtil; -import org.eclipse.tractusx.autosetup.utility.WaitingTimeUtility; +import org.springframework.beans.factory.annotation.Value; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.Retryable; import org.springframework.retry.support.RetrySynchronizationManager; import org.springframework.stereotype.Service; +import feign.FeignException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -57,7 +57,8 @@ public class DTRegistryManager { private final SDEConfigurationProperty sDEConfigurationProperty; - private final EDCProxyService eDCProxyService; + @Value("${managed.dt-registry.local:true}") + private boolean managedDTRegistryLocal; @Retryable(retryFor = { ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) @@ -73,10 +74,19 @@ public Map managePackage(Customer customerDetails, AppActions ac String dnsNameURLProtocol = inputData.get("dnsNameURLProtocol"); String dturi = sDEConfigurationProperty.getDtregistryApiUri(); - dturi = StringUtils.isAllEmpty(dturi) ? "/api/v3.0" : dturi; - String dtregistryUrl = dnsNameURLProtocol + "://" + dnsName + "/" - + sDEConfigurationProperty.getDtregistryUrlPrefix() + dturi; + dturi = StringUtils.isBlank(dturi) ? "/api/v3" : dturi; + if (managedDTRegistryLocal) { + String appName = DT_REGISTRY.name().replace("_", ""); + String localDTUrl = "http://cx-" + packageName + "-" + appName.toLowerCase() + "-registry-svc:8080"; + inputData.put("dtregistryUrl", localDTUrl); + inputData.put("dtregistryUrlWithURI", localDTUrl + dturi); + } else { + String dtregistryUrl = dnsNameURLProtocol + "://" + dnsName + "/"+ sDEConfigurationProperty.getDtregistryUrlPrefix(); + inputData.put("dtregistryUrl", dtregistryUrl); + inputData.put("dtregistryUrlWithURI", dtregistryUrl + dturi); + } + inputData.put("dtNeedExternalAccess", String.valueOf(!managedDTRegistryLocal)); inputData.put("rgdatabase", "registry"); inputData.put("rgdbpass", "admin@123"); inputData.put("rgusername", "catenax"); @@ -84,8 +94,7 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("idpIssuerUri", sDEConfigurationProperty.getResourceServerIssuer()); inputData.put("tenantId", sDEConfigurationProperty.getDtregistrytenantId()); inputData.put("dtregistryUrlPrefix", sDEConfigurationProperty.getDtregistryUrlPrefix()); - - inputData.put("dtregistryUrl", dtregistryUrl); + inputData.put("dtregistryURI", dturi); if (AppActions.CREATE.equals(action)) appManagement.createPackage(DT_REGISTRY, packageName, inputData); @@ -94,6 +103,14 @@ public Map managePackage(Customer customerDetails, AppActions ac autoSetupTriggerDetails.setStatus(TriggerStatusEnum.SUCCESS.name()); + } catch (FeignException e) { + log.error("DTRegistryManager FeignException request: " + e.request()); + log.error("DTRegistryManager FeignException response Body: " + + e.responseBody()); + String error = e.contentUTF8(); + error = StringUtils.isNotBlank(error) ? error : e.getMessage(); + throw new ServiceException("DTRegistryManager Oops! We have an FeignException - " + error); + } catch (Exception ex) { log.error("DTRegistryManager failed retry attempt: : {}", @@ -109,119 +126,4 @@ public Map managePackage(Customer customerDetails, AppActions ac return inputData; } - @Retryable(retryFor = { - ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) - public void dtRegistryRegistrationInEDC(Customer customerDetails, SelectedTools tool, Map inputData, - AutoSetupTriggerEntry triger) { - String tenantName = LogUtil.encode(customerDetails.getOrganizationName()); - try { - WaitingTimeUtility.waitingTime( - tenantName + ": Waiting for EDC asset creation after DT setup to get connector pod up"); - - List asset = eDCProxyService.getAssets(customerDetails, inputData); - - if (asset != null && asset.isEmpty()) { - createEDCDTAsset(customerDetails, tool, inputData, triger); - } - - } catch (Exception e) { - String errorMsg = tenantName - + ":It looks EDC connector is not up for DT asset creation, Oops! We have an exception - " - + e.getMessage(); - log.error(errorMsg); - throw new ServiceException(errorMsg); - } - - } - - private void createEDCDTAsset(Customer customerDetails, SelectedTools tool, Map inputData, - AutoSetupTriggerEntry triger) { - - createEDCAsset(customerDetails, tool, inputData, triger); - createEDCPolicy(customerDetails, tool, inputData, triger); - createContractDefination(customerDetails, tool, inputData, triger); - - } - - @Retryable(retryFor = { - ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) - private void createEDCAsset(Customer customerDetails, SelectedTools tool, Map inputData, - AutoSetupTriggerEntry triger) { - - AutoSetupTriggerDetails autoSetupTriggerDetails = AutoSetupTriggerDetails.builder() - .id(UUID.randomUUID().toString()).step("DT_CreateEDCAsset").build(); - String tenantName = LogUtil.encode(customerDetails.getOrganizationName()); - - log.info(tenantName + ":DT createEDCAsset creating"); - try { - - String assetId = eDCProxyService.createAsset(customerDetails, inputData); - log.info(tenantName + ":DT createEDCAsset created " + assetId); - } catch (Exception ex) { - log.error(tenantName + ":DTRegistryManager createEDCAsset failed retry attempt: : {}", - RetrySynchronizationManager.getContext().getRetryCount() + 1); - autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name()); - autoSetupTriggerDetails.setRemark(ex.getMessage()); - throw new ServiceException( - tenantName + ":DTRegistryManager createEDCAsset Oops! We have an exception - " + ex.getMessage()); - } finally { - autoSetupTriggerManager.saveTriggerDetails(autoSetupTriggerDetails, triger); - } - - } - - @Retryable(retryFor = { - ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) - private void createEDCPolicy(Customer customerDetails, SelectedTools tool, Map inputData, - AutoSetupTriggerEntry triger) { - AutoSetupTriggerDetails autoSetupTriggerDetails = AutoSetupTriggerDetails.builder() - .id(UUID.randomUUID().toString()).step("DT_CreateEDCPolicy").build(); - String tenantName = LogUtil.encode(customerDetails.getOrganizationName()); - log.info(tenantName + ":DT CreateEDCPolicy creating"); - try { - - String policyId = eDCProxyService.createPolicy(customerDetails, inputData); - log.info(tenantName + ":DT createEDCPolicy created :" + policyId); - - } catch (Exception ex) { - - log.error(tenantName + ":DTRegistryManager CreateEDCPolicy failed retry attempt: : {}", - RetrySynchronizationManager.getContext().getRetryCount() + 1); - - autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name()); - autoSetupTriggerDetails.setRemark(ex.getMessage()); - throw new ServiceException( - tenantName + ":DTRegistryManager CreateEDCPolicy Oops! We have an exception - " + ex.getMessage()); - } finally { - autoSetupTriggerManager.saveTriggerDetails(autoSetupTriggerDetails, triger); - } - } - - @Retryable(retryFor = { - ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) - private void createContractDefination(Customer customerDetails, SelectedTools tool, Map inputData, - AutoSetupTriggerEntry triger) { - AutoSetupTriggerDetails autoSetupTriggerDetails = AutoSetupTriggerDetails.builder() - .id(UUID.randomUUID().toString()).step("DT_CreateContractDefination").build(); - String tenantName = LogUtil.encode(customerDetails.getOrganizationName()); - log.info(tenantName + ":DT createContractDefination creating"); - try { - - String contractPolicyId = eDCProxyService.createContractDefination(customerDetails, inputData); - log.info(tenantName + ":DT CreateContractDefination created " + contractPolicyId); - - } catch (Exception ex) { - - log.error(tenantName + ":DTRegistryManager CreateContractDefination failed retry attempt: : {}", - RetrySynchronizationManager.getContext().getRetryCount() + 1); - - autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name()); - autoSetupTriggerDetails.setRemark(ex.getMessage()); - throw new ServiceException(tenantName - + ":DTRegistryManager CreateContractDefination Oops! We have an exception - " + ex.getMessage()); - } finally { - autoSetupTriggerManager.saveTriggerDetails(autoSetupTriggerDetails, triger); - } - } - -} +} \ No newline at end of file diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java index 8ab56aeb..3ebd6481 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -22,28 +22,31 @@ import java.net.URI; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.UUID; +import org.apache.commons.lang3.StringUtils; import org.eclipse.tractusx.autosetup.constant.TriggerStatusEnum; import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerDetails; import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry; +import org.eclipse.tractusx.autosetup.exception.NoDataFoundException; import org.eclipse.tractusx.autosetup.exception.ServiceException; +import org.eclipse.tractusx.autosetup.exception.ValidationException; import org.eclipse.tractusx.autosetup.model.Customer; import org.eclipse.tractusx.autosetup.model.SelectedTools; -import org.eclipse.tractusx.autosetup.portal.model.ClientInfo; import org.eclipse.tractusx.autosetup.portal.model.ServiceInstanceResultRequest; import org.eclipse.tractusx.autosetup.portal.model.ServiceInstanceResultResponse; -import org.eclipse.tractusx.autosetup.portal.model.TechnicalUserInfo; +import org.eclipse.tractusx.autosetup.portal.model.TechnicalUserDetails; +import org.eclipse.tractusx.autosetup.portal.model.TechnicalUsers; import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; +import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; import org.eclipse.tractusx.autosetup.utility.LogUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.Retryable; import org.springframework.retry.support.RetrySynchronizationManager; import org.springframework.stereotype.Service; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; import feign.FeignException; import lombok.RequiredArgsConstructor; @@ -55,10 +58,18 @@ @RequiredArgsConstructor public class PortalIntegrationManager { + private static final String AUTHORIZATION = "Authorization"; + + private static final String BEARER = "Bearer "; + + private static final String ACTIVE = "ACTIVE"; + private final PortalIntegrationProxy portalIntegrationProxy; private final AutoSetupTriggerManager autoSetupTriggerManager; + private final KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; + @Value("${portal.url}") private URI portalUrl; @@ -71,6 +82,9 @@ public class PortalIntegrationManager { @Value("${portal.keycloak.tokenURI}") private URI tokenURI; + @Value("${portal.request.timeout:20000}") + private int requestTimeout; + @Retryable(retryFor = { ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) public Map postServiceInstanceResultAndGetTenantSpecs(Customer customerDetails, SelectedTools tool, @@ -80,6 +94,11 @@ public Map postServiceInstanceResultAndGetTenantSpecs(Customer c .id(UUID.randomUUID().toString()).step("PostServiceInstanceResultAndGetTenantSpecs").build(); ServiceInstanceResultResponse serviceInstanceResultResponse = null; try { + String appServiceURIPath = "apps"; + + if (!"app".equalsIgnoreCase(tool.getType())) { + appServiceURIPath = "services"; + } String packageName = tool.getLabel(); String tenantName = customerDetails.getOrganizationName(); @@ -89,46 +108,36 @@ public Map postServiceInstanceResultAndGetTenantSpecs(Customer c String dnsName = inputData.get("dnsName"); String dnsNameURLProtocol = inputData.get("dnsNameURLProtocol"); String subscriptionId = inputData.get("subscriptionId"); + String offerId = inputData.get("serviceId"); String applicationURL = dnsNameURLProtocol + "://" + dnsName; inputData.put("applicationURL", applicationURL); Map header = new HashMap<>(); - header.put("Authorization", "Bearer " + getKeycloakToken()); + header.put(AUTHORIZATION, + BEARER + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); ServiceInstanceResultRequest serviceInstanceResultRequest = ServiceInstanceResultRequest.builder() .requestId(subscriptionId).offerUrl(applicationURL).build(); - if ("app".equalsIgnoreCase(tool.getType())) - serviceInstanceResultResponse = portalIntegrationProxy.postAppInstanceResultAndGetTenantSpecs(portalUrl, - header, serviceInstanceResultRequest); - else - serviceInstanceResultResponse = portalIntegrationProxy - .postServiceInstanceResultAndGetTenantSpecs(portalUrl, header, serviceInstanceResultRequest); + serviceInstanceResultResponse = processAppServiceGetResponse(subscriptionId, offerId, header, + serviceInstanceResultRequest, appServiceURIPath); - if (serviceInstanceResultResponse != null) { + handlePortalServiceExcutionResponse(inputData, autoSetupTriggerDetails, serviceInstanceResultResponse); - TechnicalUserInfo technicalUserInfo = serviceInstanceResultResponse.getTechnicalUserInfo(); - if (technicalUserInfo != null) { - inputData.put("keycloakAuthenticationClientId", technicalUserInfo.getTechnicalClientId()); - inputData.put("keycloakAuthenticationClientSecret", technicalUserInfo.getTechnicalUserSecret()); - } + log.info(LogUtil.encode(tenantName) + "-" + LogUtil.encode(packageName) + + "-PostServiceInstanceResultAndGetTenantSpecs created"); - ClientInfo clientInfo = serviceInstanceResultResponse.getClientInfo(); - if (clientInfo != null) { - inputData.put("keycloakResourceClient", clientInfo.getClientId()); - } - log.info(LogUtil.encode(tenantName) + "-" + LogUtil.encode(packageName) - + "-PostServiceInstanceResultAndGetTenantSpecs created"); - } else { - log.error("Error in request process with portal"); - } + } catch (NoDataFoundException e) { + log.error(LogUtil.encode( + "PortalIntegrationManager NoDataFoundException failed No retry attempt: : " + e.getMessage())); + throw e; } catch (FeignException e) { - log.error("PortalIntegrationManager FeignException failed retry attempt: : {}", - RetrySynchronizationManager.getContext().getRetryCount() + 1); - log.error("RequestBody: " + e.request()); - log.error("ResponseBody: " + e.contentUTF8()); + log.error(LogUtil.encode("PortalIntegrationManager FeignException failed retry attempt: : " + + RetrySynchronizationManager.getContext().getRetryCount() + 1)); + log.error(LogUtil.encode("RequestBody: " + e.request())); + log.error(LogUtil.encode("ResponseBody: " + e.contentUTF8())); autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name()); autoSetupTriggerDetails.setRemark(e.contentUTF8()); @@ -136,8 +145,8 @@ public Map postServiceInstanceResultAndGetTenantSpecs(Customer c } catch (Exception ex) { - log.error("PortalIntegrationManager Exception failed retry attempt: : {}", - RetrySynchronizationManager.getContext().getRetryCount() + 1); + log.error(LogUtil.encode("PortalIntegrationManager Exception failed retry attempt: : " + + RetrySynchronizationManager.getContext().getRetryCount() + 1)); if (serviceInstanceResultResponse != null) { String msg = "PortalIntegrationManager failed with details:" @@ -157,19 +166,157 @@ public Map postServiceInstanceResultAndGetTenantSpecs(Customer c } @SneakyThrows - private String getKeycloakToken() { + private void handlePortalServiceExcutionResponse(Map inputData, + AutoSetupTriggerDetails autoSetupTriggerDetails, + ServiceInstanceResultResponse serviceInstanceResultResponse) { + + if (serviceInstanceResultResponse != null) { + + inputData.put("keycloakResourceClient", serviceInstanceResultResponse.getAppInstanceId()); + + autoSetupTriggerDetails.setRemark(serviceInstanceResultResponse.toJsonString()); + + List technicalUserData = serviceInstanceResultResponse.getTechnicalUserData(); + + if (technicalUserData != null && !technicalUserData.isEmpty()) { + + if (technicalUserData.size() > 2) { + throw new ValidationException("We have recieved more than two tehcnical users from portal"); + } + + technicalUserData.forEach(technicalUser -> { + TechnicalUserDetails technicalUserDetails = technicalUser.getTechnicalUserDetails(); + if (technicalUser.getName().contains("dim") + && technicalUser.getPermissions().contains("Identity Wallet Management")) { + inputData.put("dimClientId", technicalUserDetails.getClientId()); + inputData.put("dimClientSecret", technicalUserDetails.getSecret()); + } else { + inputData.put("keycloakAuthenticationClientId", technicalUserDetails.getClientId()); + inputData.put("keycloakAuthenticationClientSecret", technicalUserDetails.getSecret()); + } + }); + + } else { + throw new NoDataFoundException("Technical users is null or empty recieved from Portal"); + } + } else { + throw new NoDataFoundException("Error in request process with portal"); + } + + } + + @SneakyThrows + private ServiceInstanceResultResponse processAppServiceGetResponse(String subscriptionId, String offerId, + Map header, ServiceInstanceResultRequest serviceInstanceResultRequest, + String appServiceURIPath) { + + ServiceInstanceResultResponse serviceInstanceResultResponse = verifyIsAlreadySubcribedActivatedAndGetDetails( + subscriptionId, offerId, header, serviceInstanceResultRequest, appServiceURIPath); + + if (serviceInstanceResultResponse == null) { + + portalIntegrationProxy.postAppServiceStartAutoSetup(portalUrl, header, appServiceURIPath, + serviceInstanceResultRequest); + + log.info("Post App/Service instanceURL, going to read credentials asynchronously"); - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("grant_type", "client_credentials"); - body.add("client_id", clientId); - body.add("client_secret", clientSecret); - var resultBody = portalIntegrationProxy.readAuthToken(tokenURI, body); + serviceInstanceResultResponse = verifyIsAlreadySubcribedActivatedAndGetDetails(subscriptionId, offerId, + header, serviceInstanceResultRequest, appServiceURIPath); - if (resultBody != null) { - return resultBody.getAccessToken(); } - return null; + if (serviceInstanceResultResponse == null) { + throw new ServiceException("Unable to read technical user detials from portal auto setup"); + } + + readTechnicalUserDetails(subscriptionId, header, serviceInstanceResultResponse); + + return serviceInstanceResultResponse; + } + + @SneakyThrows + private ServiceInstanceResultResponse verifyIsAlreadySubcribedActivatedAndGetDetails(String subscriptionId, + String offerId, Map header, ServiceInstanceResultRequest serviceInstanceResultRequest, + String appServiceURIPath) { + + int retry = 5; + int counter = 1; + ServiceInstanceResultResponse serviceInstanceResultResponse = null; + String offerSubscriptionStatus = null; + do { + log.info("Waiting '" + requestTimeout + "'sec to portal /provider API call to get subcription status"); + Thread.sleep(requestTimeout); + try { + + header.put(AUTHORIZATION, + BEARER + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); + + serviceInstanceResultResponse = portalIntegrationProxy.getAppServiceInstanceSubcriptionDetails( + portalUrl, header, appServiceURIPath, offerId, subscriptionId); + + offerSubscriptionStatus = serviceInstanceResultResponse.getOfferSubscriptionStatus(); + + log.info("VerifyIsAlreadySubcribedActivatedAndGetDetails: The subscription details found for " + offerId + + ", " + subscriptionId + ", status is " + offerSubscriptionStatus + ", result is " + + serviceInstanceResultResponse.toJsonString()); + + } catch (FeignException e) { + log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException request: " + e.request()); + log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException response Body: " + + e.responseBody()); + String error = e.contentUTF8(); + error = StringUtils.isAllEmpty(error) ? error : e.getMessage(); + + if (e.status() == 404) { + log.warn("VerifyIsAlreadySubcribedActivatedAndGetDetails: The no app or subscription found for " + + offerId + ", " + subscriptionId + ", result is " + error); + } else { + log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException Exception response: " + + error); + } + + } catch (Exception e) { + log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails Exception processing portal call " + + e.getMessage()); + } + counter++; + + } while (!ACTIVE.equalsIgnoreCase(offerSubscriptionStatus) && counter <= retry); + + return serviceInstanceResultResponse; + } + + @SneakyThrows + private void readTechnicalUserDetails(String subscriptionId, Map header, + ServiceInstanceResultResponse serviceInstanceResultResponse) { + + if (serviceInstanceResultResponse.getTechnicalUserData() != null) { + + header.put(AUTHORIZATION, + BEARER + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); + + serviceInstanceResultResponse.getTechnicalUserData().forEach(elel -> { + try { + TechnicalUserDetails technicalUserDetails = portalIntegrationProxy + .getTechnicalUserDetails(portalUrl, header, elel.getId()); + elel.setTechnicalUserDetails(technicalUserDetails); + } catch (FeignException e) { + log.error("ReadTechnicalUserDetails FeignException request: " + e.request()); + log.error("ReadTechnicalUserDetails FeignException response Body: " + e.responseBody()); + String error = e.contentUTF8(); + error = StringUtils.isNotBlank(error) ? error : e.getMessage(); + log.error("ReadTechnicalUserDetails FeignException Exception response: " + error); + if (e.status() == 409) + throw new NoDataFoundException(error); + else + throw new ServiceException(error); + } catch (Exception e) { + String error = "Error in read existing TechnicalUserDetails from portal " + e.getMessage(); + log.error(error); + throw new ServiceException(error); + } + }); + } } } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java index 1560bf73..38264b54 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -26,6 +26,7 @@ import java.util.UUID; import org.eclipse.tractusx.autosetup.constant.AppActions; +import org.eclipse.tractusx.autosetup.constant.EmailConfigurationProperty; import org.eclipse.tractusx.autosetup.constant.SDEConfigurationProperty; import org.eclipse.tractusx.autosetup.constant.TriggerStatusEnum; import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerDetails; @@ -53,11 +54,12 @@ public class SDEManager { @Value("${managed.dt-registry:true}") private boolean managedDtRegistry; - + @Value("${manual.update:false}") private boolean manualUpdate; private final SDEConfigurationProperty sDEConfigurationProperty; + private final EmailConfigurationProperty emailConfigurationProperty; @Retryable(retryFor = { ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) @@ -85,7 +87,7 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("sde.digital-twins.authentication.url", sDEConfigurationProperty.getDigitalTwinsAuthenticationUrl()); - + if (!manualUpdate) { inputData.put("digital-twins.authentication.clientId", inputData.get("keycloakAuthenticationClientId")); inputData.put("digital-twins.authentication.clientSecret", @@ -94,7 +96,7 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("sdebackendkeycloakclientid", inputData.get("keycloakResourceClient")); inputData.put("sdefrontendkeycloakclientid", inputData.get("keycloakResourceClient")); } - + if (managedDtRegistry) { inputData.put("sde.digital-twins.hostname", inputData.get("dtregistryUrl")); } else { @@ -105,7 +107,7 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("sde.keycloak.auth", sDEConfigurationProperty.getKeycloakAuth()); inputData.put("sde.keycloak.realm", sDEConfigurationProperty.getKeycloakRealm()); inputData.put("sde.keycloak.tokenUrl", sDEConfigurationProperty.getKeycloakTokenUrl()); - + inputData.put("sde.partner.pool.hostname", sDEConfigurationProperty.getPartnerPoolHostname()); inputData.put("sde.partner.pool.authentication.url", sDEConfigurationProperty.getPartnerPoolAuthenticationUrl()); @@ -123,6 +125,25 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("sde.discovery.clientId", sDEConfigurationProperty.getDiscoveryClientId()); inputData.put("sde.discovery.clientSecret", sDEConfigurationProperty.getDiscoveryClientSecret()); + inputData.put("sftpHost", "defaulthost"); + inputData.put("sftpPort", "22"); + inputData.put("sftpUsername", "defaultuser"); + inputData.put("sftpPassword", "defaultpass"); + inputData.put("sftpKey", ""); + + inputData.put("emailUsername", emailConfigurationProperty.getUsername()); + inputData.put("emailPassword", emailConfigurationProperty.getPassword()); + inputData.put("emailHost", emailConfigurationProperty.getHost()); + inputData.put("emailPort", emailConfigurationProperty.getPort()); + inputData.put("emailTo", customerDetails.getEmail()); + inputData.put("emailCC", emailConfigurationProperty.getReplytoAddress()); + inputData.put("emailFrom", customerDetails.getOrganizationName() +" SDE notification"); + inputData.put("emailReply", emailConfigurationProperty.getReplytoAddress()); + + inputData.put("bpdm.provider.edc.dataspace.api", sDEConfigurationProperty.getBpdmProviderEdcDataspaceApi()); + inputData.put("bpdm.provider.bpnl", sDEConfigurationProperty.getBpdmProviderBpnl()); + inputData.put("bpdm.provider.edc.public.api", sDEConfigurationProperty.getBpdmProviderEdcPublicApi()); + String packageName = tool.getLabel(); if (AppActions.CREATE.equals(action)) diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/TestConnectorServiceManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/TestConnectorServiceManager.java index 711dd83c..cb566190 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/TestConnectorServiceManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/TestConnectorServiceManager.java @@ -63,8 +63,11 @@ public Map verifyConnectorTestingThroughTestService(Customer cus try { ConnectorTestRequest connectorTestRequest = ConnectorTestRequest.builder() - .apiKeyHeader(inputData.get("edcApiKey")).apiKeyValue(inputData.get("edcApiKeyValue")) - .connectorHost(inputData.get("controlPlaneEndpoint")).build(); + .apiKeyHeader(inputData.get("edcApiKey")) + .apiKeyValue(inputData.get("edcApiKeyValue")) + .connectorId(inputData.get("bpnNumber")) + .connectorHost(inputData.get("controlPlaneEndpoint")) + .build(); inputData.put("testServiceURL", connectorTestServiceURL); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/TractusConnectorManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/TractusConnectorManager.java index c1ea1c78..05e63226 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/TractusConnectorManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/TractusConnectorManager.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -61,7 +61,7 @@ public Map managePackage(Customer customerDetails, AppActions ac try { String packageName = tool.getLabel(); - outputData = connectorCommonUtilityManager.prepareConnectorInput(packageName, inputData); + outputData = connectorCommonUtilityManager.prepareConnectorInput(customerDetails, packageName, inputData); if (AppActions.CREATE.equals(action)) appManagement.createPackage(EDC_CONNECTOR, packageName, inputData); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/VaultManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/VaultManager.java index ecda05b4..0d78b8b0 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/VaultManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/VaultManager.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -50,6 +50,7 @@ @RequiredArgsConstructor public class VaultManager { + private static final String DIM_CLIENT_SECRET = "dim-client-secret"; private static final String CLIENT_SECRET = "client-secret"; private static final String V1_SECRET_DATA = "/v1/secret/data/"; public static final String ENCRYPTIONKEYS = "encryptionkeys"; @@ -58,7 +59,6 @@ public class VaultManager { public static final String CERTIFICATE_PRIVATE_KEY = "certificate-private-key"; private final VaultAppManageProxy vaultManagerProxy; private final AutoSetupTriggerManager autoSetupTriggerManager; - private final OpenSSLClientManager openSSLClientManager; @Value("${vault.url}") private String valutURL; @@ -94,16 +94,18 @@ public Map uploadKeyandValues(Customer customerDetails, Selected tenantVaultSecret = new HashMap<>(); tenantVaultSecret.put(CONTENT, inputData.get("selfsigncertificateprivatekey")); uploadSecrete(tenantNameNamespace, CERTIFICATE_PRIVATE_KEY, tenantVaultSecret); - + tenantVaultSecret = new HashMap<>(); tenantVaultSecret.put(CONTENT, inputData.get("keycloakAuthenticationClientSecret")); uploadSecrete(tenantNameNamespace, CLIENT_SECRET, tenantVaultSecret); - String encryptionkeysalias = openSSLClientManager.executeCommand("openssl rand -base64 16"); tenantVaultSecret = new HashMap<>(); - encryptionkeysalias = encryptionkeysalias.replace("\n", ""); - tenantVaultSecret.put(CONTENT, encryptionkeysalias); + tenantVaultSecret.put(CONTENT, "c3RhbmRhcmRfZW5jX2tleQo="); uploadSecrete(tenantNameNamespace, ENCRYPTIONKEYS, tenantVaultSecret); + + tenantVaultSecret = new HashMap<>(); + tenantVaultSecret.put(CONTENT, inputData.get("dimClientSecret")); + uploadSecrete(tenantNameNamespace, DIM_CLIENT_SECRET, tenantVaultSecret); inputData.put(DAPS_CERT, DAPS_CERT); inputData.put(CERTIFICATE_PRIVATE_KEY, CERTIFICATE_PRIVATE_KEY); @@ -115,6 +117,7 @@ public Map uploadKeyandValues(Customer customerDetails, Selected inputData.put(ENCRYPTIONKEYS, ENCRYPTIONKEYS); inputData.put("certificate-data-plane-private-key", CERTIFICATE_PRIVATE_KEY); inputData.put("certificate-data-plane-public-key", CERTIFICATE_PRIVATE_KEY); + inputData.put(DIM_CLIENT_SECRET, DIM_CLIENT_SECRET); autoSetupTriggerDetails.setStatus(TriggerStatusEnum.SUCCESS.name()); log.info(LogUtil.encode(orgName) + "-" + LogUtil.encode(packageName) + "-Vault created"); @@ -164,9 +167,8 @@ public void deleteAllSecret(SelectedTools tool, Map inputData, A deleteSecret(tenantNameNamespace, CERTIFICATE_PRIVATE_KEY); deleteSecret(tenantNameNamespace, ENCRYPTIONKEYS); deleteSecret(tenantNameNamespace, CLIENT_SECRET); - - log.info(LogUtil.encode(orgName) + "-" + LogUtil.encode(packageName) + "-Vault deleted"); + log.info(LogUtil.encode(orgName) + "-" + LogUtil.encode(packageName) + "-Vault deleted"); } catch (Exception ex) { log.error("VaultManager failed retry attempt: : {}", @@ -174,7 +176,8 @@ public void deleteAllSecret(SelectedTools tool, Map inputData, A autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name()); autoSetupTriggerDetails.setRemark(ex.getMessage()); - throw new ServiceException("VaultManager Oops! We have an exception - " + ex.getMessage()); + throw new ServiceException("VaultManager Oops! We have an exception - " + ex.getMessage() + ", Cause: " + + LogUtil.getCause(ex)); } finally { autoSetupTriggerManager.saveTriggerDetails(autoSetupTriggerDetails, triger); @@ -183,7 +186,7 @@ public void deleteAllSecret(SelectedTools tool, Map inputData, A public void deleteSecret(String tenantName, String secretePath) throws URISyntaxException { - String valutURLwithpath = valutURL + V1_SECRET_DATA + tenantName+ "/data/" + secretePath; + String valutURLwithpath = valutURL + V1_SECRET_DATA + tenantName + "/data/" + secretePath; URI url = new URI(valutURLwithpath); vaultManagerProxy.deleteKeyandValue(url); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/portal/model/ServiceInstanceResultResponse.java b/src/main/java/org/eclipse/tractusx/autosetup/portal/model/ServiceInstanceResultResponse.java index 5c135d19..ac0f5b6d 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/portal/model/ServiceInstanceResultResponse.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/portal/model/ServiceInstanceResultResponse.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -20,6 +20,9 @@ package org.eclipse.tractusx.autosetup.portal.model; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; @@ -32,12 +35,19 @@ @Builder @NoArgsConstructor @AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) public class ServiceInstanceResultResponse { - - private TechnicalUserInfo technicalUserInfo; - - private ClientInfo clientInfo; + private String id; + private String offerSubscriptionStatus; + private String name; + private String customer; + private String bpn; + private List contact; + private List technicalUserData; + private String tenantUrl; + private String appInstanceId; + @SneakyThrows public String toJsonString() { final ObjectMapper mapper = new ObjectMapper(); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUserDetails.java b/src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUserDetails.java new file mode 100644 index 00000000..90ea3ed7 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUserDetails.java @@ -0,0 +1,46 @@ +/******************************************************************************** + * Copyright (c) 2024 T-Systems International GmbH + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.portal.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class TechnicalUserDetails { + + private String serviceAccountId; + private String clientId; + private String name; + private String description; + private String authenticationType; + private String companyServiceAccountTypeId; + private String secret; + + private String subscriptionId; +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUserInfo.java b/src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUsers.java similarity index 72% rename from src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUserInfo.java rename to src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUsers.java index 4254d909..7f392962 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUserInfo.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUsers.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2024 T-Systems International GmbH + * Copyright (c) 2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -20,6 +20,10 @@ package org.eclipse.tractusx.autosetup.portal.model; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -29,11 +33,14 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class TechnicalUserInfo { +@JsonIgnoreProperties(ignoreUnknown = true) +public class TechnicalUsers { - private String technicalUserId; + private String id; + + private String name; - private String technicalUserSecret; + private List permissions; - private String technicalClientId; + private TechnicalUserDetails technicalUserDetails; } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java b/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java index a9818e2e..19951fd5 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java @@ -26,13 +26,19 @@ import org.eclipse.tractusx.autosetup.model.KeycloakTokenResponse; import org.eclipse.tractusx.autosetup.portal.model.ServiceInstanceResultRequest; import org.eclipse.tractusx.autosetup.portal.model.ServiceInstanceResultResponse; +import org.eclipse.tractusx.autosetup.portal.model.TechnicalUserDetails; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; + +import com.fasterxml.jackson.databind.JsonNode; @FeignClient(name = "PortalIntegrationProxy", url = "placeholder") public interface PortalIntegrationProxy { @@ -44,18 +50,34 @@ public interface PortalIntegrationProxy { public ServiceInstanceResultResponse postAppInstanceResultAndGetTenantSpecs(URI url, @RequestHeader Map header, @RequestBody ServiceInstanceResultRequest serviceInstanceResultRequest); - - @PostMapping("/api/Services/autoSetup") - public ServiceInstanceResultResponse postServiceInstanceResultAndGetTenantSpecs(URI url, - @RequestHeader Map header, + @PostMapping("/api/{appServiceURIPath}/start-autoSetup") + public JsonNode postAppServiceStartAutoSetup(URI url, @RequestHeader Map header, + @PathVariable("appServiceURIPath") String appServiceURIPath, @RequestBody ServiceInstanceResultRequest serviceInstanceResultRequest); - + @GetMapping("/api/{appServiceURIPath}/{appId}/subscription/{subscriptionId}/provider") + public ServiceInstanceResultResponse getAppServiceInstanceSubcriptionDetails(URI url, + @RequestHeader Map header, @PathVariable("appServiceURIPath") String appServiceURIPath, + @PathVariable("appId") String appId, @PathVariable("subscriptionId") String subscriptionId); + + + @GetMapping("/api/administration/serviceaccount/owncompany/serviceaccounts/{serviceAccountId}") + public TechnicalUserDetails getTechnicalUserDetails(URI url, @RequestHeader Map header, + @PathVariable("serviceAccountId") String serviceAccountId); + @PostMapping("/api/administration/connectors/managed") public String manageConnector(URI url, @RequestHeader Map header, @RequestBody MultiValueMap body); + @GetMapping("/api/administration/connectors/offerSubscriptions") + public JsonNode getSubcriptionWithConnectors(URI url, @RequestHeader Map header, + @RequestParam("connectorIdSet") boolean connectorIdSet); + + @PutMapping("/api/administration/connectors/{offerSubscriptionId}/connectorUrl") + public String updateRegisterConnectorUrl(URI url, @RequestHeader Map header, + @RequestBody Map body); + @DeleteMapping("/api/administration/connectors/{connectorId}") public void deleteConnector(URI url, @RequestHeader Map header, @PathVariable String connectorId); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java b/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java index ba855748..947d36c8 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java @@ -29,10 +29,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; import org.eclipse.tractusx.autosetup.constant.AppActions; import org.eclipse.tractusx.autosetup.constant.TriggerStatusEnum; @@ -67,6 +67,8 @@ @RequiredArgsConstructor public class AutoSetupOrchitestratorService { + private static final String SUCCESS_HTML_TEMPLATE = "success.html"; + private static final String CONTENT = "content"; private static final String CCEMAIL = "ccemail"; private static final String TEST_SERVICE_URL = "testServiceURL"; private static final String CONNECTOR_TEST_RESULT = "connectorTestResult"; @@ -102,16 +104,19 @@ public class AutoSetupOrchitestratorService { private String targetCluster; @Value("${portal.email.address}") - private String portalEmail; - + private String technicalEmail; + @Value("${mail.replyto.address}") private String mailReplytoAddress; - + @Value("${manual.update}") private boolean manualUpdate; @Value("${managed.dt-registry:true}") private boolean managedDtRegistry; + + @Value("${managed.dt-registry.local:true}") + private boolean managedDTRegistryLocal; public String getAllInstallPackages() { return kubeAppManageProxy.getAllInstallPackages(); @@ -287,7 +292,6 @@ private void proceessTrigger(AutoSetupRequest autoSetupRequest, AppActions actio try { Customer customer = autoSetupRequest.getCustomer(); - trigger.setTriggerType(action.name()); for (AppServiceCatalogAndCustomerMapping appCatalogDetails : appCatalogListDetails) { @@ -328,17 +332,17 @@ private void proceessTrigger(AutoSetupRequest autoSetupRequest, AppActions actio log.error("Error in package creation " + e.getMessage()); trigger.setStatus(TriggerStatusEnum.FAILED.name()); trigger.setRemark(e.getMessage()); - generateNotification(autoSetupRequest.getCustomer(), "Error in autosetup execution - "+trigger.getTriggerId()); - } + generateNotification(autoSetupRequest.getCustomer(), + "Error in autosetup execution - " + trigger.getTriggerId(), "", SUCCESS_HTML_TEMPLATE); + } finally { + LocalDateTime now = LocalDateTime.now(); + trigger.setModifiedTimestamp(now.toString()); + trigger.setInputConfiguration(autoSetupTriggerMapper.fromMaptoStr(List.of(inputConfiguration))); - LocalDateTime now = LocalDateTime.now(); - trigger.setModifiedTimestamp(now.toString()); - trigger.setInputConfiguration(autoSetupTriggerMapper.fromMaptoStr(List.of(inputConfiguration))); - - autoSetupTriggerManager.saveTriggerUpdate(trigger); + autoSetupTriggerManager.saveTriggerUpdate(trigger); + } } - private void executeEDCTractus(AutoSetupRequest autoSetupRequest, AppActions action, AutoSetupTriggerEntry trigger, Map inputConfiguration, SelectedTools selectedTool) { @@ -354,33 +358,38 @@ private void executeEDCTractus(AutoSetupRequest autoSetupRequest, AppActions act private void edcDeployemnt(AutoSetupRequest autoSetupRequest, AutoSetupTriggerEntry trigger, Map edcOutput) { - String json = autoSetupTriggerMapper.fromMaptoStr(extractEDCResultMap(edcOutput)); + + List> extractResultMap = extractEDCResultMap(edcOutput); + String json = autoSetupTriggerMapper.fromMaptoStr(extractResultMap); trigger.setAutosetupResult(json); trigger.setStatus(TriggerStatusEnum.SUCCESS.name()); Customer customer = autoSetupRequest.getCustomer(); + + String connectivityTestStr = edcOutput.get(CONNECTOR_TEST_RESULT); + + boolean isTestConnectivityTestSuccess = connectivityTestStr != null + && connectivityTestStr.contains("consumer and provider"); + + String generateEmailTable = generateEmailTable(extractResultMap); // Send an email Map emailContent = new HashMap<>(); emailContent.put(ORGNAME, customer.getOrganizationName()); - emailContent.putAll(edcOutput); - - - String connectivityTestStr= edcOutput.get(CONNECTOR_TEST_RESULT); - - boolean isTestConnectivityTestSuccess = connectivityTestStr!=null && connectivityTestStr.contains("consumer and provider"); - + emailContent.put(CCEMAIL, technicalEmail); + emailContent.put(TEST_SERVICE_URL, findValueInMap(edcOutput, TEST_SERVICE_URL)); + emailContent.put(CONNECTOR_TEST_RESULT, CONNECTOR_TEST_RESULT); + emailContent.put(CONTENT, generateEmailTable); + if (isTestConnectivityTestSuccess) { emailContent.put(TOEMAIL, customer.getEmail()); - emailContent.put(CCEMAIL, portalEmail); emailManager.sendEmail(emailContent, "EDC Application Activited Successfully", "edc_success_activate.html"); - log.info(EMAIL_SENT_SUCCESSFULLY); - }else { - generateNotification(customer, "EDC Application Deployed Successfully"); + } else { + emailContent.put(TOEMAIL, technicalEmail); + emailManager.sendEmail(emailContent, "EDC Application Deployed Successfully", SUCCESS_HTML_TEMPLATE); } - - + log.info(EMAIL_SENT_SUCCESSFULLY); } private void executeSDEWithEDCTractus(AutoSetupRequest autoSetupRequest, AppActions action, @@ -409,7 +418,10 @@ private void dtDeployment(Customer customer, AppActions action, AutoSetupTrigger dtAppWorkFlow.getWorkFlow(customer, selectedTool, action, inputConfiguration, trigger); - String json = autoSetupTriggerMapper.fromMaptoStr(extractDTResultMap(inputConfiguration)); + List> extractDTResultMap = extractDTResultMap(inputConfiguration); + String generateEmailTable = generateEmailTable(extractDTResultMap); + + String json = autoSetupTriggerMapper.fromMaptoStr(extractDTResultMap); trigger.setAutosetupResult(json); trigger.setStatus(TriggerStatusEnum.SUCCESS.name()); @@ -417,9 +429,9 @@ private void dtDeployment(Customer customer, AppActions action, AutoSetupTrigger // Send an email Map emailContent = new HashMap<>(); emailContent.put(ORGNAME, customer.getOrganizationName()); - emailContent.putAll(inputConfiguration); emailContent.put(TOEMAIL, customer.getEmail()); - emailContent.put(CCEMAIL, portalEmail); + emailContent.put(CCEMAIL, technicalEmail); + emailContent.put(CONTENT, generateEmailTable); emailManager.sendEmail(emailContent, "DT registry Application Activited Successfully", "dt_success_template.html"); @@ -442,53 +454,51 @@ private void sdeDeployment(AutoSetupRequest autoSetupRequest, AppActions action, Map map = sdeWorkFlow.getWorkFlow(autoSetupRequest.getCustomer(), selectedTool, action, inputConfiguration, trigger); + List> extractResultMap = extractResultMap(map); + String generateEmailTable = generateEmailTable(extractResultMap); + + String json = autoSetupTriggerMapper.fromMaptoStr(extractResultMap); + trigger.setAutosetupResult(json); + + String connectivityTestStr = inputConfiguration.get(CONNECTOR_TEST_RESULT); + boolean isTestConnectivityTestSuccess = connectivityTestStr != null + && connectivityTestStr.contains("consumer and provider"); + Map emailContent = new HashMap<>(); - emailContent.put(SDE_FRONTEND_URL, map.get(SDE_FRONTEND_URL)); - emailContent.put(SDE_BACKEND_URL, map.get(SDE_BACKEND_URL)); - emailContent.put(CONNECTOR_TEST_RESULT, map.get(CONNECTOR_TEST_RESULT)); - emailContent.put(TEST_SERVICE_URL, map.get(TEST_SERVICE_URL)); - emailContent.putAll(map); - - String connectivityTestStr= inputConfiguration.get(CONNECTOR_TEST_RESULT); - boolean isTestConnectivityTestSuccess = connectivityTestStr!=null && connectivityTestStr.contains("consumer and provider"); + emailContent.put(ORGNAME, customer.getOrganizationName()); + emailContent.put(CCEMAIL, technicalEmail); + emailContent.put(CONTENT, generateEmailTable); if (manualUpdate || !isTestConnectivityTestSuccess) { - - generateNotification(customer, "SDE Application Deployed Successfully"); + emailContent.put(TOEMAIL, technicalEmail); + emailManager.sendEmail(emailContent, "SDE Application Deployed Successfully", SUCCESS_HTML_TEMPLATE); trigger.setStatus(TriggerStatusEnum.MANUAL_UPDATE_PENDING.name()); - } else { - trigger.setStatus(TriggerStatusEnum.SUCCESS.name()); - // Send an email - emailContent.put(ORGNAME, customer.getOrganizationName()); emailContent.put(TOEMAIL, customer.getEmail()); - emailContent.put(CCEMAIL, portalEmail); + emailContent.put(TEST_SERVICE_URL, findValueInMap(map, TEST_SERVICE_URL)); + emailContent.put(CONNECTOR_TEST_RESULT, CONNECTOR_TEST_RESULT); emailManager.sendEmail(emailContent, "SDE Application Activited Successfully", "success_activate.html"); - log.info(EMAIL_SENT_SUCCESSFULLY); // End of email sending code - } - - String json = autoSetupTriggerMapper.fromMaptoStr(extractResultMap(map)); - - trigger.setAutosetupResult(json); + log.info(EMAIL_SENT_SUCCESSFULLY); } - + @SneakyThrows - private void generateNotification(Customer customer, String emailSubject) { - + private void generateNotification(Customer customer, String emailSubject, String content, String template) { + Map emailContent = new HashMap<>(); emailContent.put(ORGNAME, customer.getOrganizationName()); emailContent.put(TOEMAIL, mailReplytoAddress); - emailContent.put(CCEMAIL, portalEmail); - emailManager.sendEmail(emailContent, emailSubject, "success.html"); + emailContent.put(CCEMAIL, technicalEmail); + emailContent.put(CONTENT, content); + + emailManager.sendEmail(emailContent, emailSubject, template); log.info(EMAIL_SENT_SUCCESSFULLY); } - private void processDeleteTrigger(AutoSetupTriggerEntry trigger, Map inputConfiguration) { if (trigger != null && trigger.getAutosetupRequest() != null) { @@ -571,10 +581,11 @@ private List> extractResultMap(Map outputMap List> processResult = new ArrayList<>(); - Map dft = new ConcurrentHashMap<>(); + Map dft = new LinkedHashMap<>(); dft.put("name", "SDE"); dft.put(SDE_FRONTEND_URL, outputMap.get(SDE_FRONTEND_URL)); dft.put(SDE_BACKEND_URL, outputMap.get(SDE_BACKEND_URL)); + processResult.add(dft); processResult.addAll(extractDependantAppResult(outputMap)); @@ -586,8 +597,11 @@ private List> extractDependantAppResult(Map List> processResult = new ArrayList<>(); - Map dt = extractDTResultMap(outputMap).get(0); - processResult.add(dt); + //commentting this beause of dt is get localy managed + if (managedDTRegistryLocal) { + Map dt = extractDTResultMap(outputMap).get(0); + processResult.add(dt); + } Map edc = extractEDCResultMap(outputMap).get(0); processResult.add(edc); @@ -599,7 +613,7 @@ private List> extractEDCResultMap(Map output List> processResult = new ArrayList<>(); - Map edc = new ConcurrentHashMap<>(); + Map edc = new LinkedHashMap<>(); edc.put("name", "EDC"); edc.put("controlPlaneEndpoint", outputMap.get("controlPlaneEndpoint")); edc.put("controlPlaneDataEndpoint", outputMap.get("controlPlaneDataEndpoint")); @@ -623,15 +637,29 @@ private List> extractDTResultMap(Map outputM List> processResult = new ArrayList<>(); - Map dt = new ConcurrentHashMap<>(); + Map dt = new LinkedHashMap<>(); dt.put("name", "DT"); - dt.put("dtregistryUrl", outputMap.get("dtregistryUrl")); + dt.put("dtregistryUrlWithURI", outputMap.get("dtregistryUrlWithURI")); dt.put("idpClientId", outputMap.get("idpClientId")); processResult.add(dt); return processResult; } + public String generateEmailTable(List> content) { + StringBuilder sb = new StringBuilder(); + sb.append(""); + content.forEach(element -> { + sb.append(""); + element.entrySet().forEach(entry -> { + if (!"name".equals(entry.getKey())) + sb.append(""); + }); + }); + sb.append("
" + element.get("name") + "
" + entry.getKey() + "" + entry.getValue() + "
"); + return sb.toString(); + } + public boolean checkNamespaceisExist(String targetNamespace) { String namespacesResult = kubeAppManageProxy.checkNamespace(targetCluster, targetNamespace); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java b/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java index 4e2d3a0d..3c23ffd6 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2023 T-Systems International GmbH - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023,2024 T-Systems International GmbH + * Copyright (c) 2023,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -51,11 +51,6 @@ public Map getWorkFlow(Customer customerDetails, SelectedTools t inputConfiguration.putAll( dtregistryManager.managePackage(customerDetails, workflowAction, tool, inputConfiguration, triger)); - if (!manualUpdate) { - dtregistryManager.dtRegistryRegistrationInEDC(customerDetails, tool, - inputConfiguration, triger); - } - return inputConfiguration; } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestRequest.java b/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestRequest.java index a8b18727..83e001cd 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestRequest.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestRequest.java @@ -32,5 +32,7 @@ public class ConnectorTestRequest { private String apiKeyHeader; private String apiKeyValue; + + private String connectorId; } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java new file mode 100644 index 00000000..ec5ce8f1 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java @@ -0,0 +1,50 @@ +/******************************************************************************** + * Copyright (c) 2024 T-Systems International GmbH + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.utility; + +import com.fasterxml.jackson.databind.JsonNode; + +import lombok.SneakyThrows; + + +public class JsonObjectProcessingUtility { + + private JsonObjectProcessingUtility() {} + + @SneakyThrows + public static String getValueFromJsonNode(JsonNode jsonNode, String propertyId) { + if (jsonNode != null && jsonNode.get(propertyId) != null) + return jsonNode.get(propertyId).asText(); + else + return ""; + } + + + @SneakyThrows + public static JsonNode getArrayNodeFromJsonNode(JsonNode jsonnode, String propertyId) { + if (jsonnode != null && jsonnode.get(propertyId) != null) + return jsonnode.get(propertyId); + else + return null; + } + + +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java new file mode 100644 index 00000000..65b5453a --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java @@ -0,0 +1,55 @@ +/******************************************************************************** + * Copyright (c) 2024 T-Systems International GmbH + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.utility; + +import java.net.URI; + +import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; +import org.springframework.stereotype.Service; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; + +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; + +@Service +@RequiredArgsConstructor +public class KeyCloakTokenProxyUtitlity { + + private final PortalIntegrationProxy portalIntegrationProxy; + + @SneakyThrows + public String getKeycloakToken(String clientId, String clientSecret, URI tokenURI) { + + MultiValueMap body = new LinkedMultiValueMap<>(); + body.add("grant_type", "client_credentials"); + body.add("client_id", clientId); + body.add("client_secret", clientSecret); + var resultBody = portalIntegrationProxy.readAuthToken(tokenURI, body); + + if (resultBody != null) { + return resultBody.getAccessToken(); + } + return null; + + } + +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/LogUtil.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/LogUtil.java index 02ba15a9..bb89ceb8 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/utility/LogUtil.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/utility/LogUtil.java @@ -30,6 +30,14 @@ private LogUtil() { public static String encode(String message) { return StringEscapeUtils.unescapeHtml4(StringEscapeUtils.escapeJava(message)); } + + public static String getCause(Exception ex) { + Throwable cause=ex.getCause(); + if(cause!=null) { + return cause.toString(); + } + return ""; + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8719d698..d8061a5a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,6 @@ #/******************************************************************************** -#* Copyright (c) 2022, 2023 T-Systems International GmbH -#* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation +#* Copyright (c) 2022,2024 T-Systems International GmbH +#* Copyright (c) 2022,2024 Contributors to the Eclipse Foundation #* #* See the NOTICE file(s) distributed with this work for additional #* information regarding copyright ownership. @@ -123,10 +123,21 @@ sde.discovery-clientId=${sde_discovery-clientId} sde.discovery-clientSecret=${sde_discovery-clientSecret} sde.discovery-grantType=${sde_discovery-grantType} +sde.bpdm-provider-edc-dataspace-api=${sde-bpdm-provider-edc-dataspace-api} +sde.bpdm-provider-bpnl=${sde-bpdm-provider-bpnl} +sde.bpdm-provider-edc-public-api=${sde-bpdm-provider-edc-public-api} + +edc.iatp.id=${edc-iatp-id} +edc.iatp.sts.dim.url=${edc-iatp-sts-dim-url} +edc.iatp.sts.oauth.token.url=${edc-iatp-sts-oauth-token-url} +edc.bdrs.server=${edc-bdrs-server} +edc.iam.trusted-issuer=${edc-iam-trusted-issuer} + #Dyanamic property for EDC connector setup as per environemnt edc.miwUrl=${edc_miwUrl} edc.ssi.authorityId=${edc_ssi_authorityId} #Flag to make optional use of managed DT regitry, if value not set default value is true -managed.dt-registry=true \ No newline at end of file +managed.dt-registry=true +managed.dt-registry.local=true \ No newline at end of file diff --git a/src/main/resources/flyway/V10__update_app_version.sql b/src/main/resources/flyway/V10__update_app_version.sql new file mode 100644 index 00000000..ae68350d --- /dev/null +++ b/src/main/resources/flyway/V10__update_app_version.sql @@ -0,0 +1,481 @@ +/******************************************************************************** + * Copyright (c) 2024 T-Systems International GmbH + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +update app_tbl set expected_input_data='{ + "sdepostgresql":{ + "enabled":true, + "primary":{ + "persistence":{ + "size":"1Gi" + } + }, + "persistence":{ + "size":"1Gi" + }, + "auth":{ + "postgresPassword":"$\{postgresPassword\}", + "password":"$\{postgresPassword\}", + "username":"$\{username\}", + "database":"$\{database\}" + } + }, + "backend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdebackend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties": "server.port=8080 + + spring.main.allow-bean-definition-overriding=true + + spring.servlet.multipart.enabled=true + + spring.servlet.multipart.file-size-threshold=2KB + + spring.servlet.multipart.max-file-size=200MB + + spring.servlet.multipart.max-request-size=215MB + + server.servlet.context-path=/backend/api + + spring.flyway.baseline-on-migrate=true + + spring.flyway.locations=classpath:/flyway + + file.upload-dir=./temp/ + + logging.level.org.apache.http=info + + logging.level.root=info + + spring.datasource.driver-class-name=org.postgresql.Driver + + spring.jpa.open-in-view=false + + digital-twins.hostname=$\{dtregistryUrl\} + + digital-twins.api=$\{dtregistryURI\} + + digital-twins.authentication.url=$\{sde.digital-twins.authentication.url\} + + digital-twins.authentication.clientId=$\{digital-twins.authentication.clientId\} + + digital-twins.authentication.clientSecret=$\{digital-twins.authentication.clientSecret\} + + digital-twins.authentication.grantType=client_credentials + + dft.hostname=$\{sdeBackEndUrl\} + + dft.apiKeyHeader=$\{sdeBackEndApiKeyHeader\} + + dft.apiKey=$\{sdeBackEndApiKey\} + + manufacturerId=$\{manufacturerId\} + + edc.hostname=$\{controlPlaneEndpoint\} + + edc.managementpath=/data + + edc.managementpath.apiversion=/v2 + + edc.dsp.endpointpath=/api/v1/dsp + + edc.dataplane.endpointpath=/api/public + + edc.apiKeyHeader=$\{edcApiKey\} + + edc.apiKey=$\{edcApiKeyValue\} + + edc.consumer.hostname=$\{controlPlaneEndpoint\} + + edc.consumer.apikeyheader=$\{edcApiKey\} + + edc.consumer.apikey=$\{edcApiKeyValue\} + + edc.consumer.managementpath=/data + + edc.consumer.managementpath.apiversion=/v2 + + edc.consumer.protocol.path=/api/v1/dsp + + keycloak.clientid=$\{sdebackendkeycloakclientid\} + + spring.security.oauth2.resourceserver.jwt.issuer-uri=$\{sde.resourceServerIssuer\} + + springdoc.api-docs.path=/api-docs + + springdoc.swagger-ui.oauth.client-id=$\{sdebackendkeycloakclientid\} + + partner.pool.hostname=$\{sde.partner.pool.hostname\} + + partner.pool.authentication.url=$\{sde.partner.pool.authentication.url\} + + partner.pool.clientId=$\{sde.partner.pool.clientId\} + + partner.pool.clientSecret=$\{sde.partner.pool.clientSecret\} + + partner.pool.grantType=client_credentials + + portal.backend.hostname=$\{sde.portal.backend.hostname\} + + portal.backend.authentication.url=$\{sde.portal.backend.authentication.url\} + + portal.backend.clientId=$\{sde.portal.backend.clientId\} + + portal.backend.clientSecret=$\{sde.portal.backend.clientSecret\} + + portal.backend.grantType=client_credentials + + bpndiscovery.hostname=$\{sde.bpndiscovery.hostname\} + + discovery.authentication.url=$\{sde.discovery.authentication.url\} + + discovery.clientId=$\{sde.discovery.clientId\} + + discovery.clientSecret=$\{sde.discovery.clientSecret\} + + discovery.grantType=client_credentials + + bpdm.provider.edc.dataspace.api=$\{bpdm.provider.edc.dataspace.api\} + + bpdm.provider.bpnl=$\{bpdm.provider.bpnl\} + + bpdm.provider.edc.public.api=$\{bpdm.provider.edc.public.api\} + + mail.smtp.username=$\{emailUsername\} + + mail.smtp.password=$\{emailPassword\} + + mail.smtp.host=$\{emailHost\} + + mail.smtp.port=$\{emailPort\} + + mail.to.address=$\{emailTo\} + + mail.cc.address=$\{emailCC\} + + mail.from.address=$\{emailFrom\} + + mail.replyto.address=$\{emailReply\} + + mail.smtp.starttls.enable=true + + mail.smtp.auth=true + + sftp.host=$\{sftpHost\} + + sftp.port=$\{sftpPort\} + + sftp.username=$\{sftpUsername\} + + sftp.password=$\{sftpPassword\} + + sftp.accessKey=$\{sftpKey\} + + sftp.location.tobeprocessed=/ToBeProcessed + + sftp.location.inprogress=/InProgress + + sftp.location.success=/Success + + sftp.location.partialsucess=/PartialSuccess + + sftp.location.failed=/Failed + + retriever.name=minio + + minio.endpoint=$\{storage.media.endpoint\} + + minio.access-key=$\{storage.media.accessKey\} + + minio.secret-key=$\{storage.media.secretKey\} + + minio.bucket-name=$\{storage.media.bucket\} + + minio.location.tobeprocessed= + + minio.location.inprogress=/InProgress + + minio.location.success=/Success + + minio.location.partialsucess=/PartialSuccess + + minio.location.failed=/Failed" + } + }, + "frontend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + "kubernetes.io/tls-acme": "true" + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdefrontend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties":"REACT_APP_API_URL=$\{sdeBackEndUrl\} + + REACT_APP_KEYCLOAK_URL=$\{sde.keycloak.auth\} + + REACT_APP_KEYCLOAK_REALM=$\{sde.keycloak.realm\} + + REACT_APP_CLIENT_ID=$\{sdefrontendkeycloakclientid\} + + REACT_APP_DEFAULT_COMPANY_BPN=$\{bpnNumber\} + + REACT_APP_FILESIZE=268435456" + } + } +}', package_identifier='tx-sde-charts/sde' ,package_version='1.2.5' where app_name='SDE'; + + +update app_tbl set expected_input_data= '{ + "enablePostgres": true, + "enableKeycloak": false, + "postgresql": { + "auth": { + "password":"$\{rgdbpass\}", + "postgresPassword":"$\{rgdbpass\}", + "username":"$\{rgusername\}", + "database":"$\{rgdatabase\}" + }, + "primary": + { + "persistence":{ + "size" :"1Gi" + } + }, + "persistence": { + "size" :"1Gi" + } + }, + "registry": { + "host": "$\{dnsName\}", + "idpClientId" : "$\{idpClientId\}", + "idpIssuerUri": "$\{idpIssuerUri\}", + "tenantId" : "$\{bpnNumber\}", + "authentication": $\{dtNeedExternalAccess\}, + "granularAccessControlFetchSize": "500", + "useGranularAccessControl": "true", + "ingress": { + "enabled": $\{dtNeedExternalAccess\}, + "hostname": "$\{dnsName\}", + "annotations": { + "cert-manager.io/cluster-issuer": letsencrypt-prod, + "nginx.ingress.kubernetes.io/cors-allow-credentials": "true", + "nginx.ingress.kubernetes.io/enable-cors": "true", + "nginx.ingress.kubernetes.io/rewrite-target": /$2, + "nginx.ingress.kubernetes.io/use-regex": "true", + "nginx.ingress.kubernetes.io/x-forwarded-prefix": /$\{dtregistryUrlPrefix\} + }, + "urlPrefix": /$\{dtregistryUrlPrefix\}, + "className": "nginx", + "tls": $\{dtNeedExternalAccess\} + } + } +}', package_identifier='tx-all-repo/digital-twin-registry', package_version='0.4.11' where app_name='DT_REGISTRY'; + + +update app_tbl set expected_input_data= '{ + "install": { + "postgresql": true, + "vault": false + }, + "participant" : { + "id": "$\{bpnNumber\}" + }, + "backendService": { + "httpProxyTokenReceiverUrl": "$\{dftAddress\}" + }, + "postgresql": { + "enabled": true, + "fullnameOverride": "postgresql", + "jdbcUrl":"jdbc:postgresql://postgresql:5432/edc", + "username":"$\{username\}", + "password":"$\{appdbpass\}", + "database": "edc", + "auth":{ + "username":"$\{username\}", + "password":"$\{appdbpass\}", + "postgresPassword":"$\{postgresPassword\}" + } + }, + "vault": { + "hashicorp": { + "enabled": true, + "url": "$\{vaulturl\}", + "token": "$\{vaulttoken\}", + "timeout": 30, + "healthCheck": { + "enabled": false, + "standbyOk": false + }, + "paths": { + "health": "/v1/sys/health", + "secret": "$\{valuttenantpath\}" + } + }, + "secretNames": { + "dapsPrivateKey": "$\{certificate-private-key\}", + "dapsPublicKey": "$\{daps-cert\}", + "transferProxyTokenEncryptionAesKey": "$\{encryptionkeys\}", + "transferProxyTokenSignerPrivateKey": "$\{certificate-data-plane-private-key\}", + "transferProxyTokenSignerPublicKey": "$\{certificate-data-plane-public-key\}" + } + }, + "iatp": { + "id": "$\{iatp.id\}", + "sts": { + "dim": { + "url": "$\{iatp.sts.dim.url\}" + }, + "oauth": { + "client": { + "id": "$\{dimClientId\}", + "secret_alias": "$\{dim-client-secret\}" + }, + "token_url": "$\{iatp.sts.oauth.token_url\}" + } + } + }, + "controlplane": { + "endpoints": { + "management": { + "authKey": "$\{edcApiKeyValue\}", + "path": "/data", + "port": "8081" + } + }, + "bdrs": { + "cache_validity_seconds": 600, + "server": { + "url": "$\{bdrs.server\}" + } + }, + "env": { + "EDC_IAM_TRUSTED-ISSUER_ISSUER1_ID": "$\{edc.iam.trusted-issuer\}" + }, + "service": { + "type": "NodePort" + }, + "securityContext": { + "readOnlyRootFilesystem": false + }, + "ssi" : { + "miw" :{ + "authorityId" : "$\{authorityId\}", + "url": "$\{edcMiwUrl\}" + }, + "oauth": { + "client" :{ + "id" :"$\{keycloakAuthenticationClientId\}", + "secretAlias": "client-secret" + }, + "tokenurl": "$\{keycloakAuthTokenURL\}" + } + }, + "ingresses": [ + { + "enabled": true, + "hostname": "$\{dnsName\}", + "annotations": {}, + "className": "nginx", + "endpoints": [ + "protocol", + "management", + "control", + "default" + ], + "tls": { + "enabled": true, + "secretName": "edctxcontrolplane" + }, + "certManager": { + "clusterIssuer": "letsencrypt-prod" + } + } + ] + }, + "dataplane": { + "token": { + "refresh": { + "expiry_seconds": 300, + "expiry_tolerance_seconds": 300, + "refresh_endpoint": "$\{dataplane.token.refresh.refresh_endpoint\}" + }, + "signer": { + "privatekey_alias": "$\{certificate-private-key\}" + }, + "verifier": { + "publickey_alias": "$\{daps-cert\}" + } + } + }, + "ingresses": [ + { + "enabled": true, + "hostname": "$\{dnsName\}", + "annotations": {}, + "className": "nginx", + "endpoints": [ + "public" + ], + "tls": { + "enabled": true, + "secretName": "edctxdataplane" + }, + "certManager": { + "clusterIssuer": "letsencrypt-prod" + } + } + ] + } +}', package_version='0.7.0', package_identifier='tx-all-repo/tractusx-connector' where app_name='EDC_CONNECTOR'; + +update app_tbl set expected_input_data= replace(replace(expected_input_data,'\{','{'),'\}','}'), required_yaml_configuration=replace(replace(required_yaml_configuration,'\{','{'),'\}','}'); \ No newline at end of file diff --git a/src/main/resources/flyway/V9__update_app_version.sql b/src/main/resources/flyway/V9__update_app_version.sql new file mode 100644 index 00000000..8f29610f --- /dev/null +++ b/src/main/resources/flyway/V9__update_app_version.sql @@ -0,0 +1,316 @@ +/******************************************************************************** + * Copyright (c) 2024 T-Systems International GmbH + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +update app_tbl set expected_input_data='{ + "sdepostgresql":{ + "enabled":true, + "primary":{ + "persistence":{ + "size":"1Gi" + } + }, + "persistence":{ + "size":"1Gi" + }, + "auth":{ + "postgresPassword":"$\{postgresPassword\}", + "password":"$\{postgresPassword\}", + "username":"$\{username\}", + "database":"$\{database\}" + } + }, + "backend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdebackend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties": "server.port=8080 + + spring.main.allow-bean-definition-overriding=true + + spring.servlet.multipart.enabled=true + + spring.servlet.multipart.file-size-threshold=2KB + + spring.servlet.multipart.max-file-size=200MB + + spring.servlet.multipart.max-request-size=215MB + + server.servlet.context-path=/backend/api + + spring.flyway.baseline-on-migrate=true + + spring.flyway.locations=classpath:/flyway + + file.upload-dir=./temp/ + + logging.level.org.apache.http=info + + logging.level.root=info + + spring.datasource.driver-class-name=org.postgresql.Driver + + spring.jpa.open-in-view=false + + digital-twins.hostname=$\{dtregistryUrl\} + + digital-twins.api=$\{dtregistryURI\} + + digital-twins.authentication.url=$\{sde.digital-twins.authentication.url\} + + digital-twins.authentication.clientId=$\{digital-twins.authentication.clientId\} + + digital-twins.authentication.clientSecret=$\{digital-twins.authentication.clientSecret\} + + digital-twins.authentication.grantType=client_credentials + + dft.hostname=$\{sdeBackEndUrl\} + + dft.apiKeyHeader=$\{sdeBackEndApiKeyHeader\} + + dft.apiKey=$\{sdeBackEndApiKey\} + + manufacturerId=$\{manufacturerId\} + + edc.hostname=$\{controlPlaneEndpoint\} + + edc.managementpath=/data + + edc.managementpath.apiversion=/v2 + + edc.dsp.endpointpath=/api/v1/dsp + + edc.dataplane.endpointpath=/api/public + + edc.apiKeyHeader=$\{edcApiKey\} + + edc.apiKey=$\{edcApiKeyValue\} + + edc.consumer.hostname=$\{controlPlaneEndpoint\} + + edc.consumer.apikeyheader=$\{edcApiKey\} + + edc.consumer.apikey=$\{edcApiKeyValue\} + + edc.consumer.managementpath=/data + + edc.consumer.managementpath.apiversion=/v2 + + edc.consumer.protocol.path=/api/v1/dsp + + keycloak.clientid=$\{sdebackendkeycloakclientid\} + + spring.security.oauth2.resourceserver.jwt.issuer-uri=$\{sde.resourceServerIssuer\} + + springdoc.api-docs.path=/api-docs + + springdoc.swagger-ui.oauth.client-id=$\{sdebackendkeycloakclientid\} + + partner.pool.hostname=$\{sde.partner.pool.hostname\} + + partner.pool.authentication.url=$\{sde.partner.pool.authentication.url\} + + partner.pool.clientId=$\{sde.partner.pool.clientId\} + + partner.pool.clientSecret=$\{sde.partner.pool.clientSecret\} + + partner.pool.grantType=client_credentials + + portal.backend.hostname=$\{sde.portal.backend.hostname\} + + portal.backend.authentication.url=$\{sde.portal.backend.authentication.url\} + + portal.backend.clientId=$\{sde.portal.backend.clientId\} + + portal.backend.clientSecret=$\{sde.portal.backend.clientSecret\} + + portal.backend.grantType=client_credentials + + bpndiscovery.hostname=$\{sde.bpndiscovery.hostname\} + + discovery.authentication.url=$\{sde.discovery.authentication.url\} + + discovery.clientId=$\{sde.discovery.clientId\} + + discovery.clientSecret=$\{sde.discovery.clientSecret\} + + discovery.grantType=client_credentials + + mail.smtp.username=$\{emailUsername\} + + mail.smtp.password=$\{emailPassword\} + + mail.smtp.host=$\{emailHost\} + + mail.smtp.port=$\{emailPort\} + + mail.to.address=$\{emailTo\} + + mail.cc.address=$\{emailCC\} + + mail.from.address=$\{emailFrom\} + + mail.replyto.address=$\{emailReply\} + + mail.smtp.starttls.enable=true + + mail.smtp.auth=true + + sftp.host=$\{sftpHost\} + + sftp.port=$\{sftpPort\} + + sftp.username=$\{sftpUsername\} + + sftp.password=$\{sftpPassword\} + + sftp.accessKey=$\{sftpKey\} + + sftp.location.tobeprocessed=/ToBeProcessed + + sftp.location.inprogress=/InProgress + + sftp.location.success=/Success + + sftp.location.partialsucess=/PartialSuccess + + sftp.location.failed=/Failed + + retriever.name=minio + + minio.endpoint=$\{storage.media.endpoint\} + + minio.access-key=$\{storage.media.accessKey\} + + minio.secret-key=$\{storage.media.secretKey\} + + minio.bucket-name=$\{storage.media.bucket\} + + minio.location.tobeprocessed= + + minio.location.inprogress=/InProgress + + minio.location.success=/Success + + minio.location.partialsucess=/PartialSuccess + + minio.location.failed=/Failed" + } + }, + "frontend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + "kubernetes.io/tls-acme": "true" + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdefrontend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties":"REACT_APP_API_URL=$\{sdeBackEndUrl\} + + REACT_APP_KEYCLOAK_URL=$\{sde.keycloak.auth\} + + REACT_APP_KEYCLOAK_REALM=$\{sde.keycloak.realm\} + + REACT_APP_CLIENT_ID=$\{sdefrontendkeycloakclientid\} + + REACT_APP_DEFAULT_COMPANY_BPN=$\{bpnNumber\} + + REACT_APP_FILESIZE=268435456" + } + } +}', package_identifier='tx-sde-charts/sde' ,package_version='1.0.1' where app_name='SDE'; + + +update app_tbl set expected_input_data= '{ + "enablePostgres": true, + "enableKeycloak": false, + "postgresql": { + "auth": { + "password":"$\{rgdbpass\}", + "postgresPassword":"$\{rgdbpass\}", + "username":"$\{rgusername\}", + "database":"$\{rgdatabase\}" + }, + "primary": + { + "persistence":{ + "size" :"1Gi" + } + }, + "persistence": { + "size" :"1Gi" + } + }, + "registry": { + "host": "$\{dnsName\}", + "idpClientId" : "$\{idpClientId\}", + "idpIssuerUri": "$\{idpIssuerUri\}", + "tenantId" : "$\{bpnNumber\}", + "authentication": $\{dtNeedExternalAccess\}, + "ingress": { + "enabled": $\{dtNeedExternalAccess\}, + "hostname": "$\{dnsName\}", + "annotations": { + "cert-manager.io/cluster-issuer": letsencrypt-prod, + "nginx.ingress.kubernetes.io/cors-allow-credentials": "true", + "nginx.ingress.kubernetes.io/enable-cors": "true", + "nginx.ingress.kubernetes.io/rewrite-target": /$2, + "nginx.ingress.kubernetes.io/use-regex": "true", + "nginx.ingress.kubernetes.io/x-forwarded-prefix": /$\{dtregistryUrlPrefix\} + }, + "urlPrefix": /$\{dtregistryUrlPrefix\}, + "className": "nginx", + "tls": $\{dtNeedExternalAccess\} + } + } +}', package_version='0.3.27' where app_name='DT_REGISTRY'; + +update app_tbl set expected_input_data= replace(replace(expected_input_data,'\{','{'),'\}','}'), required_yaml_configuration=replace(replace(required_yaml_configuration,'\{','{'),'\}','}'); \ No newline at end of file diff --git a/src/main/resources/templates/dt_success_template.html b/src/main/resources/templates/dt_success_template.html index 1867ce9e..7aec4aed 100644 --- a/src/main/resources/templates/dt_success_template.html +++ b/src/main/resources/templates/dt_success_template.html @@ -36,8 +36,7 @@

The DT registry tool successfully activated for your use.

Please find your DT registry details below:

-

DT registry URL : ${dtregistryUrl}

-

App Id : ${idpClientId}

+ ${content}

Kind Regards
Catina-X

diff --git a/src/main/resources/templates/edc_success_activate.html b/src/main/resources/templates/edc_success_activate.html index ac3c8404..0fef4055 100644 --- a/src/main/resources/templates/edc_success_activate.html +++ b/src/main/resources/templates/edc_success_activate.html @@ -34,15 +34,9 @@

Hello ${orgname},

The EDC tool successfully activated for your use.

- -

Please find your connector details below:

-

Control Plane URL : ${controlPlaneEndpoint}

-

Control Plane Data URL : ${controlPlaneDataEndpoint}

-

EDC ApiKey : ${edcApiKey}

-

EDC ApiKeyValue : ${edcApiKeyValue}

-

Data Plane URL : ${dataPlanePublicEndpoint}

+ ${content}

Your connector status through connector test service: ${connectorTestResult}, check status again here

- +

Kind Regards
Catina-X

diff --git a/src/main/resources/templates/success.html b/src/main/resources/templates/success.html index 93eb24c1..ba2ccf92 100644 --- a/src/main/resources/templates/success.html +++ b/src/main/resources/templates/success.html @@ -31,9 +31,9 @@

Hello Team,

-

The Subcribe application deployed successfully for ${orgname}.

+

The subcribe application deployed successfully for ${orgname}.

please perform manually verification to activate application for customer use.

- + ${content}

Kind Regards
Catina-X

diff --git a/src/main/resources/templates/success_activate.html b/src/main/resources/templates/success_activate.html index 3d3b56b6..dc3651cf 100644 --- a/src/main/resources/templates/success_activate.html +++ b/src/main/resources/templates/success_activate.html @@ -32,17 +32,7 @@

Hello ${orgname},

The SDE successfully activated for your use.

-

Please click here to start using it.

- -

DT Registry Details

-

DT registry URL : ${dtregistryUrl}

-

App Id : ${idpClientId}

- -

EDC Connector Details

-

Control Plane URL : ${controlPlaneEndpoint}

-

Control Plane Data URL : ${controlPlaneDataEndpoint}

-

EDC ApiKey : ${edcApiKey}

-

EDC ApiKeyValue : ${edcApiKeyValue}

+ ${content}

Your connector status through connector test service: ${connectorTestResult}, check status again here

Note: You need to use your own organization login credential to login SDE tool.

diff --git a/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java b/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java index 64ebd112..1c7a9562 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java @@ -32,10 +32,12 @@ import org.apache.commons.codec.Resources; import org.eclipse.tractusx.autosetup.constant.ToolType; +import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry; import org.eclipse.tractusx.autosetup.model.Customer; import org.eclipse.tractusx.autosetup.model.SelectedTools; import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; import org.eclipse.tractusx.autosetup.utility.Certutil; +import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.mockito.InjectMocks; @@ -61,6 +63,12 @@ class ConnectorRegistrationManagerTest { @InjectMocks private ConnectorRegistrationManager connectorRegistrationManager; + + @InjectMocks + private AutoSetupTriggerEntry triger; + + @Mock + private KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; @Test void createClient() throws IOException { @@ -85,7 +93,7 @@ void createClient() throws IOException { when(portalIntegrationProxy.manageConnector((URI)any(), any(), any())).thenReturn("CONNECTOR123"); mockInputMap.put("selfsigncertificate", Certutil.getAsString(cert)); - mockInputMap = connectorRegistrationManager.registerConnector(customer, selectedTools, mockInputMap, null); + mockInputMap = connectorRegistrationManager.registerConnector(customer, selectedTools, mockInputMap, triger); assertEquals(3, mockInputMap.size()); assertEquals("ACTIVE", mockInputMap.get("connectorstatus")); } catch (CertificateException e) { diff --git a/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java b/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java index d0a4c8a5..f629ae2c 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java @@ -25,8 +25,10 @@ import java.util.Map; import org.eclipse.tractusx.autosetup.constant.AppActions; +import org.eclipse.tractusx.autosetup.constant.EmailConfigurationProperty; import org.eclipse.tractusx.autosetup.constant.SDEConfigurationProperty; import org.eclipse.tractusx.autosetup.constant.ToolType; +import org.eclipse.tractusx.autosetup.model.Customer; import org.eclipse.tractusx.autosetup.model.SelectedTools; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -53,17 +55,27 @@ class SDEManagerTest { @Mock private SDEConfigurationProperty sDEConfigurationProperty; - + + @Mock + private EmailConfigurationProperty emailConfigurationProperty; + @Test void managePackage() { + Customer customerDetails = Customer.builder() + .organizationName("Test") + .contactNumber("Test") + .city("DE") + .email("test@test.com") + .build(); + SelectedTools selectedTools = SelectedTools.builder().tool(ToolType.SDE_WITH_EDC_TRACTUS).label("SDE").build(); Map mockInputMap = new HashMap<>(); mockInputMap.put("dnsName", "test"); mockInputMap.put("dnsNameURLProtocol", "https"); - Map resultMap = sdeManager.managePackage(null, AppActions.CREATE, selectedTools, + Map resultMap = sdeManager.managePackage(customerDetails, AppActions.CREATE, selectedTools, mockInputMap, null); - assertEquals(30, resultMap.size()); + assertEquals(46, resultMap.size()); assertEquals("test", mockInputMap.get("dnsName")); } } \ No newline at end of file diff --git a/src/test/java/org/eclipse/tractusx/autosetup/manager/VaultManagerTest.java b/src/test/java/org/eclipse/tractusx/autosetup/manager/VaultManagerTest.java index 6c35b9c5..959c5e28 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/manager/VaultManagerTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/manager/VaultManagerTest.java @@ -90,7 +90,7 @@ void uploadKeyandValues() { .build(); mockInputMap = vaultManager.uploadKeyandValues(customer, selectedTools,mockInputMap, autoSetupTriggerEntry); - assertEquals(15, mockInputMap.size()); + assertEquals(16, mockInputMap.size()); assertEquals("test", mockInputMap.get("targetCluster")); } } \ No newline at end of file diff --git a/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java b/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java index f5116bc5..7af7b98a 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java @@ -25,6 +25,7 @@ import org.eclipse.tractusx.autosetup.mapper.AutoSetupRequestMapper; import org.eclipse.tractusx.autosetup.model.AutoSetupRequest; import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; +import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.springframework.beans.factory.annotation.Autowired; @@ -49,13 +50,15 @@ class AutoSetupOrchitestratorServiceTest { @MockBean private PortalIntegrationProxy portalIntegrationProxy; - @MockBean private AutoSetupRequestMapper customerDetailsMapper; @MockBean private KubeAppManageProxy kubeAppManageProxy; - + + @MockBean + private KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; + @Test void createPackage() { diff --git a/src/test/resources/application-test.properties b/src/test/resources/application-test.properties index f759536d..6afcae36 100644 --- a/src/test/resources/application-test.properties +++ b/src/test/resources/application-test.properties @@ -88,7 +88,7 @@ mail.smtp.starttls.enable=true mail.smtp.auth=true manual.update=true -manual-connector-registration=true +manual.connector.registration=true #Dyanamic property for SDE becuase enviroment wise those will get change like INT, Beta sde.resource-server-issuer=test @@ -119,6 +119,16 @@ sde.discovery-clientId=test sde.discovery-clientSecret=test sde.discovery-grantType=test +sde.bpdm-provider-edc-dataspace-api=test +sde.bpdm-provider-bpnl=test +sde.bpdm-provider-edc-public-api=test + +edc.iatp.id=test +edc.iatp.sts.dim.url=test +edc.iatp.sts.oauth.token.url=test +edc.bdrs.server=test +edc.iam.trusted-issuer=test + edc.miwUrl=test edc.ssi.authorityId=test From 3de3d7493de63be59767609c1cda0505603be258 Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Sat, 25 May 2024 00:18:27 +0530 Subject: [PATCH 4/8] remove flyway file for limited changes --- .../flyway/V10__update_app_version.sql | 481 ------------------ .../flyway/V9__update_app_version.sql | 316 ------------ 2 files changed, 797 deletions(-) delete mode 100644 src/main/resources/flyway/V10__update_app_version.sql delete mode 100644 src/main/resources/flyway/V9__update_app_version.sql diff --git a/src/main/resources/flyway/V10__update_app_version.sql b/src/main/resources/flyway/V10__update_app_version.sql deleted file mode 100644 index ae68350d..00000000 --- a/src/main/resources/flyway/V10__update_app_version.sql +++ /dev/null @@ -1,481 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2024 T-Systems International GmbH - * Copyright (c) 2024 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -update app_tbl set expected_input_data='{ - "sdepostgresql":{ - "enabled":true, - "primary":{ - "persistence":{ - "size":"1Gi" - } - }, - "persistence":{ - "size":"1Gi" - }, - "auth":{ - "postgresPassword":"$\{postgresPassword\}", - "password":"$\{postgresPassword\}", - "username":"$\{username\}", - "database":"$\{database\}" - } - }, - "backend": { - "ingresses":[ - { - "enabled":true, - "hostname":"$\{dnsName\}", - "annotations":{ - - }, - "className":"nginx", - "endpoints":[ - "default" - ], - "tls":{ - "enabled":true, - "secretName":"sdebackend" - }, - "certManager":{ - "clusterIssuer":"letsencrypt-prod" - } - } - ], - "configuration":{ - "properties": "server.port=8080 - - spring.main.allow-bean-definition-overriding=true - - spring.servlet.multipart.enabled=true - - spring.servlet.multipart.file-size-threshold=2KB - - spring.servlet.multipart.max-file-size=200MB - - spring.servlet.multipart.max-request-size=215MB - - server.servlet.context-path=/backend/api - - spring.flyway.baseline-on-migrate=true - - spring.flyway.locations=classpath:/flyway - - file.upload-dir=./temp/ - - logging.level.org.apache.http=info - - logging.level.root=info - - spring.datasource.driver-class-name=org.postgresql.Driver - - spring.jpa.open-in-view=false - - digital-twins.hostname=$\{dtregistryUrl\} - - digital-twins.api=$\{dtregistryURI\} - - digital-twins.authentication.url=$\{sde.digital-twins.authentication.url\} - - digital-twins.authentication.clientId=$\{digital-twins.authentication.clientId\} - - digital-twins.authentication.clientSecret=$\{digital-twins.authentication.clientSecret\} - - digital-twins.authentication.grantType=client_credentials - - dft.hostname=$\{sdeBackEndUrl\} - - dft.apiKeyHeader=$\{sdeBackEndApiKeyHeader\} - - dft.apiKey=$\{sdeBackEndApiKey\} - - manufacturerId=$\{manufacturerId\} - - edc.hostname=$\{controlPlaneEndpoint\} - - edc.managementpath=/data - - edc.managementpath.apiversion=/v2 - - edc.dsp.endpointpath=/api/v1/dsp - - edc.dataplane.endpointpath=/api/public - - edc.apiKeyHeader=$\{edcApiKey\} - - edc.apiKey=$\{edcApiKeyValue\} - - edc.consumer.hostname=$\{controlPlaneEndpoint\} - - edc.consumer.apikeyheader=$\{edcApiKey\} - - edc.consumer.apikey=$\{edcApiKeyValue\} - - edc.consumer.managementpath=/data - - edc.consumer.managementpath.apiversion=/v2 - - edc.consumer.protocol.path=/api/v1/dsp - - keycloak.clientid=$\{sdebackendkeycloakclientid\} - - spring.security.oauth2.resourceserver.jwt.issuer-uri=$\{sde.resourceServerIssuer\} - - springdoc.api-docs.path=/api-docs - - springdoc.swagger-ui.oauth.client-id=$\{sdebackendkeycloakclientid\} - - partner.pool.hostname=$\{sde.partner.pool.hostname\} - - partner.pool.authentication.url=$\{sde.partner.pool.authentication.url\} - - partner.pool.clientId=$\{sde.partner.pool.clientId\} - - partner.pool.clientSecret=$\{sde.partner.pool.clientSecret\} - - partner.pool.grantType=client_credentials - - portal.backend.hostname=$\{sde.portal.backend.hostname\} - - portal.backend.authentication.url=$\{sde.portal.backend.authentication.url\} - - portal.backend.clientId=$\{sde.portal.backend.clientId\} - - portal.backend.clientSecret=$\{sde.portal.backend.clientSecret\} - - portal.backend.grantType=client_credentials - - bpndiscovery.hostname=$\{sde.bpndiscovery.hostname\} - - discovery.authentication.url=$\{sde.discovery.authentication.url\} - - discovery.clientId=$\{sde.discovery.clientId\} - - discovery.clientSecret=$\{sde.discovery.clientSecret\} - - discovery.grantType=client_credentials - - bpdm.provider.edc.dataspace.api=$\{bpdm.provider.edc.dataspace.api\} - - bpdm.provider.bpnl=$\{bpdm.provider.bpnl\} - - bpdm.provider.edc.public.api=$\{bpdm.provider.edc.public.api\} - - mail.smtp.username=$\{emailUsername\} - - mail.smtp.password=$\{emailPassword\} - - mail.smtp.host=$\{emailHost\} - - mail.smtp.port=$\{emailPort\} - - mail.to.address=$\{emailTo\} - - mail.cc.address=$\{emailCC\} - - mail.from.address=$\{emailFrom\} - - mail.replyto.address=$\{emailReply\} - - mail.smtp.starttls.enable=true - - mail.smtp.auth=true - - sftp.host=$\{sftpHost\} - - sftp.port=$\{sftpPort\} - - sftp.username=$\{sftpUsername\} - - sftp.password=$\{sftpPassword\} - - sftp.accessKey=$\{sftpKey\} - - sftp.location.tobeprocessed=/ToBeProcessed - - sftp.location.inprogress=/InProgress - - sftp.location.success=/Success - - sftp.location.partialsucess=/PartialSuccess - - sftp.location.failed=/Failed - - retriever.name=minio - - minio.endpoint=$\{storage.media.endpoint\} - - minio.access-key=$\{storage.media.accessKey\} - - minio.secret-key=$\{storage.media.secretKey\} - - minio.bucket-name=$\{storage.media.bucket\} - - minio.location.tobeprocessed= - - minio.location.inprogress=/InProgress - - minio.location.success=/Success - - minio.location.partialsucess=/PartialSuccess - - minio.location.failed=/Failed" - } - }, - "frontend": { - "ingresses":[ - { - "enabled":true, - "hostname":"$\{dnsName\}", - "annotations":{ - "kubernetes.io/tls-acme": "true" - }, - "className":"nginx", - "endpoints":[ - "default" - ], - "tls":{ - "enabled":true, - "secretName":"sdefrontend" - }, - "certManager":{ - "clusterIssuer":"letsencrypt-prod" - } - } - ], - "configuration":{ - "properties":"REACT_APP_API_URL=$\{sdeBackEndUrl\} - - REACT_APP_KEYCLOAK_URL=$\{sde.keycloak.auth\} - - REACT_APP_KEYCLOAK_REALM=$\{sde.keycloak.realm\} - - REACT_APP_CLIENT_ID=$\{sdefrontendkeycloakclientid\} - - REACT_APP_DEFAULT_COMPANY_BPN=$\{bpnNumber\} - - REACT_APP_FILESIZE=268435456" - } - } -}', package_identifier='tx-sde-charts/sde' ,package_version='1.2.5' where app_name='SDE'; - - -update app_tbl set expected_input_data= '{ - "enablePostgres": true, - "enableKeycloak": false, - "postgresql": { - "auth": { - "password":"$\{rgdbpass\}", - "postgresPassword":"$\{rgdbpass\}", - "username":"$\{rgusername\}", - "database":"$\{rgdatabase\}" - }, - "primary": - { - "persistence":{ - "size" :"1Gi" - } - }, - "persistence": { - "size" :"1Gi" - } - }, - "registry": { - "host": "$\{dnsName\}", - "idpClientId" : "$\{idpClientId\}", - "idpIssuerUri": "$\{idpIssuerUri\}", - "tenantId" : "$\{bpnNumber\}", - "authentication": $\{dtNeedExternalAccess\}, - "granularAccessControlFetchSize": "500", - "useGranularAccessControl": "true", - "ingress": { - "enabled": $\{dtNeedExternalAccess\}, - "hostname": "$\{dnsName\}", - "annotations": { - "cert-manager.io/cluster-issuer": letsencrypt-prod, - "nginx.ingress.kubernetes.io/cors-allow-credentials": "true", - "nginx.ingress.kubernetes.io/enable-cors": "true", - "nginx.ingress.kubernetes.io/rewrite-target": /$2, - "nginx.ingress.kubernetes.io/use-regex": "true", - "nginx.ingress.kubernetes.io/x-forwarded-prefix": /$\{dtregistryUrlPrefix\} - }, - "urlPrefix": /$\{dtregistryUrlPrefix\}, - "className": "nginx", - "tls": $\{dtNeedExternalAccess\} - } - } -}', package_identifier='tx-all-repo/digital-twin-registry', package_version='0.4.11' where app_name='DT_REGISTRY'; - - -update app_tbl set expected_input_data= '{ - "install": { - "postgresql": true, - "vault": false - }, - "participant" : { - "id": "$\{bpnNumber\}" - }, - "backendService": { - "httpProxyTokenReceiverUrl": "$\{dftAddress\}" - }, - "postgresql": { - "enabled": true, - "fullnameOverride": "postgresql", - "jdbcUrl":"jdbc:postgresql://postgresql:5432/edc", - "username":"$\{username\}", - "password":"$\{appdbpass\}", - "database": "edc", - "auth":{ - "username":"$\{username\}", - "password":"$\{appdbpass\}", - "postgresPassword":"$\{postgresPassword\}" - } - }, - "vault": { - "hashicorp": { - "enabled": true, - "url": "$\{vaulturl\}", - "token": "$\{vaulttoken\}", - "timeout": 30, - "healthCheck": { - "enabled": false, - "standbyOk": false - }, - "paths": { - "health": "/v1/sys/health", - "secret": "$\{valuttenantpath\}" - } - }, - "secretNames": { - "dapsPrivateKey": "$\{certificate-private-key\}", - "dapsPublicKey": "$\{daps-cert\}", - "transferProxyTokenEncryptionAesKey": "$\{encryptionkeys\}", - "transferProxyTokenSignerPrivateKey": "$\{certificate-data-plane-private-key\}", - "transferProxyTokenSignerPublicKey": "$\{certificate-data-plane-public-key\}" - } - }, - "iatp": { - "id": "$\{iatp.id\}", - "sts": { - "dim": { - "url": "$\{iatp.sts.dim.url\}" - }, - "oauth": { - "client": { - "id": "$\{dimClientId\}", - "secret_alias": "$\{dim-client-secret\}" - }, - "token_url": "$\{iatp.sts.oauth.token_url\}" - } - } - }, - "controlplane": { - "endpoints": { - "management": { - "authKey": "$\{edcApiKeyValue\}", - "path": "/data", - "port": "8081" - } - }, - "bdrs": { - "cache_validity_seconds": 600, - "server": { - "url": "$\{bdrs.server\}" - } - }, - "env": { - "EDC_IAM_TRUSTED-ISSUER_ISSUER1_ID": "$\{edc.iam.trusted-issuer\}" - }, - "service": { - "type": "NodePort" - }, - "securityContext": { - "readOnlyRootFilesystem": false - }, - "ssi" : { - "miw" :{ - "authorityId" : "$\{authorityId\}", - "url": "$\{edcMiwUrl\}" - }, - "oauth": { - "client" :{ - "id" :"$\{keycloakAuthenticationClientId\}", - "secretAlias": "client-secret" - }, - "tokenurl": "$\{keycloakAuthTokenURL\}" - } - }, - "ingresses": [ - { - "enabled": true, - "hostname": "$\{dnsName\}", - "annotations": {}, - "className": "nginx", - "endpoints": [ - "protocol", - "management", - "control", - "default" - ], - "tls": { - "enabled": true, - "secretName": "edctxcontrolplane" - }, - "certManager": { - "clusterIssuer": "letsencrypt-prod" - } - } - ] - }, - "dataplane": { - "token": { - "refresh": { - "expiry_seconds": 300, - "expiry_tolerance_seconds": 300, - "refresh_endpoint": "$\{dataplane.token.refresh.refresh_endpoint\}" - }, - "signer": { - "privatekey_alias": "$\{certificate-private-key\}" - }, - "verifier": { - "publickey_alias": "$\{daps-cert\}" - } - } - }, - "ingresses": [ - { - "enabled": true, - "hostname": "$\{dnsName\}", - "annotations": {}, - "className": "nginx", - "endpoints": [ - "public" - ], - "tls": { - "enabled": true, - "secretName": "edctxdataplane" - }, - "certManager": { - "clusterIssuer": "letsencrypt-prod" - } - } - ] - } -}', package_version='0.7.0', package_identifier='tx-all-repo/tractusx-connector' where app_name='EDC_CONNECTOR'; - -update app_tbl set expected_input_data= replace(replace(expected_input_data,'\{','{'),'\}','}'), required_yaml_configuration=replace(replace(required_yaml_configuration,'\{','{'),'\}','}'); \ No newline at end of file diff --git a/src/main/resources/flyway/V9__update_app_version.sql b/src/main/resources/flyway/V9__update_app_version.sql deleted file mode 100644 index 8f29610f..00000000 --- a/src/main/resources/flyway/V9__update_app_version.sql +++ /dev/null @@ -1,316 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2024 T-Systems International GmbH - * Copyright (c) 2024 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -update app_tbl set expected_input_data='{ - "sdepostgresql":{ - "enabled":true, - "primary":{ - "persistence":{ - "size":"1Gi" - } - }, - "persistence":{ - "size":"1Gi" - }, - "auth":{ - "postgresPassword":"$\{postgresPassword\}", - "password":"$\{postgresPassword\}", - "username":"$\{username\}", - "database":"$\{database\}" - } - }, - "backend": { - "ingresses":[ - { - "enabled":true, - "hostname":"$\{dnsName\}", - "annotations":{ - - }, - "className":"nginx", - "endpoints":[ - "default" - ], - "tls":{ - "enabled":true, - "secretName":"sdebackend" - }, - "certManager":{ - "clusterIssuer":"letsencrypt-prod" - } - } - ], - "configuration":{ - "properties": "server.port=8080 - - spring.main.allow-bean-definition-overriding=true - - spring.servlet.multipart.enabled=true - - spring.servlet.multipart.file-size-threshold=2KB - - spring.servlet.multipart.max-file-size=200MB - - spring.servlet.multipart.max-request-size=215MB - - server.servlet.context-path=/backend/api - - spring.flyway.baseline-on-migrate=true - - spring.flyway.locations=classpath:/flyway - - file.upload-dir=./temp/ - - logging.level.org.apache.http=info - - logging.level.root=info - - spring.datasource.driver-class-name=org.postgresql.Driver - - spring.jpa.open-in-view=false - - digital-twins.hostname=$\{dtregistryUrl\} - - digital-twins.api=$\{dtregistryURI\} - - digital-twins.authentication.url=$\{sde.digital-twins.authentication.url\} - - digital-twins.authentication.clientId=$\{digital-twins.authentication.clientId\} - - digital-twins.authentication.clientSecret=$\{digital-twins.authentication.clientSecret\} - - digital-twins.authentication.grantType=client_credentials - - dft.hostname=$\{sdeBackEndUrl\} - - dft.apiKeyHeader=$\{sdeBackEndApiKeyHeader\} - - dft.apiKey=$\{sdeBackEndApiKey\} - - manufacturerId=$\{manufacturerId\} - - edc.hostname=$\{controlPlaneEndpoint\} - - edc.managementpath=/data - - edc.managementpath.apiversion=/v2 - - edc.dsp.endpointpath=/api/v1/dsp - - edc.dataplane.endpointpath=/api/public - - edc.apiKeyHeader=$\{edcApiKey\} - - edc.apiKey=$\{edcApiKeyValue\} - - edc.consumer.hostname=$\{controlPlaneEndpoint\} - - edc.consumer.apikeyheader=$\{edcApiKey\} - - edc.consumer.apikey=$\{edcApiKeyValue\} - - edc.consumer.managementpath=/data - - edc.consumer.managementpath.apiversion=/v2 - - edc.consumer.protocol.path=/api/v1/dsp - - keycloak.clientid=$\{sdebackendkeycloakclientid\} - - spring.security.oauth2.resourceserver.jwt.issuer-uri=$\{sde.resourceServerIssuer\} - - springdoc.api-docs.path=/api-docs - - springdoc.swagger-ui.oauth.client-id=$\{sdebackendkeycloakclientid\} - - partner.pool.hostname=$\{sde.partner.pool.hostname\} - - partner.pool.authentication.url=$\{sde.partner.pool.authentication.url\} - - partner.pool.clientId=$\{sde.partner.pool.clientId\} - - partner.pool.clientSecret=$\{sde.partner.pool.clientSecret\} - - partner.pool.grantType=client_credentials - - portal.backend.hostname=$\{sde.portal.backend.hostname\} - - portal.backend.authentication.url=$\{sde.portal.backend.authentication.url\} - - portal.backend.clientId=$\{sde.portal.backend.clientId\} - - portal.backend.clientSecret=$\{sde.portal.backend.clientSecret\} - - portal.backend.grantType=client_credentials - - bpndiscovery.hostname=$\{sde.bpndiscovery.hostname\} - - discovery.authentication.url=$\{sde.discovery.authentication.url\} - - discovery.clientId=$\{sde.discovery.clientId\} - - discovery.clientSecret=$\{sde.discovery.clientSecret\} - - discovery.grantType=client_credentials - - mail.smtp.username=$\{emailUsername\} - - mail.smtp.password=$\{emailPassword\} - - mail.smtp.host=$\{emailHost\} - - mail.smtp.port=$\{emailPort\} - - mail.to.address=$\{emailTo\} - - mail.cc.address=$\{emailCC\} - - mail.from.address=$\{emailFrom\} - - mail.replyto.address=$\{emailReply\} - - mail.smtp.starttls.enable=true - - mail.smtp.auth=true - - sftp.host=$\{sftpHost\} - - sftp.port=$\{sftpPort\} - - sftp.username=$\{sftpUsername\} - - sftp.password=$\{sftpPassword\} - - sftp.accessKey=$\{sftpKey\} - - sftp.location.tobeprocessed=/ToBeProcessed - - sftp.location.inprogress=/InProgress - - sftp.location.success=/Success - - sftp.location.partialsucess=/PartialSuccess - - sftp.location.failed=/Failed - - retriever.name=minio - - minio.endpoint=$\{storage.media.endpoint\} - - minio.access-key=$\{storage.media.accessKey\} - - minio.secret-key=$\{storage.media.secretKey\} - - minio.bucket-name=$\{storage.media.bucket\} - - minio.location.tobeprocessed= - - minio.location.inprogress=/InProgress - - minio.location.success=/Success - - minio.location.partialsucess=/PartialSuccess - - minio.location.failed=/Failed" - } - }, - "frontend": { - "ingresses":[ - { - "enabled":true, - "hostname":"$\{dnsName\}", - "annotations":{ - "kubernetes.io/tls-acme": "true" - }, - "className":"nginx", - "endpoints":[ - "default" - ], - "tls":{ - "enabled":true, - "secretName":"sdefrontend" - }, - "certManager":{ - "clusterIssuer":"letsencrypt-prod" - } - } - ], - "configuration":{ - "properties":"REACT_APP_API_URL=$\{sdeBackEndUrl\} - - REACT_APP_KEYCLOAK_URL=$\{sde.keycloak.auth\} - - REACT_APP_KEYCLOAK_REALM=$\{sde.keycloak.realm\} - - REACT_APP_CLIENT_ID=$\{sdefrontendkeycloakclientid\} - - REACT_APP_DEFAULT_COMPANY_BPN=$\{bpnNumber\} - - REACT_APP_FILESIZE=268435456" - } - } -}', package_identifier='tx-sde-charts/sde' ,package_version='1.0.1' where app_name='SDE'; - - -update app_tbl set expected_input_data= '{ - "enablePostgres": true, - "enableKeycloak": false, - "postgresql": { - "auth": { - "password":"$\{rgdbpass\}", - "postgresPassword":"$\{rgdbpass\}", - "username":"$\{rgusername\}", - "database":"$\{rgdatabase\}" - }, - "primary": - { - "persistence":{ - "size" :"1Gi" - } - }, - "persistence": { - "size" :"1Gi" - } - }, - "registry": { - "host": "$\{dnsName\}", - "idpClientId" : "$\{idpClientId\}", - "idpIssuerUri": "$\{idpIssuerUri\}", - "tenantId" : "$\{bpnNumber\}", - "authentication": $\{dtNeedExternalAccess\}, - "ingress": { - "enabled": $\{dtNeedExternalAccess\}, - "hostname": "$\{dnsName\}", - "annotations": { - "cert-manager.io/cluster-issuer": letsencrypt-prod, - "nginx.ingress.kubernetes.io/cors-allow-credentials": "true", - "nginx.ingress.kubernetes.io/enable-cors": "true", - "nginx.ingress.kubernetes.io/rewrite-target": /$2, - "nginx.ingress.kubernetes.io/use-regex": "true", - "nginx.ingress.kubernetes.io/x-forwarded-prefix": /$\{dtregistryUrlPrefix\} - }, - "urlPrefix": /$\{dtregistryUrlPrefix\}, - "className": "nginx", - "tls": $\{dtNeedExternalAccess\} - } - } -}', package_version='0.3.27' where app_name='DT_REGISTRY'; - -update app_tbl set expected_input_data= replace(replace(expected_input_data,'\{','{'),'\}','}'), required_yaml_configuration=replace(replace(required_yaml_configuration,'\{','{'),'\}','}'); \ No newline at end of file From 1306fe0566c6f5270e3fef8878a41792dfdb6936 Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Sat, 25 May 2024 00:23:49 +0530 Subject: [PATCH 5/8] Remove utility --- .../manager/ConnectorRegistrationManager.java | 18 +++--- .../manager/PortalIntegrationManager.java | 10 ++-- .../utility/JsonObjectProcessingUtility.java | 50 ----------------- .../utility/KeyCloakTokenProxyUtitlity.java | 55 ------------------- .../ConnectorRegistrationManagerTest.java | 6 +- .../AutoSetupOrchitestratorServiceTest.java | 6 +- 6 files changed, 20 insertions(+), 125 deletions(-) delete mode 100644 src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java delete mode 100644 src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java index c63e1ca7..87b28565 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java @@ -36,8 +36,8 @@ import org.eclipse.tractusx.autosetup.model.Customer; import org.eclipse.tractusx.autosetup.model.SelectedTools; import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; -import org.eclipse.tractusx.autosetup.utility.JsonObjectProcessingUtility; -import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; +//import org.eclipse.tractusx.autosetup.utility.JsonObjectProcessingUtility; +//import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; import org.eclipse.tractusx.autosetup.utility.LogUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.retry.annotation.Backoff; @@ -77,7 +77,7 @@ public class ConnectorRegistrationManager { private final AutoSetupTriggerManager autoSetupTriggerManager; private final PortalIntegrationProxy portalIntegrationProxy; - private final KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; + //private final KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; @Retryable(retryFor = { ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) @@ -106,7 +106,7 @@ public Map registerConnector(Customer customerDetails, SelectedT body.add(SUBSCRIPTION_ID, subscriptionIdVal); Map header = new HashMap<>(); header.put("Authorization", - "Bearer " + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); + "Bearer " + ""); String connectorId = checkSubcriptionHaveConnectorRegister(header, subscriptionIdVal); @@ -175,13 +175,13 @@ private String checkSubcriptionHaveConnectorRegister(Map header, if (subcriptionWithConnectors != null && subcriptionWithConnectors.isArray()) { for (JsonNode jsonNode : subcriptionWithConnectors) { - String remoteSubscriptionId = JsonObjectProcessingUtility.getValueFromJsonNode(jsonNode, - SUBSCRIPTION_ID); + String remoteSubscriptionId = "";//JsonObjectProcessingUtility.getValueFromJsonNode(jsonNode, + //SUBSCRIPTION_ID); if (subscriptionId.equalsIgnoreCase(remoteSubscriptionId)) { - JsonNode connectorIds = JsonObjectProcessingUtility.getArrayNodeFromJsonNode(jsonNode, - "connectorIds"); + JsonNode connectorIds = null;//JsonObjectProcessingUtility.getArrayNodeFromJsonNode(jsonNode, + //"connectorIds"); if (connectorIds != null && connectorIds.isArray() && connectorIds.size() > 0) return connectorIds.get(0).asText(); @@ -214,7 +214,7 @@ public Map deleteConnector(SelectedTools tool, Map header = new HashMap<>(); header.put("Authorization", - "Bearer " + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); + "Bearer " + ""); autoSetupTriggerDetails.setStatus(TriggerStatusEnum.SUCCESS.name()); portalIntegrationProxy.deleteConnector(connectorRegistrationUrl, header, connectorId); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java index 3ebd6481..b73c5e57 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java @@ -40,7 +40,7 @@ import org.eclipse.tractusx.autosetup.portal.model.TechnicalUserDetails; import org.eclipse.tractusx.autosetup.portal.model.TechnicalUsers; import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; -import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; +//import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; import org.eclipse.tractusx.autosetup.utility.LogUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.retry.annotation.Backoff; @@ -68,7 +68,7 @@ public class PortalIntegrationManager { private final AutoSetupTriggerManager autoSetupTriggerManager; - private final KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; + //private final KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; @Value("${portal.url}") private URI portalUrl; @@ -115,7 +115,7 @@ public Map postServiceInstanceResultAndGetTenantSpecs(Customer c Map header = new HashMap<>(); header.put(AUTHORIZATION, - BEARER + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); + BEARER + ""); ServiceInstanceResultRequest serviceInstanceResultRequest = ServiceInstanceResultRequest.builder() .requestId(subscriptionId).offerUrl(applicationURL).build(); @@ -249,7 +249,7 @@ private ServiceInstanceResultResponse verifyIsAlreadySubcribedActivatedAndGetDet try { header.put(AUTHORIZATION, - BEARER + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); + BEARER + ""); serviceInstanceResultResponse = portalIntegrationProxy.getAppServiceInstanceSubcriptionDetails( portalUrl, header, appServiceURIPath, offerId, subscriptionId); @@ -293,7 +293,7 @@ private void readTechnicalUserDetails(String subscriptionId, Map if (serviceInstanceResultResponse.getTechnicalUserData() != null) { header.put(AUTHORIZATION, - BEARER + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); + BEARER + ""); serviceInstanceResultResponse.getTechnicalUserData().forEach(elel -> { try { diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java deleted file mode 100644 index ec5ce8f1..00000000 --- a/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2024 T-Systems International GmbH - * Copyright (c) 2024 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.autosetup.utility; - -import com.fasterxml.jackson.databind.JsonNode; - -import lombok.SneakyThrows; - - -public class JsonObjectProcessingUtility { - - private JsonObjectProcessingUtility() {} - - @SneakyThrows - public static String getValueFromJsonNode(JsonNode jsonNode, String propertyId) { - if (jsonNode != null && jsonNode.get(propertyId) != null) - return jsonNode.get(propertyId).asText(); - else - return ""; - } - - - @SneakyThrows - public static JsonNode getArrayNodeFromJsonNode(JsonNode jsonnode, String propertyId) { - if (jsonnode != null && jsonnode.get(propertyId) != null) - return jsonnode.get(propertyId); - else - return null; - } - - -} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java deleted file mode 100644 index 65b5453a..00000000 --- a/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2024 T-Systems International GmbH - * Copyright (c) 2024 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.autosetup.utility; - -import java.net.URI; - -import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; -import org.springframework.stereotype.Service; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; - -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; - -@Service -@RequiredArgsConstructor -public class KeyCloakTokenProxyUtitlity { - - private final PortalIntegrationProxy portalIntegrationProxy; - - @SneakyThrows - public String getKeycloakToken(String clientId, String clientSecret, URI tokenURI) { - - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("grant_type", "client_credentials"); - body.add("client_id", clientId); - body.add("client_secret", clientSecret); - var resultBody = portalIntegrationProxy.readAuthToken(tokenURI, body); - - if (resultBody != null) { - return resultBody.getAccessToken(); - } - return null; - - } - -} diff --git a/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java b/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java index 1c7a9562..68839139 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java @@ -37,7 +37,7 @@ import org.eclipse.tractusx.autosetup.model.SelectedTools; import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; import org.eclipse.tractusx.autosetup.utility.Certutil; -import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; +//import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.mockito.InjectMocks; @@ -67,8 +67,8 @@ class ConnectorRegistrationManagerTest { @InjectMocks private AutoSetupTriggerEntry triger; - @Mock - private KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; +// @Mock +// private KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; @Test void createClient() throws IOException { diff --git a/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java b/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java index 7af7b98a..07f5ec37 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java @@ -25,7 +25,7 @@ import org.eclipse.tractusx.autosetup.mapper.AutoSetupRequestMapper; import org.eclipse.tractusx.autosetup.model.AutoSetupRequest; import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; -import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; +//import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.springframework.beans.factory.annotation.Autowired; @@ -56,8 +56,8 @@ class AutoSetupOrchitestratorServiceTest { @MockBean private KubeAppManageProxy kubeAppManageProxy; - @MockBean - private KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; +// @MockBean +// private KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; @Test void createPackage() { From 5661bcb3762f70ba9eaf00a5349b1c97a359044f Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Sat, 25 May 2024 00:45:26 +0530 Subject: [PATCH 6/8] change lisece check jar version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 848a3b2b..1d289571 100644 --- a/pom.xml +++ b/pom.xml @@ -320,7 +320,7 @@ org.eclipse.dash license-tool-plugin - 1.1.0 + 1.1.1-SNAPSHOT automotive.tractusx From 663bcbd59e1bf2c8ef57a7c85ac49ffcd9648210 Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Sat, 25 May 2024 00:53:15 +0530 Subject: [PATCH 7/8] added flyway files --- .../flyway/V10__update_app_version.sql | 481 ++++++++++++++++++ .../flyway/V9__update_app_version.sql | 316 ++++++++++++ 2 files changed, 797 insertions(+) create mode 100644 src/main/resources/flyway/V10__update_app_version.sql create mode 100644 src/main/resources/flyway/V9__update_app_version.sql diff --git a/src/main/resources/flyway/V10__update_app_version.sql b/src/main/resources/flyway/V10__update_app_version.sql new file mode 100644 index 00000000..ae68350d --- /dev/null +++ b/src/main/resources/flyway/V10__update_app_version.sql @@ -0,0 +1,481 @@ +/******************************************************************************** + * Copyright (c) 2024 T-Systems International GmbH + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +update app_tbl set expected_input_data='{ + "sdepostgresql":{ + "enabled":true, + "primary":{ + "persistence":{ + "size":"1Gi" + } + }, + "persistence":{ + "size":"1Gi" + }, + "auth":{ + "postgresPassword":"$\{postgresPassword\}", + "password":"$\{postgresPassword\}", + "username":"$\{username\}", + "database":"$\{database\}" + } + }, + "backend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdebackend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties": "server.port=8080 + + spring.main.allow-bean-definition-overriding=true + + spring.servlet.multipart.enabled=true + + spring.servlet.multipart.file-size-threshold=2KB + + spring.servlet.multipart.max-file-size=200MB + + spring.servlet.multipart.max-request-size=215MB + + server.servlet.context-path=/backend/api + + spring.flyway.baseline-on-migrate=true + + spring.flyway.locations=classpath:/flyway + + file.upload-dir=./temp/ + + logging.level.org.apache.http=info + + logging.level.root=info + + spring.datasource.driver-class-name=org.postgresql.Driver + + spring.jpa.open-in-view=false + + digital-twins.hostname=$\{dtregistryUrl\} + + digital-twins.api=$\{dtregistryURI\} + + digital-twins.authentication.url=$\{sde.digital-twins.authentication.url\} + + digital-twins.authentication.clientId=$\{digital-twins.authentication.clientId\} + + digital-twins.authentication.clientSecret=$\{digital-twins.authentication.clientSecret\} + + digital-twins.authentication.grantType=client_credentials + + dft.hostname=$\{sdeBackEndUrl\} + + dft.apiKeyHeader=$\{sdeBackEndApiKeyHeader\} + + dft.apiKey=$\{sdeBackEndApiKey\} + + manufacturerId=$\{manufacturerId\} + + edc.hostname=$\{controlPlaneEndpoint\} + + edc.managementpath=/data + + edc.managementpath.apiversion=/v2 + + edc.dsp.endpointpath=/api/v1/dsp + + edc.dataplane.endpointpath=/api/public + + edc.apiKeyHeader=$\{edcApiKey\} + + edc.apiKey=$\{edcApiKeyValue\} + + edc.consumer.hostname=$\{controlPlaneEndpoint\} + + edc.consumer.apikeyheader=$\{edcApiKey\} + + edc.consumer.apikey=$\{edcApiKeyValue\} + + edc.consumer.managementpath=/data + + edc.consumer.managementpath.apiversion=/v2 + + edc.consumer.protocol.path=/api/v1/dsp + + keycloak.clientid=$\{sdebackendkeycloakclientid\} + + spring.security.oauth2.resourceserver.jwt.issuer-uri=$\{sde.resourceServerIssuer\} + + springdoc.api-docs.path=/api-docs + + springdoc.swagger-ui.oauth.client-id=$\{sdebackendkeycloakclientid\} + + partner.pool.hostname=$\{sde.partner.pool.hostname\} + + partner.pool.authentication.url=$\{sde.partner.pool.authentication.url\} + + partner.pool.clientId=$\{sde.partner.pool.clientId\} + + partner.pool.clientSecret=$\{sde.partner.pool.clientSecret\} + + partner.pool.grantType=client_credentials + + portal.backend.hostname=$\{sde.portal.backend.hostname\} + + portal.backend.authentication.url=$\{sde.portal.backend.authentication.url\} + + portal.backend.clientId=$\{sde.portal.backend.clientId\} + + portal.backend.clientSecret=$\{sde.portal.backend.clientSecret\} + + portal.backend.grantType=client_credentials + + bpndiscovery.hostname=$\{sde.bpndiscovery.hostname\} + + discovery.authentication.url=$\{sde.discovery.authentication.url\} + + discovery.clientId=$\{sde.discovery.clientId\} + + discovery.clientSecret=$\{sde.discovery.clientSecret\} + + discovery.grantType=client_credentials + + bpdm.provider.edc.dataspace.api=$\{bpdm.provider.edc.dataspace.api\} + + bpdm.provider.bpnl=$\{bpdm.provider.bpnl\} + + bpdm.provider.edc.public.api=$\{bpdm.provider.edc.public.api\} + + mail.smtp.username=$\{emailUsername\} + + mail.smtp.password=$\{emailPassword\} + + mail.smtp.host=$\{emailHost\} + + mail.smtp.port=$\{emailPort\} + + mail.to.address=$\{emailTo\} + + mail.cc.address=$\{emailCC\} + + mail.from.address=$\{emailFrom\} + + mail.replyto.address=$\{emailReply\} + + mail.smtp.starttls.enable=true + + mail.smtp.auth=true + + sftp.host=$\{sftpHost\} + + sftp.port=$\{sftpPort\} + + sftp.username=$\{sftpUsername\} + + sftp.password=$\{sftpPassword\} + + sftp.accessKey=$\{sftpKey\} + + sftp.location.tobeprocessed=/ToBeProcessed + + sftp.location.inprogress=/InProgress + + sftp.location.success=/Success + + sftp.location.partialsucess=/PartialSuccess + + sftp.location.failed=/Failed + + retriever.name=minio + + minio.endpoint=$\{storage.media.endpoint\} + + minio.access-key=$\{storage.media.accessKey\} + + minio.secret-key=$\{storage.media.secretKey\} + + minio.bucket-name=$\{storage.media.bucket\} + + minio.location.tobeprocessed= + + minio.location.inprogress=/InProgress + + minio.location.success=/Success + + minio.location.partialsucess=/PartialSuccess + + minio.location.failed=/Failed" + } + }, + "frontend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + "kubernetes.io/tls-acme": "true" + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdefrontend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties":"REACT_APP_API_URL=$\{sdeBackEndUrl\} + + REACT_APP_KEYCLOAK_URL=$\{sde.keycloak.auth\} + + REACT_APP_KEYCLOAK_REALM=$\{sde.keycloak.realm\} + + REACT_APP_CLIENT_ID=$\{sdefrontendkeycloakclientid\} + + REACT_APP_DEFAULT_COMPANY_BPN=$\{bpnNumber\} + + REACT_APP_FILESIZE=268435456" + } + } +}', package_identifier='tx-sde-charts/sde' ,package_version='1.2.5' where app_name='SDE'; + + +update app_tbl set expected_input_data= '{ + "enablePostgres": true, + "enableKeycloak": false, + "postgresql": { + "auth": { + "password":"$\{rgdbpass\}", + "postgresPassword":"$\{rgdbpass\}", + "username":"$\{rgusername\}", + "database":"$\{rgdatabase\}" + }, + "primary": + { + "persistence":{ + "size" :"1Gi" + } + }, + "persistence": { + "size" :"1Gi" + } + }, + "registry": { + "host": "$\{dnsName\}", + "idpClientId" : "$\{idpClientId\}", + "idpIssuerUri": "$\{idpIssuerUri\}", + "tenantId" : "$\{bpnNumber\}", + "authentication": $\{dtNeedExternalAccess\}, + "granularAccessControlFetchSize": "500", + "useGranularAccessControl": "true", + "ingress": { + "enabled": $\{dtNeedExternalAccess\}, + "hostname": "$\{dnsName\}", + "annotations": { + "cert-manager.io/cluster-issuer": letsencrypt-prod, + "nginx.ingress.kubernetes.io/cors-allow-credentials": "true", + "nginx.ingress.kubernetes.io/enable-cors": "true", + "nginx.ingress.kubernetes.io/rewrite-target": /$2, + "nginx.ingress.kubernetes.io/use-regex": "true", + "nginx.ingress.kubernetes.io/x-forwarded-prefix": /$\{dtregistryUrlPrefix\} + }, + "urlPrefix": /$\{dtregistryUrlPrefix\}, + "className": "nginx", + "tls": $\{dtNeedExternalAccess\} + } + } +}', package_identifier='tx-all-repo/digital-twin-registry', package_version='0.4.11' where app_name='DT_REGISTRY'; + + +update app_tbl set expected_input_data= '{ + "install": { + "postgresql": true, + "vault": false + }, + "participant" : { + "id": "$\{bpnNumber\}" + }, + "backendService": { + "httpProxyTokenReceiverUrl": "$\{dftAddress\}" + }, + "postgresql": { + "enabled": true, + "fullnameOverride": "postgresql", + "jdbcUrl":"jdbc:postgresql://postgresql:5432/edc", + "username":"$\{username\}", + "password":"$\{appdbpass\}", + "database": "edc", + "auth":{ + "username":"$\{username\}", + "password":"$\{appdbpass\}", + "postgresPassword":"$\{postgresPassword\}" + } + }, + "vault": { + "hashicorp": { + "enabled": true, + "url": "$\{vaulturl\}", + "token": "$\{vaulttoken\}", + "timeout": 30, + "healthCheck": { + "enabled": false, + "standbyOk": false + }, + "paths": { + "health": "/v1/sys/health", + "secret": "$\{valuttenantpath\}" + } + }, + "secretNames": { + "dapsPrivateKey": "$\{certificate-private-key\}", + "dapsPublicKey": "$\{daps-cert\}", + "transferProxyTokenEncryptionAesKey": "$\{encryptionkeys\}", + "transferProxyTokenSignerPrivateKey": "$\{certificate-data-plane-private-key\}", + "transferProxyTokenSignerPublicKey": "$\{certificate-data-plane-public-key\}" + } + }, + "iatp": { + "id": "$\{iatp.id\}", + "sts": { + "dim": { + "url": "$\{iatp.sts.dim.url\}" + }, + "oauth": { + "client": { + "id": "$\{dimClientId\}", + "secret_alias": "$\{dim-client-secret\}" + }, + "token_url": "$\{iatp.sts.oauth.token_url\}" + } + } + }, + "controlplane": { + "endpoints": { + "management": { + "authKey": "$\{edcApiKeyValue\}", + "path": "/data", + "port": "8081" + } + }, + "bdrs": { + "cache_validity_seconds": 600, + "server": { + "url": "$\{bdrs.server\}" + } + }, + "env": { + "EDC_IAM_TRUSTED-ISSUER_ISSUER1_ID": "$\{edc.iam.trusted-issuer\}" + }, + "service": { + "type": "NodePort" + }, + "securityContext": { + "readOnlyRootFilesystem": false + }, + "ssi" : { + "miw" :{ + "authorityId" : "$\{authorityId\}", + "url": "$\{edcMiwUrl\}" + }, + "oauth": { + "client" :{ + "id" :"$\{keycloakAuthenticationClientId\}", + "secretAlias": "client-secret" + }, + "tokenurl": "$\{keycloakAuthTokenURL\}" + } + }, + "ingresses": [ + { + "enabled": true, + "hostname": "$\{dnsName\}", + "annotations": {}, + "className": "nginx", + "endpoints": [ + "protocol", + "management", + "control", + "default" + ], + "tls": { + "enabled": true, + "secretName": "edctxcontrolplane" + }, + "certManager": { + "clusterIssuer": "letsencrypt-prod" + } + } + ] + }, + "dataplane": { + "token": { + "refresh": { + "expiry_seconds": 300, + "expiry_tolerance_seconds": 300, + "refresh_endpoint": "$\{dataplane.token.refresh.refresh_endpoint\}" + }, + "signer": { + "privatekey_alias": "$\{certificate-private-key\}" + }, + "verifier": { + "publickey_alias": "$\{daps-cert\}" + } + } + }, + "ingresses": [ + { + "enabled": true, + "hostname": "$\{dnsName\}", + "annotations": {}, + "className": "nginx", + "endpoints": [ + "public" + ], + "tls": { + "enabled": true, + "secretName": "edctxdataplane" + }, + "certManager": { + "clusterIssuer": "letsencrypt-prod" + } + } + ] + } +}', package_version='0.7.0', package_identifier='tx-all-repo/tractusx-connector' where app_name='EDC_CONNECTOR'; + +update app_tbl set expected_input_data= replace(replace(expected_input_data,'\{','{'),'\}','}'), required_yaml_configuration=replace(replace(required_yaml_configuration,'\{','{'),'\}','}'); \ No newline at end of file diff --git a/src/main/resources/flyway/V9__update_app_version.sql b/src/main/resources/flyway/V9__update_app_version.sql new file mode 100644 index 00000000..8f29610f --- /dev/null +++ b/src/main/resources/flyway/V9__update_app_version.sql @@ -0,0 +1,316 @@ +/******************************************************************************** + * Copyright (c) 2024 T-Systems International GmbH + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +update app_tbl set expected_input_data='{ + "sdepostgresql":{ + "enabled":true, + "primary":{ + "persistence":{ + "size":"1Gi" + } + }, + "persistence":{ + "size":"1Gi" + }, + "auth":{ + "postgresPassword":"$\{postgresPassword\}", + "password":"$\{postgresPassword\}", + "username":"$\{username\}", + "database":"$\{database\}" + } + }, + "backend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdebackend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties": "server.port=8080 + + spring.main.allow-bean-definition-overriding=true + + spring.servlet.multipart.enabled=true + + spring.servlet.multipart.file-size-threshold=2KB + + spring.servlet.multipart.max-file-size=200MB + + spring.servlet.multipart.max-request-size=215MB + + server.servlet.context-path=/backend/api + + spring.flyway.baseline-on-migrate=true + + spring.flyway.locations=classpath:/flyway + + file.upload-dir=./temp/ + + logging.level.org.apache.http=info + + logging.level.root=info + + spring.datasource.driver-class-name=org.postgresql.Driver + + spring.jpa.open-in-view=false + + digital-twins.hostname=$\{dtregistryUrl\} + + digital-twins.api=$\{dtregistryURI\} + + digital-twins.authentication.url=$\{sde.digital-twins.authentication.url\} + + digital-twins.authentication.clientId=$\{digital-twins.authentication.clientId\} + + digital-twins.authentication.clientSecret=$\{digital-twins.authentication.clientSecret\} + + digital-twins.authentication.grantType=client_credentials + + dft.hostname=$\{sdeBackEndUrl\} + + dft.apiKeyHeader=$\{sdeBackEndApiKeyHeader\} + + dft.apiKey=$\{sdeBackEndApiKey\} + + manufacturerId=$\{manufacturerId\} + + edc.hostname=$\{controlPlaneEndpoint\} + + edc.managementpath=/data + + edc.managementpath.apiversion=/v2 + + edc.dsp.endpointpath=/api/v1/dsp + + edc.dataplane.endpointpath=/api/public + + edc.apiKeyHeader=$\{edcApiKey\} + + edc.apiKey=$\{edcApiKeyValue\} + + edc.consumer.hostname=$\{controlPlaneEndpoint\} + + edc.consumer.apikeyheader=$\{edcApiKey\} + + edc.consumer.apikey=$\{edcApiKeyValue\} + + edc.consumer.managementpath=/data + + edc.consumer.managementpath.apiversion=/v2 + + edc.consumer.protocol.path=/api/v1/dsp + + keycloak.clientid=$\{sdebackendkeycloakclientid\} + + spring.security.oauth2.resourceserver.jwt.issuer-uri=$\{sde.resourceServerIssuer\} + + springdoc.api-docs.path=/api-docs + + springdoc.swagger-ui.oauth.client-id=$\{sdebackendkeycloakclientid\} + + partner.pool.hostname=$\{sde.partner.pool.hostname\} + + partner.pool.authentication.url=$\{sde.partner.pool.authentication.url\} + + partner.pool.clientId=$\{sde.partner.pool.clientId\} + + partner.pool.clientSecret=$\{sde.partner.pool.clientSecret\} + + partner.pool.grantType=client_credentials + + portal.backend.hostname=$\{sde.portal.backend.hostname\} + + portal.backend.authentication.url=$\{sde.portal.backend.authentication.url\} + + portal.backend.clientId=$\{sde.portal.backend.clientId\} + + portal.backend.clientSecret=$\{sde.portal.backend.clientSecret\} + + portal.backend.grantType=client_credentials + + bpndiscovery.hostname=$\{sde.bpndiscovery.hostname\} + + discovery.authentication.url=$\{sde.discovery.authentication.url\} + + discovery.clientId=$\{sde.discovery.clientId\} + + discovery.clientSecret=$\{sde.discovery.clientSecret\} + + discovery.grantType=client_credentials + + mail.smtp.username=$\{emailUsername\} + + mail.smtp.password=$\{emailPassword\} + + mail.smtp.host=$\{emailHost\} + + mail.smtp.port=$\{emailPort\} + + mail.to.address=$\{emailTo\} + + mail.cc.address=$\{emailCC\} + + mail.from.address=$\{emailFrom\} + + mail.replyto.address=$\{emailReply\} + + mail.smtp.starttls.enable=true + + mail.smtp.auth=true + + sftp.host=$\{sftpHost\} + + sftp.port=$\{sftpPort\} + + sftp.username=$\{sftpUsername\} + + sftp.password=$\{sftpPassword\} + + sftp.accessKey=$\{sftpKey\} + + sftp.location.tobeprocessed=/ToBeProcessed + + sftp.location.inprogress=/InProgress + + sftp.location.success=/Success + + sftp.location.partialsucess=/PartialSuccess + + sftp.location.failed=/Failed + + retriever.name=minio + + minio.endpoint=$\{storage.media.endpoint\} + + minio.access-key=$\{storage.media.accessKey\} + + minio.secret-key=$\{storage.media.secretKey\} + + minio.bucket-name=$\{storage.media.bucket\} + + minio.location.tobeprocessed= + + minio.location.inprogress=/InProgress + + minio.location.success=/Success + + minio.location.partialsucess=/PartialSuccess + + minio.location.failed=/Failed" + } + }, + "frontend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + "kubernetes.io/tls-acme": "true" + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdefrontend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties":"REACT_APP_API_URL=$\{sdeBackEndUrl\} + + REACT_APP_KEYCLOAK_URL=$\{sde.keycloak.auth\} + + REACT_APP_KEYCLOAK_REALM=$\{sde.keycloak.realm\} + + REACT_APP_CLIENT_ID=$\{sdefrontendkeycloakclientid\} + + REACT_APP_DEFAULT_COMPANY_BPN=$\{bpnNumber\} + + REACT_APP_FILESIZE=268435456" + } + } +}', package_identifier='tx-sde-charts/sde' ,package_version='1.0.1' where app_name='SDE'; + + +update app_tbl set expected_input_data= '{ + "enablePostgres": true, + "enableKeycloak": false, + "postgresql": { + "auth": { + "password":"$\{rgdbpass\}", + "postgresPassword":"$\{rgdbpass\}", + "username":"$\{rgusername\}", + "database":"$\{rgdatabase\}" + }, + "primary": + { + "persistence":{ + "size" :"1Gi" + } + }, + "persistence": { + "size" :"1Gi" + } + }, + "registry": { + "host": "$\{dnsName\}", + "idpClientId" : "$\{idpClientId\}", + "idpIssuerUri": "$\{idpIssuerUri\}", + "tenantId" : "$\{bpnNumber\}", + "authentication": $\{dtNeedExternalAccess\}, + "ingress": { + "enabled": $\{dtNeedExternalAccess\}, + "hostname": "$\{dnsName\}", + "annotations": { + "cert-manager.io/cluster-issuer": letsencrypt-prod, + "nginx.ingress.kubernetes.io/cors-allow-credentials": "true", + "nginx.ingress.kubernetes.io/enable-cors": "true", + "nginx.ingress.kubernetes.io/rewrite-target": /$2, + "nginx.ingress.kubernetes.io/use-regex": "true", + "nginx.ingress.kubernetes.io/x-forwarded-prefix": /$\{dtregistryUrlPrefix\} + }, + "urlPrefix": /$\{dtregistryUrlPrefix\}, + "className": "nginx", + "tls": $\{dtNeedExternalAccess\} + } + } +}', package_version='0.3.27' where app_name='DT_REGISTRY'; + +update app_tbl set expected_input_data= replace(replace(expected_input_data,'\{','{'),'\}','}'), required_yaml_configuration=replace(replace(required_yaml_configuration,'\{','{'),'\}','}'); \ No newline at end of file From f3677532d3fff9391501124fb9a99c9cbbb692c6 Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Sat, 25 May 2024 01:03:16 +0530 Subject: [PATCH 8/8] fix code ql issues --- .../GlobalDefaultExceptionHandler.java | 2 +- .../manager/ConnectorRegistrationManager.java | 2 +- .../manager/PortalIntegrationManager.java | 33 +++++++++---------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java index 0767be6e..96ebc112 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java @@ -69,7 +69,7 @@ public ResponseEntity handleValidationException(ValidationException ex, } @ExceptionHandler(FeignException.class) - public ResponseEntity> handleFeignException(FeignException ex, WebRequest request) { + public ResponseEntity> handleFeignException(FeignException ex) { log.error("FeignException: " + ex.getMessage()); log.error("FeignException RequestBody: " + ex.request()); log.error("FeignException ResponseBody: " + ex.contentUTF8()); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java index 87b28565..38b85d9f 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java @@ -178,7 +178,7 @@ private String checkSubcriptionHaveConnectorRegister(Map header, String remoteSubscriptionId = "";//JsonObjectProcessingUtility.getValueFromJsonNode(jsonNode, //SUBSCRIPTION_ID); - if (subscriptionId.equalsIgnoreCase(remoteSubscriptionId)) { + if (subscriptionId.equalsIgnoreCase(remoteSubscriptionId) && jsonNode!=null) { JsonNode connectorIds = null;//JsonObjectProcessingUtility.getArrayNodeFromJsonNode(jsonNode, //"connectorIds"); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java index b73c5e57..34ca7769 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java @@ -211,7 +211,7 @@ private ServiceInstanceResultResponse processAppServiceGetResponse(String subscr String appServiceURIPath) { ServiceInstanceResultResponse serviceInstanceResultResponse = verifyIsAlreadySubcribedActivatedAndGetDetails( - subscriptionId, offerId, header, serviceInstanceResultRequest, appServiceURIPath); + subscriptionId, offerId, header, appServiceURIPath); if (serviceInstanceResultResponse == null) { @@ -221,7 +221,7 @@ private ServiceInstanceResultResponse processAppServiceGetResponse(String subscr log.info("Post App/Service instanceURL, going to read credentials asynchronously"); serviceInstanceResultResponse = verifyIsAlreadySubcribedActivatedAndGetDetails(subscriptionId, offerId, - header, serviceInstanceResultRequest, appServiceURIPath); + header, appServiceURIPath); } @@ -229,15 +229,14 @@ private ServiceInstanceResultResponse processAppServiceGetResponse(String subscr throw new ServiceException("Unable to read technical user detials from portal auto setup"); } - readTechnicalUserDetails(subscriptionId, header, serviceInstanceResultResponse); + readTechnicalUserDetails(header, serviceInstanceResultResponse); return serviceInstanceResultResponse; } @SneakyThrows private ServiceInstanceResultResponse verifyIsAlreadySubcribedActivatedAndGetDetails(String subscriptionId, - String offerId, Map header, ServiceInstanceResultRequest serviceInstanceResultRequest, - String appServiceURIPath) { + String offerId, Map header, String appServiceURIPath) { int retry = 5; int counter = 1; @@ -256,28 +255,28 @@ private ServiceInstanceResultResponse verifyIsAlreadySubcribedActivatedAndGetDet offerSubscriptionStatus = serviceInstanceResultResponse.getOfferSubscriptionStatus(); - log.info("VerifyIsAlreadySubcribedActivatedAndGetDetails: The subscription details found for " + offerId + log.info(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails: The subscription details found for " + offerId + ", " + subscriptionId + ", status is " + offerSubscriptionStatus + ", result is " - + serviceInstanceResultResponse.toJsonString()); + + serviceInstanceResultResponse.toJsonString())); } catch (FeignException e) { - log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException request: " + e.request()); - log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException response Body: " - + e.responseBody()); + log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException request: " + e.request())); + log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException response Body: " + + e.responseBody())); String error = e.contentUTF8(); error = StringUtils.isAllEmpty(error) ? error : e.getMessage(); if (e.status() == 404) { - log.warn("VerifyIsAlreadySubcribedActivatedAndGetDetails: The no app or subscription found for " - + offerId + ", " + subscriptionId + ", result is " + error); + log.warn(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails: The no app or subscription found for " + + offerId + ", " + subscriptionId + ", result is " + error)); } else { - log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException Exception response: " - + error); + log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException Exception response: " + + error)); } } catch (Exception e) { - log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails Exception processing portal call " - + e.getMessage()); + log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails Exception processing portal call " + + e.getMessage())); } counter++; @@ -287,7 +286,7 @@ private ServiceInstanceResultResponse verifyIsAlreadySubcribedActivatedAndGetDet } @SneakyThrows - private void readTechnicalUserDetails(String subscriptionId, Map header, + private void readTechnicalUserDetails(Map header, ServiceInstanceResultResponse serviceInstanceResultResponse) { if (serviceInstanceResultResponse.getTechnicalUserData() != null) {