This simple odrl parser is a policy parser, developed in python that translates odrl based policies to the human readable text.
python odrl-parser.py sample-policy.json
- Permissions
- Prohitbitions
- Obligations
{
"@context": {
"odrl": "http://www.w3.org/ns/odrl/2/"
},
"@type": "PolicyDefinitionRequestDto",
"@id": "example-policy",
"policy": {
"@type": "odrl:Set",
"odrl:permission": [
{
"odrl:action": {
"odrl:type": "USE"
},
"odrl:constraint": {
"@type": "LogicalConstraint",
"odrl:and": [
{
"@type": "Constraint",
"odrl:leftOperand": {
"@id": "Membership"
},
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "active"
},
{
"@type": "Constraint",
"odrl:leftOperand": {
"@id": "UsagePurpose"
},
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "non-commercial"
}
]
}
}
],
"odrl:prohibition": [
{
"odrl:action": {
"odrl:type": "USE"
},
"odrl:constraint": {
"@type": "LogicalConstraint",
"odrl:and": [
{
"@type": "Constraint",
"odrl:leftOperand": {
"@id": "purpose"
},
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "http://example.com/music/4567"
}
]
}
}
]
}
}
Interpretation:
You are allowed to use the resource. This is allowed if the Membership eq active and the UsagePurpose eq non-commercial. You are prohibited to use the resource. This is prohibited if the purpose eq http://example.com/music/4567.