From 17a396abbea4cc989a50e6139d9ecb21c86baafa Mon Sep 17 00:00:00 2001 From: dvasunin Date: Tue, 26 Sep 2023 22:26:09 +0300 Subject: [PATCH 01/17] unification of SDF versions for different contexts and MIW --- DEPENDENCIES | 157 +++++++++--------- pom.xml | 100 +++-------- .../SDFactoryCatenaX.java => SDFactory.java} | 58 ++++--- .../config/BeansFactory.java | 11 +- .../config/DefaultFeignConfig.java | 28 ++-- .../dto/SDDocumentDto.java | 43 ----- .../service/Claims.java | 29 ---- .../service/SDFactory.java | 25 --- .../service/SDFactoryGaiaX.java | 73 -------- .../service/Validator.java | 60 ------- .../service/clearinghouse/ClearingHouse.java | 4 +- .../{vrel3 => converter}/RegCodeMapper.java | 22 +-- .../TermsAndConditionsHelper.java} | 25 +-- .../fcformat/LegalParticipantSDConverter.java | 75 +++++++++ .../fcformat/ServiceOfferingSDConverter.java | 93 +++++++++++ .../gaiax/LegalParticipantSDConverter.java | 65 ++++++++ .../gaiax/ServiceOfferingSDConverter.java | 81 +++++++++ .../vrel3/LegalParticipantSDConverter.java | 63 +++++++ .../vrel3/ServiceOfferingSDConverter.java | 89 ++++++++++ .../service/keycloak/KeycloakClient.java | 16 +- .../service/keycloak/KeycloakManager.java | 59 ++++++- .../service/v2210/SDocumentConverter.java | 58 ------- .../service/vrel3/ApiDelegate.java | 40 ----- .../vrel3/SDocumentConverterCatenaX.java | 115 ------------- .../vrel3/SDocumentConverterGaiaX.java | 129 -------------- 25 files changed, 716 insertions(+), 802 deletions(-) rename src/main/java/org/eclipse/tractusx/selfdescriptionfactory/{service/SDFactoryCatenaX.java => SDFactory.java} (56%) delete mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/dto/SDDocumentDto.java delete mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/Claims.java delete mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/SDFactory.java delete mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/SDFactoryGaiaX.java delete mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/Validator.java rename src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/{vrel3 => converter}/RegCodeMapper.java (68%) rename src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/{vrel3/SDocumentConverter.java => converter/TermsAndConditionsHelper.java} (68%) create mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/LegalParticipantSDConverter.java create mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/ServiceOfferingSDConverter.java create mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/gaiax/LegalParticipantSDConverter.java create mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/gaiax/ServiceOfferingSDConverter.java create mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/LegalParticipantSDConverter.java create mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/ServiceOfferingSDConverter.java delete mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/v2210/SDocumentConverter.java delete mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/ApiDelegate.java delete mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/SDocumentConverterCatenaX.java delete mode 100644 src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/SDocumentConverterGaiaX.java diff --git a/DEPENDENCIES b/DEPENDENCIES index 1081c739..8535b82b 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,19 +1,16 @@ -maven/mavencentral/ch.qos.logback/logback-classic/1.4.7, EPL-1.0 OR LGPL-2.1-only, approved, #3435 -maven/mavencentral/ch.qos.logback/logback-core/1.4.7, EPL-1.0 OR LGPL-2.1-only, approved, #3373 +maven/mavencentral/ch.qos.logback/logback-classic/1.4.11, EPL-1.0 OR LGPL-2.1-only, approved, #3435 +maven/mavencentral/ch.qos.logback/logback-core/1.4.11, EPL-1.0 OR LGPL-2.1-only, approved, #3373 maven/mavencentral/com.apicatalog/titanium-json-ld/1.1.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.danubetech/key-formats-java/1.2.0, Apache-2.0, approved, #3467 -maven/mavencentral/com.danubetech/verifiable-credentials-java/1.0.0, Apache-2.0, approved, #3465 -maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.0, Apache-2.0, approved, #7947 -maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.15.0, MIT AND Apache-2.0, approved, #7932 -maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.0, Apache-2.0, approved, #7934 -maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.0, Apache-2.0, approved, #8802 -maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.15.0, Apache-2.0, approved, #8808 -maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.15.0, Apache-2.0, approved, #7930 -maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.15.0, Apache-2.0, approved, #8803 +maven/mavencentral/com.danubetech/key-formats-java/1.6.0, , restricted, clearlydefined +maven/mavencentral/com.danubetech/verifiable-credentials-java/1.1.0, , restricted, clearlydefined +maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.2, Apache-2.0, approved, #7947 +maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.15.2, MIT AND Apache-2.0, approved, #7932 +maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.2, Apache-2.0, approved, #7934 +maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.2, Apache-2.0, approved, #8802 +maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.15.2, Apache-2.0, approved, #8808 +maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.15.2, Apache-2.0, approved, #7930 +maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.15.2, Apache-2.0, approved, #8803 maven/mavencentral/com.fasterxml/classmate/1.5.1, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.github.jnr/jffi/1.2.9, Apache-2.0, approved, CQ9095 -maven/mavencentral/com.github.jnr/jnr-ffi/2.0.5, Apache-2.0, approved, CQ12035 -maven/mavencentral/com.github.jnr/jnr-x86asm/1.0.2, MIT, approved, CQ9094 maven/mavencentral/com.github.multiformats/java-multibase/v1.1.0, MIT AND BSD-3-Clause AND EPL-1.0 AND Apache-2.0, approved, #4095 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 @@ -22,23 +19,24 @@ maven/mavencentral/com.google.guava/failureaccess/1.0.1, Apache-2.0, approved, C maven/mavencentral/com.google.guava/guava/32.1.1-jre, Apache-2.0 AND CC0-1.0 AND LicenseRef-Public-Domain, approved, #9229 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.google.protobuf/protobuf-java/3.22.3, BSD-3-Clause, approved, #8370 +maven/mavencentral/com.google.protobuf/protobuf-javalite/3.22.3, BSD-3-Clause, approved, clearlydefined +maven/mavencentral/com.goterl/lazysodium-java/5.1.1, NOASSERTION, restricted, clearlydefined maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.31, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.sun.activation/jakarta.activation/1.2.2, EPL-2.0 OR BSD-3-Clause OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jaf +maven/mavencentral/com.squareup.okhttp3/okhttp/4.10.0, Apache-2.0 AND MPL-2.0, approved, #3057 +maven/mavencentral/com.squareup.okio/okio-jvm/3.0.0, Apache-2.0, approved, clearlydefined maven/mavencentral/commons-codec/commons-codec/1.15, Apache-2.0 AND BSD-3-Clause AND LicenseRef-Public-Domain, approved, CQ22641 -maven/mavencentral/commons-fileupload/commons-fileupload/1.5, Apache-2.0, approved, #7109 -maven/mavencentral/commons-io/commons-io/2.11.0, Apache-2.0, approved, CQ23745 -maven/mavencentral/decentralized-identity/jsonld-common-java/1.0.0, Apache-2.0, approved, #3108 -maven/mavencentral/info.weboftrust/ld-signatures-java/1.0.0, Apache-2.0, approved, #3463 +maven/mavencentral/commons-fileupload/commons-fileupload/1.4, Apache-2.0, approved, clearlydefined +maven/mavencentral/decentralized-identity/jsonld-common-java/1.1.0, , restricted, clearlydefined +maven/mavencentral/info.weboftrust/ld-signatures-java/1.2.0, , restricted, clearlydefined maven/mavencentral/io.github.classgraph/classgraph/4.8.149, MIT, approved, CQ22530 maven/mavencentral/io.github.erdtman/java-json-canonicalization/1.1, Apache-2.0, approved, clearlydefined maven/mavencentral/io.github.openfeign.form/feign-form-spring/3.8.0, Apache-2.0, approved, clearlydefined maven/mavencentral/io.github.openfeign.form/feign-form/3.8.0, Apache-2.0, approved, clearlydefined maven/mavencentral/io.github.openfeign/feign-core/12.3, Apache-2.0, approved, clearlydefined maven/mavencentral/io.github.openfeign/feign-slf4j/12.3, Apache-2.0, approved, clearlydefined -maven/mavencentral/io.micrometer/micrometer-commons/1.11.0, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #9243 -maven/mavencentral/io.micrometer/micrometer-core/1.11.0, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #9238 -maven/mavencentral/io.micrometer/micrometer-observation/1.11.0, Apache-2.0, approved, #9242 +maven/mavencentral/io.micrometer/micrometer-commons/1.11.4, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #9243 +maven/mavencentral/io.micrometer/micrometer-core/1.11.4, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #9238 +maven/mavencentral/io.micrometer/micrometer-observation/1.11.4, Apache-2.0, approved, #9242 maven/mavencentral/io.setl/rdf-urdna/1.1, Apache-2.0, approved, clearlydefined maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.8, Apache-2.0, approved, #5947 maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.8, Apache-2.0, approved, #5929 @@ -47,77 +45,76 @@ maven/mavencentral/io.vavr/vavr-match/0.10.4, Apache-2.0, approved, clearlydefin maven/mavencentral/io.vavr/vavr/0.10.4, Apache-2.0, approved, clearlydefined 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.validation/jakarta.validation-api/3.0.2, Apache-2.0, approved, clearlydefined -maven/mavencentral/jakarta.xml.bind/jakarta.xml.bind-api/4.0.0, BSD-3-Clause, approved, ee4j.jaxb -maven/mavencentral/net.minidev/accessors-smart/2.4.9, Apache-2.0, approved, #7515 -maven/mavencentral/net.minidev/json-smart/2.4.10, Apache-2.0, approved, #3288 -maven/mavencentral/org.abstractj.kalium/kalium/0.8.0, Apache-2.0, approved, clearlydefined +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.1, BSD-3-Clause, approved, ee4j.jaxb maven/mavencentral/org.apache.commons/commons-lang3/3.12.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.apache.logging.log4j/log4j-api/2.20.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.apache.logging.log4j/log4j-to-slf4j/2.20.0, Apache-2.0, approved, #8799 -maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-core/10.1.8, 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.8, Apache-2.0, approved, #6997 -maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-websocket/10.1.8, Apache-2.0, approved, #7920 -maven/mavencentral/org.apache.tomcat/tomcat-annotations-api/10.1.8, Apache-2.0, approved, #8196 -maven/mavencentral/org.aspectj/aspectjweaver/1.9.19, EPL-1.0, approved, tools.aspectj -maven/mavencentral/org.bitcoinj/bitcoinj-core/0.15.10, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.bouncycastle/bcpkix-jdk15on/1.69, MIT, approved, clearlydefined -maven/mavencentral/org.bouncycastle/bcprov-jdk15on/1.69, MIT, approved, clearlydefined -maven/mavencentral/org.bouncycastle/bcprov-jdk15to18/1.68, MIT, approved, #3464 -maven/mavencentral/org.bouncycastle/bcutil-jdk15on/1.69, MIT, approved, clearlydefined +maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-core/10.1.13, 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.13, Apache-2.0, approved, #6997 +maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-websocket/10.1.13, Apache-2.0, approved, #7920 +maven/mavencentral/org.apache.tomcat/tomcat-annotations-api/10.1.13, Apache-2.0, approved, #8196 +maven/mavencentral/org.aspectj/aspectjweaver/1.9.20, EPL-1.0, approved, tools.aspectj +maven/mavencentral/org.bitcoinj/bitcoinj-core/0.16.1, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.bouncycastle/bcpkix-jdk15on/1.70, MIT, approved, clearlydefined +maven/mavencentral/org.bouncycastle/bcprov-jdk15on/1.70, MIT, approved, #1712 +maven/mavencentral/org.bouncycastle/bcprov-jdk18on/1.71, MIT, approved, #3475 +maven/mavencentral/org.bouncycastle/bcutil-jdk15on/1.70, MIT, approved, clearlydefined maven/mavencentral/org.checkerframework/checker-qual/3.33.0, MIT, approved, clearlydefined maven/mavencentral/org.glassfish/jakarta.json/2.0.0, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jsonp -maven/mavencentral/org.hibernate.validator/hibernate-validator/8.0.0.Final, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.jboss.logging/jboss-logging/3.5.0.Final, Apache-2.0, approved, #9471 -maven/mavencentral/org.keycloak/keycloak-common/21.1.1, Apache-2.0 AND LicenseRef-public-domain, approved, #8195 -maven/mavencentral/org.keycloak/keycloak-core/21.1.1, Apache-2.0, approved, #8194 -maven/mavencentral/org.ow2.asm/asm-analysis/5.0.3, BSD-2-Clause, approved, CQ9714 -maven/mavencentral/org.ow2.asm/asm-commons/5.0.3, BSD-2-Clause, approved, CQ9714 -maven/mavencentral/org.ow2.asm/asm-tree/5.0.3, BSD-2-Clause, approved, CQ9714 -maven/mavencentral/org.ow2.asm/asm-util/5.0.3, BSD-2-Clause, approved, CQ9714 -maven/mavencentral/org.ow2.asm/asm/9.3, BSD-3-Clause, approved, clearlydefined -maven/mavencentral/org.projectlombok/lombok/1.18.26, MIT AND LicenseRef-Public-Domain, approved, CQ23907 -maven/mavencentral/org.slf4j/jul-to-slf4j/2.0.7, MIT, approved, #7698 -maven/mavencentral/org.slf4j/slf4j-api/2.0.7, MIT, approved, #5915 +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.8.22, Apache-2.0, approved, #8910 +maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.8.22, Apache-2.0, approved, #8807 +maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.8.22, Apache-2.0, approved, #8875 +maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib/1.8.22, Apache-2.0, approved, #8865 +maven/mavencentral/org.jetbrains/annotations/13.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.projectlombok/lombok/1.18.30, MIT AND LicenseRef-Public-Domain, approved, CQ23907 +maven/mavencentral/org.slf4j/jul-to-slf4j/2.0.9, MIT, approved, #7698 +maven/mavencentral/org.slf4j/slf4j-api/2.0.9, MIT, approved, #5915 maven/mavencentral/org.springdoc/springdoc-openapi-starter-common/2.0.4, Apache-2.0, approved, #5920 maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-api/2.0.4, Apache-2.0, approved, #5950 maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-ui/2.0.4, Apache-2.0, approved, #5923 -maven/mavencentral/org.springframework.boot/spring-boot-actuator-autoconfigure/3.1.0, Apache-2.0, approved, #9348 -maven/mavencentral/org.springframework.boot/spring-boot-actuator/3.1.0, Apache-2.0, approved, #9342 -maven/mavencentral/org.springframework.boot/spring-boot-autoconfigure/3.1.0, Apache-2.0, approved, #9341 -maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.1.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.springframework.boot/spring-boot-starter-actuator/3.1.0, Apache-2.0, approved, #9344 -maven/mavencentral/org.springframework.boot/spring-boot-starter-aop/3.1.0, Apache-2.0, approved, #9338 -maven/mavencentral/org.springframework.boot/spring-boot-starter-json/3.1.0, Apache-2.0, approved, #9336 -maven/mavencentral/org.springframework.boot/spring-boot-starter-logging/3.1.0, Apache-2.0, approved, #9343 -maven/mavencentral/org.springframework.boot/spring-boot-starter-oauth2-resource-server/3.1.0, Apache-2.0, approved, #8804 -maven/mavencentral/org.springframework.boot/spring-boot-starter-security/3.1.0, Apache-2.0, approved, #9337 -maven/mavencentral/org.springframework.boot/spring-boot-starter-tomcat/3.1.0, Apache-2.0, approved, #9351 -maven/mavencentral/org.springframework.boot/spring-boot-starter-validation/3.1.0, Apache-2.0, approved, #9335 -maven/mavencentral/org.springframework.boot/spring-boot-starter-web/3.1.0, Apache-2.0, approved, #9347 -maven/mavencentral/org.springframework.boot/spring-boot-starter/3.1.0, Apache-2.0, approved, #9349 -maven/mavencentral/org.springframework.boot/spring-boot/3.1.0, Apache-2.0, approved, #9352 +maven/mavencentral/org.springframework.boot/spring-boot-actuator-autoconfigure/3.1.4, Apache-2.0, approved, #9348 +maven/mavencentral/org.springframework.boot/spring-boot-actuator/3.1.4, Apache-2.0, approved, #9342 +maven/mavencentral/org.springframework.boot/spring-boot-autoconfigure/3.1.4, Apache-2.0, approved, #9341 +maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.1.4, , restricted, clearlydefined +maven/mavencentral/org.springframework.boot/spring-boot-starter-actuator/3.1.4, Apache-2.0, approved, #9344 +maven/mavencentral/org.springframework.boot/spring-boot-starter-aop/3.1.4, Apache-2.0, approved, #9338 +maven/mavencentral/org.springframework.boot/spring-boot-starter-json/3.1.4, Apache-2.0, approved, #9336 +maven/mavencentral/org.springframework.boot/spring-boot-starter-logging/3.1.4, Apache-2.0, approved, #9343 +maven/mavencentral/org.springframework.boot/spring-boot-starter-oauth2-resource-server/3.1.4, Apache-2.0, approved, #8804 +maven/mavencentral/org.springframework.boot/spring-boot-starter-security/3.1.4, Apache-2.0, approved, #9337 +maven/mavencentral/org.springframework.boot/spring-boot-starter-tomcat/3.1.4, Apache-2.0, approved, #9351 +maven/mavencentral/org.springframework.boot/spring-boot-starter-validation/3.1.4, Apache-2.0, approved, #9335 +maven/mavencentral/org.springframework.boot/spring-boot-starter-web/3.1.4, Apache-2.0, approved, #9347 +maven/mavencentral/org.springframework.boot/spring-boot-starter/3.1.4, Apache-2.0, approved, #9349 +maven/mavencentral/org.springframework.boot/spring-boot/3.1.4, Apache-2.0, approved, #9352 maven/mavencentral/org.springframework.cloud/spring-cloud-commons/4.0.3, Apache-2.0, approved, #7292 maven/mavencentral/org.springframework.cloud/spring-cloud-context/4.0.3, Apache-2.0, approved, #7306 maven/mavencentral/org.springframework.cloud/spring-cloud-openfeign-core/4.0.3, Apache-2.0, approved, #7305 maven/mavencentral/org.springframework.cloud/spring-cloud-starter-openfeign/4.0.3, Apache-2.0, approved, #7302 maven/mavencentral/org.springframework.cloud/spring-cloud-starter/4.0.3, Apache-2.0, approved, #7299 -maven/mavencentral/org.springframework.security/spring-security-config/6.1.2, Apache-2.0, approved, #9736 -maven/mavencentral/org.springframework.security/spring-security-core/6.1.0, Apache-2.0, approved, #9801 -maven/mavencentral/org.springframework.security/spring-security-crypto/6.1.0, Apache-2.0 AND ISC, approved, #9735 -maven/mavencentral/org.springframework.security/spring-security-oauth2-core/6.1.0, Apache-2.0, approved, #9741 -maven/mavencentral/org.springframework.security/spring-security-oauth2-jose/6.1.0, Apache-2.0, approved, #9345 -maven/mavencentral/org.springframework.security/spring-security-oauth2-resource-server/6.1.0, Apache-2.0, approved, #8798 +maven/mavencentral/org.springframework.security/spring-security-config/6.1.4, Apache-2.0, approved, #9736 +maven/mavencentral/org.springframework.security/spring-security-core/6.1.4, Apache-2.0, approved, #9801 +maven/mavencentral/org.springframework.security/spring-security-crypto/6.1.4, Apache-2.0 AND ISC, approved, #9735 +maven/mavencentral/org.springframework.security/spring-security-oauth2-core/6.1.4, Apache-2.0, approved, #9741 +maven/mavencentral/org.springframework.security/spring-security-oauth2-jose/6.1.4, Apache-2.0, approved, #9345 +maven/mavencentral/org.springframework.security/spring-security-oauth2-resource-server/6.1.4, Apache-2.0, approved, #8798 maven/mavencentral/org.springframework.security/spring-security-rsa/1.0.11.RELEASE, Apache-2.0, approved, CQ20647 -maven/mavencentral/org.springframework.security/spring-security-web/6.1.0, Apache-2.0, approved, #9800 -maven/mavencentral/org.springframework/spring-aop/6.0.9, Apache-2.0, approved, #5940 -maven/mavencentral/org.springframework/spring-beans/6.0.9, Apache-2.0, approved, #5937 -maven/mavencentral/org.springframework/spring-context/6.0.9, Apache-2.0, approved, #5936 -maven/mavencentral/org.springframework/spring-core/6.0.9, Apache-2.0 AND BSD-3-Clause, approved, #5948 -maven/mavencentral/org.springframework/spring-expression/6.0.9, Apache-2.0, approved, #3284 -maven/mavencentral/org.springframework/spring-jcl/6.0.9, Apache-2.0, approved, #3283 -maven/mavencentral/org.springframework/spring-web/6.0.9, Apache-2.0, approved, #5942 -maven/mavencentral/org.springframework/spring-webmvc/6.0.9, Apache-2.0, approved, #5944 +maven/mavencentral/org.springframework.security/spring-security-web/6.1.4, Apache-2.0, approved, #9800 +maven/mavencentral/org.springframework/spring-aop/6.0.12, Apache-2.0, approved, #5940 +maven/mavencentral/org.springframework/spring-beans/6.0.12, Apache-2.0, approved, #5937 +maven/mavencentral/org.springframework/spring-context/6.0.12, Apache-2.0, approved, #5936 +maven/mavencentral/org.springframework/spring-core/6.0.12, Apache-2.0 AND BSD-3-Clause, approved, #5948 +maven/mavencentral/org.springframework/spring-expression/6.0.12, Apache-2.0, approved, #3284 +maven/mavencentral/org.springframework/spring-jcl/6.0.12, Apache-2.0, approved, #3283 +maven/mavencentral/org.springframework/spring-web/6.0.12, Apache-2.0, approved, #5942 +maven/mavencentral/org.springframework/spring-webmvc/6.0.12, Apache-2.0, approved, #5944 +maven/mavencentral/org.web3j/abi/5.0.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.web3j/crypto/5.0.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.web3j/rlp/5.0.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.web3j/utils/5.0.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.webjars/swagger-ui/4.18.1, Apache-2.0, approved, #7850 maven/mavencentral/org.webjars/webjars-locator-core/0.52, MIT, approved, clearlydefined maven/mavencentral/org.yaml/snakeyaml/2.0, 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, #7275 diff --git a/pom.xml b/pom.xml index fa660d47..43e62420 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.0 + 3.1.4 com.tsystems @@ -16,7 +16,7 @@ 17 ^ - 2022.0.1 + 2022.0.3 @@ -32,11 +32,6 @@ org.apache.tomcat.embed tomcat-embed-core - - com.google.guava - guava - 32.1.1-jre - org.springframework spring-webmvc @@ -85,23 +80,23 @@ com.danubetech verifiable-credentials-java - 1.0.0 - compile + 1.1.0 + - org.springframework.cloud - spring-cloud-starter-openfeign - 4.0.3 + org.bouncycastle + bcpkix-jdk15on + 1.70 com.google.protobuf - protobuf-java + protobuf-javalite 3.22.3 - commons-fileupload - commons-fileupload - 1.5 + com.google.guava + guava + 32.1.1-jre com.nimbusds @@ -128,73 +123,30 @@ spring-security-test test - - org.springframework.security - spring-security-config - 6.1.2 - - - org.springframework.security - spring-security-core - 6.1.2 - - - org.springframework.security - spring-security-oauth2-resource-server - 6.1.2 - - - org.springframework.security - spring-security-oauth2-core - 6.1.2 - - - org.springframework.security - spring-security-oauth2-jose - 6.1.2 - - - org.springframework.security - spring-security-crypto - 6.1.2 - - - org.springframework.security - spring-security-web - 6.1.2 - org.yaml snakeyaml 2.0 - - com.google.protobuf - protobuf-java - 3.22.3 - - - commons-fileupload - commons-fileupload - 1.5 - - - - org.keycloak - keycloak-core - 21.1.1 - - - net.minidev - json-smart - 2.4.10 - org.springframework.boot spring-boot-starter-actuator + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + danubetech-maven-public @@ -248,8 +200,8 @@ maven-compiler-plugin 3.10.1 - 17 - 17 + 21 + 21 true lines,vars,source diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/SDFactoryCatenaX.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/SDFactory.java similarity index 56% rename from src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/SDFactoryCatenaX.java rename to src/main/java/org/eclipse/tractusx/selfdescriptionfactory/SDFactory.java index 072db609..90d787a1 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/SDFactoryCatenaX.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/SDFactory.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022,2023 T-Systems International GmbH - * Copyright (c) 2022,2023 Contributors to the Eclipse Foundation + * Copyright (c) 2021,2022 T-Systems International GmbH + * Copyright (c) 2021,2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -18,28 +18,28 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.selfdescriptionfactory.service; +package org.eclipse.tractusx.selfdescriptionfactory; import com.danubetech.verifiablecredentials.CredentialSubject; import com.danubetech.verifiablecredentials.VerifiableCredential; -import foundation.identity.jsonld.JsonLDUtils; +import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.eclipse.tractusx.selfdescriptionfactory.api.vrel3.ApiApiDelegate; +import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.SelfdescriptionPostRequest; import org.eclipse.tractusx.selfdescriptionfactory.service.clearinghouse.ClearingHouse; import org.eclipse.tractusx.selfdescriptionfactory.service.wallet.CustodianWallet; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; import org.springframework.core.convert.ConversionService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import java.net.URI; import java.time.Duration; import java.time.Instant; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.Optional; -import java.util.UUID; +import java.util.*; /** * A service to create and manipulate of Self-Description document @@ -47,32 +47,40 @@ @Service @RequiredArgsConstructor @Slf4j -@Profile("catena-x-ctx") -public class SDFactoryCatenaX implements SDFactory{ +public class SDFactory implements ApiApiDelegate { @Value("${app.verifiableCredentials.durationDays:90}") private int duration; + private final CustodianWallet custodianWallet; private final ConversionService conversionService; private final ClearingHouse clearingHouse; - @Override @PreAuthorize("hasAuthority(@securityRoles.createRole)") - public void createVC(Object document) { - var claimsHolder = Optional.ofNullable(conversionService.convert(document, Claims.class)).orElseThrow(); - var claims = new LinkedHashMap<>(claimsHolder.claims()); - var holder = claims.remove("holder"); - var issuer = claims.remove("issuer"); - var externalId = claims.remove("externalId"); - var credentialSubject = CredentialSubject.fromJsonObject(claims); + @Override + public ResponseEntity selfdescriptionPost(SelfdescriptionPostRequest selfdescriptionPostRequest) { + var processed = Objects.requireNonNull(conversionService.convert(selfdescriptionPostRequest, SelfDescription.class), "Converted SD-Document is null. Very strange"); var verifiableCredential = VerifiableCredential.builder() - .contexts(claimsHolder.vocabularies()) + .contexts(processed.getContexts()) + .id(URI.create("http://example.org/" + UUID.randomUUID())) + .issuer(URI.create(processed.getIssuer())) .issuanceDate(new Date()) - .id(URI.create(UUID.randomUUID().toString())) .expirationDate(Date.from(Instant.now().plus(Duration.ofDays(duration)))) - .credentialSubject(credentialSubject) + .credentialSubject(CredentialSubject.fromJsonObject(processed)) + .type(processed.getType()) .build(); - JsonLDUtils.jsonLdAdd(verifiableCredential, "issuer", issuer); - //var vc = custodianWallet.getSignedVC(verifiableCredential); - clearingHouse.sendToClearingHouse(verifiableCredential, externalId.toString()); + var verifiableCredentialSigned = custodianWallet.getSignedVC(verifiableCredential); + clearingHouse.sendToClearingHouse(verifiableCredentialSigned, processed.getExternalId()); + + return new ResponseEntity<>(HttpStatus.ACCEPTED); + } + + @Getter + @RequiredArgsConstructor + public static class SelfDescription extends LinkedHashMap { + private final List contexts; + private final String holder; + private final String issuer; + private final String externalId; + private final String type; } } diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/config/BeansFactory.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/config/BeansFactory.java index f5fd67f5..46d0da41 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/config/BeansFactory.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/config/BeansFactory.java @@ -26,10 +26,15 @@ import com.fasterxml.jackson.databind.json.JsonMapper; import feign.Feign; import feign.Target; +import feign.form.spring.SpringFormEncoder; import org.eclipse.tractusx.selfdescriptionfactory.service.keycloak.KeycloakClient; import org.springframework.beans.factory.ObjectFactory; +import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.http.HttpMessageConverters; +import org.springframework.cloud.openfeign.support.HttpMessageConverterCustomizer; import org.springframework.cloud.openfeign.support.SpringDecoder; +import org.springframework.cloud.openfeign.support.SpringEncoder; +import org.springframework.cloud.openfeign.support.SpringMvcContract; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -44,9 +49,11 @@ ObjectMapper nonNullObjectMapper() { } @Bean - public KeycloakClient keycloakClient(ObjectFactory converters){ + public KeycloakClient keycloakClient(ObjectFactory converters, ObjectProvider customizerProvider){ return Feign.builder() - .decoder(new SpringDecoder(converters)) + .decoder(new SpringDecoder(converters, customizerProvider)) + .encoder(new SpringFormEncoder(new SpringEncoder(converters))) + .contract(new SpringMvcContract()) .target(Target.EmptyTarget.create(KeycloakClient.class)); } } diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/config/DefaultFeignConfig.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/config/DefaultFeignConfig.java index 1a672e89..af171f0e 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/config/DefaultFeignConfig.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/config/DefaultFeignConfig.java @@ -32,6 +32,8 @@ import org.springframework.http.HttpStatusCode; import org.springframework.web.server.ResponseStatusException; +import java.io.StringReader; +import java.util.NoSuchElementException; import java.util.Objects; import java.util.Optional; @@ -49,17 +51,23 @@ public RequestInterceptor getRequestInterceptor(KeycloakManager keycloakManager) @Bean public ErrorDecoder getErrorDecoder(ObjectMapper mapper) { return (methodKey, response) -> { - var msg = Try.of(() -> response.body().asReader(response.charset())) - .mapTry(mapper::readTree) - .map(node -> node.get("message")) - .filter(Objects::nonNull) - .map(JsonNode::asText) - .map(" : "::concat) - .recover(err -> "").get(); + String contentType = response.headers().get("Content-Type").stream() + .findFirst() + .orElse("Unknown"); + var responseStr = Try.of(() -> response.body().asInputStream().readAllBytes()).map(bytes -> new String(bytes, response.charset())).getOrElse(""); + var msg = (contentType.contains("json") ? Try.success(new StringReader(responseStr)) : Try.failure(new NoSuchElementException())) + .mapTry(mapper::readTree) + .recover(any -> mapper.createObjectNode()) + .map(jsonNode -> jsonNode.get("message")) + .filter(Objects::nonNull) + .map(JsonNode::asText) + .getOrElse(responseStr); var statusCode = HttpStatusCode.valueOf(response.status()); - log.error("Original payload: {}", new String(response.request().body(), response.request().charset())); - return new ResponseStatusException(statusCode, methodKey.concat(msg)); - + log.error("Error in Feign client: {}", msg); + if (response.request().body() != null) { + log.error("Original payload: {}", new String(response.request().body(), response.request().charset())); + } + return new ResponseStatusException(statusCode, methodKey.concat(" : ").concat(msg)); }; } } diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/dto/SDDocumentDto.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/dto/SDDocumentDto.java deleted file mode 100644 index 5558cc89..00000000 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/dto/SDDocumentDto.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021,2022 T-Systems International GmbH - * Copyright (c) 2021,2022 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.selfdescriptionfactory.dto; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -@JsonIgnoreProperties(ignoreUnknown = true) -public class SDDocumentDto { - String company_number; - String headquarter_country; - String legal_country; - String service_provider; - String sd_type; - String bpn; - String holder; - String issuer; -} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/Claims.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/Claims.java deleted file mode 100644 index c4a78a4a..00000000 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/Claims.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2023 T-Systems International GmbH - * Copyright (c) 2022,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.selfdescriptionfactory.service; - -import java.net.URI; -import java.util.List; -import java.util.Map; - - -public record Claims(Map claims, List vocabularies) { -} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/SDFactory.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/SDFactory.java deleted file mode 100644 index 5e21bd3a..00000000 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/SDFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021,2022 T-Systems International GmbH - * Copyright (c) 2021,2022 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.selfdescriptionfactory.service; - -public interface SDFactory { - void createVC(Object document); -} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/SDFactoryGaiaX.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/SDFactoryGaiaX.java deleted file mode 100644 index 61be41d9..00000000 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/SDFactoryGaiaX.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2023 T-Systems International GmbH - * Copyright (c) 2022,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.selfdescriptionfactory.service; - -import com.danubetech.verifiablecredentials.CredentialSubject; -import com.danubetech.verifiablecredentials.VerifiableCredential; -import foundation.identity.jsonld.JsonLDUtils; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.selfdescriptionfactory.service.clearinghouse.ClearingHouse; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.core.convert.ConversionService; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.stereotype.Service; - -import java.time.Duration; -import java.time.Instant; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.Optional; - -/** - * A service to create and manipulate of Self-Description document - */ -@Service -@RequiredArgsConstructor -@Slf4j -@Profile("gaia-x-ctx") -public class SDFactoryGaiaX implements SDFactory{ - @Value("${app.verifiableCredentials.durationDays:90}") - private int duration; - private final ConversionService conversionService; - private final ClearingHouse clearingHouse; - - @Override - @PreAuthorize("hasAuthority(@securityRoles.createRole)") - public void createVC(Object document) { - var claimsHolder = Optional.ofNullable(conversionService.convert(document, Claims.class)).orElseThrow(); - var claims = new LinkedHashMap<>(claimsHolder.claims()); - claims.remove("holder"); - claims.remove("issuer"); - var type = claims.remove("type"); - var externalId = claims.remove("externalId"); - var credentialSubject = CredentialSubject.fromJsonObject(claims); - var verifiableCredential = VerifiableCredential.builder() - .contexts(claimsHolder.vocabularies()) - .issuanceDate(new Date()) - .expirationDate(Date.from(Instant.now().plus(Duration.ofDays(duration)))) - .credentialSubject(credentialSubject) - .build(); - JsonLDUtils.jsonLdAdd(verifiableCredential, "type", type); - clearingHouse.sendToClearingHouse(verifiableCredential, externalId.toString()); - } -} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/Validator.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/Validator.java deleted file mode 100644 index 6d75a13c..00000000 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/Validator.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2023 T-Systems International GmbH - * Copyright (c) 2022,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.selfdescriptionfactory.service; - -import io.vavr.Lazy; -import io.vavr.control.Try; -import jakarta.validation.Valid; -import org.eclipse.tractusx.selfdescriptionfactory.Utils; -import org.springframework.beans.factory.ObjectFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Component; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.server.ResponseStatusException; - -import java.util.function.Function; -import java.util.function.Supplier; - -@Component -@Validated -public class Validator { - private final Lazy self; - - public Validator(@Autowired ObjectFactory validatorObjectFactory) { - self = Lazy.of(validatorObjectFactory::getObject); - } - - public Supplier validated(Supplier fn) { - return () -> validated(any -> fn.get()).apply(null); - } - - public Function validated(Function fn) { - return t -> fn.andThen(r -> Try.of(() -> self.get().checkIfValid(r)) - .recoverWith(Utils.mapFailure( - err -> new ResponseStatusException(HttpStatus.BAD_REQUEST, err.getMessage(), err) - ))).apply(t).get(); - } - - public T checkIfValid(@Valid T t) { - return t; - } -} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/clearinghouse/ClearingHouse.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/clearinghouse/ClearingHouse.java index ba229f2a..910da773 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/clearinghouse/ClearingHouse.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/clearinghouse/ClearingHouse.java @@ -26,6 +26,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import java.util.Optional; + @RequiredArgsConstructor public abstract class ClearingHouse { @Value("${app.usersDetails.clearingHouse.uri}") @@ -36,6 +38,6 @@ public abstract class ClearingHouse { public abstract void doWork(String url, VerifiableCredential payload, String externalId, String token); public void sendToClearingHouse(VerifiableCredential verifiableCredential, String externalId) { - doWork(clearingHouseUrl, verifiableCredential, externalId, "Bearer ".concat(keycloakManager.getToken("clearingHouse"))); + doWork(clearingHouseUrl, verifiableCredential, externalId, "Bearer ".concat(Optional.ofNullable(keycloakManager.getToken("clearingHouse")).orElse(""))); } } diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/RegCodeMapper.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/RegCodeMapper.java similarity index 68% rename from src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/RegCodeMapper.java rename to src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/RegCodeMapper.java index 45d9c16c..8d8118ee 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/RegCodeMapper.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/RegCodeMapper.java @@ -18,20 +18,20 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.selfdescriptionfactory.service.vrel3; +package org.eclipse.tractusx.selfdescriptionfactory.service.converter; -import lombok.experimental.Delegate; import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.RegistrationNumberSchema.TypeEnum; import java.util.Map; -public class RegCodeMapper implements Map{ - @Delegate - private final Map regNumMap = Map.of( - TypeEnum.TAXID, "gx:taxID", - TypeEnum.VATID, "gx:vatID", - TypeEnum.EUID, "gx:EUID", - TypeEnum.EORI, "gx:EORI", - TypeEnum.LEICODE, "gx:leiCode" - ); +public class RegCodeMapper { + public static Map getRegCodeMapper(String prefix) { + return Map.of( + TypeEnum.TAXID, prefix.concat("local"), + TypeEnum.VATID, prefix.concat("vatID"), + TypeEnum.EUID, prefix.concat("EUID"), + TypeEnum.EORI, prefix.concat("EORI"), + TypeEnum.LEICODE, prefix.concat("leiCode") + ); + } } diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/SDocumentConverter.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/TermsAndConditionsHelper.java similarity index 68% rename from src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/SDocumentConverter.java rename to src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/TermsAndConditionsHelper.java index cd298eea..9d28cbb2 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/SDocumentConverter.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/TermsAndConditionsHelper.java @@ -18,31 +18,36 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.selfdescriptionfactory.service.vrel3; +package org.eclipse.tractusx.selfdescriptionfactory.service.converter; import io.vavr.control.Try; import org.apache.commons.codec.digest.DigestUtils; import org.eclipse.tractusx.selfdescriptionfactory.Utils; -import org.eclipse.tractusx.selfdescriptionfactory.model.v2210.TermsAndConditionsSchema; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; import org.springframework.web.server.ResponseStatusException; import java.net.URI; -import java.net.URL; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.function.Function; -public class SDocumentConverter { +@Component +public class TermsAndConditionsHelper { @Value("${app.maxRedirect:5}") private int maxRedirect; - protected TermsAndConditionsSchema getTermsAndConditions(String urlStr) { - return Try.of(() -> new URL(urlStr)) + public Map getTermsAndConditions(String urlStr, Function> urlMaker, Function> hashMaker) { + return Try.of(() -> URI.create(urlStr).toURL()) .mapTry(url -> Utils.getConnectionIfRedirected(url, maxRedirect)) .flatMap(urlConnection -> Try.withResources(urlConnection::getInputStream).of(DigestUtils::sha256Hex)) - .map(sha -> new TermsAndConditionsSchema() - .URL(URI.create(urlStr)) - .hash(sha)) - .recoverWith(Utils.mapFailure(err -> + .map(sha -> { + Map res = new LinkedHashMap<>(); + if (urlMaker != null) res.putAll(urlMaker.apply(urlStr)); + if (hashMaker != null) res.putAll(hashMaker.apply(sha)); + return res; + }).recoverWith(Utils.mapFailure(err -> new ResponseStatusException( HttpStatus.BAD_REQUEST, "Could not retrieve TermsAndConditions from '" + urlStr + "'", diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/LegalParticipantSDConverter.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/LegalParticipantSDConverter.java new file mode 100644 index 00000000..eb999317 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/LegalParticipantSDConverter.java @@ -0,0 +1,75 @@ +/******************************************************************************** + * Copyright (c) 2021,2022 T-Systems International GmbH + * Copyright (c) 2021,2022 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.selfdescriptionfactory.service.converter.fcformat; + +import lombok.RequiredArgsConstructor; +import org.eclipse.tractusx.selfdescriptionfactory.SDFactory; +import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.LegalParticipantSchema; +import org.eclipse.tractusx.selfdescriptionfactory.service.wallet.CustodianWallet; +import org.springframework.context.annotation.Profile; +import org.springframework.core.convert.converter.Converter; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +@Profile("fc-ctx") +public class LegalParticipantSDConverter implements Converter { + + private final CustodianWallet custodianWallet; + + @Override + public SDFactory.SelfDescription convert(@NonNull LegalParticipantSchema legalPersonSchema) { + /* + if (legalPersonSchema.getRegistrationNumber().size() != 1) { + throw new ResponseStatusException( + HttpStatus.BAD_REQUEST, + "Registration Number must have single element for Federated Catalog" + ); + } + LegalParticipantSD legalParticipantSD = new LegalParticipantSD(); + legalParticipantSD.put("@context", ImmutableMap.of( + "gx", "https://w3id.org/gaia-x/gax-trust-framework#", + "xsd", "http://www.w3.org/2001/XMLSchema#", + "vcard", "http://www.w3.org/2006/vcard/ns#", + "ctxsd", "https://w3id.org/catena-x/core#") + ); + legalParticipantSD.put("@id", custodianWallet.getWalletData(legalPersonSchema.getHolder()).get("did")); + legalParticipantSD.put("@type", "gx:LegalPerson"); + legalParticipantSD.put("ctxsd:bpn", legalPersonSchema.getBpn()); + legalParticipantSD.put("gx:name", custodianWallet.getWalletData(legalPersonSchema.getBpn()).get("name")); + legalParticipantSD.put("gx:registrationNumber", legalPersonSchema.getRegistrationNumber().iterator().next().getValue()); + legalParticipantSD.put("gx:headquarterAddress", + ImmutableMap.of( "@type", "vcard:Address", + "vcard:country-name", legalPersonSchema.getHeadquarterAddressCountry() + ) + ); + legalParticipantSD.put("gx:legalAddress", + ImmutableMap.of( "@type", "vcard:Address", + "vcard:country-name", legalPersonSchema.getLegalAddressCountry() + ) + ); + return legalParticipantSD; + + */ + return null; + } +} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/ServiceOfferingSDConverter.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/ServiceOfferingSDConverter.java new file mode 100644 index 00000000..405787b4 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/ServiceOfferingSDConverter.java @@ -0,0 +1,93 @@ +/******************************************************************************** + * Copyright (c) 2021,2022 T-Systems International GmbH + * Copyright (c) 2021,2022 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.selfdescriptionfactory.service.converter.fcformat; + +import lombok.RequiredArgsConstructor; +import org.eclipse.tractusx.selfdescriptionfactory.SDFactory; +import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.ServiceOfferingSchema; +import org.eclipse.tractusx.selfdescriptionfactory.service.converter.TermsAndConditionsHelper; +import org.eclipse.tractusx.selfdescriptionfactory.service.wallet.CustodianWallet; +import org.springframework.context.annotation.Profile; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +@Profile("fc-ctx") +public class ServiceOfferingSDConverter implements Converter { + + private final CustodianWallet custodianWallet; + private final TermsAndConditionsHelper termsAndConditionsHelper; + + @Override + public SDFactory.SelfDescription convert(ServiceOfferingSchema serviceOfferingSchema) { + /* + var serviceOfferingSD = new ServiceOfferingSD(); + serviceOfferingSD.put("@context", ImmutableMap.of( + "gx", "https://w3id.org/gaia-x/gax-trust-framework#", + "gax-core", "https://w3id.org/gaia-x/core#", + "ctxsd", "https://w3id.org/catena-x/core#", + "xsd", "http://www.w3.org/2001/XMLSchema#" + ) + ); + serviceOfferingSD.put("@id", custodianWallet.getWalletData(serviceOfferingSchema.getHolder()).get("did")); + serviceOfferingSD.put("@type", "gx:ServiceOffering"); + serviceOfferingSD.put("ctxsd:connector-url", "https://connector-placeholder.net"); + //WARNING! In Trust Framework specs it is called 'providedBy' + //but in FC it is referred as 'gax-core:offeredBy' + serviceOfferingSD.put("gax-core:offeredBy", ImmutableMap.of( + "@id", serviceOfferingSchema.getProvidedBy()) + ); + serviceOfferingSD.put("gx:dataAccountExport", ImmutableMap.of( + "gx:requestType", "email", + "gx:accessType", "digital", + "gx:formatType", "json") + ); + var setter = new Object() { + Consumer set(String fieldName) { + return any -> serviceOfferingSD.put(fieldName, any); + } + }; + Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getAggregationOf(), Utils::uriFromStr) + .map(l -> l.size() == 1 ? l.iterator().next() : l) + .ifPresent(setter.set("gx:aggregationOf")); + setter.set("gx:termsAndConditions").accept( + Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getTermsAndConditions(), url -> termsAndConditionsHelper.getTermsAndConditions(url, "gx:")) + .map(l -> l.size() == 1 ? l.iterator().next() : l) + .map(Object.class::cast) + .orElse(ImmutableMap.of( + "gx:content", ImmutableMap.of( + "@type", "xsd:anyURI", + "@value", "http://example.org/tac-placeholder"), + "gx:hash", "1234") + ) + ); + setter.set("gx:policy").accept( + Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getPolicies(), Function.identity()) + .map(Object.class::cast) + .orElse("policy_placeholder") + ); + return serviceOfferingSD; + + */ + return null; + } +} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/gaiax/LegalParticipantSDConverter.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/gaiax/LegalParticipantSDConverter.java new file mode 100644 index 00000000..ccd887c0 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/gaiax/LegalParticipantSDConverter.java @@ -0,0 +1,65 @@ +/******************************************************************************** + * Copyright (c) 2021,2022 T-Systems International GmbH + * Copyright (c) 2021,2022 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.selfdescriptionfactory.service.converter.gaiax; + +import lombok.RequiredArgsConstructor; +import org.eclipse.tractusx.selfdescriptionfactory.SDFactory; +import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.LegalParticipantSchema; +import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.RegistrationNumberSchema; +import org.eclipse.tractusx.selfdescriptionfactory.service.converter.RegCodeMapper; +import org.eclipse.tractusx.selfdescriptionfactory.service.wallet.CustodianWallet; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Profile; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +import java.net.URI; +import java.util.List; +import java.util.Map; + +@Component +@RequiredArgsConstructor +@Profile("gaia-x-ctx") +public class LegalParticipantSDConverter implements Converter { + + private final CustodianWallet custodianWallet; + private final Map regCodeMapper = RegCodeMapper.getRegCodeMapper("gx:"); + @Value("${app.verifiableCredentials.gaia-x-participant-schema}") + private URI contextUri; + + + @Override + public SDFactory.SelfDescription convert(LegalParticipantSchema legalParticipantSchema) { + var legalParticipantSD = new SDFactory.SelfDescription(List.of(contextUri), legalParticipantSchema.getHolder(), legalParticipantSchema.getIssuer(), legalParticipantSchema.getExternalId(), null); + legalParticipantSD.put("@context", Map.of("ctxsd", "https://w3id.org/catena-x/core#")); + legalParticipantSD.put("id", custodianWallet.getWalletData(legalParticipantSchema.getBpn()).get("did")); + legalParticipantSD.put("type", "gx:LegalParticipant"); + legalParticipantSD.put("ctxsd:bpn", legalParticipantSchema.getBpn()); + legalParticipantSD.put("gx:legalName", custodianWallet.getWalletData(legalParticipantSchema.getBpn()).get("name")); + legalParticipantSD.put( + "gx:legalRegistrationNumber", + legalParticipantSchema.getRegistrationNumber().stream().map(regNum -> Map.of(regCodeMapper.get(regNum.getType()), regNum.getValue())).toList() + ); + legalParticipantSD.put("gx:headquarterAddress", Map.of("gx:countrySubdivisionCode", legalParticipantSchema.getHeadquarterAddressCountry())); + legalParticipantSD.put("gx:legalAddress", Map.of("gx:countrySubdivisionCode", legalParticipantSchema.getLegalAddressCountry())); + return legalParticipantSD; + } +} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/gaiax/ServiceOfferingSDConverter.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/gaiax/ServiceOfferingSDConverter.java new file mode 100644 index 00000000..9f8608fd --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/gaiax/ServiceOfferingSDConverter.java @@ -0,0 +1,81 @@ +/******************************************************************************** + * Copyright (c) 2021,2022 T-Systems International GmbH + * Copyright (c) 2021,2022 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.selfdescriptionfactory.service.converter.gaiax; + +import lombok.RequiredArgsConstructor; +import org.eclipse.tractusx.selfdescriptionfactory.SDFactory; +import org.eclipse.tractusx.selfdescriptionfactory.Utils; +import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.ServiceOfferingSchema; +import org.eclipse.tractusx.selfdescriptionfactory.service.converter.TermsAndConditionsHelper; +import org.eclipse.tractusx.selfdescriptionfactory.service.wallet.CustodianWallet; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Profile; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +import java.net.URI; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Function; + +@Component +@RequiredArgsConstructor +@Profile("gaia-x-ctx") +public class ServiceOfferingSDConverter implements Converter { + + private final CustodianWallet custodianWallet; + private final TermsAndConditionsHelper termsAndConditionsHelper; + @Value("${app.verifiableCredentials.gaia-x-service-schema}") + private URI contextUri; + + @Override + public SDFactory.SelfDescription convert(ServiceOfferingSchema serviceOfferingSchema) { + var serviceOfferingSD = new SDFactory.SelfDescription(List.of(contextUri), serviceOfferingSchema.getHolder(), serviceOfferingSchema.getIssuer(), serviceOfferingSchema.getExternalId(), null); + serviceOfferingSD.put("@context", Map.of("ctxsd", "https://w3id.org/catena-x/core#")); + serviceOfferingSD.put("id", custodianWallet.getWalletData(serviceOfferingSchema.getHolder()).get("did")); + serviceOfferingSD.put("type", "gx:ServiceOffering"); + serviceOfferingSD.put("ctxsd:connector-url", "https://connector-placeholder.net"); + serviceOfferingSD.put("gx:providedBy", Map.of("id", serviceOfferingSchema.getProvidedBy())); + Map dataAccountExportNode = new LinkedHashMap<>(); + dataAccountExportNode.put("gx:requestType", "email"); + dataAccountExportNode.put("gx:accessType", "digital"); + dataAccountExportNode.put("gx:formatType", "json"); + serviceOfferingSD.put("gx:dataAccountExport", List.of(dataAccountExportNode)); + var setter = new Object() { + Consumer set(String fieldName) { + return t -> serviceOfferingSD.put(fieldName, t); + } + }; + Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getAggregationOf(), Utils::uriFromStr).ifPresent(setter.set("gx:aggregationOf")); + Utils.getNonEmptyListFromCommaSeparated( + serviceOfferingSchema.getTermsAndConditions(), + url -> termsAndConditionsHelper.getTermsAndConditions( + url, + u -> Map.of("gx:URL", u), + h -> Map.of("gx:hash", h) + ) + ).ifPresent(setter.set("gx:termsAndConditions")); + Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getPolicies(), Function.identity()).ifPresent(setter.set("gx:policy")); + return serviceOfferingSD; + } +} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/LegalParticipantSDConverter.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/LegalParticipantSDConverter.java new file mode 100644 index 00000000..52c6b234 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/LegalParticipantSDConverter.java @@ -0,0 +1,63 @@ +/******************************************************************************** + * Copyright (c) 2021,2022 T-Systems International GmbH + * Copyright (c) 2021,2022 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.selfdescriptionfactory.service.converter.vrel3; + +import lombok.RequiredArgsConstructor; +import org.eclipse.tractusx.selfdescriptionfactory.SDFactory; +import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.LegalParticipantSchema; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Profile; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +import java.net.URI; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Component +@RequiredArgsConstructor +@Profile("catena-x-ctx") +public class LegalParticipantSDConverter implements Converter { + + @Value("${app.verifiableCredentials.schema2210Url}") + private URI contextUri; + + @Override + public SDFactory.SelfDescription convert(LegalParticipantSchema legalParticipantSchema) { + var legalParticipantSD = new SDFactory.SelfDescription(List.of(contextUri), legalParticipantSchema.getHolder(), legalParticipantSchema.getIssuer(), legalParticipantSchema.getExternalId(), legalParticipantSchema.getType()); + legalParticipantSD.put("bpn", legalParticipantSchema.getBpn()); + legalParticipantSD.put( + "registrationNumber", + legalParticipantSchema.getRegistrationNumber().stream() + .map(rNum -> { + var val = new LinkedHashMap(); + val.put("type", rNum.getType()); + val.put("value", rNum.getValue()); + return val; + }).collect(Collectors.toUnmodifiableSet()) + ); + legalParticipantSD.put("headquarterAddress", Map.of("countryCode", legalParticipantSchema.getHeadquarterAddressCountry())); + legalParticipantSD.put("legalAddress", Map.of("countryCode", legalParticipantSchema.getLegalAddressCountry())); + return legalParticipantSD; + } +} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/ServiceOfferingSDConverter.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/ServiceOfferingSDConverter.java new file mode 100644 index 00000000..26a3c732 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/ServiceOfferingSDConverter.java @@ -0,0 +1,89 @@ +/******************************************************************************** + * Copyright (c) 2021,2022 T-Systems International GmbH + * Copyright (c) 2021,2022 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.selfdescriptionfactory.service.converter.vrel3; + +import io.vavr.control.Try; +import lombok.RequiredArgsConstructor; +import org.apache.commons.codec.digest.DigestUtils; +import org.eclipse.tractusx.selfdescriptionfactory.SDFactory; +import org.eclipse.tractusx.selfdescriptionfactory.Utils; +import org.eclipse.tractusx.selfdescriptionfactory.model.v2210.DataAccountExportSchema; +import org.eclipse.tractusx.selfdescriptionfactory.model.v2210.TermsAndConditionsSchema; +import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.ServiceOfferingSchema; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Profile; +import org.springframework.core.convert.converter.Converter; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; +import org.springframework.web.server.ResponseStatusException; + +import java.net.URI; +import java.net.URL; +import java.util.List; +import java.util.function.Function; + +@Component +@RequiredArgsConstructor +@Profile("catena-x-ctx") +public class ServiceOfferingSDConverter implements Converter { + + @Value("${app.maxRedirect:5}") + private int maxRedirect; + + @Value("${app.verifiableCredentials.schema2210Url}") + private URI contextUri; + + @Override + public SDFactory.SelfDescription convert(ServiceOfferingSchema serviceOfferingSchema) { + var aggregationOf = Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getAggregationOf(), Utils::uriFromStr).orElse(null); + var termsAndConditions = Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getTermsAndConditions(), this::getTermsAndConditions).orElse(null); + var policy = Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getPolicies(), Function.identity()).orElse(null); + var serviceOfferingSD = new SDFactory.SelfDescription(List.of(contextUri), serviceOfferingSchema.getHolder(), serviceOfferingSchema.getIssuer(), serviceOfferingSchema.getExternalId(), serviceOfferingSchema.getType()); + serviceOfferingSD.put("providedBy", serviceOfferingSchema.getProvidedBy()); + serviceOfferingSD.put("aggregationOf", aggregationOf); + serviceOfferingSD.put("termsAndConditions", termsAndConditions); + serviceOfferingSD.put("policy", policy); + serviceOfferingSD.put("dataAccountExport", List.of( + new DataAccountExportSchema() + .requestType(DataAccountExportSchema.RequestTypeEnum.EMAIL) + .accessType(DataAccountExportSchema.AccessTypeEnum.DIGITAL) + .formatType("json") + ) + ); + return serviceOfferingSD; + } + + private TermsAndConditionsSchema getTermsAndConditions(String urlStr) { + return Try.of(() -> new URL(urlStr)) + .mapTry(url -> Utils.getConnectionIfRedirected(url, maxRedirect)) + .flatMap(urlConnection -> Try.withResources(urlConnection::getInputStream).of(DigestUtils::sha256Hex)) + .map(sha-> new TermsAndConditionsSchema() + .URL(URI.create(urlStr)) + .hash(sha)) + .recoverWith(Utils.mapFailure(err -> + new ResponseStatusException( + HttpStatus.BAD_REQUEST, + "Could not retrieve TermsAndConditions from '"+ urlStr +"'", + err) + ) + ).get(); + } +} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/keycloak/KeycloakClient.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/keycloak/KeycloakClient.java index db5750c2..51856d48 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/keycloak/KeycloakClient.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/keycloak/KeycloakClient.java @@ -1,4 +1,3 @@ - /******************************************************************************** * Copyright (c) 2022,2023 T-Systems International GmbH * Copyright (c) 2022,2023 Contributors to the Eclipse Foundation @@ -22,17 +21,16 @@ package org.eclipse.tractusx.selfdescriptionfactory.service.keycloak; -import feign.Body; -import feign.Headers; -import feign.Param; -import feign.RequestLine; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import java.net.URI; import java.util.Map; public interface KeycloakClient { - @RequestLine("POST /realms/{realm}/protocol/openid-connect/token") - @Headers("Content-Type: application/x-www-form-urlencoded") - @Body("grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}&scope=openid") - Map getTokens(URI serverUrl, @Param("realm") String realm, @Param("client_id") String clientId, @Param("client_secret") String clientSecret); + @RequestMapping(method = RequestMethod.POST, value = "/realms/{realm}/protocol/openid-connect/token", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) + Map getTokens(URI serverUrl, @PathVariable("realm") String realm, Map params); + } diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/keycloak/KeycloakManager.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/keycloak/KeycloakManager.java index 492ce054..3348de24 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/keycloak/KeycloakManager.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/keycloak/KeycloakManager.java @@ -41,7 +41,7 @@ public class KeycloakManager { private static final long REFRESH_GAP = 60L; private final TechnicalUsersDetails technicalUsersDetails; - private final Map tokenMap = new HashMap<>(); + private final Map> tokenMap = new HashMap<>(); private final KeycloakClient keycloakClient; @@ -49,19 +49,62 @@ public class KeycloakManager { @SneakyThrows public String getToken(String name) { - var token = tokenMap.get(name); - if (!Objects.isNull(token)) { + var kk = tokenMap.get(name); + var details = technicalUsersDetails.getUsersDetails().get(name); + if (Objects.isNull(details)) + return null; + if (!Objects.isNull(kk)) { + var token = kk.get("access_token").toString(); var jwt = mapper.readValue(Base64.getDecoder().decode(token.split("\\.")[1]), new TypeReference>(){}); var expirationInstant = Instant.ofEpochSecond((Integer) jwt.get("exp")); if (Duration.between(Instant.now(), expirationInstant).compareTo(Duration.ofSeconds(REFRESH_GAP)) > 0) { + //token still valid return token; + } else { + //try to obtain access token using refresh token + var refreshToken = kk.get("refresh_token"); + if (!Objects.isNull(refreshToken)) { + var refreshedToken = refresh(refreshToken.toString(), name, details); + if (refreshedToken != null) return refreshedToken; + } } } - var details = technicalUsersDetails.getUsersDetails().get(name); - if (Objects.isNull(details)) + // Trying to get token using supplied credentials + var param = new HashMap(); + if (details.username() == null || details.username().isBlank()) { + param.put("grant_type", "client_credentials"); + } else { + param.put("grant_type", "password"); + param.put("username", details.username()); + param.put("password", details.password()); + } + param.put("client_id", details.clientId()); + param.put("client_secret", details.clientSecret()); + param.put("scope", "openid"); + kk = keycloakClient.getTokens(URI.create(details.serverUrl()), details.realm(), param); + tokenMap.put(name, kk); + return kk.get("access_token").toString(); + } + + private String refresh(String refreshToken, String name, TechnicalUsersDetails.UserDetail details) { + try { + var token = mapper.readValue(Base64.getDecoder().decode(refreshToken.split("\\.")[1]), new TypeReference>() {}); + var expirationInstant = Instant.ofEpochSecond((Integer) token.get("exp")); + if (Duration.between(Instant.now(), expirationInstant).compareTo(Duration.ofSeconds(REFRESH_GAP)) > 0) { + var kk = keycloakClient.getTokens( + URI.create(details.serverUrl()), details.realm(), Map.of( + "grant_type", "refresh_token", + "client_id", details.clientId(), + "client_secret", details.clientSecret(), + "scope", "open_id", + "refresh_token", refreshToken + ) + ); + tokenMap.put(name, kk); + return kk.get("access_token").toString(); + } else return null; + } catch (Exception e) { return null; - token = keycloakClient.getTokens(URI.create(details.serverUrl()), details.realm(), details.clientId(), details.clientSecret()).get("access_token").toString(); - tokenMap.put(name, token); - return token; + } } } diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/v2210/SDocumentConverter.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/v2210/SDocumentConverter.java deleted file mode 100644 index ed905068..00000000 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/v2210/SDocumentConverter.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021,2022 T-Systems International GmbH - * Copyright (c) 2021,2022 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.selfdescriptionfactory.service.v2210; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.RequiredArgsConstructor; -import org.eclipse.tractusx.selfdescriptionfactory.model.v2210.SelfdescriptionPostRequest; -import org.eclipse.tractusx.selfdescriptionfactory.model.v2210.ServiceOfferingSchema; -import org.eclipse.tractusx.selfdescriptionfactory.service.Claims; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.core.convert.converter.Converter; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Component; - -import java.net.URI; -import java.util.Collections; -import java.util.LinkedHashMap; - -@Component -@RequiredArgsConstructor -@Profile("catena-x-ctx") -public class SDocumentConverter implements Converter { - private final ObjectMapper objectMapper; - @Value("${app.verifiableCredentials.schema2210Url}") - private String schemaUrl; - - @Override - public @NonNull Claims convert(@NonNull SelfdescriptionPostRequest source) { - var sdoc2210Map = objectMapper.convertValue(source, new TypeReference>(){}); - if (!sdoc2210Map.containsKey("bpn") && source instanceof ServiceOfferingSchema so) { - sdoc2210Map.put("bpn", so.getHolder()); - } - return new Claims( - sdoc2210Map, - Collections.singletonList(URI.create(schemaUrl)) - ); - } -} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/ApiDelegate.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/ApiDelegate.java deleted file mode 100644 index 4218fbce..00000000 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/ApiDelegate.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021,2022 T-Systems International GmbH - * Copyright (c) 2021,2022 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.selfdescriptionfactory.service.vrel3; - -import lombok.RequiredArgsConstructor; -import org.eclipse.tractusx.selfdescriptionfactory.api.vrel3.ApiApiDelegate; -import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.SelfdescriptionPostRequest; -import org.eclipse.tractusx.selfdescriptionfactory.service.SDFactory; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class ApiDelegate implements ApiApiDelegate { - private final SDFactory sdFactory; - - public ResponseEntity selfdescriptionPost(SelfdescriptionPostRequest selfdescriptionPostRequest) { - sdFactory.createVC(selfdescriptionPostRequest); - return new ResponseEntity<>(HttpStatus.ACCEPTED); - } -} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/SDocumentConverterCatenaX.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/SDocumentConverterCatenaX.java deleted file mode 100644 index c12dc487..00000000 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/SDocumentConverterCatenaX.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2023 T-Systems International GmbH - * Copyright (c) 2022,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.selfdescriptionfactory.service.vrel3; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.RequiredArgsConstructor; -import org.eclipse.tractusx.selfdescriptionfactory.Utils; -import org.eclipse.tractusx.selfdescriptionfactory.model.v2210.AddressSchema; -import org.eclipse.tractusx.selfdescriptionfactory.model.v2210.DataAccountExportSchema; -import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.LegalParticipantSchema; -import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.SelfdescriptionPostRequest; -import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.ServiceOfferingSchema; -import org.eclipse.tractusx.selfdescriptionfactory.service.Claims; -import org.springframework.context.annotation.Profile; -import org.springframework.core.convert.converter.Converter; -import org.springframework.http.HttpStatus; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Component; -import org.springframework.web.server.ResponseStatusException; - -import java.util.HashMap; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -@Component -@RequiredArgsConstructor -@Profile("catena-x-ctx") -public class SDocumentConverterCatenaX extends SDocumentConverter implements Converter { - private final ObjectMapper objectMapper; - private final org.eclipse.tractusx.selfdescriptionfactory.service.v2210.SDocumentConverter converter2210; - private final org.eclipse.tractusx.selfdescriptionfactory.service.Validator validator; - - @Override - public Claims convert(@NonNull SelfdescriptionPostRequest source) { - String externalId; - org.eclipse.tractusx.selfdescriptionfactory.model.v2210.SelfdescriptionPostRequest converted2210; - if (source instanceof LegalParticipantSchema lp) { - externalId = lp.getExternalId(); - converted2210 = validator.validated(this::convertRel3LegalParticipant2210).apply(lp); - } else if (source instanceof ServiceOfferingSchema so) { - externalId = so.getExternalId(); - converted2210 = validator.validated(this::convertRel3ServiceOffering2210).apply(so); - } else { - throw new ResponseStatusException( - HttpStatus.BAD_REQUEST, - "LegalParticipantSchema and ServiceOffering are supported only" - ); - } - var mapOf2210 = converter2210.convert(converted2210); - var withExternalId = new HashMap<>(mapOf2210.claims()); - withExternalId.put("externalId", externalId); - return new Claims(withExternalId, mapOf2210.vocabularies()); - } - - private org.eclipse.tractusx.selfdescriptionfactory.model.v2210.LegalParticipantSchema convertRel3LegalParticipant2210( - org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.LegalParticipantSchema source - ) { - return new org.eclipse.tractusx.selfdescriptionfactory.model.v2210.LegalParticipantSchema() - .type(source.getType()) - .holder(source.getHolder()) - .issuer(source.getIssuer()) - .bpn(source.getBpn()) - .registrationNumber(source.getRegistrationNumber().stream() - .map(rNum -> objectMapper.convertValue(rNum, org.eclipse.tractusx.selfdescriptionfactory.model.v2210.RegistrationNumberSchema.class)) - .collect(Collectors.toSet())) - .headquarterAddress(convertCountryCode(source.getHeadquarterAddressCountry())) - .legalAddress(convertCountryCode(source.getLegalAddressCountry())); - } - - private AddressSchema convertCountryCode(String countryCode) { - return new AddressSchema().countryCode(countryCode); - } - - private org.eclipse.tractusx.selfdescriptionfactory.model.v2210.ServiceOfferingSchema convertRel3ServiceOffering2210( - org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.ServiceOfferingSchema source - ) { - var aggregationOf = Utils.getNonEmptyListFromCommaSeparated(source.getAggregationOf(), Utils::uriFromStr).orElse(null); - var termsAndConditions = Utils.getNonEmptyListFromCommaSeparated(source.getTermsAndConditions(), this::getTermsAndConditions).orElse(null); - var policy = Utils.getNonEmptyListFromCommaSeparated(source.getPolicies(), Function.identity()).orElse(null); - return new org.eclipse.tractusx.selfdescriptionfactory.model.v2210.ServiceOfferingSchema() - .type(source.getType()) - .holder(source.getHolder()) - .issuer(source.getIssuer()) - .providedBy(source.getProvidedBy()) - .aggregationOf(aggregationOf) - .termsAndConditions(termsAndConditions) - .policy(policy) - .dataAccountExport(List.of( - new DataAccountExportSchema() - .requestType(DataAccountExportSchema.RequestTypeEnum.EMAIL) - .accessType(DataAccountExportSchema.AccessTypeEnum.DIGITAL) - .formatType("json") - ) - ); - } -} diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/SDocumentConverterGaiaX.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/SDocumentConverterGaiaX.java deleted file mode 100644 index 3eecfa09..00000000 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/vrel3/SDocumentConverterGaiaX.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2023 T-Systems International GmbH - * Copyright (c) 2022,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.selfdescriptionfactory.service.vrel3; - -import lombok.RequiredArgsConstructor; -import org.eclipse.tractusx.selfdescriptionfactory.Utils; -import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.LegalParticipantSchema; -import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.RegistrationNumberSchema; -import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.SelfdescriptionPostRequest; -import org.eclipse.tractusx.selfdescriptionfactory.model.vrel3.ServiceOfferingSchema; -import org.eclipse.tractusx.selfdescriptionfactory.service.Claims; -import org.eclipse.tractusx.selfdescriptionfactory.service.wallet.CustodianWallet; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.core.convert.converter.Converter; -import org.springframework.http.HttpStatus; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Component; -import org.springframework.web.server.ResponseStatusException; - -import java.net.URI; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.stream.Stream; - -@Component -@Profile("gaia-x-ctx") -@RequiredArgsConstructor -public class SDocumentConverterGaiaX extends SDocumentConverter implements Converter { - - private final CustodianWallet custodianWallet; - @Value("${app.verifiableCredentials.gaia-x-participant-schema}") - private String gaiaxParticipantSchema; - @Value("${app.verifiableCredentials.gaia-x-service-schema}") - private String gaiaxServiceOfferingSchema; - @Value("${app.verifiableCredentials.catena-x-schema}") - private String catenaxSchema; - - private Map regCodeMapper = new RegCodeMapper(); - - @Override - public Claims convert(@NonNull SelfdescriptionPostRequest source) { - String externalId; - Map converted; - List contexts; - if (source instanceof LegalParticipantSchema lp) { - externalId = lp.getExternalId(); - converted = LegalParticipant(lp); - contexts = Stream.of(gaiaxParticipantSchema, catenaxSchema).map(URI::create).toList(); - } else if (source instanceof ServiceOfferingSchema so) { - externalId = so.getExternalId(); - converted = serviceOffering(so); - contexts = Stream.of(gaiaxServiceOfferingSchema, catenaxSchema).map(URI::create).toList(); - } else { - throw new ResponseStatusException( - HttpStatus.BAD_REQUEST, - "LegalParticipantSchema is supported only" - ); - } - var withExternalId = new LinkedHashMap<>(converted); - withExternalId.put("externalId", externalId); - return new Claims( - withExternalId, - contexts - ); - } - - private Map LegalParticipant(LegalParticipantSchema legalParticipantSchema) { - Map res = new LinkedHashMap<>(); - res.put("id", custodianWallet.getWalletData(legalParticipantSchema.getBpn()).get("did")); - res.put("type", legalParticipantSchema.getType()); - res.put("ctxsd:bpn", legalParticipantSchema.getBpn()); - res.put("gx:name", custodianWallet.getWalletData(legalParticipantSchema.getBpn()).get("name")); - res.put( - "gx:legalRegistrationNumber", - legalParticipantSchema.getRegistrationNumber().stream() - .map( - regNum -> Map.of(regCodeMapper.get(regNum.getType()), regNum.getValue()) - ).toList() - ); - res.put("gx:headquarterAddress", Map.of("gx:addressCountryCode", legalParticipantSchema.getHeadquarterAddressCountry())); - res.put("gx:legalAddress", Map.of("gx:addressCountryCode", legalParticipantSchema.getLegalAddressCountry())); - return res; - } - - private Map serviceOffering(ServiceOfferingSchema serviceOfferingSchema) { - Map res = new LinkedHashMap<>(); - res.put("id", custodianWallet.getWalletData(serviceOfferingSchema.getHolder()).get("did")); - res.put("type", serviceOfferingSchema.getType()); - res.put("ctxsd:connector-url", "https://connector-placeholder.net"); - res.put("gx-service:providedBy", serviceOfferingSchema.getProvidedBy()); - Map dataAccountExportNode = new LinkedHashMap<>(); - dataAccountExportNode.put("gx-service:requestType", "email"); - dataAccountExportNode.put("gx-service:accessType", "digital"); - dataAccountExportNode.put("gx-service:formatType", "json"); - res.put("gx-service:dataAccountExport", List.of(dataAccountExportNode)); - var setter = new Object() { - Consumer set(String fieldName) { - return t -> res.put(fieldName, t); - } - }; - Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getAggregationOf(), Utils::uriFromStr).ifPresent(setter.set("gx-service:aggregationOf")); - Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getTermsAndConditions(), this::getTermsAndConditions).ifPresent(setter.set("gx-service:termsAndConditions")); - Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getPolicies(), Function.identity()).ifPresent(setter.set("gx-service:policy")); - return res; - } -} - From 4c74cef0348a99c36381c80ceb4cd35925a0a9cf Mon Sep 17 00:00:00 2001 From: dvasunin Date: Wed, 27 Sep 2023 13:56:06 +0300 Subject: [PATCH 02/17] add support for FC schema. Warning: new MIW does not accept this format for whoknows reason --- .../fcformat/LegalParticipantSDConverter.java | 33 ++++++----- .../fcformat/ServiceOfferingSDConverter.java | 59 +++++++++++-------- 2 files changed, 53 insertions(+), 39 deletions(-) diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/LegalParticipantSDConverter.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/LegalParticipantSDConverter.java index eb999317..346f8c42 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/LegalParticipantSDConverter.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/fcformat/LegalParticipantSDConverter.java @@ -26,8 +26,13 @@ import org.eclipse.tractusx.selfdescriptionfactory.service.wallet.CustodianWallet; import org.springframework.context.annotation.Profile; import org.springframework.core.convert.converter.Converter; +import org.springframework.http.HttpStatus; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; +import org.springframework.web.server.ResponseStatusException; + +import java.util.List; +import java.util.Map; @Component @RequiredArgsConstructor @@ -37,39 +42,35 @@ public class LegalParticipantSDConverter implements Converter set(String fieldName) { .map(l -> l.size() == 1 ? l.iterator().next() : l) .ifPresent(setter.set("gx:aggregationOf")); setter.set("gx:termsAndConditions").accept( - Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getTermsAndConditions(), url -> termsAndConditionsHelper.getTermsAndConditions(url, "gx:")) - .map(l -> l.size() == 1 ? l.iterator().next() : l) - .map(Object.class::cast) - .orElse(ImmutableMap.of( - "gx:content", ImmutableMap.of( - "@type", "xsd:anyURI", - "@value", "http://example.org/tac-placeholder"), - "gx:hash", "1234") - ) + Utils.getNonEmptyListFromCommaSeparated( + serviceOfferingSchema.getTermsAndConditions(), + url -> termsAndConditionsHelper.getTermsAndConditions( + url, + u -> Map.of("gx:content", + Map.of("@type", "xsd:anyURI", + "@value", u + ) + ), + h -> Map.of("gx:hash", h) + ) + ).map(l -> l.size() == 1 ? l.iterator().next() : l) + .orElse(Map.of( + "gx:content", Map.of( + "@type", "xsd:anyURI", + "@value", "http://example.org/tac-placeholder"), + "gx:hash", "1234") + ) ); setter.set("gx:policy").accept( - Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getPolicies(), Function.identity()) - .map(Object.class::cast) + Utils.getNonEmptyListFromCommaSeparated( + serviceOfferingSchema.getPolicies(), + Function.identity() + ).map(l -> l.size() == 1 ? l.iterator().next() : l) .orElse("policy_placeholder") ); return serviceOfferingSD; - - */ - return null; } } From 3fcd1177aee137b0ecf8073cc4127412bb030515 Mon Sep 17 00:00:00 2001 From: dvasunin Date: Wed, 27 Sep 2023 13:57:51 +0300 Subject: [PATCH 03/17] disable signing VC --- .../eclipse/tractusx/selfdescriptionfactory/SDFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/SDFactory.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/SDFactory.java index 90d787a1..513a84a7 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/SDFactory.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/SDFactory.java @@ -68,8 +68,8 @@ public ResponseEntity selfdescriptionPost(SelfdescriptionPostRequest selfd .credentialSubject(CredentialSubject.fromJsonObject(processed)) .type(processed.getType()) .build(); - var verifiableCredentialSigned = custodianWallet.getSignedVC(verifiableCredential); - clearingHouse.sendToClearingHouse(verifiableCredentialSigned, processed.getExternalId()); + //var verifiableCredentialSigned = custodianWallet.getSignedVC(verifiableCredential); + clearingHouse.sendToClearingHouse(verifiableCredential, processed.getExternalId()); return new ResponseEntity<>(HttpStatus.ACCEPTED); } From e3001e47efa0df965a870df23956bf705cef868e Mon Sep 17 00:00:00 2001 From: adkumar1 Date: Thu, 28 Sep 2023 17:10:41 +0530 Subject: [PATCH 04/17] bump version --- README.md | 4 ++-- charts/sdfactory/Chart.yaml | 4 ++-- charts/sdfactory/README.md | 2 +- pom.xml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 48b96412..a091f93e 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ further processing. ## Software Version ```shell -Software version: 2.1.6 -Helm Chart version: 2.1.7 +Software version: 2.1.7 +Helm Chart version: 2.1.8 ``` diff --git a/charts/sdfactory/Chart.yaml b/charts/sdfactory/Chart.yaml index d2e926b8..e53b903b 100644 --- a/charts/sdfactory/Chart.yaml +++ b/charts/sdfactory/Chart.yaml @@ -38,11 +38,11 @@ sources: # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: "2.1.7" +version: "2.1.8" # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "2.1.6" +appVersion: "2.1.7" diff --git a/charts/sdfactory/README.md b/charts/sdfactory/README.md index 08c630a7..3ce0fc7f 100644 --- a/charts/sdfactory/README.md +++ b/charts/sdfactory/README.md @@ -1,6 +1,6 @@ # sdfactory -![Version: 2.1.7](https://img.shields.io/badge/Version-2.1.7-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.1.6](https://img.shields.io/badge/AppVersion-2.1.6-informational?style=flat-square) +![Version: 2.1.8](https://img.shields.io/badge/Version-2.1.8-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.1.7](https://img.shields.io/badge/AppVersion-2.1.7-informational?style=flat-square) Helm Charts for SD Factory application. Self-Description Factory component is responsible for the creation of Self Descriptions. diff --git a/pom.xml b/pom.xml index 43e62420..acad7f02 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.tsystems sd-factory - 2.1.6 + 2.1.7 Self-Description Hub Prototype jar From 5d9494ff0943a5eb072f3d68f03bc41b08bc187a Mon Sep 17 00:00:00 2001 From: dvasunin Date: Tue, 3 Oct 2023 14:33:35 +0300 Subject: [PATCH 05/17] add type to the subject as it was before --- .../service/converter/vrel3/LegalParticipantSDConverter.java | 3 ++- .../service/converter/vrel3/ServiceOfferingSDConverter.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/LegalParticipantSDConverter.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/LegalParticipantSDConverter.java index 52c6b234..29cc0ff6 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/LegalParticipantSDConverter.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/LegalParticipantSDConverter.java @@ -44,7 +44,8 @@ public class LegalParticipantSDConverter implements Converter Date: Tue, 3 Oct 2023 17:37:10 +0300 Subject: [PATCH 06/17] add BPN to the ServiceOffering subject as it was before --- .../service/converter/vrel3/ServiceOfferingSDConverter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/ServiceOfferingSDConverter.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/ServiceOfferingSDConverter.java index d5486e89..ebc06d43 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/ServiceOfferingSDConverter.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/vrel3/ServiceOfferingSDConverter.java @@ -58,6 +58,7 @@ public SDFactory.SelfDescription convert(ServiceOfferingSchema serviceOfferingSc var policy = Utils.getNonEmptyListFromCommaSeparated(serviceOfferingSchema.getPolicies(), Function.identity()).orElse(null); var serviceOfferingSD = new SDFactory.SelfDescription(List.of(contextUri), serviceOfferingSchema.getHolder(), serviceOfferingSchema.getIssuer(), serviceOfferingSchema.getExternalId(), null); serviceOfferingSD.put("type", "ServiceOffering"); + serviceOfferingSD.put("bpn", serviceOfferingSchema.getHolder()); serviceOfferingSD.put("providedBy", serviceOfferingSchema.getProvidedBy()); serviceOfferingSD.put("aggregationOf", aggregationOf); serviceOfferingSD.put("termsAndConditions", termsAndConditions); From 96a752bd3f5c1fd7c76e1ef6e1e9390a2d170b60 Mon Sep 17 00:00:00 2001 From: dvasunin Date: Thu, 5 Oct 2023 12:09:35 +0300 Subject: [PATCH 07/17] fix some smells --- .../eclipse/tractusx/selfdescriptionfactory/SDFactory.java | 5 ++++- .../service/converter/RegCodeMapper.java | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/SDFactory.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/SDFactory.java index 513a84a7..14be86ef 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/SDFactory.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/SDFactory.java @@ -22,6 +22,7 @@ import com.danubetech.verifiablecredentials.CredentialSubject; import com.danubetech.verifiablecredentials.VerifiableCredential; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -68,7 +69,8 @@ public ResponseEntity selfdescriptionPost(SelfdescriptionPostRequest selfd .credentialSubject(CredentialSubject.fromJsonObject(processed)) .type(processed.getType()) .build(); - //var verifiableCredentialSigned = custodianWallet.getSignedVC(verifiableCredential); + // This call signs the VC at MIW as it was in versions prior to CH + // var verifiableCredentialSigned = custodianWallet.getSignedVC(verifiableCredential); clearingHouse.sendToClearingHouse(verifiableCredential, processed.getExternalId()); return new ResponseEntity<>(HttpStatus.ACCEPTED); @@ -76,6 +78,7 @@ public ResponseEntity selfdescriptionPost(SelfdescriptionPostRequest selfd @Getter @RequiredArgsConstructor + @EqualsAndHashCode(callSuper = true) public static class SelfDescription extends LinkedHashMap { private final List contexts; private final String holder; diff --git a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/RegCodeMapper.java b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/RegCodeMapper.java index 8d8118ee..fe054ed0 100644 --- a/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/RegCodeMapper.java +++ b/src/main/java/org/eclipse/tractusx/selfdescriptionfactory/service/converter/RegCodeMapper.java @@ -25,6 +25,7 @@ import java.util.Map; public class RegCodeMapper { + private RegCodeMapper(){} public static Map getRegCodeMapper(String prefix) { return Map.of( TypeEnum.TAXID, prefix.concat("local"), From cf8dc63c0b5da04a0b9a7d2a490fe514b0c6bfdc Mon Sep 17 00:00:00 2001 From: adkumar1 Date: Thu, 5 Oct 2023 17:32:09 +0530 Subject: [PATCH 08/17] Updated new version changes --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d754892..cfa8b30c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] - NA +## [2.1.7] - 2023-10-05 + +### Added +- Unification of SDFactory versions for different contexts and MIW +- Added support for FC schema. +- Added type to the subject +- Added BPN to the ServiceOffering subject as it was before + +### Removed + - Disable signing VC ## [2.1.6] - 2023-08-21 From 2ed809cf1d3365af4fc9d9dc49348424fc8156c8 Mon Sep 17 00:00:00 2001 From: adkumar1 Date: Thu, 5 Oct 2023 18:09:19 +0530 Subject: [PATCH 09/17] Updated helm lint updated helm upgrade --- .github/workflows/helm-lint.yaml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/helm-lint.yaml b/.github/workflows/helm-lint.yaml index 6e078cd7..71ad8a65 100644 --- a/.github/workflows/helm-lint.yaml +++ b/.github/workflows/helm-lint.yaml @@ -38,9 +38,9 @@ on: required: false type: string upgrade_from: - description: 'portal chart version to upgrade from' - # portal version from 3.1 release - default: '1.3.0' + description: 'SD Factory chart version to upgrade from' + # SD Factory version from 3.2 release + default: '2.1.7' required: false type: string @@ -90,13 +90,17 @@ jobs: - name: Run chart-testing (lint) run: ct lint --charts charts/sdfactory --config charts/chart-testing-config.yaml - # Preparing a kind cluster to install and test charts on - - name: Create kind cluster - uses: helm/kind-action@v1.4.0 - if: ${{ env.CHART_CHANGED == 'true' }} # install the chart to the kind cluster and run helm test # define charts to test with the --charts parameter - name: Run chart-testing (install) run: ct install --charts charts/sdfactory --config charts/chart-testing-config.yaml --helm-extra-set-args "--set=image.tag=testing --set=image.repository=kind-registry:5000/sdfactory" - if: ${{ env.CHART_CHANGED == 'true' }} + if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true' + # Upgrade the released chart version with the locally available chart + # default value for event_name != workflow_dispatch + - name: Run helm upgrade + run: | + helm repo add tractusx-dev https://eclipse-tractusx.github.io/charts/dev + helm install sdf tractusx-dev/sdfactory + helm upgrade sdf charts/sdfactory + if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true' From 5eb95202f302392ae0e1ec8ec98c3fe09fddca38 Mon Sep 17 00:00:00 2001 From: adkumar1 Date: Thu, 5 Oct 2023 18:23:26 +0530 Subject: [PATCH 10/17] Updated CHANGELOG for new version --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfa8b30c..b3cee5a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added type to the subject - Added BPN to the ServiceOffering subject as it was before +### Changed + - Updated helm lint + ### Removed - Disable signing VC From 8b5acc64f1e88a20a6bae3bf710e02efcdf14206 Mon Sep 17 00:00:00 2001 From: dvasunin Date: Fri, 6 Oct 2023 11:40:49 +0300 Subject: [PATCH 11/17] upgrade commons-fileupload to mitigate an issue in openfeign 4.0.3 --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index acad7f02..8bc8558b 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,11 @@ org.springframework.cloud spring-cloud-starter-openfeign + + commons-fileupload + commons-fileupload + 1.5 + org.springframework.boot spring-boot-starter-web From 29079126bdab2bd59c4b787c3e92f84457e6979b Mon Sep 17 00:00:00 2001 From: dvasunin Date: Fri, 6 Oct 2023 11:53:39 +0300 Subject: [PATCH 12/17] update DEPENDENCIES. Need to check restricted dependencies --- DEPENDENCIES | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index 8535b82b..abcae8e6 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -25,7 +25,8 @@ maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.31, Apache-2.0, approved, clea maven/mavencentral/com.squareup.okhttp3/okhttp/4.10.0, Apache-2.0 AND MPL-2.0, approved, #3057 maven/mavencentral/com.squareup.okio/okio-jvm/3.0.0, Apache-2.0, approved, clearlydefined maven/mavencentral/commons-codec/commons-codec/1.15, Apache-2.0 AND BSD-3-Clause AND LicenseRef-Public-Domain, approved, CQ22641 -maven/mavencentral/commons-fileupload/commons-fileupload/1.4, Apache-2.0, approved, clearlydefined +maven/mavencentral/commons-fileupload/commons-fileupload/1.5, Apache-2.0, approved, #7109 +maven/mavencentral/commons-io/commons-io/2.11.0, Apache-2.0, approved, CQ23745 maven/mavencentral/decentralized-identity/jsonld-common-java/1.1.0, , restricted, clearlydefined maven/mavencentral/info.weboftrust/ld-signatures-java/1.2.0, , restricted, clearlydefined maven/mavencentral/io.github.classgraph/classgraph/4.8.149, MIT, approved, CQ22530 @@ -78,7 +79,7 @@ maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-ui/2.0.4, Apac maven/mavencentral/org.springframework.boot/spring-boot-actuator-autoconfigure/3.1.4, Apache-2.0, approved, #9348 maven/mavencentral/org.springframework.boot/spring-boot-actuator/3.1.4, Apache-2.0, approved, #9342 maven/mavencentral/org.springframework.boot/spring-boot-autoconfigure/3.1.4, Apache-2.0, approved, #9341 -maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.1.4, , restricted, clearlydefined +maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.1.4, Apache-2.0, approved, clearlydefined maven/mavencentral/org.springframework.boot/spring-boot-starter-actuator/3.1.4, Apache-2.0, approved, #9344 maven/mavencentral/org.springframework.boot/spring-boot-starter-aop/3.1.4, Apache-2.0, approved, #9338 maven/mavencentral/org.springframework.boot/spring-boot-starter-json/3.1.4, Apache-2.0, approved, #9336 From a6889934707037f2ae7910fa905142053d36d4dd Mon Sep 17 00:00:00 2001 From: dvasunin Date: Fri, 6 Oct 2023 14:11:58 +0300 Subject: [PATCH 13/17] update license-tool-plugin version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8bc8558b..a1cccba5 100644 --- a/pom.xml +++ b/pom.xml @@ -268,7 +268,7 @@ org.eclipse.dash license-tool-plugin - 0.0.1-SNAPSHOT + 1.0.3-SNAPSHOT license-check From 4b265ad3fce95bfdaaaa6df3d31faf97a6068e01 Mon Sep 17 00:00:00 2001 From: adkumar1 Date: Mon, 9 Oct 2023 13:58:02 +0530 Subject: [PATCH 14/17] Update deployment.yaml Updating readiness, liveness probe --- charts/sdfactory/templates/deployment.yaml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/charts/sdfactory/templates/deployment.yaml b/charts/sdfactory/templates/deployment.yaml index 8288d90e..4f4ded72 100644 --- a/charts/sdfactory/templates/deployment.yaml +++ b/charts/sdfactory/templates/deployment.yaml @@ -112,17 +112,18 @@ spec: valueFrom: secretKeyRef: name: {{ include "sdfactory.applicationSecret.name" . }} - key: clearingHouse-clientSecret + key: clearingHouse-clientSecret - livenessProbe: - httpGet: - path: "/actuator/health/liveness" - port: {{ .Values.service.targetPort }} - # @url: https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-setting-up-health-checks-with-readiness-and-liveness-probes readinessProbe: - httpGet: - path: "/actuator/health/readiness" - port: {{ .Values.service.targetPort }} + tcpSocket: + port: { .Values.service.targetPort }} + initialDelaySeconds: 10 + periodSeconds: 10 + livenessProbe: + tcpSocket: + port: { .Values.service.targetPort }} + initialDelaySeconds: 10 + periodSeconds: 10 resources: {{- toYaml .Values.resources | nindent 12 }} From 0dc040b973dd10ac9c2ad7966728850f7ea47d41 Mon Sep 17 00:00:00 2001 From: adkumar1 Date: Mon, 9 Oct 2023 14:04:50 +0530 Subject: [PATCH 15/17] Update deployment.yaml brace correction --- charts/sdfactory/templates/deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/sdfactory/templates/deployment.yaml b/charts/sdfactory/templates/deployment.yaml index 4f4ded72..e4cff92a 100644 --- a/charts/sdfactory/templates/deployment.yaml +++ b/charts/sdfactory/templates/deployment.yaml @@ -116,12 +116,12 @@ spec: readinessProbe: tcpSocket: - port: { .Values.service.targetPort }} + port: {{ .Values.service.targetPort }} initialDelaySeconds: 10 periodSeconds: 10 livenessProbe: tcpSocket: - port: { .Values.service.targetPort }} + port: {{ .Values.service.targetPort }} initialDelaySeconds: 10 periodSeconds: 10 From 3102633209e413f203836efdce9658f9c4c75eae Mon Sep 17 00:00:00 2001 From: almadigabor Date: Tue, 10 Oct 2023 10:01:26 +0200 Subject: [PATCH 16/17] chore: update DEPENDENCIES file with dash --- DEPENDENCIES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index abcae8e6..0e41be85 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -20,7 +20,7 @@ maven/mavencentral/com.google.guava/guava/32.1.1-jre, Apache-2.0 AND CC0-1.0 AND 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.google.protobuf/protobuf-javalite/3.22.3, BSD-3-Clause, approved, clearlydefined -maven/mavencentral/com.goterl/lazysodium-java/5.1.1, NOASSERTION, restricted, clearlydefined +maven/mavencentral/com.goterl/lazysodium-java/5.1.1, MPL-2.0, approved, #10952 maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.31, Apache-2.0, approved, clearlydefined maven/mavencentral/com.squareup.okhttp3/okhttp/4.10.0, Apache-2.0 AND MPL-2.0, approved, #3057 maven/mavencentral/com.squareup.okio/okio-jvm/3.0.0, Apache-2.0, approved, clearlydefined From 2f78a295200357a7a93f2fe1f0f1ebfe048034a6 Mon Sep 17 00:00:00 2001 From: almadigabor Date: Tue, 17 Oct 2023 08:53:50 +0200 Subject: [PATCH 17/17] chore: updarte DEPENDENCIES file --- DEPENDENCIES | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index 0e41be85..440c3807 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,8 +1,8 @@ maven/mavencentral/ch.qos.logback/logback-classic/1.4.11, EPL-1.0 OR LGPL-2.1-only, approved, #3435 maven/mavencentral/ch.qos.logback/logback-core/1.4.11, EPL-1.0 OR LGPL-2.1-only, approved, #3373 maven/mavencentral/com.apicatalog/titanium-json-ld/1.1.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.danubetech/key-formats-java/1.6.0, , restricted, clearlydefined -maven/mavencentral/com.danubetech/verifiable-credentials-java/1.1.0, , restricted, clearlydefined +maven/mavencentral/com.danubetech/key-formats-java/1.6.0, None, restricted, #10950 +maven/mavencentral/com.danubetech/verifiable-credentials-java/1.1.0, None, restricted, #10953 maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.2, Apache-2.0, approved, #7947 maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.15.2, MIT AND Apache-2.0, approved, #7932 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.2, Apache-2.0, approved, #7934 @@ -27,8 +27,8 @@ maven/mavencentral/com.squareup.okio/okio-jvm/3.0.0, Apache-2.0, approved, clear maven/mavencentral/commons-codec/commons-codec/1.15, Apache-2.0 AND BSD-3-Clause AND LicenseRef-Public-Domain, approved, CQ22641 maven/mavencentral/commons-fileupload/commons-fileupload/1.5, Apache-2.0, approved, #7109 maven/mavencentral/commons-io/commons-io/2.11.0, Apache-2.0, approved, CQ23745 -maven/mavencentral/decentralized-identity/jsonld-common-java/1.1.0, , restricted, clearlydefined -maven/mavencentral/info.weboftrust/ld-signatures-java/1.2.0, , restricted, clearlydefined +maven/mavencentral/decentralized-identity/jsonld-common-java/1.1.0, Apache-2.0, approved, #10954 +maven/mavencentral/info.weboftrust/ld-signatures-java/1.2.0, None, restricted, #10951 maven/mavencentral/io.github.classgraph/classgraph/4.8.149, MIT, approved, CQ22530 maven/mavencentral/io.github.erdtman/java-json-canonicalization/1.1, Apache-2.0, approved, clearlydefined maven/mavencentral/io.github.openfeign.form/feign-form-spring/3.8.0, Apache-2.0, approved, clearlydefined