odrl-validator
v0.1.0
Published
Validating ODRL policies regarding syntax, semantics and consistency
Downloads
160
Readme
ODRL Validator
The ODRL Validator is a Typescript tool to aid development of consistent ODRL policies. This means the tool can validate whether the policies are syntactically (the correct syntax using the ODRL Vocabulary) and semantically (the terms are used in the correct place according to the model) correct. Furthermore, the tool can detect whether the policies do not contain inconsistencies, that is do they contain two or more rules that contradict each other.
An online version of the ODRL Validator can be found here.
Architecture
ODRL Validator
flowchart LR
Policies["Set of ODRL Policies"]
subgraph ODRLValidator["ODRL Validator"]
Atomization --> Validation
Validation["ODRL Validation\n(Syntactic & Semantic)"]
ConflictDetection["Conflict Detection"]
Validation --> ConflictDetection
end
Output["Output\n(Validation Results & Conflicts)"]
Policies --> ODRLValidator
ODRLValidator --> OutputRunning the ODRL Validator
The following example demonstrates how to parse a policy and run the validator.
import { ODRLValidator } from "odrl-validator";
import { Parser } from "n3";
const policyText = `
@prefix odrl: <http://www.w3.org/ns/odrl/2/> .
@prefix ex: <http://example.org/> .
ex:policy
a odrl:Policy ;
odrl:permission ex:permissionRule ;
odrl:prohibition ex:prohibitionRule .
ex:permissionRule
a odrl:Permission ;
odrl:target ex:resource ;
odrl:assignee ex:alice ;
odrl:action odrl:use .
ex:prohibitionRule
a odrl:Prohibition ;
odrl:target ex:resource ;
odrl:assignee ex:alice ;
odrl:action odrl:use .
ex:alice a odrl:Party .
ex:resource a odrl:Asset .
`;
const quads = parser.parse(policyText);
const validator = new ODRLValidator();
const results = await validator.validate(quads);
console.log(results);The validator operates in two stages:
- SHACL validation
The input policy is first checked against the ODRL information model using SHACL constraints. - Conflict detection
If the policy passes validation (i.e. no violations), conflict detection is performed.
Currently, this step focuses on identifying deontic conflicts.
Therefore the output of the validate function (ValidatorResult) contains three fields:
valid:trueiff no SHACL violations were foundvalidationResults: SHACL outcomesWarning: Indicates a potential issue, but does not invalidate the policy.Violation: Indicates an error against the ODRL information model.
conflicts: detected inconsistenciesmessage: describes the reason for the conflict- It also identifies the two rules involved (
ruleAandruleB)
In the future, we want to include more kinds of conflicts:
- Lex Specialis
- constraint/refinement similarity
- correct constraint operator detection
Comments
uidproperty- In JSON-LD, ODRL’s
uidis mapped to@idto uniquely identify policies or rules. (Victors policy do not have this property) - suggestion: In Turtle (TTL), this mapping isn’t required, so
uidcan be omitted while still remaining ODRL-compliant.
- In JSON-LD, ODRL’s
Feedback and questions
Do not hesitate to report a bug.
Further questions can also be asked to Wout Slabbinck or Elena Molino (developers and maintainers of this repository).
