diff --git a/DEPENDENCIES_BACKEND b/DEPENDENCIES_BACKEND
index 329d42f5..d5be54a6 100644
--- a/DEPENDENCIES_BACKEND
+++ b/DEPENDENCIES_BACKEND
@@ -8,9 +8,7 @@ maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.15.3,
maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.15.3, Apache-2.0, approved, #7930
maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.15.3, Apache-2.0, approved, #8803
maven/mavencentral/com.fasterxml/classmate/1.6.0, Apache-2.0, approved, clearlydefined
-maven/mavencentral/com.github.stephenc.jcip/jcip-annotations/1.0-1, Apache-2.0, approved, CQ21949
maven/mavencentral/com.jayway.jsonpath/json-path/2.8.0, Apache-2.0, approved, clearlydefined
-maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.37.3, Apache-2.0, approved, #11701
maven/mavencentral/com.squareup.okhttp3/okhttp/4.12.0, Apache-2.0, approved, #11156
maven/mavencentral/com.squareup.okio/okio-jvm/3.6.0, Apache-2.0, approved, #11158
maven/mavencentral/com.squareup.okio/okio/3.6.0, Apache-2.0, approved, #11155
diff --git a/backend/DEPENDENCIES b/backend/DEPENDENCIES
index 329d42f5..d5be54a6 100644
--- a/backend/DEPENDENCIES
+++ b/backend/DEPENDENCIES
@@ -8,9 +8,7 @@ maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.15.3,
maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.15.3, Apache-2.0, approved, #7930
maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.15.3, Apache-2.0, approved, #8803
maven/mavencentral/com.fasterxml/classmate/1.6.0, Apache-2.0, approved, clearlydefined
-maven/mavencentral/com.github.stephenc.jcip/jcip-annotations/1.0-1, Apache-2.0, approved, CQ21949
maven/mavencentral/com.jayway.jsonpath/json-path/2.8.0, Apache-2.0, approved, clearlydefined
-maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.37.3, Apache-2.0, approved, #11701
maven/mavencentral/com.squareup.okhttp3/okhttp/4.12.0, Apache-2.0, approved, #11156
maven/mavencentral/com.squareup.okio/okio-jvm/3.6.0, Apache-2.0, approved, #11158
maven/mavencentral/com.squareup.okio/okio/3.6.0, Apache-2.0, approved, #11155
diff --git a/backend/pom.xml b/backend/pom.xml
index 68987a8f..e79e5871 100644
--- a/backend/pom.xml
+++ b/backend/pom.xml
@@ -1,9 +1,9 @@
-
- com.nimbusds
- nimbus-jose-jwt
- ${nimbus.version}
-
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/controller/EndpointDataReferenceReceiver.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/controller/EndpointDataReferenceReceiver.java
index 08b029eb..20bd59e6 100644
--- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/controller/EndpointDataReferenceReceiver.java
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/controller/EndpointDataReferenceReceiver.java
@@ -37,7 +37,6 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
-import java.util.Date;
import java.util.regex.Pattern;
/**
@@ -89,7 +88,7 @@ private ResponseEntity authCodeReceivingEndpoint(@RequestBody JsonNode b
return ResponseEntity.status(400).build();
}
- edrService.save(transferId, new EdrDto(authKey, authCode, endpoint, new Date()));
+ edrService.save(transferId, new EdrDto(authKey, authCode, endpoint));
log.debug("EDR endpoint stored authCode for " + transferId);
return ResponseEntity.status(200).build();
}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/dto/EdrDto.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/dto/EdrDto.java
index b8ccdb56..0efc4908 100644
--- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/dto/EdrDto.java
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/dto/EdrDto.java
@@ -23,20 +23,17 @@
import org.eclipse.tractusx.puris.backend.common.edc.logic.service.EndpointDataReferenceService;
-import java.util.Date;
-
/**
* An internal, immutable Dto class used by the {@link EndpointDataReferenceService}
* It contains an authKey, authCode and endpoint.
*
- * @param authKey This defines the key, under which the
- * authCode is to be sent to the data plane.
- * For example: "Authorization"
- * @param authCode This is the secret key to be sent
- * to the data plane.
- * @param endpoint The address of the data plane that has
- * to handle the consumer pull.
- * @param expiresAt The expiry data in ms till data
+ * @param authKey This defines the key, under which the
+ * authCode is to be sent to the data plane.
+ * For example: "Authorization"
+ * @param authCode This is the secret key to be sent
+ * to the data plane.
+ * @param endpoint The address of the data plane that has
+ * to handle the consumer pull.
*/
-public record EdrDto(String authKey, String authCode, String endpoint, Date expiresAt) {
+public record EdrDto(String authKey, String authCode, String endpoint) {
}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java
index 31238abe..a7df0baa 100644
--- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java
@@ -23,9 +23,6 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.nimbusds.jwt.JWT;
-import com.nimbusds.jwt.JWTClaimsSet;
-import com.nimbusds.jwt.JWTParser;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.eclipse.tractusx.puris.backend.common.edc.domain.model.SubmodelType;
@@ -36,12 +33,12 @@
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.MaterialPartnerRelation;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm.DirectionCharacteristic;
+import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
-import java.text.ParseException;
import java.util.*;
import java.util.regex.Pattern;
@@ -58,8 +55,6 @@ public class EdcAdapterService {
private final ObjectMapper objectMapper;
@Autowired
private EdcRequestBodyBuilder edcRequestBodyBuilder;
- @Autowired
- private EndpointDataReferenceService edrService;
@Autowired
private EdcContractMappingService edcContractMappingService;
@@ -580,16 +575,8 @@ private JsonNode getSubmodelFromPartner(MaterialPartnerRelation mpr, SubmodelTyp
break;
}
}
- EdrDto edrDto = null;
- // Await arrival of edr
- for (int i = 0; i < 100; i++) {
- Thread.sleep(100);
- edrDto = getEdrForTransferProcessId(transferId); //edrService.findByTransferId(transferId);
- if (edrDto != null) {
- log.info("Received EDR data for " + assetId + " with " + partner.getEdcUrl());
- break;
- }
- }
+ EdrDto edrDto = getAndAwaitEdrDto(transferId);
+ log.info("Received EDR data for " + assetId + " with " + partner.getEdcUrl());
if (edrDto == null) {
log.error("Failed to obtain EDR data for " + assetId + " with " + partner.getEdcUrl());
return doSubmodelRequest(type, mpr, direction, --retries);
@@ -622,6 +609,26 @@ private JsonNode getSubmodelFromPartner(MaterialPartnerRelation mpr, SubmodelTyp
return getSubmodelFromPartner(mpr, type, direction, --retries);
}
+ /**
+ * get the EDR via edr api and retry multiple times in case the EDR has not yet been available
+ *
+ * @param transferProcessId to get the EDR for, not null
+ * @return edr received, or null if not yet available
+ * @throws InterruptedException if thread was not able to sleep
+ */
+ private @Nullable EdrDto getAndAwaitEdrDto(String transferProcessId) throws InterruptedException {
+ EdrDto edrDto = null;
+ // retry, if Data Space Protocol / Data Plane Provisioning communication needs time to prepare
+ for (int i = 0; i < 100; i++) {
+ edrDto = getEdrForTransferProcessId(transferProcessId);
+ if (edrDto != null) {
+ break;
+ }
+ Thread.sleep(100);
+ }
+ return edrDto;
+ }
+
public JsonNode doSubmodelRequest(SubmodelType type, MaterialPartnerRelation mpr, DirectionCharacteristic direction, int retries) {
if (retries < 0) {
return null;
@@ -779,19 +786,12 @@ private JsonNode getAasSubmodelDescriptors(String manufacturerPartId, String man
break;
}
}
- EdrDto edrDto = null;
- // Await arrival of edr
- for (int i = 0; i < 100; i++) {
- edrDto = getEdrForTransferProcessId(transferId);//edrService.findByTransferId(transferId);
- if (edrDto != null) {
- log.info("Received EDR data for " + assetId + " with " + partner.getEdcUrl());
- break;
- }
- Thread.sleep(100);
- }
+ EdrDto edrDto = getAndAwaitEdrDto(transferId);
if (edrDto == null) {
log.error("Failed to obtain EDR data for " + assetId + " with " + partner.getEdcUrl());
return getAasSubmodelDescriptors(manufacturerPartId, manufacturerId, mpr, --retries);
+ } else {
+ log.info("Received EDR data for " + assetId + " with " + partner.getEdcUrl());
}
HttpUrl.Builder urlBuilder = HttpUrl.parse(edrDto.endpoint()).newBuilder()
.addPathSegment("api")
@@ -863,26 +863,6 @@ private JsonNode getAasSubmodelDescriptors(String manufacturerPartId, String man
*/
private EdrDto getEdrForTransferProcessId(String transferProcessId) {
- // Note: If we decode the auth token, we could add the exp as expiresAt so that I can store the EDR and lookup
- // again
- EdrDto storedEdr = edrService.findByTransferId(transferProcessId);
- log.debug("storedEdr: {}", storedEdr);
-
- // got a stored edr that has an auth token that will not expire within 5 seconds
- // Notes:
- // - this might cause an issue if there are different time zones between EDC and us
- // - we could also implement an ProxyRequestInterceptor that gets a fresh token for a TransferProcessId
- if (storedEdr != null && storedEdr.expiresAt().before(new Date(System.currentTimeMillis() + 5000))) {
- log.info("Reuse EDR directly as it will not expire within 5 seconds");
- return storedEdr;
- }
-
- if (storedEdr != null) {
- log.debug("Expiry edr: {} VS expiry within 5 sec {}", storedEdr.expiresAt(), new Date(System.currentTimeMillis() + 5000));
- } else {
- log.debug("No EDR token found");
- }
-
try (Response response = sendGetRequest(
List.of("v2", "edrs", transferProcessId, "dataaddress"),
Map.of("auto_refresh", "true"))
@@ -892,18 +872,11 @@ private EdrDto getEdrForTransferProcessId(String transferProcessId) {
String dataPlaneEndpoint = responseObject.get("endpoint").asText();
String authToken = responseObject.get("authorization").asText();
- JWT jwt = JWTParser.parse(authToken);
- JWTClaimsSet claims = jwt.getJWTClaimsSet();
- Date expirationTime = claims.getExpirationTime();
-
- storedEdr = new EdrDto("Authorization", authToken, dataPlaneEndpoint, expirationTime);
- edrService.save(transferProcessId, storedEdr);
- log.debug("Requested EDR successfully: {}", storedEdr);
+ EdrDto edr = new EdrDto("Authorization", authToken, dataPlaneEndpoint);
+ log.debug("Requested EDR successfully: {}", edr);
- return storedEdr;
+ return edr;
- } catch (ParseException e) {
- log.error("EDR token could not be parsed: {}", e);
} catch (IOException e) {
log.error("EDR token for transfer process with ID {} could not be obtained", transferProcessId);
}
@@ -937,7 +910,7 @@ private void terminateTransfer(String transferProcessId) {
log.info("Terminated transfer process with id {}.", transferProcessId);
}
} catch (IOException e) {
- log.error("Error while trying to terminate transfer: {}", e);
+ log.error("Error while trying to terminate transfer: ", e);
}
}
@@ -1058,7 +1031,7 @@ private boolean testContractPolicyConstraints(JsonNode catalogEntry) {
}
boolean result = true;
- if (constraint.isPresent() && constraint.get().isArray() && constraint.get().size() == 2) {
+ if (constraint.get().isArray() && constraint.get().size() == 2) {
Optional frameworkAgreementConstraint = Optional.empty();
Optional purposeConstraint = Optional.empty();
@@ -1106,7 +1079,7 @@ private boolean testContractPolicyConstraints(JsonNode catalogEntry) {
private boolean testSingleConstraint(Optional constraintToTest, String targetLeftOperand, String targetOperator, String targetRightOperand) {
- if (!constraintToTest.isPresent()) return false;
+ if (constraintToTest.isEmpty()) return false;
JsonNode con = constraintToTest.get();
@@ -1126,7 +1099,7 @@ private boolean testSingleConstraint(Optional constraintToTest, String
}
JsonNode rightOperandNode = con.get("odrl:rightOperand");
- if (operatorNode == null || !targetRightOperand.equals(rightOperandNode.asText())) {
+ if (rightOperandNode == null || !targetRightOperand.equals(rightOperandNode.asText())) {
String rightOperand = rightOperandNode == null ? "null" : rightOperandNode.asText();
log.debug("Right operand '{}' odes not equal expected value '{}'.", rightOperand, targetRightOperand);
return false;
diff --git a/local/tractus-x-edc/config/customer/puris-backend.properties b/local/tractus-x-edc/config/customer/puris-backend.properties
index 0a795e30..e4a5673d 100644
--- a/local/tractus-x-edc/config/customer/puris-backend.properties
+++ b/local/tractus-x-edc/config/customer/puris-backend.properties
@@ -11,16 +11,14 @@ puris.frameworkagreement.credential=puris
puris.frameworkagreement.version=1.0
puris.purpose.name=cx.puris.base
puris.purpose.version=1
-logging.level.org.eclipse.tractusx.puris.backend=DEBUG
+logging.level.org.eclipse.tractusx.puris.backend=INFO
puris.api.key=${CUSTOMER_BACKEND_API_KEY}
puris.dtr.url=http://dtr-customer:4243
puris.generatematerialcatenaxid=true
-
edc.controlplane.key=${EDC_API_PW}
edc.controlplane.management.url=http://customer-control-plane:8181/management
edc.controlplane.protocol.url=http://customer-control-plane:8184/api/v1/dsp
edc.dataplane.public.url=http://customer-data-plane:8285/api/public/
-
own.bpnl=BPNL4444444444XX
own.name=Control Unit Creator Inc.
own.bpns=BPNS4444444444XX
diff --git a/local/tractus-x-edc/config/supplier/puris-backend.properties b/local/tractus-x-edc/config/supplier/puris-backend.properties
index 035a70a5..3277e983 100644
--- a/local/tractus-x-edc/config/supplier/puris-backend.properties
+++ b/local/tractus-x-edc/config/supplier/puris-backend.properties
@@ -11,16 +11,14 @@ puris.frameworkagreement.credential=puris
puris.frameworkagreement.version=1.0
puris.purpose.name=cx.puris.base
puris.purpose.version=1
-logging.level.org.eclipse.tractusx.puris.backend=DEBUG
+logging.level.org.eclipse.tractusx.puris.backend=INFO
puris.api.key=${SUPPLIER_BACKEND_API_KEY}
puris.dtr.url=http://dtr-supplier:4243
puris.generatematerialcatenaxid=true
-
edc.controlplane.key=${EDC_API_PW}
edc.controlplane.management.url=http://supplier-control-plane:9181/management
edc.controlplane.protocol.url=http://supplier-control-plane:9184/api/v1/dsp
edc.dataplane.public.url=http://supplier-data-plane:9285/api/public/
-
own.bpnl=BPNL1234567890ZZ
own.name=Semiconductor Supplier Inc.
own.bpns=BPNS1234567890ZZ