From 2e8ec973d608bde573e8404076c7c38120f922e6 Mon Sep 17 00:00:00 2001 From: "Krzysztof Massalski (Extern)" Date: Tue, 7 May 2024 16:12:01 +0200 Subject: [PATCH 1/3] feat(impl):[#358] fix cid retrieval --- .../irs/edc/client/ContractNegotiationService.java | 8 +------- .../tractusx/irs/edc/client/EdcSubmodelClientImpl.java | 10 +--------- .../decentral/DecentralDigitalTwinRegistryService.java | 8 +------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java index e944066e97..107c90a202 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java @@ -43,7 +43,6 @@ import org.eclipse.tractusx.irs.edc.client.exceptions.UsagePolicyException; import org.eclipse.tractusx.irs.edc.client.model.CatalogItem; import org.eclipse.tractusx.irs.edc.client.model.ContractOffer; -import org.eclipse.tractusx.irs.edc.client.model.EDRAuthCode; import org.eclipse.tractusx.irs.edc.client.model.NegotiationRequest; import org.eclipse.tractusx.irs.edc.client.model.NegotiationResponse; import org.eclipse.tractusx.irs.edc.client.model.Response; @@ -95,12 +94,7 @@ public NegotiationResponse negotiate(final String providerConnectorUrl, final Ca contractAgreementId = negotiationResponse.getContractAgreementId(); } case EXPIRED -> { - final String authCode = resultEndpointDataReferenceStatus.endpointDataReference().getAuthCode(); - if (authCode == null) { - throw new IllegalStateException("Missing information about AuthKey."); - } - log.error("AuthCode to be parsed: {}", authCode); - contractAgreementId = EDRAuthCode.fromAuthCodeToken(authCode).getCid(); + contractAgreementId = resultEndpointDataReferenceStatus.endpointDataReference().getContractId(); log.info( "Cached endpoint data reference has expired token. Refreshing token without new contract negotiation for contractAgreementId: {}", Masker.mask(contractAgreementId)); diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java index 73c50742f6..0abebaabdd 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java @@ -37,7 +37,6 @@ import io.github.resilience4j.retry.RetryRegistry; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.validator.routines.UrlValidator; import org.eclipse.edc.spi.types.domain.edr.EndpointDataReference; import org.eclipse.tractusx.irs.edc.client.cache.endpointdatareference.EndpointDataReferenceCacheService; @@ -47,14 +46,12 @@ import org.eclipse.tractusx.irs.edc.client.exceptions.TransferProcessException; import org.eclipse.tractusx.irs.edc.client.exceptions.UsagePolicyException; import org.eclipse.tractusx.irs.edc.client.model.CatalogItem; -import org.eclipse.tractusx.irs.edc.client.model.EDRAuthCode; import org.eclipse.tractusx.irs.edc.client.model.NegotiationResponse; import org.eclipse.tractusx.irs.edc.client.model.SubmodelDescriptor; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotificationResponse; import org.eclipse.tractusx.irs.edc.client.model.notification.NotificationContent; import org.eclipse.tractusx.irs.edc.client.util.Masker; -import org.jetbrains.annotations.Nullable; import org.springframework.util.StopWatch; /** @@ -103,17 +100,12 @@ private Optional retrieveSubmodelData(final String submodelD stopWatchOnEdcTask(stopWatch); return Optional.of( - new SubmodelDescriptor(getContractAgreementId(endpointDataReference.getAuthCode()), payload)); + new SubmodelDescriptor(endpointDataReference.getContractId(), payload)); } return Optional.empty(); } - @Nullable - private String getContractAgreementId(final String authCode) { - return StringUtils.isNotBlank(authCode) ? EDRAuthCode.fromAuthCodeToken(authCode).getCid() : null; - } - private Optional retrieveEndpointReference(final String storageId, final StopWatch stopWatch) { diff --git a/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryService.java b/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryService.java index d7daf1c2f9..ea3ec0833d 100644 --- a/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryService.java +++ b/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryService.java @@ -27,7 +27,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -44,7 +43,6 @@ import org.eclipse.tractusx.irs.component.assetadministrationshell.AssetAdministrationShellDescriptor; import org.eclipse.tractusx.irs.component.assetadministrationshell.IdentifierKeyValuePair; import org.eclipse.tractusx.irs.edc.client.EdcConfiguration; -import org.eclipse.tractusx.irs.edc.client.model.EDRAuthCode; import org.eclipse.tractusx.irs.registryclient.DigitalTwinRegistryKey; import org.eclipse.tractusx.irs.registryclient.DigitalTwinRegistryService; import org.eclipse.tractusx.irs.registryclient.discovery.ConnectorEndpointsService; @@ -193,7 +191,7 @@ private List fetchShellDescriptorsForKey(final List new Shell(contractNegotiationId(endpointDataReference.getAuthCode()), + .map(key -> new Shell(endpointDataReference.getContractId(), fetchShellDescriptor(endpointDataReference, key))) .toList(); } finally { @@ -219,10 +217,6 @@ private AssetAdministrationShellDescriptor fetchShellDescriptor(final EndpointDa } } - private String contractNegotiationId(final String token) { - return Optional.ofNullable(token).map(EDRAuthCode::fromAuthCodeToken).map(EDRAuthCode::getCid).orElse(""); - } - /** * This method takes the provided ID and maps it to the corresponding asset administration shell ID. * If the ID is already a shellId, the same ID will be returned. From 0ea825fd72d5d73efa6d1bcacca92dd8572398ba Mon Sep 17 00:00:00 2001 From: Jaro Hartmann <57985712+ds-jhartmann@users.noreply.github.com> Date: Tue, 7 May 2024 16:39:07 +0200 Subject: [PATCH 2/3] chore(docs):[#358] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b654c974c1..9a56f67bba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ _**For better traceability add the corresponding GitHub issue number in each cha ## [Unreleased] +### Fixed + +- Fixed issue in EDR Token renewal #358 + ## [5.1.0] - 2024-05-06 ### Changed From ff052bfddb3c1b5705cd372572fddfa94fd70523 Mon Sep 17 00:00:00 2001 From: Jaro Hartmann <57985712+ds-jhartmann@users.noreply.github.com> Date: Tue, 7 May 2024 16:41:25 +0200 Subject: [PATCH 3/3] chore(docs):[#358] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02c1eb6884..6d4b8f8652 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha - Fixed issue in EDR Token renewal #358 -## Added +### Added - Cucumber test step definitions for Policy Store API (Happy Path) including some test helper utilities. #518