Skip to content

Commit

Permalink
chore: update the provision policy
Browse files Browse the repository at this point in the history
  • Loading branch information
majadlymhmd committed Jul 5, 2024
1 parent 0276cfb commit a7123cd
Show file tree
Hide file tree
Showing 20 changed files with 545 additions and 509 deletions.
53 changes: 23 additions & 30 deletions policy/policy-02-provision/contractoffer.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
{
"@context": {
"edc": "https://w3id.org/edc/v0.0.1/ns/",
"odrl": "http://www.w3.org/ns/odrl/2/"
"@vocab": "https://w3id.org/edc/v0.0.1/ns/"
},
"@type": "Offer",
"connectorId": "provider",
"consumerId": "cosumer",
"providerId": "provider",
"connectorAddress": "http://localhost:8282/protocol",
"@type": "ContractRequest",
"counterPartyAddress": "http://localhost:8282/protocol",
"protocol": "dataspace-protocol-http",
"offer": {
"offerId": "1:test-document:3a75736e-001d-4364-8bd4-9888490edb58",
"assetId": "test-document",
"policy": {
"@id": "1:test-document:13dce0f1-52ed-4554-a194-e83e92733ee5",
"@type": "set",
"odrl:permission": [
{
"odrl:action": "USE",
"odrl:constraint": [
{
"odrl:leftOperand": "POLICY_REGULATE_FILE_PATH",
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "path/to/desired/location/transfer.txt",
"odrl:target": "test-document"
}
],
"odrl:target": "test-document"
"policy": {
"@context": "http://www.w3.org/ns/odrl.jsonld",
"@id": "MQ==:dGVzdC1kb2N1bWVudA==:YjY2YWU2OGQtNjVmMS00ODEyLTg0MzktMjNlYmZjZjY5YTdk",
"@type": "Offer",
"assigner": "provider",
"target": "test-document",
"permission": [
{
"action": {
"@id": "USE"
},
"constraint": {
"leftOperand": {
"@id": "POLICY_REGULATE_FILE_PATH"
},
"operator": {
"@id": "odrl:eq"
},
"rightOperand": "path/to/desired/location/transfer.txt"
}
],
"odrl:target": "test-document"
}
}
]
}
}
5 changes: 1 addition & 4 deletions policy/policy-02-provision/filetransfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
"dataDestination": {
"type": "File"
},
"transferType": {
"contentType": "application/octet-stream",
"isFinite": true
},
"transferType": "File-PUSH",
"managedResources": true,
"counterPartyAddress": "http://localhost:8282/protocol",
"connectorId": "consumer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,40 @@
* Fraunhofer Institute for Software and Systems Engineering - initial API and implementation
*
*/

plugins {
`java-library`
id("application")
alias(libs.plugins.shadow)
}

dependencies {
api(libs.edc.data.plane.spi)

implementation(libs.edc.api.observability)
implementation(libs.edc.auth.tokenbased)
implementation(libs.edc.configuration.filesystem)
implementation(libs.edc.control.plane.api.client)
implementation(libs.edc.control.plane.api)
implementation(libs.edc.control.plane.core)
implementation(libs.edc.data.plane.core)
implementation(libs.edc.dsp)
implementation(libs.edc.configuration.filesystem)
implementation(libs.edc.iam.mock)
implementation(libs.edc.management.api)
implementation(libs.opentelemetry.annotations)
implementation(libs.edc.data.plane.spi)
implementation(libs.edc.transfer.data.plane.signaling)
implementation(libs.edc.transfer.pull.http.receiver)
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.selector.api)
implementation(libs.edc.data.plane.selector.core)
implementation(libs.edc.control.plane.api.client)

implementation(libs.edc.data.plane.self.registration)
implementation(libs.edc.data.plane.control.api)
implementation(libs.edc.data.plane.public.api)
implementation(libs.edc.data.plane.core)
implementation(libs.edc.data.plane.http)
}

application {
mainClass.set("org.eclipse.edc.boot.system.runtime.BaseRuntime")
mainClass.set("$group.boot.system.runtime.BaseRuntime")
}

tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
edc.participant.id=consumer
edc.dsp.callback.address=http://localhost:9292/protocol
web.http.port=9191
web.http.path=/api
web.http.management.port=9192
web.http.management.path=/management
web.http.protocol.port=9292
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=9195
web.http.public.path=/public
web.http.control.port=9193
web.http.control.path=/control

edc.api.auth.key=password
edc.dsp.callback.address=http://localhost:9292/protocol
edc.ids.id=urn:connector:consumer
edc.participant.id=consumer
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;

import static org.eclipse.edc.connector.transfer.spi.provision.ResourceManifestGenerator.MANIFEST_VERIFICATION_SCOPE;
import static org.eclipse.edc.connector.controlplane.transfer.spi.provision.ResourceManifestGenerator.MANIFEST_VERIFICATION_SCOPE;
import static org.eclipse.edc.policy.engine.spi.PolicyEngine.ALL_SCOPES;

@Extension(value = ConsumerPolicyFunctionsExtension.NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package org.eclipse.edc.sample.extension.policy;

import org.eclipse.edc.connector.transfer.spi.provision.ResourceManifestContext;
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.ResourceManifestContext;
import org.eclipse.edc.policy.engine.spi.AtomicConstraintFunction;
import org.eclipse.edc.policy.engine.spi.PolicyContext;
import org.eclipse.edc.policy.model.Operator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

package org.eclipse.edc.sample.extension.provision;

import org.eclipse.edc.connector.transfer.spi.provision.ConsumerResourceDefinitionGenerator;
import org.eclipse.edc.connector.transfer.spi.types.DataRequest;
import org.eclipse.edc.connector.transfer.spi.types.ResourceDefinition;
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.ConsumerResourceDefinitionGenerator;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.ResourceDefinition;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcess;
import org.eclipse.edc.policy.model.Policy;
import org.jetbrains.annotations.Nullable;

Expand All @@ -33,8 +33,8 @@ public class LocalConsumerResourceDefinitionGenerator implements ConsumerResourc
private static final String DESTINATION = "any path";

@Override
public @Nullable ResourceDefinition generate(DataRequest dataRequest, Policy policy) {
Objects.requireNonNull(dataRequest, "dataRequest must always be provided");
public @Nullable ResourceDefinition generate(TransferProcess transferProcess, Policy policy) {
Objects.requireNonNull(transferProcess, "transferProcess must always be provided");
Objects.requireNonNull(policy, "policy must always be provided");

return LocalResourceDefinition.Builder.newInstance()
Expand All @@ -44,12 +44,11 @@ public class LocalConsumerResourceDefinitionGenerator implements ConsumerResourc
}

@Override
public boolean canGenerate(DataRequest dataRequest, Policy policy) {
Objects.requireNonNull(dataRequest, "dataRequest must always be provided");
public boolean canGenerate(TransferProcess transferProcess, Policy policy) {
Objects.requireNonNull(transferProcess, "dataRequest must always be provided");
Objects.requireNonNull(policy, "policy must always be provided");

return TYPE.equals(dataRequest.getDestinationType());
return TYPE.equals(transferProcess.getDestinationType());
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package org.eclipse.edc.sample.extension.provision;

import dev.failsafe.RetryPolicy;
import org.eclipse.edc.connector.transfer.spi.provision.ProvisionManager;
import org.eclipse.edc.connector.transfer.spi.provision.ResourceManifestGenerator;
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.ProvisionManager;
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.ResourceManifestGenerator;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.runtime.metamodel.annotation.Setting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import org.eclipse.edc.connector.transfer.spi.types.ProvisionedDataDestinationResource;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.ProvisionedDataDestinationResource;


@JsonDeserialize(builder = LocalProvisionedResource.Builder.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package org.eclipse.edc.sample.extension.provision;

import org.eclipse.edc.connector.transfer.spi.types.ResourceDefinition;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.ResourceDefinition;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
package org.eclipse.edc.sample.extension.provision;

import dev.failsafe.RetryPolicy;
import org.eclipse.edc.connector.transfer.spi.provision.Provisioner;
import org.eclipse.edc.connector.transfer.spi.types.DeprovisionedResource;
import org.eclipse.edc.connector.transfer.spi.types.ProvisionResponse;
import org.eclipse.edc.connector.transfer.spi.types.ProvisionedResource;
import org.eclipse.edc.connector.transfer.spi.types.ResourceDefinition;
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.Provisioner;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.DeprovisionedResource;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.ProvisionResponse;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.ProvisionedResource;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.ResourceDefinition;
import org.eclipse.edc.policy.model.Policy;
import org.eclipse.edc.spi.monitor.Monitor;
import org.eclipse.edc.spi.response.StatusResult;
Expand Down Expand Up @@ -92,7 +92,6 @@ private StatusResult<ProvisionResponse> provisionSucceeded(LocalResourceDefiniti

monitor.debug("LocalResourceProvisioner: Resource request submitted: " + resourceDefinition.getPathName());

// not using the secret token
var response = ProvisionResponse.Builder.newInstance().resource(resource).build();
return StatusResult.success(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,40 @@ plugins {
}

dependencies {
api(libs.edc.data.plane.spi)

implementation(libs.edc.api.observability)
implementation(libs.edc.auth.tokenbased)
implementation(libs.edc.configuration.filesystem)
implementation(libs.edc.control.plane.api.client)
implementation(libs.edc.control.plane.api)
implementation(libs.edc.control.plane.core)
implementation(libs.edc.dsp)
implementation(libs.edc.configuration.filesystem)
implementation(libs.edc.iam.mock)
implementation(libs.edc.management.api)
implementation(libs.edc.control.plane.api.client)
implementation(libs.edc.transfer.data.plane.signaling)
implementation(libs.edc.transfer.pull.http.receiver)
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.selector.api)
implementation(libs.edc.data.plane.selector.core)
implementation(libs.edc.data.plane.util)

implementation(libs.edc.data.plane.self.registration)
implementation(libs.edc.data.plane.control.api)
implementation(libs.edc.data.plane.public.api)
implementation(libs.edc.data.plane.core)
implementation(libs.edc.data.plane.http)

//implementation(project(":transfer:transfer-01-file-transfer:transfer-file-local"))
}

application {
mainClass.set("org.eclipse.edc.boot.system.runtime.BaseRuntime")
mainClass.set("$group.boot.system.runtime.BaseRuntime")
}

tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
exclude("**/pom.properties", "**/pom.xm")
mergeServiceFiles()
archiveFileName.set("provider.jar")
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
edc.participant.id=provider
edc.dsp.callback.address=http://localhost:8282/protocol
web.http.port=8181
web.http.path=/api
web.http.management.port=8182
web.http.management.path=/management
web.http.protocol.port=8282
web.http.protocol.path=/protocol

edc.api.auth.key=password
edc.dsp.callback.address=http://localhost:8282/protocol
edc.ids.id=urn:connector:provider
edc.participant.id=provider

edc.samples.policy-02.asset.path = path/to/file
edc.samples.policy-02.constraint.desired.file.path = path/to/desired/location/transfer.txt

edc.transfer.proxy.token.signer.privatekey.alias=private-key
edc.transfer.proxy.token.verifier.publickey.alias=public-key
web.http.public.port=8185
web.http.public.path=/public
web.http.control.port=8183
web.http.control.path=/control
edc.samples.policy-02.asset.path=path/to/file
edc.samples.policy-02.constraint.desired.file.path=path/to/desired/location/transfer.txt
edc.dataplane.api.public.baseurl=http://localhost:8185/public
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

package org.eclipse.edc.sample.extension.policy;

import org.eclipse.edc.connector.contract.spi.offer.store.ContractDefinitionStore;
import org.eclipse.edc.connector.contract.spi.types.offer.ContractDefinition;
import org.eclipse.edc.connector.policy.spi.PolicyDefinition;
import org.eclipse.edc.connector.policy.spi.store.PolicyDefinitionStore;
import org.eclipse.edc.connector.controlplane.asset.spi.domain.Asset;
import org.eclipse.edc.connector.controlplane.contract.spi.offer.store.ContractDefinitionStore;
import org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition;
import org.eclipse.edc.connector.controlplane.policy.spi.PolicyDefinition;
import org.eclipse.edc.connector.controlplane.policy.spi.store.PolicyDefinitionStore;
import org.eclipse.edc.policy.engine.spi.RuleBindingRegistry;
import org.eclipse.edc.policy.model.Action;
import org.eclipse.edc.policy.model.AtomicConstraint;
Expand All @@ -30,7 +31,6 @@
import org.eclipse.edc.spi.query.Criterion;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.spi.types.domain.asset.Asset;

import java.util.List;

Expand Down Expand Up @@ -109,13 +109,13 @@ private void registerContractDefinition(ServiceExtensionContext context) {

var contractDefinition = ContractDefinition.Builder.newInstance()
.id("1")
.accessPolicyId(accessPolicy.getUid())
.contractPolicyId(contractPolicy.getUid())
.accessPolicyId(accessPolicy.getId())
.contractPolicyId(contractPolicy.getId())
.assetsSelector(List.of(Criterion.Builder.newInstance()
.operandLeft(Asset.PROPERTY_ID)
.operator("=") // TODO changed to EQ?
.operandRight(RIGHT_OPERAND)
.build()))
.operandLeft(Asset.PROPERTY_ID)
.operator("=") // TODO changed to EQ?
.operandRight(RIGHT_OPERAND)
.build()))
.build();
contractDefinitionStore.save(contractDefinition);
}
Expand Down
Loading

0 comments on commit a7123cd

Please sign in to comment.