diff --git a/core/json-ld-core/build.gradle.kts b/core/json-ld-core/build.gradle.kts index 22bf99e1a..b43a2063e 100644 --- a/core/json-ld-core/build.gradle.kts +++ b/core/json-ld-core/build.gradle.kts @@ -17,6 +17,7 @@ plugins { } dependencies { + implementation(project(":spi:core-spi")) implementation(libs.edc.spi.core) implementation(libs.edc.spi.jsonld) testImplementation(testFixtures(libs.edc.junit)) diff --git a/core/json-ld-core/src/main/java/org/eclipse/tractusx/edc/jsonld/JsonLdExtension.java b/core/json-ld-core/src/main/java/org/eclipse/tractusx/edc/jsonld/JsonLdExtension.java index aab292b8e..66d33c122 100644 --- a/core/json-ld-core/src/main/java/org/eclipse/tractusx/edc/jsonld/JsonLdExtension.java +++ b/core/json-ld-core/src/main/java/org/eclipse/tractusx/edc/jsonld/JsonLdExtension.java @@ -29,10 +29,15 @@ import static java.lang.String.format; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static org.eclipse.tractusx.edc.edr.spi.CoreConstants.EDC_CONTEXT; +import static org.eclipse.tractusx.edc.edr.spi.CoreConstants.TX_CONTEXT; +import static org.eclipse.tractusx.edc.edr.spi.CoreConstants.TX_NAMESPACE; +import static org.eclipse.tractusx.edc.edr.spi.CoreConstants.TX_PREFIX; public class JsonLdExtension implements ServiceExtension { public static final String CREDENTIALS_V_1 = "https://www.w3.org/2018/credentials/v1"; + public static final String CREDENTIALS_SUMMARY_V_1 = "https://w3id.org/2023/catenax/credentials/summary/v1"; public static final String CREDENTIALS_SUMMARY_V_1_FALLBACK = "https://catenax-ng.github.io/product-core-schemas/SummaryVC.json"; public static final String SECURITY_JWS_V1 = "https://w3id.org/security/suites/jws-2020/v1"; @@ -43,7 +48,9 @@ public class JsonLdExtension implements ServiceExtension { CREDENTIALS_SUMMARY_V_1, PREFIX + "summary-vc-context-v1.jsonld", CREDENTIALS_SUMMARY_V_1_FALLBACK, PREFIX + "summary-vc-context-v1.jsonld", SECURITY_JWS_V1, PREFIX + "security-jws-2020.jsonld", - SECURITY_ED25519_V1, PREFIX + "security-ed25519-2020.jsonld"); + SECURITY_ED25519_V1, PREFIX + "security-ed25519-2020.jsonld", + TX_CONTEXT, PREFIX + "tx-v1.jsonld", + EDC_CONTEXT, PREFIX + "edc-v1.jsonld"); @Inject private JsonLd jsonLdService; @@ -52,6 +59,7 @@ public class JsonLdExtension implements ServiceExtension { @Override public void initialize(ServiceExtensionContext context) { + jsonLdService.registerNamespace(TX_PREFIX, TX_NAMESPACE); FILES.entrySet().stream().map(this::mapToFile) .forEach(result -> result.onSuccess(entry -> jsonLdService.registerCachedDocument(entry.getKey(), entry.getValue())) .onFailure(failure -> monitor.warning("Failed to register cached json-ld document: " + failure.getFailureDetail()))); diff --git a/core/json-ld-core/src/main/resources/document/edc-v1.jsonld b/core/json-ld-core/src/main/resources/document/edc-v1.jsonld new file mode 100644 index 000000000..d539d3e0f --- /dev/null +++ b/core/json-ld-core/src/main/resources/document/edc-v1.jsonld @@ -0,0 +1,47 @@ +{ + "@context": { + "edc": "https://w3id.org/edc/v0.0.1/ns/", + "@vocab": "https://w3id.org/edc/v0.0.1/ns/", + "schema": "http://schema.org/", + "PolicyDefinition": "edc:PolicyDefinition", + "AssetEntryNewDto": "edc:AssetEntryNewDto", + "DataAddress": "edc:DataAddress", + "NegotiationState": "edc:NegotiationState", + "TerminateNegotiation": "edc:TerminateNegotiation", + "ContractRequest": "edc:ContractRequest", + "policy": { + "@id": "edc:policy", + "@type": "@id", + "@context": [ + "http://www.w3.org/ns/odrl.jsonld" + ] + }, + "createdAt": "edc:createdAt", + "properties": "edc:properties", + "privateProperties": "edc:privateProperties", + "dataAddress": "edc:dataAddress", + "type": "edc:type", + "counterPartyAddress": "edc:counterPartyAddress", + "protocol": "edc:protocol", + "querySpec": "edc:querySpec", + "accessPolicyId": "edc:accessPolicyId", + "contractPolicyId": "edc:contractPolicyId", + "assetsSelector": "edc:assetsSelector", + "state": "edc:state", + "reason": "edc:reason", + "connectorAddress": "edc:connectorAddress", + "offer": "edc:offer", + "asset": "edc:asset", + "offerId": "edc:offerId", + "assetId": "edc:assetId", + "contractId": "edc:contractId", + "connectorId": "edc:connectorId", + "callbackAddresses": "edc:callbackAddresses", + "dataDestination": "edc:dataDestination", + "baseUrl": "edc:baseUrl", + "providerId": "edc:providerId", + "uri": "edc:uri", + "events": "edc:events", + "transactional": "edc:transactional" + } +} \ No newline at end of file diff --git a/core/json-ld-core/src/main/resources/document/tx-v1.jsonld b/core/json-ld-core/src/main/resources/document/tx-v1.jsonld new file mode 100644 index 000000000..58d3c974e --- /dev/null +++ b/core/json-ld-core/src/main/resources/document/tx-v1.jsonld @@ -0,0 +1,21 @@ +{ + "@context": { + "@version": 1.1, + "@protected": true, + "tx": "https://w3id.org/tractusx/v0.0.1/ns/", + "BusinessPartnerNumber": "tx:BusinessPartnerNumber", + "NegotiationInitiateRequestDto": "tx:NegotiationInitiateRequestDto", + "BusinessPartnerGroup": "tx:BusinessPartnerGroup", + "EndpointDataReferenceEntry": "tx:EndpointDataReferenceEntry", + "Membership": "tx:Membership", + "Dismantler": "tx:Dismantler", + "FrameworkAgreement.pcf": "tx:FrameworkAgreement.pcf", + "FrameworkAgreement.sustainability": "tx:FrameworkAgreement.sustainability", + "FrameworkAgreement.quality": "tx:FrameworkAgreement.quality", + "FrameworkAgreement.traceability": "tx:FrameworkAgreement.traceability", + "FrameworkAgreement.behavioraltwin": "tx:FrameworkAgreement.behavioraltwin", + "BPN": "tx:BPN", + "expirationDate": "tx:expirationDate", + "edrState": "tx:edrState" + } +} diff --git a/edc-extensions/bpn-validation/bpn-validation-core/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtension.java b/edc-extensions/bpn-validation/bpn-validation-core/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtension.java index 7cca8f600..0be759ea8 100644 --- a/edc-extensions/bpn-validation/bpn-validation-core/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtension.java +++ b/edc-extensions/bpn-validation/bpn-validation-core/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtension.java @@ -27,6 +27,7 @@ import static org.eclipse.edc.connector.contract.spi.offer.ContractDefinitionResolver.CATALOGING_SCOPE; import static org.eclipse.edc.connector.contract.spi.validation.ContractValidationService.NEGOTIATION_SCOPE; import static org.eclipse.edc.connector.contract.spi.validation.ContractValidationService.TRANSFER_SCOPE; +import static org.eclipse.edc.policy.model.OdrlNamespace.ODRL_SCHEMA; /** * Registers a {@link org.eclipse.tractusx.edc.validation.businesspartner.functions.BusinessPartnerGroupFunction} for the following scopes: @@ -49,7 +50,7 @@ *
* Note that the {@link BusinessPartnerGroupFunction} is an {@link org.eclipse.edc.policy.engine.spi.AtomicConstraintFunction}, thus it is registered with the {@link PolicyEngine} for the {@link Permission} class.
*/
-@Extension(value = "Registers a function to evaluate whether a BPN number is covered by a certain policy or not", categories = {"policy", "contract"})
+@Extension(value = "Registers a function to evaluate whether a BPN number is covered by a certain policy or not", categories = { "policy", "contract" })
public class BusinessPartnerValidationExtension implements ServiceExtension {
private static final String USE = "USE";
@@ -71,6 +72,7 @@ public void initialize(ServiceExtensionContext context) {
private void bindToScope(BusinessPartnerGroupFunction function, String scope) {
ruleBindingRegistry.bind(USE, scope);
+ ruleBindingRegistry.bind(ODRL_SCHEMA + "use", scope);
ruleBindingRegistry.bind(BusinessPartnerGroupFunction.BUSINESS_PARTNER_CONSTRAINT_KEY, scope);
policyEngine.registerFunction(scope, Permission.class, BusinessPartnerGroupFunction.BUSINESS_PARTNER_CONSTRAINT_KEY, function);
diff --git a/edc-extensions/cx-policy/build.gradle.kts b/edc-extensions/cx-policy/build.gradle.kts
index b146181fc..4b7ffd4cf 100644
--- a/edc-extensions/cx-policy/build.gradle.kts
+++ b/edc-extensions/cx-policy/build.gradle.kts
@@ -17,6 +17,7 @@ plugins {
}
dependencies {
+ implementation(project(":spi:core-spi"))
implementation(project(":spi:ssi-spi"))
implementation(libs.edc.spi.policyengine)
implementation(libs.jakartaJson)
diff --git a/edc-extensions/cx-policy/src/main/java/org/eclipse/tractusx/edc/policy/cx/summary/SummaryConstraintFunctionsProvider.java b/edc-extensions/cx-policy/src/main/java/org/eclipse/tractusx/edc/policy/cx/summary/SummaryConstraintFunctionsProvider.java
index a7f27fe8f..8d6d5241f 100644
--- a/edc-extensions/cx-policy/src/main/java/org/eclipse/tractusx/edc/policy/cx/summary/SummaryConstraintFunctionsProvider.java
+++ b/edc-extensions/cx-policy/src/main/java/org/eclipse/tractusx/edc/policy/cx/summary/SummaryConstraintFunctionsProvider.java
@@ -18,8 +18,12 @@
import org.eclipse.edc.policy.engine.spi.RuleBindingRegistry;
import org.eclipse.edc.policy.model.Permission;
+import java.util.HashMap;
import java.util.Map;
+import static java.util.Collections.unmodifiableMap;
+import static org.eclipse.edc.policy.model.OdrlNamespace.ODRL_SCHEMA;
+import static org.eclipse.tractusx.edc.edr.spi.CoreConstants.TX_NAMESPACE;
import static org.eclipse.tractusx.edc.policy.cx.common.PolicyScopes.CATALOG_REQUEST_SCOPE;
import static org.eclipse.tractusx.edc.policy.cx.common.PolicyScopes.CATALOG_SCOPE;
import static org.eclipse.tractusx.edc.policy.cx.common.PolicyScopes.NEGOTIATION_REQUEST_SCOPE;
@@ -35,16 +39,26 @@ public class SummaryConstraintFunctionsProvider {
/**
* Mappings from policy constraint left operand values to the corresponding item value in the summary VP.
*/
- static final Map