From c31a91811f1a0f6d0c3e30736e93102dde12c9fc Mon Sep 17 00:00:00 2001 From: ndr_brt Date: Wed, 14 Oct 2026 09:53:01 +0200 Subject: [PATCH] refactor: get rid of transfer samples --- README.md | 23 +- advanced/README.md | 2 +- advanced/advanced-01-open-telemetry/README.md | 6 +- .../docker-compose.yaml | 10 +- .../consumer-configuration.properties | 0 .../provider-configuration.properties | 0 .../resources/create-asset.json | 0 .../resources/create-contract-definition.json | 0 .../resources/create-policy.json | 0 basic/basic-04-event-consumer/README.md | 2 +- .../consumer-configuration.properties | 16 ++ federated-catalog/fc-00-basic/README.md | 15 +- .../participant-connector}/build.gradle.kts | 15 +- .../participant-connector/config.properties | 7 - .../resources/create-asset.json | 16 ++ .../resources/create-contract-definition.json | 9 + .../resources/create-policy.json | 14 ++ gradle/libs.versions.toml | 13 - policy/policy-01-policy-enforcement/README.md | 3 +- settings.gradle.kts | 6 +- system-tests/build.gradle.kts | 3 +- .../advanced/Advanced01openTelemetryTest.java | 9 +- .../basic/Basic04eventConsumerTest.java | 3 +- .../common/FederatedCatalogCommon.java | 10 +- .../common/FileTransferCloudCommon.java | 75 ------ .../edc/samples/common/NegotiationCommon.java | 26 +- .../samples/common/PrerequisitesCommon.java | 15 +- .../FederatedCatalog01embeddedTest.java | 10 +- .../FederatedCatalog02standaloneTest.java | 10 +- ...eratedCatalog03staticNodeResolverTest.java | 10 +- .../transfer/Transfer01negotiationTest.java | 55 ---- .../transfer/Transfer02providerPushTest.java | 59 ----- .../Transfer03httpProxyConsumerPullTest.java | 86 ------- .../util/HttpRequestLoggerConsumer.java | 36 --- .../util/HttpRequestLoggerContainer.java | 44 ---- transfer/README.md | 31 --- transfer/transfer-00-prerequisites/README.md | 63 ----- .../connector/build.gradle.kts | 55 ---- .../sample/runtime/SeedVaultExtension.java | 87 ------- ...rg.eclipse.edc.spi.system.ServiceExtension | 1 - transfer/transfer-01-negotiation/README.md | 238 ------------------ .../resources/fetch-catalog.json | 8 - .../resources/get-dataset.json | 8 - .../resources/negotiate-contract.json | 16 -- transfer/transfer-02-provider-push/README.md | 79 ------ .../resources/start-transfer.json | 15 -- transfer/transfer-03-consumer-pull/README.md | 193 -------------- .../proxy/CustomProxyDataPlaneExtension.java | 68 ----- .../extension/proxy/ProxyController.java | 87 ------- ...rg.eclipse.edc.spi.system.ServiceExtension | 1 - .../resources/start-transfer.json | 11 - util/README.md | 3 - util/http-request-logger/Dockerfile | 12 - util/http-request-logger/build.gradle.kts | 25 -- .../samples/util/HttpRequestLoggerServer.java | 56 ----- 55 files changed, 128 insertions(+), 1537 deletions(-) rename {transfer/transfer-00-prerequisites => advanced/advanced-01-open-telemetry}/resources/configuration/consumer-configuration.properties (100%) rename {transfer/transfer-00-prerequisites => advanced/advanced-01-open-telemetry}/resources/configuration/provider-configuration.properties (100%) rename {transfer/transfer-01-negotiation => advanced/advanced-01-open-telemetry}/resources/create-asset.json (100%) rename {transfer/transfer-01-negotiation => advanced/advanced-01-open-telemetry}/resources/create-contract-definition.json (100%) rename {transfer/transfer-01-negotiation => advanced/advanced-01-open-telemetry}/resources/create-policy.json (100%) create mode 100644 basic/basic-04-event-consumer/resources/configuration/consumer-configuration.properties rename {transfer/transfer-03-consumer-pull/provider-proxy-data-plane => federated-catalog/fc-00-basic/participant-connector}/build.gradle.kts (64%) rename transfer/transfer-03-consumer-pull/resources/configuration/provider.properties => federated-catalog/fc-00-basic/participant-connector/config.properties (50%) create mode 100644 federated-catalog/fc-00-basic/participant-connector/resources/create-asset.json create mode 100644 federated-catalog/fc-00-basic/participant-connector/resources/create-contract-definition.json create mode 100644 federated-catalog/fc-00-basic/participant-connector/resources/create-policy.json delete mode 100644 system-tests/src/test/java/org/eclipse/edc/samples/common/FileTransferCloudCommon.java delete mode 100644 system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer01negotiationTest.java delete mode 100644 system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer02providerPushTest.java delete mode 100644 system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer03httpProxyConsumerPullTest.java delete mode 100644 system-tests/src/test/java/org/eclipse/edc/samples/util/HttpRequestLoggerConsumer.java delete mode 100644 system-tests/src/test/java/org/eclipse/edc/samples/util/HttpRequestLoggerContainer.java delete mode 100644 transfer/README.md delete mode 100644 transfer/transfer-00-prerequisites/README.md delete mode 100644 transfer/transfer-00-prerequisites/connector/build.gradle.kts delete mode 100644 transfer/transfer-00-prerequisites/connector/src/main/java/org/eclipse/edc/sample/runtime/SeedVaultExtension.java delete mode 100644 transfer/transfer-00-prerequisites/connector/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension delete mode 100644 transfer/transfer-01-negotiation/README.md delete mode 100644 transfer/transfer-01-negotiation/resources/fetch-catalog.json delete mode 100644 transfer/transfer-01-negotiation/resources/get-dataset.json delete mode 100644 transfer/transfer-01-negotiation/resources/negotiate-contract.json delete mode 100644 transfer/transfer-02-provider-push/README.md delete mode 100644 transfer/transfer-02-provider-push/resources/start-transfer.json delete mode 100644 transfer/transfer-03-consumer-pull/README.md delete mode 100644 transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/java/org/eclipse/edc/sample/extension/proxy/CustomProxyDataPlaneExtension.java delete mode 100644 transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/java/org/eclipse/edc/sample/extension/proxy/ProxyController.java delete mode 100644 transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension delete mode 100644 transfer/transfer-03-consumer-pull/resources/start-transfer.json delete mode 100644 util/README.md delete mode 100644 util/http-request-logger/Dockerfile delete mode 100644 util/http-request-logger/build.gradle.kts delete mode 100644 util/http-request-logger/src/main/java/org/eclipse/edc/samples/util/HttpRequestLoggerServer.java diff --git a/README.md b/README.md index 491b3a82..1f238aa7 100644 --- a/README.md +++ b/README.md @@ -38,20 +38,6 @@ link above to learn about the basic samples in more detail. All basic samples are located in the `basic` directory. -### [Transfer](./transfer/README.md) - -This scope revolves around the topic of data transfer. In these samples you will learn how a data transfer works in the -EDC and run different transfer scenarios. Click the link above to learn about the transfer samples in more detail. - -All transfer samples are located in the `transfer` directory. - -### [Advanced](./advanced/README.md) - -Collection of advanced topics regarding the EDC framework. -Click the link above to learn about the transfer samples in more detail. - -All transfer samples are located in the `advanced` directory. - ### [Policy](./policy/README.md) These samples deal with the topic of policies and their evaluation and enforcement. They will teach you what @@ -69,6 +55,15 @@ a set of all offered catalogs. All federated catalog samples are located in the [`federated-catalog`](./federated-catalog/README.md) directory. +### [Advanced](./advanced/README.md) + +Collection of advanced topics regarding the EDC framework. +Click the link above to learn about the transfer samples in more detail. + +All transfer samples are located in the `advanced` directory. + + + ## Contributing See [how to contribute](https://github.com/eclipse-edc/docs/blob/main/CONTRIBUTING.md). diff --git a/advanced/README.md b/advanced/README.md index a9a645b3..70b363d4 100644 --- a/advanced/README.md +++ b/advanced/README.md @@ -2,7 +2,7 @@ The samples in this scope teach advanced topics about the EDC framework. -> Before starting with these samples, be sure to check out the [basic](../basic/README.md) and [transfer](../transfer/README.md) samples! +> Before starting with these samples, be sure to check out the [basic](../basic/README.md) samples! ## Samples diff --git a/advanced/advanced-01-open-telemetry/README.md b/advanced/advanced-01-open-telemetry/README.md index 79af79c7..31aedd80 100644 --- a/advanced/advanced-01-open-telemetry/README.md +++ b/advanced/advanced-01-open-telemetry/README.md @@ -41,7 +41,7 @@ Create an asset: ```bash curl -H "X-Api-Key: password" \ - -d @transfer/transfer-01-negotiation/resources/create-asset.json \ + -d @advanced/advanced-01-open-telemetry/resources/create-asset.json \ -H 'content-type: application/json' http://localhost:19193/management/v3/assets \ -s | jq ``` @@ -50,7 +50,7 @@ Create a Policy on the provider connector: ```bash curl -H "X-Api-Key: password" \ - -d @transfer/transfer-01-negotiation/resources/create-policy.json \ + -d @advanced/advanced-01-open-telemetry/resources/create-policy.json \ -H 'content-type: application/json' http://localhost:19193/management/v3/policydefinitions \ -s | jq ``` @@ -59,7 +59,7 @@ Follow up with the creation of a contract definition: ```bash curl -H "X-Api-Key: password" \ - -d @transfer/transfer-01-negotiation/resources/create-contract-definition.json \ + -d @advanced/advanced-01-open-telemetry/resources/create-contract-definition.json \ -H 'content-type: application/json' http://localhost:19193/management/v3/contractdefinitions \ -s | jq ``` diff --git a/advanced/advanced-01-open-telemetry/docker-compose.yaml b/advanced/advanced-01-open-telemetry/docker-compose.yaml index f754395f..2a084b49 100644 --- a/advanced/advanced-01-open-telemetry/docker-compose.yaml +++ b/advanced/advanced-01-open-telemetry/docker-compose.yaml @@ -7,7 +7,6 @@ services: context: open-telemetry-runtime volumes: - ./:/open-telemetry - - ../../transfer/transfer-00-prerequisites/:/prerequisites ports: - "29193:29193" - "29194:29194" @@ -34,9 +33,7 @@ services: EDC_CONTROL_ENDPOINT: http://consumer:29192/control EDC_DSP_CALLBACK_ADDRESS: http://consumer:29194/protocol EDC_PARTICIPANT_ID: consumer - EDC_KEYSTORE: /prerequisites/resources/certs/cert.pfx - EDC_KEYSTORE_PASSWORD: 123456 - EDC_FS_CONFIG: /prerequisites/resources/configuration/provider-configuration.properties + EDC_FS_CONFIG: /open-telemetry/resources/configuration/provider-configuration.properties EDC_DPF_SELECTOR_URL: http://localhost:29192/control entrypoint: java -javaagent:/app/opentelemetry-javaagent.jar @@ -48,7 +45,6 @@ services: context: open-telemetry-runtime volumes: - ./:/open-telemetry - - ../../transfer/transfer-00-prerequisites/:/prerequisites ports: - "19193:19193" - "19192:19192" @@ -74,9 +70,7 @@ services: EDC_CONTROL_ENDPOINT: http://provider:19192/control EDC_DSP_CALLBACK_ADDRESS: http://provider:19194/protocol EDC_PARTICIPANT_ID: provider - EDC_KEYSTORE: /prerequisites/resources/certs/cert.pfx - EDC_KEYSTORE_PASSWORD: 123456 - EDC_FS_CONFIG: /prerequisites/resources/configuration/consumer-configuration.properties + EDC_FS_CONFIG: /open-telemetry/resources/configuration/consumer-configuration.properties EDC_SAMPLES_TRANSFER_01_ASSET_PATH: /open-telemetry/README.md EDC_DPF_SELECTOR_URL: http://localhost:29192/control entrypoint: java diff --git a/transfer/transfer-00-prerequisites/resources/configuration/consumer-configuration.properties b/advanced/advanced-01-open-telemetry/resources/configuration/consumer-configuration.properties similarity index 100% rename from transfer/transfer-00-prerequisites/resources/configuration/consumer-configuration.properties rename to advanced/advanced-01-open-telemetry/resources/configuration/consumer-configuration.properties diff --git a/transfer/transfer-00-prerequisites/resources/configuration/provider-configuration.properties b/advanced/advanced-01-open-telemetry/resources/configuration/provider-configuration.properties similarity index 100% rename from transfer/transfer-00-prerequisites/resources/configuration/provider-configuration.properties rename to advanced/advanced-01-open-telemetry/resources/configuration/provider-configuration.properties diff --git a/transfer/transfer-01-negotiation/resources/create-asset.json b/advanced/advanced-01-open-telemetry/resources/create-asset.json similarity index 100% rename from transfer/transfer-01-negotiation/resources/create-asset.json rename to advanced/advanced-01-open-telemetry/resources/create-asset.json diff --git a/transfer/transfer-01-negotiation/resources/create-contract-definition.json b/advanced/advanced-01-open-telemetry/resources/create-contract-definition.json similarity index 100% rename from transfer/transfer-01-negotiation/resources/create-contract-definition.json rename to advanced/advanced-01-open-telemetry/resources/create-contract-definition.json diff --git a/transfer/transfer-01-negotiation/resources/create-policy.json b/advanced/advanced-01-open-telemetry/resources/create-policy.json similarity index 100% rename from transfer/transfer-01-negotiation/resources/create-policy.json rename to advanced/advanced-01-open-telemetry/resources/create-policy.json diff --git a/basic/basic-04-event-consumer/README.md b/basic/basic-04-event-consumer/README.md index 60209269..2c43529c 100644 --- a/basic/basic-04-event-consumer/README.md +++ b/basic/basic-04-event-consumer/README.md @@ -44,7 +44,7 @@ public void on(EventEnvelope envelope) { ```bash ./gradlew basic:basic-04-event-consumer:connector-with-event-subscriber:build -java -Dedc.fs.config=transfer/transfer-00-prerequisites/resources/configuration/consumer-configuration.properties \ +java -Dedc.fs.config=basic/basic-04-event-consumer/resources/configuration/consumer-configuration.properties \ -jar basic/basic-04-event-consumer/connector-with-event-subscriber/build/libs/connector.jar ``` diff --git a/basic/basic-04-event-consumer/resources/configuration/consumer-configuration.properties b/basic/basic-04-event-consumer/resources/configuration/consumer-configuration.properties new file mode 100644 index 00000000..5d680385 --- /dev/null +++ b/basic/basic-04-event-consumer/resources/configuration/consumer-configuration.properties @@ -0,0 +1,16 @@ +edc.participant.id=consumer +edc.dsp.callback.address=http://localhost:29194/protocol +web.http.port=29191 +web.http.path=/api +web.http.management.port=29193 +web.http.management.path=/management +web.http.protocol.port=29194 +web.http.protocol.path=/protocol +web.http.public.port=29291 +web.http.public.path=/public +web.http.control.port=29192 +web.http.control.path=/control\ +web.http.signaling.port=29196 +web.http.signaling.path=/signaling +edc.transfer.proxy.token.signer.privatekey.alias=private-key +edc.transfer.proxy.token.verifier.publickey.alias=public-key diff --git a/federated-catalog/fc-00-basic/README.md b/federated-catalog/fc-00-basic/README.md index 95eecf0e..0aee7551 100644 --- a/federated-catalog/fc-00-basic/README.md +++ b/federated-catalog/fc-00-basic/README.md @@ -51,24 +51,23 @@ can successfully request and retrieve these catalogs, we need at least one conne Therefore, in this section, we will start a connector and then create a contract for this connector. In the future samples, we will refer to it as `participant-connector`. This `participant-connector` will function as a provider. -We will use the resources from the [transfer](../../transfer) sample to set up this connector. In the rest of this section we will, +The `participant-connector` is a minimal control-plane connector that lives in the +[participant-connector](./participant-connector) module. In the rest of this section we will, * run the `participant-connector` * create an asset for this `participant-connector` * create a policy * create a contract offer -Although these topics were covered in the [transfer](../../transfer) section, we’ll document all the necessary commands here for easier execution. - #### Build connector jar Use the following command to build a connector jar. ```shell -./gradlew transfer:transfer-00-prerequisites:connector:build +./gradlew federated-catalog:fc-00-basic:participant-connector:build ``` #### Run the connector Execute the following to run the connector jar. ```shell -java -Dedc.fs.config=transfer/transfer-00-prerequisites/resources/configuration/provider-configuration.properties -jar transfer/transfer-00-prerequisites/connector/build/libs/connector.jar +java -Dedc.fs.config=federated-catalog/fc-00-basic/participant-connector/config.properties -jar federated-catalog/fc-00-basic/participant-connector/build/libs/participant-connector.jar ``` --- @@ -76,21 +75,21 @@ java -Dedc.fs.config=transfer/transfer-00-prerequisites/resources/configuration/ Once the connector is running, carry out the commands below in sequence. #### Create an asset ```shell -curl -d @transfer/transfer-01-negotiation/resources/create-asset.json \ +curl -d @federated-catalog/fc-00-basic/participant-connector/resources/create-asset.json \ -H 'content-type: application/json' http://localhost:19193/management/v3/assets \ -s | jq ``` #### Create a policy ```bash -curl -d @transfer/transfer-01-negotiation/resources/create-policy.json \ +curl -d @federated-catalog/fc-00-basic/participant-connector/resources/create-policy.json \ -H 'content-type: application/json' http://localhost:19193/management/v3/policydefinitions \ -s | jq ``` #### Create a contract definition ```bash -curl -d @transfer/transfer-01-negotiation/resources/create-contract-definition.json \ +curl -d @federated-catalog/fc-00-basic/participant-connector/resources/create-contract-definition.json \ -H 'content-type: application/json' http://localhost:19193/management/v3/contractdefinitions \ -s | jq ``` diff --git a/transfer/transfer-03-consumer-pull/provider-proxy-data-plane/build.gradle.kts b/federated-catalog/fc-00-basic/participant-connector/build.gradle.kts similarity index 64% rename from transfer/transfer-03-consumer-pull/provider-proxy-data-plane/build.gradle.kts rename to federated-catalog/fc-00-basic/participant-connector/build.gradle.kts index 4e20f324..7f458ce1 100644 --- a/transfer/transfer-03-consumer-pull/provider-proxy-data-plane/build.gradle.kts +++ b/federated-catalog/fc-00-basic/participant-connector/build.gradle.kts @@ -12,7 +12,6 @@ * */ - plugins { `java-library` id("application") @@ -20,26 +19,20 @@ plugins { } dependencies { - implementation(libs.edc.data.plane.spi) - implementation(libs.edc.web.spi) - - runtimeOnly(project(":transfer:transfer-00-prerequisites:connector")) + runtimeOnly(libs.edc.bom.controlplane.base) + runtimeOnly(libs.edc.iam.mock) } application { - mainClass.set("$group.boot.system.runtime.BaseRuntime") + mainClass.set("org.eclipse.edc.boot.system.runtime.BaseRuntime") } var distTar = tasks.getByName("distTar") var distZip = tasks.getByName("distZip") -tasks.withType { - dependsOn(":transfer:transfer-00-prerequisites:connector:shadowJar") -} - tasks.shadowJar { mergeServiceFiles() - archiveFileName.set("connector.jar") + archiveFileName.set("participant-connector.jar") dependsOn(distTar, distZip) duplicatesStrategy = DuplicatesStrategy.INCLUDE } diff --git a/transfer/transfer-03-consumer-pull/resources/configuration/provider.properties b/federated-catalog/fc-00-basic/participant-connector/config.properties similarity index 50% rename from transfer/transfer-03-consumer-pull/resources/configuration/provider.properties rename to federated-catalog/fc-00-basic/participant-connector/config.properties index 7c924a47..d4a1a5ed 100644 --- a/transfer/transfer-03-consumer-pull/resources/configuration/provider.properties +++ b/federated-catalog/fc-00-basic/participant-connector/config.properties @@ -6,12 +6,5 @@ web.http.management.port=19193 web.http.management.path=/management web.http.protocol.port=19194 web.http.protocol.path=/protocol -edc.transfer.proxy.token.signer.privatekey.alias=private-key -edc.transfer.proxy.token.verifier.publickey.alias=public-key -web.http.public.port=19291 -web.http.public.path=/public web.http.control.port=19192 web.http.control.path=/control -web.http.signaling.port=19195 -web.http.signaling.path=/signaling -edc.dataplane.proxy.public.endpoint=http://localhost:19291/public diff --git a/federated-catalog/fc-00-basic/participant-connector/resources/create-asset.json b/federated-catalog/fc-00-basic/participant-connector/resources/create-asset.json new file mode 100644 index 00000000..018e9f6e --- /dev/null +++ b/federated-catalog/fc-00-basic/participant-connector/resources/create-asset.json @@ -0,0 +1,16 @@ +{ + "@context": { + "@vocab": "https://w3id.org/edc/v0.0.1/ns/" + }, + "@id": "assetId", + "properties": { + "name": "product description", + "contenttype": "application/json" + }, + "dataAddress": { + "type": "HttpData", + "name": "Test asset", + "baseUrl": "https://jsonplaceholder.typicode.com/users", + "proxyPath": "true" + } +} diff --git a/federated-catalog/fc-00-basic/participant-connector/resources/create-contract-definition.json b/federated-catalog/fc-00-basic/participant-connector/resources/create-contract-definition.json new file mode 100644 index 00000000..5ee5c67f --- /dev/null +++ b/federated-catalog/fc-00-basic/participant-connector/resources/create-contract-definition.json @@ -0,0 +1,9 @@ +{ + "@context": { + "@vocab": "https://w3id.org/edc/v0.0.1/ns/" + }, + "@id": "1", + "accessPolicyId": "aPolicy", + "contractPolicyId": "aPolicy", + "assetsSelector": [] +} diff --git a/federated-catalog/fc-00-basic/participant-connector/resources/create-policy.json b/federated-catalog/fc-00-basic/participant-connector/resources/create-policy.json new file mode 100644 index 00000000..cf7a4703 --- /dev/null +++ b/federated-catalog/fc-00-basic/participant-connector/resources/create-policy.json @@ -0,0 +1,14 @@ +{ + "@context": { + "@vocab": "https://w3id.org/edc/v0.0.1/ns/", + "odrl": "http://www.w3.org/ns/odrl/2/" + }, + "@id": "aPolicy", + "policy": { + "@context": "http://www.w3.org/ns/odrl.jsonld", + "@type": "Set", + "permission": [], + "prohibition": [], + "obligation": [] + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dd749990..b19c4bef 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,23 +13,13 @@ testcontainers = "1.21.4" edc-boot = { module = "org.eclipse.edc:boot", version.ref = "edc" } edc-asset-spi = { module = "org.eclipse.edc:asset-spi", version.ref = "edc" } edc-bom-controlplane-base = { module = "org.eclipse.edc:controlplane-base-bom", version.ref = "edc" } -edc-bom-dataplane-base = { module = "org.eclipse.edc:dataplane-base-bom", version.ref = "edc" } edc-configuration-filesystem = { module = "org.eclipse.edc:configuration-filesystem", version.ref = "edc" } edc-connector-core = { module = "org.eclipse.edc:connector-core", version.ref = "edc" } -edc-control-plane-api-client = { module = "org.eclipse.edc:control-plane-api-client", version.ref = "edc" } edc-control-plane-core = { module = "org.eclipse.edc:control-plane-core", version.ref = "edc" } edc-control-plane-spi = { module = "org.eclipse.edc:control-plane-spi", version.ref = "edc" } -edc-data-plane-signaling-api = { module = "org.eclipse.edc:data-plane-signaling-api", version.ref = "edc" } -edc-data-plane-signaling-client = { module = "org.eclipse.edc:data-plane-signaling-client", version.ref = "edc" } -edc-data-plane-core = { module = "org.eclipse.edc:data-plane-core", version.ref = "edc" } -edc-data-plane-http = { module = "org.eclipse.edc:data-plane-http", version.ref = "edc" } -edc-data-plane-iam = { module = "org.eclipse.edc:data-plane-iam", version.ref = "edc" } -edc-data-plane-self-registration = { module = "org.eclipse.edc:data-plane-self-registration", version.ref = "edc" } edc-data-plane-spi = { module = "org.eclipse.edc:data-plane-spi", version.ref = "edc" } edc-dsp = { module = "org.eclipse.edc:dsp", version.ref = "edc" } -edc-edr-cache-api = { module = "org.eclipse.edc:edr-cache-api", version.ref = "edc" } edc-edr-store-core = { module = "org.eclipse.edc:edr-store-core", version.ref = "edc" } -edc-edr-store-receiver = { module = "org.eclipse.edc:edr-store-receiver", version.ref = "edc" } edc-federatedcatalog-base-bom = { module = "org.eclipse.edc:federatedcatalog-base-bom", version.ref = "edc" } edc-fc-spi-crawler = { module = "org.eclipse.edc:crawler-spi", version.ref = "edc" } edc-http = { module = "org.eclipse.edc:http", version.ref = "edc" } @@ -43,9 +33,6 @@ edc-participant-context-config-spi = { module = "org.eclipse.edc:participant-con edc-runtime-core = { module = "org.eclipse.edc:runtime-core", version.ref = "edc" } edc-token-core = { module = "org.eclipse.edc:token-core", version.ref = "edc" } edc-transfer-spi = { module = "org.eclipse.edc:transfer-spi", version.ref = "edc" } -edc-transfer-data-plane-signaling = { module = "org.eclipse.edc:transfer-data-plane-signaling", version.ref = "edc" } -edc-validator-data-address-http-data = { module = "org.eclipse.edc:validator-data-address-http-data", version.ref = "edc" } -edc-web-spi = { module = "org.eclipse.edc:web-spi", version.ref = "edc" } awaitility = { module = "org.awaitility:awaitility", version.ref = "awaitility" } jakarta-rsApi = { module = "jakarta.ws.rs:jakarta.ws.rs-api", version.ref = "rsApi" } diff --git a/policy/policy-01-policy-enforcement/README.md b/policy/policy-01-policy-enforcement/README.md index 1d0abcf2..70c1c121 100644 --- a/policy/policy-01-policy-enforcement/README.md +++ b/policy/policy-01-policy-enforcement/README.md @@ -119,8 +119,7 @@ In the build file, we define the following dependencies for both connectors: **Note**: we do not include any `data-plane` modules, as we are not going to transfer any data in this sample. To be able to actually transfer data, additional dependencies are required. More information can be found in the -[documentation](https://github.com/eclipse-edc/Connector/blob/main/docs/developer/build-your-own-connector.md) and in -the [transfer samples](../../transfer/README.md). +[documentation](https://github.com/eclipse-edc/Connector/blob/main/docs/developer/build-your-own-connector.md). #### Provider diff --git a/settings.gradle.kts b/settings.gradle.kts index 8acf41cb..fdeac611 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -33,9 +33,6 @@ include(":basic:basic-02-health-endpoint") include(":basic:basic-03-configuration") include(":basic:basic-04-event-consumer:connector-with-event-subscriber") -include(":transfer:transfer-00-prerequisites:connector") -include(":transfer:transfer-03-consumer-pull:provider-proxy-data-plane") - include(":advanced:advanced-01-open-telemetry:open-telemetry-runtime") //policy @@ -46,6 +43,7 @@ include(":policy:policy-01-policy-enforcement:policy-functions") // federated catalog include(":federated-catalog:fc-00-basic:federated-catalog-base") include(":federated-catalog:fc-00-basic:fixed-node-resolver") +include(":federated-catalog:fc-00-basic:participant-connector") include(":federated-catalog:fc-01-embedded:fc-connector") include(":federated-catalog:fc-02-standalone:standalone-fc") include(":federated-catalog:fc-03-static-node-directory:target-node-resolver") @@ -56,6 +54,4 @@ include(":federated-catalog:fc-03-static-node-directory:embedded-fc-with-node-re // modules for code samples ------------------------------------------------------------------------ include(":advanced:advanced-02-custom-runtime") -include(":util:http-request-logger") - include(":system-tests") diff --git a/system-tests/build.gradle.kts b/system-tests/build.gradle.kts index d8c9d755..adbdd833 100644 --- a/system-tests/build.gradle.kts +++ b/system-tests/build.gradle.kts @@ -36,8 +36,6 @@ dependencies { testCompileOnly(project(":basic:basic-02-health-endpoint")) testCompileOnly(project(":basic:basic-03-configuration")) - testCompileOnly(project(":transfer:transfer-00-prerequisites:connector")) - testCompileOnly(project(":transfer:transfer-03-consumer-pull:provider-proxy-data-plane")) testCompileOnly(project(":basic:basic-04-event-consumer:connector-with-event-subscriber")) testCompileOnly(project(":advanced:advanced-01-open-telemetry:open-telemetry-runtime")) @@ -47,6 +45,7 @@ dependencies { testCompileOnly(project(":policy:policy-01-policy-enforcement:policy-functions")) testCompileOnly(project(":federated-catalog:fc-00-basic:fixed-node-resolver")) + testCompileOnly(project(":federated-catalog:fc-00-basic:participant-connector")) testCompileOnly(project(":federated-catalog:fc-01-embedded:fc-connector")) testCompileOnly(project(":federated-catalog:fc-02-standalone:standalone-fc")) testCompileOnly(project(":federated-catalog:fc-03-static-node-directory:target-node-resolver")) diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/advanced/Advanced01openTelemetryTest.java b/system-tests/src/test/java/org/eclipse/edc/samples/advanced/Advanced01openTelemetryTest.java index 5f9d73ad..56a39bf2 100644 --- a/system-tests/src/test/java/org/eclipse/edc/samples/advanced/Advanced01openTelemetryTest.java +++ b/system-tests/src/test/java/org/eclipse/edc/samples/advanced/Advanced01openTelemetryTest.java @@ -41,6 +41,9 @@ public class Advanced01openTelemetryTest { private static final String SAMPLE_FOLDER = "advanced/advanced-01-open-telemetry"; private static final String DOCKER_COMPOSE_YAML = SAMPLE_FOLDER + "/docker-compose.yaml"; + private static final String CREATE_ASSET_FILE_PATH = SAMPLE_FOLDER + "/resources/create-asset.json"; + private static final String CREATE_POLICY_FILE_PATH = SAMPLE_FOLDER + "/resources/create-policy.json"; + private static final String CREATE_CONTRACT_DEFINITION_FILE_PATH = SAMPLE_FOLDER + "/resources/create-contract-definition.json"; private static final String FETCH_DATASET_FROM_CATALOG_FILE_PATH = SAMPLE_FOLDER + "/resources/get-dataset.json"; private static final String NEGOTIATE_CONTRACT_FILE_PATH = SAMPLE_FOLDER + "/resources/negotiate-contract.json"; private static final String START_TRANSFER_FILE_PATH = SAMPLE_FOLDER + "/resources/start-transfer.json"; @@ -54,9 +57,9 @@ public class Advanced01openTelemetryTest { @Test void runSampleSteps() { - createAsset(); - createPolicy(); - createContractDefinition(); + createAsset(CREATE_ASSET_FILE_PATH); + createPolicy(CREATE_POLICY_FILE_PATH); + createContractDefinition(CREATE_CONTRACT_DEFINITION_FILE_PATH); var catalogDatasetId = fetchDatasetFromCatalog(FETCH_DATASET_FROM_CATALOG_FILE_PATH); var contractNegotiationId = negotiateContract(NEGOTIATE_CONTRACT_FILE_PATH, catalogDatasetId); var contractAgreementId = getContractAgreementId(contractNegotiationId); diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/basic/Basic04eventConsumerTest.java b/system-tests/src/test/java/org/eclipse/edc/samples/basic/Basic04eventConsumerTest.java index d08af46f..6060b3d0 100644 --- a/system-tests/src/test/java/org/eclipse/edc/samples/basic/Basic04eventConsumerTest.java +++ b/system-tests/src/test/java/org/eclipse/edc/samples/basic/Basic04eventConsumerTest.java @@ -33,11 +33,12 @@ class Basic04eventConsumerTest { private static final String CONNECTOR_MODULE_PATH = ":basic:basic-04-event-consumer:connector-with-event-subscriber"; + private static final String CONFIG_PROPERTIES_FILE_PATH = "basic/basic-04-event-consumer/resources/configuration/consumer-configuration.properties"; private static final String CREATE_ASSET_FILE_PATH = "basic/basic-04-event-consumer/resources/create-asset.json"; private static final String V3_ASSETS_PATH = "/v3/assets"; @RegisterExtension - static RuntimeExtension connector = getConsumer(CONNECTOR_MODULE_PATH); + static RuntimeExtension connector = getConsumer(CONNECTOR_MODULE_PATH, CONFIG_PROPERTIES_FILE_PATH); @Test void runSampleSteps() { diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/common/FederatedCatalogCommon.java b/system-tests/src/test/java/org/eclipse/edc/samples/common/FederatedCatalogCommon.java index 20199175..3c2dc2e9 100644 --- a/system-tests/src/test/java/org/eclipse/edc/samples/common/FederatedCatalogCommon.java +++ b/system-tests/src/test/java/org/eclipse/edc/samples/common/FederatedCatalogCommon.java @@ -36,7 +36,11 @@ import static org.hamcrest.Matchers.emptyString; public class FederatedCatalogCommon { - private static final String CREATE_ASSET_FILE_PATH = "transfer/transfer-01-negotiation/resources/create-asset.json"; + public static final String PARTICIPANT_CONNECTOR_MODULE_PATH = ":federated-catalog:fc-00-basic:participant-connector"; + public static final String PARTICIPANT_CONNECTOR_CONFIG_PROPERTIES_FILE_PATH = "federated-catalog/fc-00-basic/participant-connector/config.properties"; + public static final String CREATE_ASSET_FILE_PATH = "federated-catalog/fc-00-basic/participant-connector/resources/create-asset.json"; + public static final String CREATE_POLICY_FILE_PATH = "federated-catalog/fc-00-basic/participant-connector/resources/create-policy.json"; + public static final String CREATE_CONTRACT_DEFINITION_FILE_PATH = "federated-catalog/fc-00-basic/participant-connector/resources/create-contract-definition.json"; private static final String V3_ASSETS_PATH = "/v3/assets"; private static final String STANDALONE_FC = "standalone-fc"; @@ -56,6 +60,10 @@ public class FederatedCatalogCommon { public static final String TYPE = "[0].@type"; public static final String DATASET_ASSET_ID = "[0].dataset[0].@id"; + public static RuntimeExtension getParticipantConnector() { + return PrerequisitesCommon.getProvider(PARTICIPANT_CONNECTOR_MODULE_PATH, PARTICIPANT_CONNECTOR_CONFIG_PROPERTIES_FILE_PATH); + } + public static RuntimeExtension getFcEmbeddedConnector(String modulePath) { return getRuntime(modulePath, EMBEDDED_FC, FC_CONNECTOR_CONFIG_PROPERTIES_FILE_PATH); } diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/common/FileTransferCloudCommon.java b/system-tests/src/test/java/org/eclipse/edc/samples/common/FileTransferCloudCommon.java deleted file mode 100644 index 471a9cc0..00000000 --- a/system-tests/src/test/java/org/eclipse/edc/samples/common/FileTransferCloudCommon.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2022 Microsoft Corporation - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Materna Information & Communications SE - initial test implementation for sample - * - */ - -package org.eclipse.edc.samples.common; - -import java.util.Objects; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.awaitility.Awaitility.await; -import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath; -import static org.eclipse.edc.samples.util.TransferUtil.POLL_INTERVAL; -import static org.eclipse.edc.samples.util.TransferUtil.TIMEOUT; -import static org.eclipse.edc.samples.util.TransferUtil.get; -import static org.eclipse.edc.samples.util.TransferUtil.post; - -public class FileTransferCloudCommon { - - private static final String CONSUMER_MANAGEMENT_URL = "http://localhost:29193/management"; - private static final String V3_CATALOG_DATASET_REQUEST_PATH = "/v3/catalog/dataset/request"; - private static final String FETCH_DATASET_FROM_CATALOG_FILE_PATH = "transfer/transfer-05-file-transfer-cloud/resources/get-dataset.json"; - private static final String CATALOG_DATASET_ID = "\"hasPolicy\"[0].'@id'"; - private static final String NEGOTIATE_CONTRACT_FILE_PATH = "transfer/transfer-05-file-transfer-cloud/resources/negotiate-contract.json"; - private static final String V3_CONTRACT_NEGOTIATIONS_PATH = "/v3/contractnegotiations/"; - private static final String CONTRACT_NEGOTIATION_ID = "@id"; - private static final String CONTRACT_AGREEMENT_ID = "contractAgreementId"; - private static final String CONTRACT_OFFER_ID_KEY = "{{contract-offer-id}}"; - - public static String fetchDatasetFromCatalog(String fetchDatasetFromCatalogFilePath) { - var catalogDatasetId = post( - CONSUMER_MANAGEMENT_URL + V3_CATALOG_DATASET_REQUEST_PATH, - getFileContentFromRelativePath(fetchDatasetFromCatalogFilePath), - CATALOG_DATASET_ID - ); - assertThat(catalogDatasetId).isNotEmpty(); - return catalogDatasetId; - } - - public static String negotiateContract(String negotiateContractFilePath, String catalogDatasetId) { - var requestBody = getFileContentFromRelativePath(negotiateContractFilePath) - .replace(CONTRACT_OFFER_ID_KEY, catalogDatasetId); - var contractNegotiationId = post( - CONSUMER_MANAGEMENT_URL + V3_CONTRACT_NEGOTIATIONS_PATH, - requestBody, - CONTRACT_NEGOTIATION_ID - ); - assertThat(contractNegotiationId).isNotEmpty(); - return contractNegotiationId; - } - - public static String getContractAgreementId(String contractNegotiationId) { - var url = CONSUMER_MANAGEMENT_URL + V3_CONTRACT_NEGOTIATIONS_PATH + contractNegotiationId; - return await() - .atMost(TIMEOUT) - .pollInterval(POLL_INTERVAL) - .until(() -> get(url, CONTRACT_AGREEMENT_ID), Objects::nonNull); - } - - public static String runNegotiation() { - var catalogDatasetId = fetchDatasetFromCatalog(FETCH_DATASET_FROM_CATALOG_FILE_PATH); - var contractNegotiationId = negotiateContract(NEGOTIATE_CONTRACT_FILE_PATH, catalogDatasetId); - return getContractAgreementId(contractNegotiationId); - } - -} diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/common/NegotiationCommon.java b/system-tests/src/test/java/org/eclipse/edc/samples/common/NegotiationCommon.java index 4c56eb4f..15fd6635 100644 --- a/system-tests/src/test/java/org/eclipse/edc/samples/common/NegotiationCommon.java +++ b/system-tests/src/test/java/org/eclipse/edc/samples/common/NegotiationCommon.java @@ -27,31 +27,26 @@ public class NegotiationCommon { - private static final String CREATE_ASSET_FILE_PATH = "transfer/transfer-01-negotiation/resources/create-asset.json"; private static final String V3_ASSETS_PATH = "/v3/assets"; - private static final String CREATE_POLICY_FILE_PATH = "transfer/transfer-01-negotiation/resources/create-policy.json"; private static final String V2_POLICY_DEFINITIONS_PATH = "/v3/policydefinitions"; - private static final String CREATE_CONTRACT_DEFINITION_FILE_PATH = "transfer/transfer-01-negotiation/resources/create-contract-definition.json"; private static final String V2_CONTRACT_DEFINITIONS_PATH = "/v3/contractdefinitions"; private static final String V2_CATALOG_DATASET_REQUEST_PATH = "/v3/catalog/dataset/request"; - private static final String FETCH_DATASET_FROM_CATALOG_FILE_PATH = "transfer/transfer-01-negotiation/resources/get-dataset.json"; private static final String CATALOG_DATASET_ID = "\"hasPolicy\"[0].'@id'"; - private static final String NEGOTIATE_CONTRACT_FILE_PATH = "transfer/transfer-01-negotiation/resources/negotiate-contract.json"; private static final String V2_CONTRACT_NEGOTIATIONS_PATH = "/v3/contractnegotiations/"; private static final String CONTRACT_NEGOTIATION_ID = "@id"; private static final String CONTRACT_AGREEMENT_ID = "contractAgreementId"; private static final String CONTRACT_OFFER_ID_KEY = "{{contract-offer-id}}"; - public static void createAsset() { - post(PrerequisitesCommon.PROVIDER_MANAGEMENT_URL + V3_ASSETS_PATH, getFileContentFromRelativePath(CREATE_ASSET_FILE_PATH)); + public static void createAsset(String createAssetFilePath) { + post(PrerequisitesCommon.PROVIDER_MANAGEMENT_URL + V3_ASSETS_PATH, getFileContentFromRelativePath(createAssetFilePath)); } - public static void createPolicy() { - post(PrerequisitesCommon.PROVIDER_MANAGEMENT_URL + V2_POLICY_DEFINITIONS_PATH, getFileContentFromRelativePath(CREATE_POLICY_FILE_PATH)); + public static void createPolicy(String createPolicyFilePath) { + post(PrerequisitesCommon.PROVIDER_MANAGEMENT_URL + V2_POLICY_DEFINITIONS_PATH, getFileContentFromRelativePath(createPolicyFilePath)); } - public static void createContractDefinition() { - post(PrerequisitesCommon.PROVIDER_MANAGEMENT_URL + V2_CONTRACT_DEFINITIONS_PATH, getFileContentFromRelativePath(CREATE_CONTRACT_DEFINITION_FILE_PATH)); + public static void createContractDefinition(String createContractDefinitionFilePath) { + post(PrerequisitesCommon.PROVIDER_MANAGEMENT_URL + V2_CONTRACT_DEFINITIONS_PATH, getFileContentFromRelativePath(createContractDefinitionFilePath)); } public static String fetchDatasetFromCatalog(String fetchDatasetFromCatalogFilePath) { @@ -88,13 +83,4 @@ public static String getContractNegotiationState(String contractNegotiationId) { var url = PrerequisitesCommon.CONSUMER_MANAGEMENT_URL + V2_CONTRACT_NEGOTIATIONS_PATH + contractNegotiationId; return get(url, "state"); } - - public static String runNegotiation() { - createAsset(); - createPolicy(); - createContractDefinition(); - var catalogDatasetId = fetchDatasetFromCatalog(FETCH_DATASET_FROM_CATALOG_FILE_PATH); - var contractNegotiationId = negotiateContract(NEGOTIATE_CONTRACT_FILE_PATH, catalogDatasetId); - return getContractAgreementId(contractNegotiationId); - } } diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/common/PrerequisitesCommon.java b/system-tests/src/test/java/org/eclipse/edc/samples/common/PrerequisitesCommon.java index 88bd0832..6748d0f4 100644 --- a/system-tests/src/test/java/org/eclipse/edc/samples/common/PrerequisitesCommon.java +++ b/system-tests/src/test/java/org/eclipse/edc/samples/common/PrerequisitesCommon.java @@ -25,26 +25,15 @@ public class PrerequisitesCommon { public static final String PROVIDER_MANAGEMENT_URL = "http://localhost:19193/management"; public static final String CONSUMER_MANAGEMENT_URL = "http://localhost:29193/management"; - private static final String CONNECTOR_MODULE_PATH = ":transfer:transfer-00-prerequisites:connector"; private static final String PROVIDER = "provider"; private static final String CONSUMER = "consumer"; - private static final String PROVIDER_CONFIG_PROPERTIES_FILE_PATH = "transfer/transfer-00-prerequisites/resources/configuration/provider-configuration.properties"; - private static final String CONSUMER_CONFIG_PROPERTIES_FILE_PATH = "transfer/transfer-00-prerequisites/resources/configuration/consumer-configuration.properties"; - - public static RuntimeExtension getProvider() { - return getProvider(CONNECTOR_MODULE_PATH, PROVIDER_CONFIG_PROPERTIES_FILE_PATH); - } public static RuntimeExtension getProvider(String modulePath, String configPath) { return getConnector(modulePath, PROVIDER, configPath); } - public static RuntimeExtension getConsumer() { - return getConsumer(CONNECTOR_MODULE_PATH); - } - - public static RuntimeExtension getConsumer(String modulePath) { - return getConnector(modulePath, CONSUMER, CONSUMER_CONFIG_PROPERTIES_FILE_PATH); + public static RuntimeExtension getConsumer(String modulePath, String configPath) { + return getConnector(modulePath, CONSUMER, configPath); } private static RuntimeExtension getConnector( diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog01embeddedTest.java b/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog01embeddedTest.java index 1f89726c..fdcafd1d 100644 --- a/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog01embeddedTest.java +++ b/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog01embeddedTest.java @@ -25,24 +25,26 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.CRAWLER_EXECUTION_DELAY_VALUE; +import static org.eclipse.edc.samples.common.FederatedCatalogCommon.CREATE_CONTRACT_DEFINITION_FILE_PATH; +import static org.eclipse.edc.samples.common.FederatedCatalogCommon.CREATE_POLICY_FILE_PATH; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.DATASET_ASSET_ID; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.EMBEDDED_FC_CATALOG_API_ENDPOINT; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.EMPTY_QUERY_FILE_PATH; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.TIMEOUT; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.createAsset; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.getFcEmbeddedConnector; +import static org.eclipse.edc.samples.common.FederatedCatalogCommon.getParticipantConnector; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.postAndAssertType; import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath; import static org.eclipse.edc.samples.common.NegotiationCommon.createContractDefinition; import static org.eclipse.edc.samples.common.NegotiationCommon.createPolicy; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider; @EndToEndTest public class FederatedCatalog01embeddedTest { @RegisterExtension @Order(0) - static final RuntimeExtension PARTICIPANT_CONNECTOR = getProvider(); + static final RuntimeExtension PARTICIPANT_CONNECTOR = getParticipantConnector(); @RegisterExtension @Order(1) @@ -51,8 +53,8 @@ public class FederatedCatalog01embeddedTest { @Test void runSampleSteps() { var assetId = createAsset(); - createPolicy(); - createContractDefinition(); + createPolicy(CREATE_POLICY_FILE_PATH); + createContractDefinition(CREATE_CONTRACT_DEFINITION_FILE_PATH); await() .atMost(Duration.ofSeconds(TIMEOUT)) diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog02standaloneTest.java b/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog02standaloneTest.java index e37d76ce..cf4ec65b 100644 --- a/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog02standaloneTest.java +++ b/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog02standaloneTest.java @@ -24,22 +24,24 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.CRAWLER_EXECUTION_DELAY_VALUE; +import static org.eclipse.edc.samples.common.FederatedCatalogCommon.CREATE_CONTRACT_DEFINITION_FILE_PATH; +import static org.eclipse.edc.samples.common.FederatedCatalogCommon.CREATE_POLICY_FILE_PATH; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.DATASET_ASSET_ID; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.EMPTY_QUERY_FILE_PATH; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.STANDALONE_FC_CATALOG_API_ENDPOINT; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.TIMEOUT; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.createAsset; +import static org.eclipse.edc.samples.common.FederatedCatalogCommon.getParticipantConnector; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.getStandaloneFc; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.postAndAssertType; import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath; import static org.eclipse.edc.samples.common.NegotiationCommon.createContractDefinition; import static org.eclipse.edc.samples.common.NegotiationCommon.createPolicy; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider; @EndToEndTest public class FederatedCatalog02standaloneTest { @RegisterExtension - static final RuntimeExtension PARTICIPANT_CONNECTOR = getProvider(); + static final RuntimeExtension PARTICIPANT_CONNECTOR = getParticipantConnector(); @RegisterExtension static final RuntimeExtension STANDALONE_FC_RUNTIME = getStandaloneFc(":federated-catalog:fc-02-standalone:standalone-fc"); @@ -47,8 +49,8 @@ public class FederatedCatalog02standaloneTest { @Test void runSampleSteps() { var assetId = createAsset(); - createPolicy(); - createContractDefinition(); + createPolicy(CREATE_POLICY_FILE_PATH); + createContractDefinition(CREATE_CONTRACT_DEFINITION_FILE_PATH); await() .atMost(Duration.ofSeconds(TIMEOUT)) diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog03staticNodeResolverTest.java b/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog03staticNodeResolverTest.java index 152e8fce..660d029a 100644 --- a/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog03staticNodeResolverTest.java +++ b/system-tests/src/test/java/org/eclipse/edc/samples/federated/catalog/FederatedCatalog03staticNodeResolverTest.java @@ -23,6 +23,8 @@ import static org.awaitility.Awaitility.await; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.CRAWLER_EXECUTION_DELAY_VALUE; +import static org.eclipse.edc.samples.common.FederatedCatalogCommon.CREATE_CONTRACT_DEFINITION_FILE_PATH; +import static org.eclipse.edc.samples.common.FederatedCatalogCommon.CREATE_POLICY_FILE_PATH; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.DATASET_ASSET_ID; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.EMBEDDED_FC_CATALOG_API_ENDPOINT; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.EMPTY_QUERY_FILE_PATH; @@ -30,18 +32,18 @@ import static org.eclipse.edc.samples.common.FederatedCatalogCommon.TIMEOUT; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.createAsset; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.getFcEmbeddedConnector; +import static org.eclipse.edc.samples.common.FederatedCatalogCommon.getParticipantConnector; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.getStandaloneFc; import static org.eclipse.edc.samples.common.FederatedCatalogCommon.postAndAssertType; import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath; import static org.eclipse.edc.samples.common.NegotiationCommon.createContractDefinition; import static org.eclipse.edc.samples.common.NegotiationCommon.createPolicy; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider; @EndToEndTest public class FederatedCatalog03staticNodeResolverTest { @RegisterExtension - static final RuntimeExtension PARTICIPANT_CONNECTOR = getProvider(); + static final RuntimeExtension PARTICIPANT_CONNECTOR = getParticipantConnector(); @RegisterExtension static final RuntimeExtension STANDALONE_FC_RUNTIME = getStandaloneFc(":federated-catalog:fc-03-static-node-directory:standalone-fc-with-node-resolver"); @@ -52,8 +54,8 @@ public class FederatedCatalog03staticNodeResolverTest { @Test void runSampleSteps() { var assetId = createAsset(); - createPolicy(); - createContractDefinition(); + createPolicy(CREATE_POLICY_FILE_PATH); + createContractDefinition(CREATE_CONTRACT_DEFINITION_FILE_PATH); // call catalog API from standalone FC await() diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer01negotiationTest.java b/system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer01negotiationTest.java deleted file mode 100644 index 4d0e3174..00000000 --- a/system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer01negotiationTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Mercedes-Benz Tech Innovation GmbH - Sample workflow test - * Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - use current ids instead of placeholder - * - */ - -package org.eclipse.edc.samples.transfer; - -import org.eclipse.edc.junit.annotations.EndToEndTest; -import org.eclipse.edc.junit.extensions.RuntimeExtension; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.samples.common.NegotiationCommon.createAsset; -import static org.eclipse.edc.samples.common.NegotiationCommon.createContractDefinition; -import static org.eclipse.edc.samples.common.NegotiationCommon.createPolicy; -import static org.eclipse.edc.samples.common.NegotiationCommon.fetchDatasetFromCatalog; -import static org.eclipse.edc.samples.common.NegotiationCommon.getContractAgreementId; -import static org.eclipse.edc.samples.common.NegotiationCommon.negotiateContract; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider; - -@EndToEndTest -public class Transfer01negotiationTest { - - @RegisterExtension - static RuntimeExtension provider = getProvider(); - - @RegisterExtension - static RuntimeExtension consumer = getConsumer(); - - private static final String NEGOTIATE_CONTRACT_FILE_PATH = "transfer/transfer-01-negotiation/resources/negotiate-contract.json"; - private static final String FETCH_DATASET_FROM_CATALOG_FILE_PATH = "transfer/transfer-01-negotiation/resources/get-dataset.json"; - - @Test - void runSampleSteps() { - createAsset(); - createPolicy(); - createContractDefinition(); - var catalogDatasetId = fetchDatasetFromCatalog(FETCH_DATASET_FROM_CATALOG_FILE_PATH); - var contractNegotiationId = negotiateContract(NEGOTIATE_CONTRACT_FILE_PATH, catalogDatasetId); - var contractAgreementId = getContractAgreementId(contractNegotiationId); - assertThat(contractAgreementId).isNotEmpty(); - } -} diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer02providerPushTest.java b/system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer02providerPushTest.java deleted file mode 100644 index f22b4843..00000000 --- a/system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer02providerPushTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2022 Microsoft Corporation - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Microsoft Corporation - initial test implementation for sample - * Mercedes-Benz Tech Innovation GmbH - refactor test cases - * - */ - -package org.eclipse.edc.samples.transfer; - -import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates; -import org.eclipse.edc.junit.annotations.EndToEndTest; -import org.eclipse.edc.junit.extensions.RuntimeExtension; -import org.eclipse.edc.samples.util.HttpRequestLoggerContainer; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath; -import static org.eclipse.edc.samples.common.NegotiationCommon.runNegotiation; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider; -import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus; -import static org.eclipse.edc.samples.util.TransferUtil.startTransfer; - -@EndToEndTest -@Testcontainers -public class Transfer02providerPushTest { - - private static final String START_TRANSFER_FILE_PATH = "transfer/transfer-02-provider-push/resources/start-transfer.json"; - - @RegisterExtension - static RuntimeExtension provider = getProvider(); - - @RegisterExtension - static RuntimeExtension consumer = getConsumer(); - - @Container - public static HttpRequestLoggerContainer httpRequestLoggerContainer = new HttpRequestLoggerContainer(); - - @Test - void runSampleSteps() { - var contractAgreementId = runNegotiation(); - var requestBody = getFileContentFromRelativePath(START_TRANSFER_FILE_PATH) - .replace("4000", String.valueOf(httpRequestLoggerContainer.getPort())); - var transferProcessId = startTransfer(requestBody, contractAgreementId); - checkTransferStatus(transferProcessId, TransferProcessStates.COMPLETED); - assertThat(httpRequestLoggerContainer.getLog()).contains("Leanne Graham"); - } -} diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer03httpProxyConsumerPullTest.java b/system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer03httpProxyConsumerPullTest.java deleted file mode 100644 index e66c237a..00000000 --- a/system-tests/src/test/java/org/eclipse/edc/samples/transfer/Transfer03httpProxyConsumerPullTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2022 Microsoft Corporation - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Microsoft Corporation - initial test implementation for sample - * Mercedes-Benz Tech Innovation GmbH - refactor test cases - * - */ - -package org.eclipse.edc.samples.transfer; - -import org.apache.http.HttpStatus; -import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates; -import org.eclipse.edc.junit.annotations.EndToEndTest; -import org.eclipse.edc.junit.extensions.RuntimeExtension; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -import static io.restassured.RestAssured.given; -import static org.apache.http.HttpHeaders.AUTHORIZATION; -import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath; -import static org.eclipse.edc.samples.common.NegotiationCommon.runNegotiation; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.API_KEY_HEADER_KEY; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.API_KEY_HEADER_VALUE; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.CONSUMER_MANAGEMENT_URL; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer; -import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider; -import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus; -import static org.eclipse.edc.samples.util.TransferUtil.startTransfer; -import static org.hamcrest.Matchers.emptyString; -import static org.hamcrest.Matchers.not; - -@EndToEndTest -public class Transfer03httpProxyConsumerPullTest { - - private static final String SAMPLE_NAME = "transfer-03-consumer-pull"; - private static final String START_TRANSFER_FILE_PATH = "transfer/%s/resources/start-transfer.json".formatted(SAMPLE_NAME); - - @RegisterExtension - static RuntimeExtension provider = getProvider( - ":transfer:%s:provider-proxy-data-plane".formatted(SAMPLE_NAME), - "transfer/%s/resources/configuration/provider.properties".formatted(SAMPLE_NAME) - ); - - @RegisterExtension - static RuntimeExtension consumer = getConsumer(); - - @Test - void runSampleSteps() { - var requestBody = getFileContentFromRelativePath(START_TRANSFER_FILE_PATH); - var contractAgreementId = runNegotiation(); - var transferProcessId = startTransfer(requestBody, contractAgreementId); - checkTransferStatus(transferProcessId, TransferProcessStates.STARTED); - - var edr = given() - .when() - .get(CONSUMER_MANAGEMENT_URL + "/v3/edrs/{id}/dataaddress", transferProcessId) - .then() - .log().ifValidationFails() - .statusCode(200) - .extract().body().jsonPath(); - - var result = given() - .header(API_KEY_HEADER_KEY, API_KEY_HEADER_VALUE) - .header(AUTHORIZATION, edr.getString("authorization")) - .when() - .get(edr.getString("endpoint")) - .then() - .statusCode(HttpStatus.SC_OK) - .log().ifValidationFails() - .body("[0].name", not(emptyString())) - .extract() - .jsonPath() - .get("[0].name"); - - assertThat(result).isEqualTo("Leanne Graham"); - } - -} diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/util/HttpRequestLoggerConsumer.java b/system-tests/src/test/java/org/eclipse/edc/samples/util/HttpRequestLoggerConsumer.java deleted file mode 100644 index 687612d7..00000000 --- a/system-tests/src/test/java/org/eclipse/edc/samples/util/HttpRequestLoggerConsumer.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Mercedes-Benz Tech Innovation GmbH - Initial implementation - * - */ - -package org.eclipse.edc.samples.util; - -import org.testcontainers.containers.output.ToStringConsumer; - -import java.util.regex.Pattern; - -import static java.lang.String.format; -import static org.apache.commons.lang3.StringUtils.EMPTY; - -public class HttpRequestLoggerConsumer extends ToStringConsumer { - - private static final String REGEX_FORMAT = "(?<=\"%s\":\")[^\"]*"; - - public String getJsonValue(String key) { - var pattern = Pattern.compile(format(REGEX_FORMAT, key)); - var matcher = pattern.matcher(toUtf8String()); - if (matcher.find()) { - return matcher.group(); - } - return EMPTY; - } -} diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/util/HttpRequestLoggerContainer.java b/system-tests/src/test/java/org/eclipse/edc/samples/util/HttpRequestLoggerContainer.java deleted file mode 100644 index 8bd3c2ab..00000000 --- a/system-tests/src/test/java/org/eclipse/edc/samples/util/HttpRequestLoggerContainer.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022 Microsoft Corporation - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Mercedes-Benz Tech Innovation GmbH - initial implementation - * - */ - -package org.eclipse.edc.samples.util; - -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.output.ToStringConsumer; -import org.testcontainers.images.builder.ImageFromDockerfile; - -import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath; - -public class HttpRequestLoggerContainer extends GenericContainer { - - private static final String HTTP_REQUEST_LOGGER_DOCKERFILE_PATH = "util/http-request-logger/Dockerfile"; - private static final ImageFromDockerfile IMAGE_FROM_DOCKERFILE = new ImageFromDockerfile() - .withDockerfile(getFileFromRelativePath(HTTP_REQUEST_LOGGER_DOCKERFILE_PATH).toPath()); - private final ToStringConsumer toStringConsumer; - - public HttpRequestLoggerContainer() { - super(IMAGE_FROM_DOCKERFILE); - this.toStringConsumer = new HttpRequestLoggerConsumer(); - this.withLogConsumer(toStringConsumer) - .withExposedPorts(4000); - } - - public String getLog() { - return this.toStringConsumer.toUtf8String(); - } - - public int getPort() { - return this.getFirstMappedPort(); - } -} diff --git a/transfer/README.md b/transfer/README.md deleted file mode 100644 index 5510a802..00000000 --- a/transfer/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Transfer samples - -The samples in this scope revolve around the topic of transferring data between two connectors. Here -you will learn about the steps required for a transfer on provider as well as consumer side. The -samples start with the simple example of a building and configuring the connector library. -Furthermore, you will learn about the contract negotiation workflow and how to perform a data transfer. - -> Before starting with these samples, be sure to check out the [basic samples](../basic/README.md)! - -## Samples - -### [Transfer sample 00](./transfer-00-prerequisites/README.md): Prerequisites - -This is a prerequisite for the following chapters. -You will build the connector library here, configure and execute it. - -### [Transfer sample 01](./transfer-01-negotiation/README.md): Negotiation - -Before two connectors can exchange actual data, negotiation has to take place. -The final goal of this example is to showcase the negotiation workflow between two connectors so that -the actual data transfer can take place. This chapter is a prerequisite to the following chapters. - -### [Transfer sample 02](transfer-02-provider-push/README.md): Perform a provider push exchange between a consumer and a provider - -This sample demonstrates the "provider push" use case. -More details on [Consumer Pull and Provider Push Transfers](https://eclipse-edc.github.io/documentation/for-adopters/control-plane/#consumer-pull-and-provider-push-transfers). - -### [Transfer sample 03](./transfer-03-consumer-pull): Implement a custom Http Proxy for PULL transfer - -This sample demonstrates how a custom HTTP Proxy Data Plane can be implemented to address PULL transfer type. -More details on [Consumer Pull and Provider Push Transfers](https://eclipse-edc.github.io/documentation/for-adopters/control-plane/#consumer-pull-and-provider-push-transfers). \ No newline at end of file diff --git a/transfer/transfer-00-prerequisites/README.md b/transfer/transfer-00-prerequisites/README.md deleted file mode 100644 index e4a7daab..00000000 --- a/transfer/transfer-00-prerequisites/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# Prerequisites - -The purpose of this example is to make preparations for a connector-to-connector communication. -For that we'll set up two connectors. - -One connector will be the "consumer" connector while the other will act as the -"provider" connector. More on that in the following chapters. - -For the sake of simplicity, the provider and the consumer -will run on the same machine, but in a real world configuration, they will likely be on different -machines. - -This sample will go through: - -* Building the connector module -* Running the provider connector -* Running the consumer connector -* Registering data plane instance for the provider connector - -## Run the sample - -### 1. Build the connector - -When we talk about a connector in the context of Eclipse Dataspace Components, we really mean a JAR file that runs on a machine. -Before we can run a connector, we need to build the JAR file. - -Execute this command in project root: - -```bash -./gradlew transfer:transfer-00-prerequisites:connector:build -``` - -After the build end you should verify that the connector.jar is created in the directory -[/connector/build/libs/connector.jar](connector/build/libs/connector.jar) - -We can use the same .jar file for both connectors. Note that the consumer and provider connectors differ in their configuration. - -Inspect the different configuration files below: - -* [provider-configuration.properties](resources/configuration/provider-configuration.properties) -* [consumer-configuration.properties](resources/configuration/consumer-configuration.properties) - -### 2. Run the connectors - -To run the provider, just run the following command - -```bash -java -Dedc.fs.config=transfer/transfer-00-prerequisites/resources/configuration/provider-configuration.properties -jar transfer/transfer-00-prerequisites/connector/build/libs/connector.jar -``` - -To run the consumer, just run the following command (different terminal) - -```bash -java -Dedc.fs.config=transfer/transfer-00-prerequisites/resources/configuration/consumer-configuration.properties -jar transfer/transfer-00-prerequisites/connector/build/libs/connector.jar -``` - -Assuming you didn't change the ports in config files, the consumer will listen on the -ports `29191`, `29192` (management API) and `29292` (DSP API) and the provider will listen on the -ports `12181`, `19182` (management API) and `19282` (DSP API). - -The connectors have been configured successfully and are ready to be used. - -[Next Chapter](../transfer-01-negotiation/README.md) diff --git a/transfer/transfer-00-prerequisites/connector/build.gradle.kts b/transfer/transfer-00-prerequisites/connector/build.gradle.kts deleted file mode 100644 index 970bcb4b..00000000 --- a/transfer/transfer-00-prerequisites/connector/build.gradle.kts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -plugins { - `java-library` - id("application") - alias(libs.plugins.shadow) -} - -dependencies { - runtimeOnly(libs.edc.bom.controlplane.base) { - exclude(group = "org.eclipse.edc", module = "data-plane-signaling-core") - exclude(group = "org.eclipse.edc", module = "data-plane-signaling-oauth2") - } - implementation(libs.edc.control.plane.api.client) - implementation(libs.edc.iam.mock) - implementation(libs.edc.transfer.data.plane.signaling) - implementation(libs.edc.validator.data.address.http.data) - - implementation(libs.edc.edr.cache.api) - implementation(libs.edc.edr.store.core) - implementation(libs.edc.edr.store.receiver) - - implementation(libs.edc.data.plane.self.registration) - implementation(libs.edc.data.plane.signaling.api) - implementation(libs.edc.data.plane.signaling.client) - implementation(libs.edc.data.plane.core) - implementation(libs.edc.data.plane.http) - implementation(libs.edc.data.plane.iam) -} - -application { - mainClass.set("$group.boot.system.runtime.BaseRuntime") -} - -var distTar = tasks.getByName("distTar") -var distZip = tasks.getByName("distZip") - -tasks.shadowJar { - mergeServiceFiles() - archiveFileName.set("connector.jar") - dependsOn(distTar, distZip) - duplicatesStrategy = DuplicatesStrategy.INCLUDE -} diff --git a/transfer/transfer-00-prerequisites/connector/src/main/java/org/eclipse/edc/sample/runtime/SeedVaultExtension.java b/transfer/transfer-00-prerequisites/connector/src/main/java/org/eclipse/edc/sample/runtime/SeedVaultExtension.java deleted file mode 100644 index 171d96ff..00000000 --- a/transfer/transfer-00-prerequisites/connector/src/main/java/org/eclipse/edc/sample/runtime/SeedVaultExtension.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.sample.runtime; - -import org.eclipse.edc.runtime.metamodel.annotation.Inject; -import org.eclipse.edc.spi.security.Vault; -import org.eclipse.edc.spi.system.ServiceExtension; -import org.eclipse.edc.spi.system.ServiceExtensionContext; - -public class SeedVaultExtension implements ServiceExtension { - - @Inject - private Vault vault; - - private static final String PUBLIC_KEY = """ - -----BEGIN CERTIFICATE----- - MIIDazCCAlOgAwIBAgIUZ3/sZXYzW4PjmOXKrZn6WBmUJ+4wDQYJKoZIhvcNAQEL - BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM - GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMjAyMjMxNTA2MDNaFw0zMjAy - MjExNTA2MDNaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw - HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB - AQUAA4IBDwAwggEKAoIBAQDBl6XaJnXTL+6DWip3aBhU+MzmY4d1V9hbTm1tiZ3g - E0VbUrvGO3LoYaxpPv6zFmsg3uJv6JxVAde7EddidN0ITHB9cQNdAfdUJ5njmsGS - PbdQuOQTHw0aG7/QvTI/nsvfEE6e0lbV/0e7DHacZT/+OztBH1RwkG2ymM94Hf8H - I6x7q6yfRTAZOqeOMrPCYTcluAgE9NskoPvjX5qASakBtXISKIsOU84N0/2HDN3W - EGMXvoHUQu6vrij6BwiwxKaw1AKwWENKoga775bPXN3M+JTSaIKE7dZbKzvx0Zi0 - h5X+bxc3BJi3Z/CsUBCzE+Y0SFetOiYmyl/2YmnneYoVAgMBAAGjUzBRMB0GA1Ud - DgQWBBTvK1wVERwjni4B2vdH7KtEJeVWFzAfBgNVHSMEGDAWgBTvK1wVERwjni4B - 2vdH7KtEJeVWFzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBn - QHiPA7OBYukHd9gS7c0HXE+fsWcS3GZeLqcHfQQnV3pte1vTmu9//IVW71wNCJ1/ - rySRyODPQoPehxEcyHwupNZSzXK//nPlTdSgjMfFxscvt1YndyQLQYCfyOJMixAe - Aqrb14GTFHUUrdor0PyElhkULjkOXUrSIsdBrfWrwLTkelE8NK3tb5ZG8KPzD9Jy - +NwEPPr9d+iHkUkM7EFWw/cl56wka9ryBb97RI7DqbO6/j6OXHMk4GByxKv7DSIR - IvF9/Dw20qytajtaHV0pluFcOBuFc0NfiDvCaQlbTsfjzbc6UmZWbOi9YOJl3VQ/ - g3h+15GuzbsSzOCOEYOT - -----END CERTIFICATE----- - """; - - private static final String PRIVATE_KEY = """ - -----BEGIN PRIVATE KEY----- - MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDBl6XaJnXTL+6D - Wip3aBhU+MzmY4d1V9hbTm1tiZ3gE0VbUrvGO3LoYaxpPv6zFmsg3uJv6JxVAde7 - EddidN0ITHB9cQNdAfdUJ5njmsGSPbdQuOQTHw0aG7/QvTI/nsvfEE6e0lbV/0e7 - DHacZT/+OztBH1RwkG2ymM94Hf8HI6x7q6yfRTAZOqeOMrPCYTcluAgE9NskoPvj - X5qASakBtXISKIsOU84N0/2HDN3WEGMXvoHUQu6vrij6BwiwxKaw1AKwWENKoga7 - 75bPXN3M+JTSaIKE7dZbKzvx0Zi0h5X+bxc3BJi3Z/CsUBCzE+Y0SFetOiYmyl/2 - YmnneYoVAgMBAAECggEBAJHXiN6bctAyn+DcoHlsNkhtVw+Jk5bXIutGXjHTJtiU - K//siAGC78IZMyXmi0KndPVCdBwShROVW8xWWIiXuZxy2Zvm872xqX4Ah3JsN7/Q - NrXdVBUDo38zwIGkxqIfIz9crZ4An+J/eq5zaTfRHzCLtswMqjRS2hFeBY5cKrBY - 4bkSDGTP/c5cP7xS/UwaiTR2Ptd41f4zTyd4l5rl30TYHpazQNlbdxcOV4jh2Rnp - E0+cFEvEfeagVq7RmfBScKG5pk4qcRG0q2QHMyK5y00hdYvhdRjSgN7xIDkeO5B8 - s8/tSLU78nCl2gA9IKxTXYLitpISwZ81Q04mEAKRRtECgYEA+6lKnhn//aXerkLo - ZOLOjWQZhh005jHdNxX7DZqLpTrrfxc8v15KWUkAK1H0QHqYvfPrbbsBV1MY1xXt - sKmkeu/k8fJQzCIvFN4K2J5W5kMfq9PSw5d3XPeDaQuXUVaxBVp0gzPEPHmkKRbA - AkUqY0oJwA9gMKf8dK+flmLZfbsCgYEAxO4Roj2G46/Oox1GEZGxdLpiMpr9rEdR - JlSZ9kMGfddNLV7sFp6yPXDcyc/AOqeNj7tw1MyoT3Ar454+V0q83EZzCXvs4U6f - jUrfFcoVWIwf9AV/J4KWzMIzfqPIeNwqymZKd6BrZgcXXvAEPWt27mwO4a1GhC4G - oZv0t3lAsm8CgYAQ8C0IhSF4tgBN5Ez19VoHpDQflbmowLRt77nNCZjajyOokyzQ - iI0ig0pSoBp7eITtTAyNfyew8/PZDi3IVTKv35OeQTv08VwP4H4EZGve5aetDf3C - kmBDTpl2qYQOwnH5tUPgTMypcVp+NXzI6lTXB/WuCprjy3qvc96e5ZpT3wKBgQC8 - Xny/k9rTL/eYTwgXBiWYYjBL97VudUlKQOKEjNhIxwkrvQBXIrWbz7lh0Tcu49al - BcaHxru4QLO6pkM7fGHq0fh3ufJ8EZjMrjF1xjdk26Q05o0aXe+hLKHVIRVBhlfo - ArB4fRo+HcpdJXjox0KcDQCvHe+1v9DYBTWvymv4QQKBgBy3YH7hKz35DcXvA2r4 - Kis9a4ycuZqTXockO4rkcIwC6CJp9JbHDIRzig8HYOaRqmZ4a+coqLmddXr2uOF1 - 7+iAxxG1KzdT6uFNd+e/j2cdUjnqcSmz49PRtdDswgyYhoDT+W4yVGNQ4VuKg6a3 - Z3pC+KTdoHSKeA2FyAGnSUpD - -----END PRIVATE KEY----- - """; - - @Override - public void initialize(ServiceExtensionContext context) { - vault.storeSecret("public-key", PUBLIC_KEY); - vault.storeSecret("private-key", PRIVATE_KEY); - } -} diff --git a/transfer/transfer-00-prerequisites/connector/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension b/transfer/transfer-00-prerequisites/connector/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension deleted file mode 100644 index eaca6845..00000000 --- a/transfer/transfer-00-prerequisites/connector/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.edc.sample.runtime.SeedVaultExtension diff --git a/transfer/transfer-01-negotiation/README.md b/transfer/transfer-01-negotiation/README.md deleted file mode 100644 index 72181e71..00000000 --- a/transfer/transfer-01-negotiation/README.md +++ /dev/null @@ -1,238 +0,0 @@ -# Implement a negotiation workflow between two connectors - - -Before two connectors can exchange actual data, negotiation has to take place. - -The final goal of this example is to showcase the negotiation workflow between two connectors so that -the actual data transfer can take place. The actual data transfer will be part of the next chapters. - -You will: - -* Create an asset on the provider (the asset will be the data to be shared) -* Create an access policy on the provider (the policy will define the access right to the data) -* Create a contract definition on the provider - -At this step, the consumer should be able to fetch the catalog from the provider and to see the -contract offer generated from the resources that have been created. - -Once the catalog is available, to access the data, the consumer should follow the following steps: - -* Perform a contract negotiation with the provider - -> For the sake of simplicity, we will use an in-memory catalog and fill it with just one single -> asset. This will be deleted after the provider shutdown. - -The provider connector is the one managing assets and respective access policies for which a contract negotiation -can be executed while the consumer is the one "requesting" assets and initiating contract negotiations. - -## Run the sample - -Running this sample consists of multiple steps, that are executed one by one and following the same -order. - -The following steps assume your provider and consumer connector are still up and running. -If not, re-run them as described in the [Prerequisites](../transfer-00-prerequisites/README.md) chapter. - -### 1. Create an Asset on the provider side - -The provider connector needs to transfer a file to the location specified by the consumer connector -when the data are requested. In order to offer any data, the provider must maintain an internal list -of resources offered, through a contract offer, the so-called "catalog". - -The following [request](resources/create-asset.json) creates an asset on the provider connector. - -```bash -curl -d @transfer/transfer-01-negotiation/resources/create-asset.json \ - -H 'content-type: application/json' http://localhost:19193/management/v3/assets \ - -s | jq -``` - -> It is important to note that the `baseUrl` property of the `dataAddress` is a fake data used for -> the purpose of this example. It will be the data that the consumer will pull on the sample -> execution. - -### 2. Create a Policy on the provider - -In order to manage the accessibility rules of an asset, it is essential to create a policy. However, -to keep things simple, we will choose a policy that gives direct access to all the assets that are -associated within the contract definitions. -This means that the consumer connector can request any asset from the provider connector. - -```bash -curl -d @transfer/transfer-01-negotiation/resources/create-policy.json \ - -H 'content-type: application/json' http://localhost:19193/management/v3/policydefinitions \ - -s | jq -``` - -### 3. Create a contract definition on Provider - -To ensure an exchange between provider and consumer, the provider must create a contract offer for -the asset, on the basis of which a contract agreement can be negotiated. The contract definition -associates policies to a selection of assets to generate the contract offers that will be put in the -catalog. In this case, the selection is empty, so every asset is attached to these policies. - -```bash -curl -d @transfer/transfer-01-negotiation/resources/create-contract-definition.json \ - -H 'content-type: application/json' http://localhost:19193/management/v3/contractdefinitions \ - -s | jq - -``` - -Sample output: - -```json -{ - ... - "@id": "1", - "createdAt": 1674578184023, - ... -} -``` - -### 4. How to fetch catalog on consumer side - -In order to request any data, the consumer must fetch the catalog from the provider, which contains -all the contract offers available for negotiation. In our case, it will contain a single contract -offer, the so-called "catalog". To get the catalog from the consumer side, you can use the following -request: - -```bash -curl -X POST "http://localhost:29193/management/v3/catalog/request" \ - -H 'Content-Type: application/json' \ - -d @transfer/transfer-01-negotiation/resources/fetch-catalog.json -s | jq -``` - -Sample output: - -```json -{ - "@id": "31f6d748-d35b-4dec-9e34-d141fd17b458", - "@type": "dcat:Catalog", - "dcat:dataset": { - "@id": "assetId", - "@type": "dcat:Dataset", - "odrl:hasPolicy": { - "@id": "MQ==:YXNzZXRJZA==:YTc4OGEwYjMtODRlZi00NWYwLTgwOWQtMGZjZTMwMGM3Y2Ey", - "@type": "odrl:Set", - "odrl:permission": [], - "odrl:prohibition": [], - "odrl:obligation": [], - "odrl:target": "assetId" - }, - "dcat:distribution": [ - { - "@type": "dcat:Distribution", - "dct:format": { - "@id": "HttpProxy" - }, - "dcat:accessService": "2a5178c3-c937-4ac2-85be-c46dbc6c5642" - }, - { - "@type": "dcat:Distribution", - "dct:format": { - "@id": "HttpData" - }, - "dcat:accessService": "2a5178c3-c937-4ac2-85be-c46dbc6c5642" - } - ], - "name": "product description", - "id": "assetId", - "contenttype": "application/json" - }, - "dcat:service": { - "@id": "2a5178c3-c937-4ac2-85be-c46dbc6c5642", - "@type": "dcat:DataService", - "dct:terms": "connector", - "dct:endpointUrl": "http://localhost:19194/protocol/2025-1" - }, - "participantId": "anonymous", - "@context": { - "@vocab": "https://w3id.org/edc/v0.0.1/ns/", - "dct": "https://purl.org/dc/terms/", - "dcat": "https://www.w3.org/ns/dcat/", - "odrl": "http://www.w3.org/ns/odrl/2/", - "dspace": "https://w3id.org/dspace/2025/1/" - } -} -``` - -### 5. Negotiate a contract - -In order to request any data, a contract gets negotiated, and an agreement is resulting has to be -negotiated between providers and consumers. - -The consumer now needs to initiate a contract negotiation sequence with the provider. That sequence -looks as follows: - -1. Consumer sends a contract offer to the provider (__currently, this has to be equal to the - provider's offer!__) -2. Provider validates the received offer against its own offer -3. Provider either sends an agreement or a rejection, depending on the validation result -4. In case of successful validation, provider and consumer store the received agreement for later - reference - -Of course, this is the simplest possible negotiation sequence. Later on, both connectors can also -send counteroffers in addition to just confirming or declining an offer. - -Please replace the `{{contract-offer-id}}` placeholder in the [`negotiate-contract.json`](resources/negotiate-contract.json) -file with the contract offer id you found in the catalog at the path `dcat:dataset.odrl:hasPolicy.@id`. - -```bash -curl -d @transfer/transfer-01-negotiation/resources/negotiate-contract.json \ - -X POST -H 'content-type: application/json' http://localhost:29193/management/v3/contractnegotiations \ - -s | jq -``` - -Sample output: - -```json -{ - ... - "@id": "254015f3-5f1e-4a59-9ad9-bf0e42d4819e", - "createdAt": 1685525281848, - ... -} -``` - -### 6. Getting the contract agreement id - -After calling the endpoint for initiating a contract negotiation, we get a UUID as the response. -This UUID is the ID of the ongoing contract negotiation between consumer and provider. The -negotiation sequence between provider and consumer is executed asynchronously in the background by a -state machine. Once both provider and consumer either reach the `confirmed` or the `declined` -state, the negotiation is finished. We can now use the UUID to check the current status of the -negotiation using an endpoint on the consumer side. - -```bash -curl -X GET "http://localhost:29193/management/v3/contractnegotiations/{{contract-negotiation-id}}" \ - --header 'Content-Type: application/json' \ - -s | jq -``` - -Sample output: - -```json -{ - "@type": "ContractNegotiation", - "@id": "5ca21b82-075b-4682-add8-c26c9a2ced67", - "type": "CONSUMER", - "protocol": "dataspace-protocol-http:2025-1", - "state": "FINALIZED", - "counterPartyAddress": "http://localhost:19194/protocol/2025-1", - "callbackAddresses": [], - "contractAgreementId": "0b3150be-feaf-43bc-91e1-90f050de28bd", <--------- - "@context": { - "@vocab": "https://w3id.org/edc/v0.0.1/ns/", - "dct": "https://purl.org/dc/terms/", - "dcat": "https://www.w3.org/ns/dcat/", - "odrl": "http://www.w3.org/ns/odrl/2/", - "dspace": "https://w3id.org/dspace/2025/1/" - } -} -``` -At this point contract negotiation has been successfully completed. -The connectors are now ready to enter the data transfer phase. - -Note down the `contractAgreementId`. You will need it in the next chapters. - -[Next Chapter](../transfer-02-provider-push/README.md) diff --git a/transfer/transfer-01-negotiation/resources/fetch-catalog.json b/transfer/transfer-01-negotiation/resources/fetch-catalog.json deleted file mode 100644 index 28a0a7e7..00000000 --- a/transfer/transfer-01-negotiation/resources/fetch-catalog.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "@context": { - "@vocab": "https://w3id.org/edc/v0.0.1/ns/" - }, - "counterPartyId": "provider", - "counterPartyAddress": "http://localhost:19194/protocol/2025-1", - "protocol": "dataspace-protocol-http:2025-1" -} diff --git a/transfer/transfer-01-negotiation/resources/get-dataset.json b/transfer/transfer-01-negotiation/resources/get-dataset.json deleted file mode 100644 index f37c1661..00000000 --- a/transfer/transfer-01-negotiation/resources/get-dataset.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@type": "DatasetRequest", - "@id": "assetId", - "counterPartyId": "provider", - "counterPartyAddress": "http://localhost:19194/protocol/2025-1", - "protocol": "dataspace-protocol-http:2025-1" -} diff --git a/transfer/transfer-01-negotiation/resources/negotiate-contract.json b/transfer/transfer-01-negotiation/resources/negotiate-contract.json deleted file mode 100644 index bd76cb54..00000000 --- a/transfer/transfer-01-negotiation/resources/negotiate-contract.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "@context": { - "@vocab": "https://w3id.org/edc/v0.0.1/ns/" - }, - "@type": "ContractRequest", - "counterPartyId": "provider", - "counterPartyAddress": "http://localhost:19194/protocol/2025-1", - "protocol": "dataspace-protocol-http:2025-1", - "policy": { - "@context": "http://www.w3.org/ns/odrl.jsonld", - "@id": "{{contract-offer-id}}", - "@type": "Offer", - "assigner": "provider", - "target": "assetId" - } -} diff --git a/transfer/transfer-02-provider-push/README.md b/transfer/transfer-02-provider-push/README.md deleted file mode 100644 index 5b34b462..00000000 --- a/transfer/transfer-02-provider-push/README.md +++ /dev/null @@ -1,79 +0,0 @@ -# Implement a simple "Provider Push" Http transfer flow - -This sample demonstrates the "provider push" use case that you can find more details -on [Transfer data plane documentation](https://eclipse-edc.github.io/documentation/for-adopters/control-plane/#transfer-processes). - -This samples consists of: - -* Performing a file transfer - * The consumer will initiate a file transfer - * Provider Control Plane retrieves the DataAddress of the actual data source and creates a - DataFlowRequest based on the received DataRequest and this data address -* Provider Data Plane fetches data from the actual data source -* Provider Data Plane pushes data to the consumer service - -## Prerequisites - -The following steps assume your provider and consumer connectors are still up and running and contract -negotiation has taken place successfully. Furthermore, the http server should be up as well. -If not, re-visit the [Prerequisites](../transfer-00-prerequisites/README.md) -and [Negotiation](../transfer-01-negotiation/README.md) chapters. - -# Run the sample - -Running this sample consists of multiple steps, that are executed one by one and following the same -order. - -### 1. Start a http server - -As a pre-requisite, you need to have a logging webserver that runs on port 4000 and logs all the incoming requests, the -data will be sent to this server. - -```bash -docker build -t http-request-logger util/http-request-logger -docker run -p 4000:4000 http-request-logger -``` - -### 2. Start the transfer - -Before executing the request, modify the [request body](resources/start-transfer.json) by inserting the contract agreement ID -from the [Negotiation](../transfer-01-negotiation/README.md) chapter. -You can re-use the same asset, policies and contract negotiation from before. - -```bash -curl -X POST "http://localhost:29193/management/v3/transferprocesses" \ - -H "Content-Type: application/json" \ - -d @transfer/transfer-02-provider-push/resources/start-transfer.json \ - -s | jq -``` -> keep in mind that, to make a transfer with a provider push method, the dataDestination type should -> be any value different from the "HttpProxy". - -Sample output: - -```json - { - ... - "@id": "591bb609-1edb-4a6b-babe-50f1eca3e1e9", - "createdAt": 1674078357807, - ... -} -``` - -### 3. Check the transfer status - -Due to the nature of the transfer, it will be very fast and most likely already done by the time you -read the UUID. - -```bash -curl http://localhost:29193/management/v3/transferprocesses/ -``` - -Notice the transfer COMPLETED state - -### 4. Check the data - -At this step, you can check the data by checking the log of the http server exposed on port 4000, you should see a log -that shows the same data that you can get from https://jsonplaceholder.typicode.com/users. - -[Next Chapter](../transfer-03-consumer-pull/README.md) diff --git a/transfer/transfer-02-provider-push/resources/start-transfer.json b/transfer/transfer-02-provider-push/resources/start-transfer.json deleted file mode 100644 index 29e424e7..00000000 --- a/transfer/transfer-02-provider-push/resources/start-transfer.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "@context": { - "@vocab": "https://w3id.org/edc/v0.0.1/ns/" - }, - "@type": "TransferRequestDto", - "connectorId": "provider", - "counterPartyAddress": "http://localhost:19194/protocol/2025-1", - "contractId": "{{contract-agreement-id}}", - "protocol": "dataspace-protocol-http:2025-1", - "transferType": "HttpData-PUSH", - "dataDestination": { - "type": "HttpData", - "baseUrl": "http://localhost:4000/api/consumer/store" - } -} diff --git a/transfer/transfer-03-consumer-pull/README.md b/transfer/transfer-03-consumer-pull/README.md deleted file mode 100644 index dadcee5c..00000000 --- a/transfer/transfer-03-consumer-pull/README.md +++ /dev/null @@ -1,193 +0,0 @@ -# Implement a simple "Consumer Pull" Http transfer flow - -The purpose of this sample is to show a data exchange between two connectors, one representing the -data provider and the other, the consumer. You can find more details -on [consumer pull and provider push transfers documentation](https://eclipse-edc.github.io/documentation/for-adopters/control-plane/#consumer-pull-and-provider-push-transfers). - -This sample consists of the following steps: - -* Provide a simple Http Proxy data plane implementation -* Perform a file transfer initiated by the consumer -* The provider will send an EndpointDataReference to the consumer -* The consumer will call the endpoint and fetch the data - -The Http Proxy functionality is not provided by EDC because out there is plenty of FOSS proxy implementations that can -be extended to being able to interact with the EDC, but for example purposes we will implement a really basic Http Proxy -that, please note, it's not meant to be used in production. - -## Prerequisites - -The following steps assume you already built the base connector in the [Prerequisites](../transfer-00-prerequisites/README.md), -that will be used for the "consumer" instance. - -## Implement a simple Http Proxy data plane - -In the [provider-proxy-data-plane](provider-proxy-data-plane) there's a connector based on the [basic one](../transfer-00-prerequisites/connector): - -```kotlin - runtimeOnly(project(":transfer:transfer-00-prerequisites:connector")) -``` - -The proxy implementation provided in this runtime is really bare-bone and it supports only `GET`. Needless to say, it is -only for sample purposes, for a production environment you should rely on a proper proxy implementation. - -Here's the rundown of the implementation: - -### `CustomProxyDataPlaneExtension` - -Is the extension that takes care to inject the needed services and: -- registers a `PortMapping` on the `PortMappingRegistry`: this tells the underlying Web Server (jetty) to expose an endpoint - under the configured port and path -- adds an endpoint generator function on the `generatorFunction`, this will ensure that all the `EndpointDataReference`s - generated by the connector will point to the data-plane proxy public endpoint. Note that this endpoint can be configured, - because in a real world scenario it will need to point to a public endpoint exposed on the internet. -- registers the `ProxyController`, that is the actual proxy implementation. - -[Please check out the code](provider-proxy-data-plane/src/main/java/org/eclipse/edc/sample/extension/proxy/CustomProxyDataPlaneExtension.java). - -### `ProxyController` - -This is modeled as a classic Jersey controller, implementing only, as stated above, only the `GET` method. -On every call the proxy will: -- verify the `Authorization` token -- extract the source `DataAddress` from the token using the `authorizationService` -- create and send an http request to the source server -- pipe the response body stream to the output, adding status code and content-type information. - -[Please check out the code](provider-proxy-data-plane/src/main/java/org/eclipse/edc/sample/extension/proxy/ProxyController.java). - -## Run the sample - -Running this sample consists of multiple steps, that are executed one by one and following the same -order. - -### Build the provider connector - -```bash -./gradlew transfer:transfer-03-consumer-pull:provider-proxy-data-plane:build -``` - -### Run the connectors - -To run the provider, just run the following command - -```bash -java -Dedc.fs.config=transfer/transfer-03-consumer-pull/resources/configuration/provider.properties \ - -jar transfer/transfer-03-consumer-pull/provider-proxy-data-plane/build/libs/connector.jar -``` - -To run the consumer, just run the following command (different terminal). Note that the consumer is the same that was built -in the [prerequisites sample](../transfer-00-prerequisites) - -```bash -java -Dedc.fs.config=transfer/transfer-00-prerequisites/resources/configuration/consumer-configuration.properties \ - -jar transfer/transfer-00-prerequisites/connector/build/libs/connector.jar -``` - -### Negotiate the contract - -You can follow the instructions in the [`transfer-01-negotiation`](../transfer-01-negotiation/README.md) to set up a -Contract Negotiation between the two parts. - -### Start the transfer - -In the [request body](resources/start-transfer.json), we need to specify which asset we want transferred, the ID of the -contract agreement, the address of the provider connector and where we want the file transferred. -Before executing the request, insert the `contractAgreementId` from the previous chapter. Then run: - -```bash -curl -X POST "http://localhost:29193/management/v3/transferprocesses" \ - -H "Content-Type: application/json" \ - -d @transfer/transfer-03-consumer-pull/resources/start-transfer.json \ - -s | jq -``` - -> the "HttpData-PULL" transfer type is used for the consumer pull method, and it means that it will be up to -> the consumer to request the data to the provider and that the request will be a proxy for the datasource - -Then, we will get a UUID in the response. This time, this is the ID of the `TransferProcess` (process id) created on the -consumer side, because like the contract negotiation, the data transfer is handled in a state machine and performed -asynchronously. - -Sample output: - -```json -{ - ... - "@id": "591bb609-1edb-4a6b-babe-50f1eca3e1e9", - "createdAt": 1674078357807, - ... -} -``` - -### Check the transfer status - -Due to the nature of the transfer, it will be very fast and most likely already done by the time you -read the UUID. - -```bash -curl http://localhost:29193/management/v3/transferprocesses/ | jq -``` - -You should see the Transfer Process in `STARTED` state: - -```json -{ - ... - "@id": "591bb609-1edb-4a6b-babe-50f1eca3e1e9", - "state": "STARTED", - ... -} - -``` - -> Note that for the consumer pull scenario the TP will stay in STARTED state after the data has been transferred successfully. -> It might get eventually get shifted to TERMINATED or DEPROVISIONED by other components, but this is not scope of this sample. - -### Check the data - -At this step, an EndpointDataReference would have been generated by the provider and sent to the consumer. The latter -stored it in a cache, so we can obtain it using the transfer process id: -```bash -curl http://localhost:29193/management/v3/edrs//dataaddress | jq -``` - -```json -{ - "@type": "DataAddress", - "type": "https://w3id.org/idsa/v4.1/HTTP", - "endpoint": "http://localhost:19291/public", - "authType": "bearer", - "endpointType": "https://w3id.org/idsa/v4.1/HTTP", - "authorization": "eyJraWQiOiJwdWJsaWMta2V5IiwiYWxnIjoiUlMyNTYifQ.eyJpc3MiOiJwcm92aWRlciIsImF1ZCI6ImNvbnN1bWVyIiwic3ViIjoicHJvdmlkZXIiLCJpYXQiOjE3MTc3NjkyMzEyOTYsImp0aSI6IjM2M2RhMGU4LWZmOGItNDY1My05YjQwLWY4MjdlMWMzOGMzYyJ9.WOVPz6m7XzIrbiMTfLqOXacGYz8Xk_-iQu7gmxoIgDFYsgo0da2Iv51EsugIpqbodPsmB0kK7zkyrmsFOfAASAq7fjsy4gQF-u5egYwoGpcxjYaJJdQa5lkwjC0fRxdVFVwZwrOaT5Mg-vGA9HssTEnlA64q-O0ae_aTH5ToflmPDM3FhAgL55I3odM5ysM2POEJY6pgOxIV9XjuhZFl_i_iTiUCZy__oQUZiYk58wKoqfK758Sy1WzpH-eyZCDUi_Z3n6cJB80_0ZThoPhtiFH7Tl9DfStnjsCoaeqMLFnTXp0s8h4ZGFmjfBc-72aAdRQqqLDT8WXNg3Csv5B56Q", - "@context": { - "@vocab": "https://w3id.org/edc/v0.0.1/ns/", - "edc": "https://w3id.org/edc/v0.0.1/ns/", - "odrl": "http://www.w3.org/ns/odrl/2/" - } -} - -``` - -Once this json is read, use a tool like postman or curl to execute the following query, to read the -data - -```bash -curl --location --request GET 'http://localhost:19291/public/' --header 'Authorization: ' -``` - -At the end, and to be sure that you correctly achieved the pull, you can check if the data you get -is the same as the one you can get at https://jsonplaceholder.typicode.com/users - - -Since we configured the `HttpData` with `proxyPath`, we could also ask for a specific user with: - -```bash -curl --location --request GET 'http://localhost:19291/public/1' --header 'Authorization: ' -``` - -And the data returned will be the same as in https://jsonplaceholder.typicode.com/users/1 - -Your first data transfer has been completed successfully. - -[Next Chapter](../../basic/basic-04-event-consumer/README.md) diff --git a/transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/java/org/eclipse/edc/sample/extension/proxy/CustomProxyDataPlaneExtension.java b/transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/java/org/eclipse/edc/sample/extension/proxy/CustomProxyDataPlaneExtension.java deleted file mode 100644 index cb20d046..00000000 --- a/transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/java/org/eclipse/edc/sample/extension/proxy/CustomProxyDataPlaneExtension.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2025 Cofinity-X - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Cofinity-X - initial API and implementation - * - */ - -package org.eclipse.edc.sample.extension.proxy; - -import org.eclipse.edc.connector.dataplane.spi.Endpoint; -import org.eclipse.edc.connector.dataplane.spi.iam.DataPlaneAuthorizationService; -import org.eclipse.edc.connector.dataplane.spi.iam.PublicEndpointGeneratorService; -import org.eclipse.edc.runtime.metamodel.annotation.Configuration; -import org.eclipse.edc.runtime.metamodel.annotation.Inject; -import org.eclipse.edc.runtime.metamodel.annotation.Setting; -import org.eclipse.edc.runtime.metamodel.annotation.Settings; -import org.eclipse.edc.spi.system.ServiceExtension; -import org.eclipse.edc.spi.system.ServiceExtensionContext; -import org.eclipse.edc.web.spi.WebService; -import org.eclipse.edc.web.spi.configuration.PortMapping; -import org.eclipse.edc.web.spi.configuration.PortMappingRegistry; - -public class CustomProxyDataPlaneExtension implements ServiceExtension { - - private static final int DEFAULT_PUBLIC_PORT = 8185; - private static final String DEFAULT_PUBLIC_PATH = "/api/public"; - - @Configuration - private PublicApiConfiguration apiConfiguration; - @Setting(description = "Base url of the public API endpoint without the trailing slash. This should point to the public endpoint configured.", - key = "edc.dataplane.proxy.public.endpoint") - private String proxyPublicEndpoint; - - @Inject - private PortMappingRegistry portMappingRegistry; - @Inject - private PublicEndpointGeneratorService generatorService; - @Inject - private WebService webService; - @Inject - private DataPlaneAuthorizationService authorizationService; - - @Override - public void initialize(ServiceExtensionContext context) { - portMappingRegistry.register(new PortMapping("public", apiConfiguration.port(), apiConfiguration.path())); - - generatorService.addGeneratorFunction("HttpData", dataAddress -> Endpoint.url(proxyPublicEndpoint)); - - webService.registerResource("public", new ProxyController(authorizationService)); - } - - @Settings - record PublicApiConfiguration( - @Setting(key = "web.http.public.port", description = "Port for public api context", defaultValue = DEFAULT_PUBLIC_PORT + "") - int port, - @Setting(key = "web.http.public.path", description = "Path for public api context", defaultValue = DEFAULT_PUBLIC_PATH) - String path - ) { - - } -} diff --git a/transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/java/org/eclipse/edc/sample/extension/proxy/ProxyController.java b/transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/java/org/eclipse/edc/sample/extension/proxy/ProxyController.java deleted file mode 100644 index e751e98f..00000000 --- a/transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/java/org/eclipse/edc/sample/extension/proxy/ProxyController.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2025 Cofinity-X - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Cofinity-X - initial API and implementation - * - */ - -package org.eclipse.edc.sample.extension.proxy; - -import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.container.ContainerRequestContext; -import jakarta.ws.rs.core.Context; -import jakarta.ws.rs.core.Response; -import org.eclipse.edc.connector.dataplane.spi.iam.DataPlaneAuthorizationService; - -import java.io.IOException; -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; - -import static jakarta.ws.rs.core.HttpHeaders.AUTHORIZATION; -import static jakarta.ws.rs.core.HttpHeaders.CONTENT_TYPE; -import static jakarta.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM; -import static jakarta.ws.rs.core.MediaType.WILDCARD; -import static jakarta.ws.rs.core.Response.Status.FORBIDDEN; -import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; -import static java.util.Collections.emptyMap; -import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; - -@Path("{any:.*}") -@Consumes(WILDCARD) -@Produces(WILDCARD) -public class ProxyController { - - private final DataPlaneAuthorizationService authorizationService; - - public ProxyController(DataPlaneAuthorizationService authorizationService) { - this.authorizationService = authorizationService; - } - - private final HttpClient httpClient = HttpClient.newHttpClient(); - - @GET - public Response proxyGet(@Context ContainerRequestContext requestContext) { - var token = requestContext.getHeaderString(AUTHORIZATION); - if (token == null) { - return Response.status(UNAUTHORIZED).build(); - } - - var authorization = authorizationService.authorize(token, emptyMap()); - if (authorization.failed()) { - return Response.status(FORBIDDEN).build(); - } - - var sourceDataAddress = authorization.getContent(); - - try { - var targetUrl = sourceDataAddress.getStringProperty(EDC_NAMESPACE + "baseUrl") + "/" + requestContext.getUriInfo().getPath(); - var request = HttpRequest.newBuilder() - .uri(URI.create(targetUrl)) - .method(requestContext.getMethod(), HttpRequest.BodyPublishers.ofInputStream(requestContext::getEntityStream)) - .build(); - - var response = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); - return Response.status(response.statusCode()) - .header(CONTENT_TYPE, response.headers().firstValue(CONTENT_TYPE).orElse(APPLICATION_OCTET_STREAM)) - .entity(response.body()) - .build(); - } catch (IOException | InterruptedException e) { - return Response.status(Response.Status.BAD_GATEWAY) - .entity("{\"error\": \"Failed to contact backend service\"}") - .build(); - } - } - -} diff --git a/transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension b/transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension deleted file mode 100644 index d1f67d99..00000000 --- a/transfer/transfer-03-consumer-pull/provider-proxy-data-plane/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.edc.sample.extension.proxy.CustomProxyDataPlaneExtension diff --git a/transfer/transfer-03-consumer-pull/resources/start-transfer.json b/transfer/transfer-03-consumer-pull/resources/start-transfer.json deleted file mode 100644 index f59ec024..00000000 --- a/transfer/transfer-03-consumer-pull/resources/start-transfer.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "@context": { - "@vocab": "https://w3id.org/edc/v0.0.1/ns/" - }, - "@type": "TransferRequestDto", - "connectorId": "provider", - "counterPartyAddress": "http://localhost:19194/protocol/2025-1", - "contractId": "{{contract-agreement-id}}", - "protocol": "dataspace-protocol-http:2025-1", - "transferType": "HttpData-PULL" -} diff --git a/util/README.md b/util/README.md deleted file mode 100644 index 65105c04..00000000 --- a/util/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Util - -Here there are modules that are used by different samples diff --git a/util/http-request-logger/Dockerfile b/util/http-request-logger/Dockerfile deleted file mode 100644 index 549a206e..00000000 --- a/util/http-request-logger/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM gradle:jdk17 AS build - -WORKDIR /home/gradle/project -COPY --chown=gradle:gradle . /home/gradle/project -RUN gradle build - -FROM eclipse-temurin:25-alpine - -WORKDIR /app -COPY --from=build /home/gradle/project/build/libs/http-request-logger.jar /app/http-request-logger.jar - -CMD ["java","-jar","/app/http-request-logger.jar"] diff --git a/util/http-request-logger/build.gradle.kts b/util/http-request-logger/build.gradle.kts deleted file mode 100644 index aa623cc6..00000000 --- a/util/http-request-logger/build.gradle.kts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -plugins { - id("java") -} - -tasks.withType { - from(sourceSets["main"].output) - manifest { - attributes["Main-Class"] = "org.eclipse.edc.samples.util.HttpRequestLoggerServer" - } - archiveFileName.set("http-request-logger.jar") -} diff --git a/util/http-request-logger/src/main/java/org/eclipse/edc/samples/util/HttpRequestLoggerServer.java b/util/http-request-logger/src/main/java/org/eclipse/edc/samples/util/HttpRequestLoggerServer.java deleted file mode 100644 index 0900ebac..00000000 --- a/util/http-request-logger/src/main/java/org/eclipse/edc/samples/util/HttpRequestLoggerServer.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.samples.util; - -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpServer; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.util.Optional; - -public class HttpRequestLoggerServer { - - static final String HTTP_PORT = "HTTP_SERVER_PORT"; - - public static void main(String[] args) { - int port = Integer.parseInt(Optional.ofNullable(System.getenv(HTTP_PORT)).orElse("4000")); - try { - var server = HttpServer.create(new InetSocketAddress(port), 0); - server.createContext("/", new ReceiverHandler()); - server.setExecutor(null); - server.start(); - System.out.println("HTTP request server logger started at " + port); - } catch (IOException e) { - throw new RuntimeException("Unable to start server at port " + port, e); - } - } - - private static class ReceiverHandler implements HttpHandler { - - @Override - public void handle(HttpExchange exchange) throws IOException { - System.out.println("Incoming request"); - System.out.println("Method: " + exchange.getRequestMethod()); - System.out.println("Path: " + exchange.getRequestURI()); - System.out.println("Body:"); - System.out.println(new String(exchange.getRequestBody().readAllBytes())); - System.out.println("============="); - exchange.sendResponseHeaders(200, -1); - } - } - -}