Skip to content

This simple odrl parser is a policy parser that translates odrl based policies to the human readable text.

Notifications You must be signed in to change notification settings

saudkhan116/odrl-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

ODRL Parser

This simple odrl parser is a policy parser, developed in python that translates odrl based policies to the human readable text.

Usage

python odrl-parser.py sample-policy.json

Condition types:

  • Permissions
  • Prohitbitions
  • Obligations

Example Policy

{
    "@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"
                        }
                    ]
                }
            }
        ]
    }
}

Output

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.

About

This simple odrl parser is a policy parser that translates odrl based policies to the human readable text.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages