|
| 1 | +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . |
| 2 | +@prefix odrl: <http://www.w3.org/ns/odrl/2/> . |
| 3 | +@prefix : <http://example.org/> . |
| 4 | +@prefix acl: <http://www.w3.org/ns/auth/acl#>. |
| 5 | +@prefix fno: <https://w3id.org/function/ontology#> . |
| 6 | +@prefix log: <http://www.w3.org/2000/10/swap/log#> . |
| 7 | +@prefix string: <http://www.w3.org/2000/10/swap/string#> . |
| 8 | +@prefix list: <http://www.w3.org/2000/10/swap/list#> . |
| 9 | +@prefix time: <http://www.w3.org/2000/10/swap/time#> . |
| 10 | +@prefix math: <http://www.w3.org/2000/10/swap/math#> . |
| 11 | +# Create ODRL Rule: doesn't exist (`odrl:write` and `odrl:append` are deprecated) |
| 12 | +{ :currentTime :is ?currentTime } <= { "" time:localTime ?currentTime }. |
| 13 | + |
| 14 | +# Read ODRL rule |
| 15 | +{ |
| 16 | + ?permission a odrl:Permission; |
| 17 | + odrl:action ?action ; |
| 18 | + odrl:target ?targetResource ; |
| 19 | + odrl:assignee ?requestedParty; |
| 20 | + odrl:assigner ?resourceOwner . |
| 21 | + |
| 22 | + ?action list:in (odrl:use odrl:read) . # multiple options |
| 23 | + |
| 24 | + # context of a request |
| 25 | + ?context |
| 26 | + :resourceOwner ?resourceOwner; |
| 27 | + :requestingParty ?requestedParty; |
| 28 | + :target ?targetResource; |
| 29 | + :requestPermission acl:Read. |
| 30 | + |
| 31 | + :uuid5 log:uuid ?uuidStringdataUsagePolicyExecution. |
| 32 | + ( "urn:uuid:" ?uuidStringdataUsagePolicyExecution) string:concatenation ?urnUuidStringdataUsagePolicyExecution. |
| 33 | + ?dataUsagePolicyExecution log:uri ?urnUuidStringdataUsagePolicyExecution . |
| 34 | + |
| 35 | + # Constraint checking |
| 36 | + # number of constraints must be two (temporal needs lower and upper bound) |
| 37 | + (?template {?permission odrl:constraint _:s} ?L) log:collectAllIn ?SCOPE. |
| 38 | + ?L list:length 3 . |
| 39 | + |
| 40 | + :currentTime :is ?currentTime . |
| 41 | + |
| 42 | + # lower bound |
| 43 | + ?permission odrl:constraint ?lowerBoundIRI . |
| 44 | + ?lowerBoundIRI odrl:leftOperand odrl:dateTime ; |
| 45 | + odrl:operator odrl:gt ; |
| 46 | + odrl:rightOperand ?lowerBound . |
| 47 | + |
| 48 | + # greater bound |
| 49 | + ?permission odrl:constraint ?upperBoundIRI . |
| 50 | + ?upperBoundIRI odrl:leftOperand odrl:dateTime ; |
| 51 | + odrl:operator odrl:lt ; |
| 52 | + odrl:rightOperand ?upperBound . |
| 53 | + |
| 54 | + # ?lowerBound < ?currentTime < ?upperBound |
| 55 | + ?currentTime math:greaterThan ?lowerBound . |
| 56 | + ?currentTime math:lessThan ?upperBound . |
| 57 | + |
| 58 | + # purpose constraint |
| 59 | + ?permission odrl:constraint ?purposeConstraint . |
| 60 | + ?purposeConstraint odrl:leftOperand odrl:purpose ; |
| 61 | + odrl:operator odrl:eq ; |
| 62 | + odrl:rightOperand ?purposeValue |
| 63 | + # Note: nothing is done with the purpose right now TODO: needs checking |
| 64 | +} => |
| 65 | +{ |
| 66 | + ?dataUsagePolicyExecution a fno:Execution; |
| 67 | + fno:executes <http://example.org/dataUsage> ; |
| 68 | + :accessModesAllowed acl:Read. |
| 69 | + ?dataUsagePolicyExecution <http://purl.org/dc/terms/issued> ?currentTime . |
| 70 | + |
| 71 | +}. |
| 72 | + |
0 commit comments