Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Connector-Restricted-Usage Policy #727 #792

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Connector-Restricted-Usage Policy #727
  • Loading branch information
efiege committed Feb 13, 2024
commit b888f8715e891b785d4b290584b3e792a3473c30
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md).

#### Minor Changes
- Add new MDS fields and migrate existing MDS asset keys to mobilityDCAT-AP
- Fix Connector-Restricted-Usage Policy

#### Patch Changes
- Docs: Enhanced starting a Http-Pull over the EDC-Ui documentation
1 change: 1 addition & 0 deletions extensions/policy-referring-connector/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ plugins {
dependencies {
api("${edcGroup}:auth-spi:${edcVersion}")
api("${edcGroup}:policy-engine-spi:${edcVersion}")
api("${edcGroup}:contract-spi:${edcVersion}")
testImplementation("${edcGroup}:junit:${edcVersion}")

testImplementation("org.mockito:mockito-core:${mockitoVersion}")
Original file line number Diff line number Diff line change
@@ -27,11 +27,15 @@
import de.sovity.edc.extension.policy.functions.ReferringConnectorDutyFunction;
import de.sovity.edc.extension.policy.functions.ReferringConnectorPermissionFunction;
import de.sovity.edc.extension.policy.functions.ReferringConnectorProhibitionFunction;
import org.eclipse.edc.connector.contract.spi.offer.ContractDefinitionResolver;
import org.eclipse.edc.connector.contract.spi.validation.ContractValidationService;
import org.eclipse.edc.policy.engine.spi.AtomicConstraintFunction;
import org.eclipse.edc.policy.engine.spi.PolicyEngine;
import org.eclipse.edc.policy.engine.spi.RuleBindingRegistry;
import org.eclipse.edc.policy.model.Duty;
import org.eclipse.edc.policy.model.Permission;
import org.eclipse.edc.policy.model.Prohibition;
import org.eclipse.edc.policy.model.Rule;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
@@ -97,17 +101,16 @@ public String name() {

@Override
public void initialize(ServiceExtensionContext context) {
final var monitor = context.getMonitor();
ruleBindingRegistry.bind(REFERRING_CONNECTOR_CONSTRAINT_KEY, ContractValidationService.NEGOTIATION_SCOPE);
ruleBindingRegistry.bind(REFERRING_CONNECTOR_CONSTRAINT_KEY, ContractDefinitionResolver.CATALOGING_SCOPE);

final var dutyFunction = new ReferringConnectorDutyFunction(monitor);
final var permissionFunction = new ReferringConnectorPermissionFunction(monitor);
final var prohibitionFunction = new ReferringConnectorProhibitionFunction(monitor);

ruleBindingRegistry.bind("USE", ALL_SCOPES);
ruleBindingRegistry.bind(REFERRING_CONNECTOR_CONSTRAINT_KEY, ALL_SCOPES);
var monitor = context.getMonitor();
registerPolicyFunction(Duty.class, new ReferringConnectorDutyFunction(monitor));
registerPolicyFunction(Permission.class, new ReferringConnectorPermissionFunction(monitor));
registerPolicyFunction(Prohibition.class, new ReferringConnectorProhibitionFunction(monitor));
}

policyEngine.registerFunction(ALL_SCOPES, Duty.class, REFERRING_CONNECTOR_CONSTRAINT_KEY, dutyFunction);
policyEngine.registerFunction(ALL_SCOPES, Permission.class, REFERRING_CONNECTOR_CONSTRAINT_KEY, permissionFunction);
policyEngine.registerFunction(ALL_SCOPES, Prohibition.class, REFERRING_CONNECTOR_CONSTRAINT_KEY, prohibitionFunction);
private <R extends Rule> void registerPolicyFunction(Class<R> type, AtomicConstraintFunction<R> function) {
policyEngine.registerFunction(ALL_SCOPES, type, REFERRING_CONNECTOR_CONSTRAINT_KEY, function);
}
}
Loading