Skip to content

Commit

Permalink
Merge pull request #709 from catenax-ng/feature/#256-add-documentation
Browse files Browse the repository at this point in the history
feat(irs):[#256] added documentation, fixed problem with parsing authCode
  • Loading branch information
ds-psosnowski authored Jan 11, 2024
2 parents d22e9c2 + 5b47b1a commit 104bcfb
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
43 changes: 43 additions & 0 deletions docs/src/docs/arc42/cross-cutting/under-the-hood.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,46 @@ When the EDC Discovery is requested to return the EDC connector endpoint URLs fo
The time to live for both caches can be configured separately as described in the Administration Guide.

Further information on Discovery Service can be found in the chapter "System scope and context".

=== EDC

EndpointDataReferenceStorage is in-memory local storage that holds records (EndpointDataReferences) by either assetId or contractAgreementId.

When EDC gets EndpointDataReference describing endpoint serving data it uses EndpointDataReferenceStorage and query it by assetId.
This allows reuse of already existing EndpointDataReference if it is present, valid, and it's token is not expired,
rather than starting whole new contract negotiation process.

In case token is expired the process is also shortened. We don't have to start new contract negotiation process,
since we can obtain required contractAgreementId from present authCode. This improves request processing time.

[source, mermaid]
....
sequenceDiagram
autonumber
participant EdcSubmodelClient
participant ContractNegotiationService
participant EndpointDataReferenceStorage
participant EdcCallbackController
participant EdcDataPlaneClient
EdcSubmodelClient ->> EndpointDataReferenceStorage: Get EDR Token for EDC asset id
EndpointDataReferenceStorage ->> EdcSubmodelClient: Return Optional<EDR Token>
alt Token is present and not expired
EdcSubmodelClient ->> EdcSubmodelClient: Optional.get
else
alt Token is expired
EdcSubmodelClient ->> ContractNegotiationService: Renew EDR Token based on existing Token
else Token is not present
EdcSubmodelClient ->> ContractNegotiationService: Negotiate new EDR Token
end
ContractNegotiationService -->> EdcCallbackController: EDC flow
EdcCallbackController ->> EndpointDataReferenceStorage: Store EDR token by EDC asset id after EDC callback
loop While EDR Token is not present
EdcSubmodelClient ->> EndpointDataReferenceStorage: Poll for EDR Token
end
EndpointDataReferenceStorage ->> EdcSubmodelClient: Return EDR Token
end
EdcSubmodelClient ->> EdcDataPlaneClient: Get data(EDR Token, Dataplane URL)
EdcDataPlaneClient ->> EdcSubmodelClient: Return data
....


Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ public NegotiationResponse negotiate(final String providerConnectorUrl, final Ca
contractAgreementId = negotiationResponse.getContractAgreementId();
}
case EXPIRED -> {
final String authKey = resultEndpointDataReferenceStatus.endpointDataReference().getAuthKey();
if (authKey == null) {
final String authCode = resultEndpointDataReferenceStatus.endpointDataReference().getAuthCode();
if (authCode == null) {
throw new IllegalStateException("Missing information about AuthKey.");
}
contractAgreementId = EDRAuthCode.fromAuthCodeToken(authKey).getCid();
log.error("AuthCode to be parsed: " + authCode);
contractAgreementId = EDRAuthCode.fromAuthCodeToken(authCode).getCid();
log.info(
"Cached endpoint data reference has expired token. Refreshing token without new contract negotiation for contractAgreementId: {}",
Masker.mask(contractAgreementId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ private static String getStorageId(final EndpointDataReferenceStatus endpointDat
if (response != null) {
storageId = response.getContractAgreementId();
} else {
final String authKey = endpointDataReferenceStatus.endpointDataReference().getAuthKey();
if (authKey == null) {
throw new IllegalStateException("Missing information about AuthKey.");
final String authCode = endpointDataReferenceStatus.endpointDataReference().getAuthCode();
if (authCode == null) {
throw new IllegalStateException("Missing information about AuthCode.");
}
storageId = EDRAuthCode.fromAuthCodeToken(authKey).getCid();
storageId = EDRAuthCode.fromAuthCodeToken(authCode).getCid();
}
return storageId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ void shouldNotStartNewNegotiationWhenTokenIsExpired()
Response.builder().responseId("transferProcessId").build());
when(edcControlPlaneClient.getTransferProcess(any())).thenReturn(
CompletableFuture.completedFuture(TransferProcessResponse.builder().build()));
final String encodedAuthKey = "eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjE3MDA3NDc0NjMsImRhZCI6IkFXanRhclZySVdtaVE4V1R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bAig0KTAL2rN6WMufSWMjgLUU0mhRbd9bWvqs3JKLVzvagQgS3hMTj5a-C2Tw";

// when
testee.negotiate(CONNECTOR_URL, catalogItem, new EndpointDataReferenceStatus(
EndpointDataReference.Builder.newInstance().authKey(encodedAuthKey).endpoint("").authCode("").build(),
EndpointDataReference.Builder.newInstance().authKey("").authCode(encodedAuthCode).endpoint("").build(),
EndpointDataReferenceStatus.TokenStatus.EXPIRED));

// then
Expand Down

0 comments on commit 104bcfb

Please sign in to comment.