Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Busk committed Jan 23, 2025
1 parent b321a11 commit a03b350
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public boolean evaluate(Operator operator, Object rightValue, R rule, PolicyCont
}

context.reportProblem(format("Unsupported right-value, expected either an ISO-8061 String or a expression matching '%s', but got '%s'",
ContractExpiryCheckFunction.CONTRACT_EXPIRY_EVALUATION_KEY, rightValueStr));
EXPRESSION_REGEX, rightValueStr));
} catch (NullPointerException | DateTimeParseException ex) {
monitor.warning(format("Exception during time policy evaluation: %s %s", ex.getClass().getCanonicalName(), ex.getMessage()));
context.reportProblem(ex.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;

import static org.eclipse.edc.connector.contract.spi.validation.ContractValidationService.TRANSFER_SCOPE;
import static org.eclipse.edc.policy.model.OdrlNamespace.ODRL_SCHEMA;

import java.util.Map;
Expand Down Expand Up @@ -57,18 +58,28 @@ public String name() {
public void initialize(ServiceExtensionContext context) {
var monitor = context.getMonitor();

// register use action for both negotiation and transfer scope
// register use action for both negotiation scope
ruleBindingRegistry.bind("use", NEGOTIATION_SCOPE);
ruleBindingRegistry.bind("USE", NEGOTIATION_SCOPE);
ruleBindingRegistry.bind(ODRL_SCHEMA + "use", NEGOTIATION_SCOPE);

// iterate over claim constraint key map and register functions for negotiation and transfer scope
ruleBindingRegistry.bind("use", TRANSFER_SCOPE);
ruleBindingRegistry.bind("USE", TRANSFER_SCOPE);
ruleBindingRegistry.bind(ODRL_SCHEMA + "use", TRANSFER_SCOPE);

// iterate over claim constraint key map and register functions for negotiation scope
for (Map.Entry<String, String> entry : CONSTRAINT_KEY_MAP.entrySet()) {
ruleBindingRegistry.bind(entry.getKey(), NEGOTIATION_SCOPE);
policyEngine.registerFunction(NEGOTIATION_SCOPE, Permission.class, entry.getKey(),
new ClientClaimConstraintFunction<>(monitor, entry.getValue(), VERBOSE));
policyEngine.registerFunction(NEGOTIATION_SCOPE, Prohibition.class, entry.getKey(),
new ClientClaimConstraintFunction<>(monitor, entry.getValue(), VERBOSE));

ruleBindingRegistry.bind(entry.getKey(), TRANSFER_SCOPE);
policyEngine.registerFunction(TRANSFER_SCOPE, Permission.class, entry.getKey(),
new ClientClaimConstraintFunction<>(monitor, entry.getValue(), VERBOSE));
policyEngine.registerFunction(TRANSFER_SCOPE, Prohibition.class, entry.getKey(),
new ClientClaimConstraintFunction<>(monitor, entry.getValue(), VERBOSE));
}

// also register reimplementation of standard edc contract expiry check function for negotiation scope
Expand Down

0 comments on commit a03b350

Please sign in to comment.