Short Links
Click here to show or hide short links that help you to directly jump to the element you are looking for.
-
Policy: <policy>, <mechanism>, <variableDeclaration>
-
Decisions: <then>, <else>, <allow>, <allow>, <modify>, <execute>
-
Variables: <variable:boolean>, <variable:number>, <variable:string>, <variable:object>, <variable:list>
-
Parameters: <parameter:boolean>, <parameter:number>, <parameter:string>, <parameter:object>, <parameter:list>
-
Event References: <event:boolean>, <event:number>, <event:string>, <event:object>, <event:list>, <eventHasParameter>
-
Constants: <constant:boolean>, <constant:number>, <constant:string>, <constant:object>, <constant:list>
-
PIPs: <pip:boolean>, <pip:number>, <pip:string>, <pip:object>, <pip:list>
-
Arithmetic Functions: <plus>, <minus>, <multiply>, <divide>, <size>
-
Boolean Functions: <and>, <or>, <xor>, <not>, <implies>, <contains>, <regex>
-
Comparison Functions: <less>, <lessEqual>, <equals>, <greaterEqual>, <greater>
-
Event History: <count>, <valueChanged>, <continuousOccurrence>, <eventOccurrence>, <when>
-
Concatenation: <concat>
Introduction
This documentation is about the specification of privacy policies with the MY DATA Control Technologies policy language regulating security-relevant system events. The MY DATA Control Technologies policy language is designed to express restrictions on data usage. It is an XML-based language, based on boolean logic, arithmetics, temporal information based on an event history. Furthermore, it allows for evaluations based on push (event-triggered) or pull (timer-triggered). Connection to external systems for information retrieval is fully supported. Enforcement decisions can be specified by means of event inhibition, data modification using JsonPath (via PEP modifier plugins) and via the execution of actions (via PXP plugins).
The Event-Condition-Action Schema
MY DATA Control Technologies defines policies based security-relevant events that are occurring at a certain time in a system and are intercepted by "Policy Enforcement Point" (PEP). These events are sent to a "Policy Decision Point" (PDP), which evaluates the policies and returns an Authorization Decision based on the policies. This decision is then enforced by the PEP.
Depending on the system and PEP type, events can highly differ. In general, events contain:
-
An action name that defines the type of the event
-
The time the event occurred
-
A key-value list with event parameters
The following example shows an event we will refer to multiple times in this documentation. It shows an event that is executed when someone reads bank transactions in a web service.
Event ID: "urn:action:banking-demo:get-transactions" Time: 1533545200 Parameters: - "customerID" (Number) - "psd2Id" (Number) - "transactions" (List of Transaction Objects)
MY DATA Control Technologies policies are based on the Event-Condition-Action (ECA). If a system event E (see above) is fetched and a condition C is satisfied, then action A (authorization decision) is performed. MY DATA Control Technologies follows a blacklisting approach. Events that are not covered by policies are allowed by default.
The following policy shows a simple example. It translates to: "Inhibit the event urn:action:banking-demo:get-transactions if it is after 3pm (i.e., if the external information source getCurrentHour returns a value below or equal to 15)"
<policy id='urn:policy:banking-demo:getTransactions'>
<mechanism event='urn:action:banking-demo:get-transactions'> <!-- Event -->
<if> <!-- Condition -->
<less>
<pip:number method='urn:info:banking-demo:getCurrentHour' default='0'/>
<constant:number value='15'/>
</less>
<then>
<inhibit/> <!-- Action -->
</then>
</if>
</mechanism>
</policy>
Policy Structure
A policy consists of one or more mechanisms that are based on the Event-Condition-Action (ECA) schema. MY DATA Control Technologies follows a blacklisting approach. Events that are not covered by policies are allowed by default.
Policy
The <policy> tag is the root element of an MY DATA Control Technologies security policy. It has the following attributes:
Attribute | Type | Required | Meaning |
---|---|---|---|
id |
URN |
required |
The unique id of the policy. The id syntax is urn:policy:<solution>:<identifier>. The <solution> matches your solution ID and defines the range of effect. The <identifier> uniquely identifies the policy within the scope. |
name |
String |
optional |
A human readable (short) name for the policy. |
description |
String |
optional |
A more detailed natural language description of the security policy. |
The <policy> tag must have at least one mechanism child and can optionally contain variableDeclarations.
Mechanisms
A <mechanism> tag describes a rule of a policy based on a monitored, intercepted or time triggered event. An intercepted event can be allowed (event is released and executed normally), modified (the event is changed according to the modifiers specified in the mechanism before it is executed) or inhibited (the event is dropped and will not be executed). A time triggered or monitored event cannot be inhibited or modified - thus, are always allowed. You can use PXPs to react on these events.
The <mechanism> element has the following attributes:
Attribute | Type | Required | Meaning |
---|---|---|---|
event |
URN |
required |
Specifies the event by which the mechanism is triggered and for which the mechanism provides a security rule. The event follows this pattern: urn:action:<solution>:<identifier> |
id |
String |
optional |
A unique id for the mechanism, used for logging purposes only. |
description |
String |
optional |
A natural language description of the mechanism. |
Mechanisms follow the if-then-else schema. Thus, a <mechanism> tag can have the following children:
-
<if>: A condition that leads to an authorization decision if it matches
-
<elseif>: A condition that leads to an authorization decision if it matches and the previous if or else-ifs did not match
-
<else>: A condition that leads to an authorization decision if none of the previous if or else-ifs matched
-
<execute>: The unconditional execution of an action
Policy Specification Rules
|
Policy Evaluation Rules
|
<policy id='urn:policy:banking-demo:getAccounts' description='Inhibits access to transactions and loggs the action'>
<mechanism event='urn:action:banking-demo:get-transactions'>
<if>
<less>
<pip:number method='urn:info:banking-demo:getCurrentHour' default='0'/>
<constant:number value='15'/>
</less>
<then>
<inhibit/>
<execute action='urn:action:banking-demo:logNotification'>
<parameter:string name='message' value='Access attempt to account data after 3pm'/>
</execute>
</then>
</if>
<else>
<allow/>
<execute action='urn:action:banking-demo:logNotification'>
<parameter:string name='message' value='Access attempt to account data before 3pm'/>
</execute>
</else>
<execute action='urn:action:banking-demo:logNotification'>
<parameter:string name='message' value='Access attempt to account data'/>
</execute>
</mechanism>
</policy>
Conditions
The <if> and the <elseif> elements declare the condition that is evaluated each time the mechanism fires.
A condition must have the following child elements:
-
A boolean-function that defines the condition
-
A <then> that defines an authorization decision that the mechanism enforces if the condition matches
Policy Specification Rules
|
Policy Evaluation Rules
|
<policy id='urn:policy:banking-demo:getTransactions'>
<mechanism event='urn:action:banking-demo:get-transactions'>
<if>
<lessEqual>
<constant:number value='15'/>
<pip:number method='urn:info:banking-demo:getCurrentHour' default='0'/>
</lessEqual>
<then>
<inhibit/>
</then>
</if>
<elseif>
<and>
<greaterEqual>
<pip:number method='urn:banking-demo:getCurrentHour' default='0'/>
<constant:number value='14'/>
</greaterEqual>
<less>
<pip:number method='urn:info:banking-demo:getCurrentHour' default='0'/>
<constant:number value='15'/>
</less>
</and>
<then>
<execute action='urn:action:banking-demo:logNotification'>
<parameter:string name='message' value='Access attempt to account data between 2 and 3pm'/>
</execute>
</then>
</elseif>
<else>
<constant:true/>
<then>
<allow/>
<execute action='urn:action:banking-demo:logNotification'>
<parameter:string name='message' value='Someone accessed the transactions'/>
</execute>
</then>
</else>
</mechanism>
</policy>
Decisions
Decisions are defined inside a <then> element inside a condition (<if> or <elseif>), or in an <else> element, which is used if no condition is fulfilled. These two elements can have the following child elements:
Policy Specification Rules
|
<policy id='urn:policy:cs4:anonymizeTasksOfOthers'>
<mechanism event='urn:action:cs4:show-task'>
<if>
<equals>
<pip:string method='urn:info:cs4:getRoleByUsername' default=''>
<parameter:string name='userId'>
<event:string eventParameter='user' default='' jsonPathQuery='$.userId'/>
</parameter:string>
</pip:string>
<constant:string value='ROLE_USER'/>
</equals>
<then>
<modify eventParameter='task' method='anagram' jsonPathQuery='$.description'>
<parameter:number name='percentage' value='100'/>
</modify>
<modify eventParameter='task' method='replace' jsonPathQuery='$.name'>
<parameter:string name='replaceWith' value='******'/>
</modify>
<modify eventParameter='task' method='delete' jsonPathQuery='$.budget'/>
</then>
</if>
<else>
<inhibit/>
</else>
</mechanism>
</policy>
Simple Decisions
Similar to basic access control mechanisms, an event can be allowed or inhibited. The <allow> tag is part of a positive authorization decision. It informs the PEP that the intercepted event can be released for reaching its destination. The <inhibit> tag is part of a negative authorization decision. It informs the PEP that the intercepted event must be dropped so that it never reaches its destination. A reason can be added to both elements:
Attribute | Type | Required | Meaning |
---|---|---|---|
reason |
String |
optional |
The description or rationale for the decision. |
<policy id='urn:policy:banking-demo:checkRoleExample'>
<mechanism event='urn:action:banking-demo:get-transactions'>
<if>
<equals>
<pip:string method='urn:info:banking-demo:checkRole' default=''/>
<constant:string value='Banker'/>
</equals>
<then>
<allow reason='Banker is authorized to get transactions'/>
</then>
</if>
<else>
<inhibit reason='User is not authorized'/>
</else>
</mechanism>
</policy>
Complex Decisions with Event Modifications
In addition to basic access control mechanisms, MY DATA Control Technologies allows the modification of the intercepted event. The <modify> element is used to specify event modifications that the PEP must enforce before releasing the intercepted event. It has the following attributes:
Attribute | Type | Required | Meaning |
---|---|---|---|
eventParameter |
String |
required |
The name of the event parameter that should be modified. |
method |
String |
required |
The name of the modification that should be applied (e.g., delete, anonymize). This depends on the capabilities of the PEP. Available modifier methods can be checked in your component overview and are proposed by the policy editor. |
jsonPathQuery |
String |
optional |
If the parameter contains a complex object, modifications can be applied to specific parts of the data structure. For example a query "$.firstName" of a parameter "user" will result in the modification of the first name of the user object only. |
reason |
String |
optional |
The description or rationale for the event modification. |
Some modification methods ("modifiers") require additional parameters. For example, the "replace" modifier gives you the option to replace a certain string (either the event parameter or part of a complex object) with another String. This String has to be provided as a parameter, as the following example shows. Our editor will automatically add stubs for all required parameters.
<policy id='urn:policy:banking-demo:getAccounts'>
<mechanism event='urn:action:banking-demo:get-accounts'>
<if>
<constant:true/>
<then>
<modify eventParameter='accounts' method='replace' jsonPathQuery='$.accounts.bankCodeNumber'>
<parameter:string name='replaceWith' value='XXXXX'/>
</modify>
</then>
</if>
</mechanism>
</policy>
JSONPath
JSONPath is an instrument to query JSON structures, similar to XPath for XML. JSONPath uses special notation to represent nodes and their connections to adjacent nodes in a JsonPath path. Plese refer to https://github.com/json-path/JsonPath for a full documentation on JsonPath. |
Policy Evaluation Rules
When you are using JsonPath, type safety cannot be guaranteed. This means for example that you can overwrite a Number with a String or List. While this is not a problem for Json / JsonPath, it can (and most likely will) cause problems when deserializting the Json back to an Object at the PEP side. Thus, you need to take care that all modifications you are doing preserve the type. Our editor will show corresponding warnings. |
Variable Declarations
See chapter Working with Variables.
Data Types
MY DATA Control Technologies works with five data types: String, Number, Boolean, Object and List. All operators can be combined only depending on their type. For example, if you have a boolean <and> operator, any kind of boolean children can be attached (e.g., <variable:boolean>, <constant:boolean>, <event:boolen>, <not>, <execute>).
Operators
Basic Operators
For each of the five data types, MY DATA Control Technologies provides five basic operators: Constants, Variables, Event References, Parameters, and PIPs. These operators will be explained in the following.
Constants
Constants are used to define a string, number, object, list or boolean that does not depend on any external factor, i.e. cannot change at runtime. Thus, the value is set during policy specification and does never change.
The following constants are available:
-
<constant:string>
-
<constant:number>
-
<constant:object>
-
<constant:list>
-
<constant:true>
-
<constant:false>
Constants (except <constant:true> and <constant:false>) have the following attributes:
Attribute | Type | Required | Meaning |
---|---|---|---|
value |
depends on constant type (string, number, boolean) |
required |
The value of the constant. |
<policy id='urn:policy:banking-demo:getTransactions'>
<mechanism event='urn:action:banking-demo:get-transactions'>
<if>
<equals>
<pip:string method='urn:info:banking-demo:checkRole' default=''/>
<constant:string value='Banker'/>
</equals>
<then>
<inhibit/>
</then>
</if>
</mechanism>
</policy>
Policy Specification Rules
Boolean constants do not have a value. They are explicitly available as <constant:true> and <constant:false>. |
Variables
See chapter Working with Variables.
Event references
The event elements are used to reference an event parameter. The following event elements are available:
-
<event:string>
-
<event:number>
-
<event:object>
-
<event:list>
-
<event:boolean>
The elements have the following attributes:
Attribute | Type | Required | Meaning |
---|---|---|---|
eventParameter |
String |
required |
The name of an event parameter. |
default |
same as the event parameter type (string, number, boolean) |
required |
The value that is returned if the parameter does not exist in the event. |
jsonPathQuery |
String |
optional |
The JSONPath expression to be executed on the parameter value, if the value is a complex object. Please refer to https://github.com/json-path/JsonPath for more information about JsonPath. |
Remember our example event:
Event ID: "urn:action:banking-demo:get-transactions" Time: 1533545200 Parameters: - "customerID" (Number) - "psd2Id" (Number) - "transactions" (List of Transaction Objects)
<policy id='urn:policy:banking-demo:getTransactions'>
<mechanism event='urn:action:banking-demo:get-transactions'>
<if>
<and>
<equals>
<event:number eventParameter='customerID' default='1'/>
<constant:number value='1'/>
</equals>
<greater>
<event:number eventParameter='transactions' default='1001' jsonPathQuery="$.transactions.amount.value"/>
<constant:number value='1000'/>
</greater>
</and>
<then>
<modify eventParameter='transactions' method='replace'>
<parameter:object name='replaceWith' value='XXX'/>
</modify>
</then>
</if>
</mechanism>
</policy>
Parameters
The parameter elements are used for parameterized methods. In our case this can be either
-
a PIP or
-
an execute or
-
an event modification
The following parameter-elements are available:
-
<parameter:string>
-
<parameter:number>
-
<parameter:object>
-
<parameter:list>
-
<parameter:boolean>
Parameters always have a name and a value.
Attribute | Type | Required | Meaning |
---|---|---|---|
name |
String |
required |
The name of the parameter. |
value |
String |
optional |
The value of the parameter. |
Parameters can have one child of the same type (e.g., a string parameter can have a string child).
Policy Specification Rules
A parameter must have either a value attribute or a child |
Policy Evaluation Rules
|
<policy id='urn:policy:cs4:showUser'>
<mechanism event='urn:action:cs4:show-project'>
<if>
<or>
<equals>
<pip:string method='urn:info:cs4:getRoleByUsername' default=''>
<parameter:string name='userId' value='1'/> <!-- attribute value is used -->
</pip:string>
<constant:string value='Manager'/>
</equals>
<equals>
<pip:string method='urn:info:cs4:getRoleByUsername' default=''>
<parameter:string name='userId'> <!-- child value is used -->
<event:string eventParameter='transactions' default='1001' jsonPathQuery="$.transactions.userId"/>
</parameter:string>
</pip:string>
<constant:string value='Manager'/>
</equals>
</or>
<then>
<allow/>
</then>
</if>
</mechanism>
</policy>
External Information Sources (PIPs)
The pip elements are used to request information from a PIP. Each element returns their value (String, number, object, list, boolean). The parameters that can be added as child elements are sent to the PIP as request parameters.
The following pip elements are available:
-
<pip:string>
-
<pip:number>
-
<pip:object>
-
<pip:list>
-
<pip:boolean>
The elements have the following attributes:
Attribute | Type | Required | Meaning |
---|---|---|---|
method |
String |
required |
The name of a PIP method. |
default |
same as the pip type (string, number, boolean) |
required |
The value that is returned if the PIP is not reachable. |
ttl |
time interval notation |
optional |
The "time to live" value sets the time interval that the response value of the PIP is cached. The ttl follows the following syntax: (([0-9]+y)?([0-9]+w)?([0-9]+d)?([0-9]+h)?([0-9]+m)?([0-9]+s)?) (e.g., 1y), where y = years, w = weeks, d = days, h = hours, m = minutes, s = seconds. For example if the pip value should be cached for 1 week, 4 days and 2 hours it would look like "1w4d2h". |
Policy Evaluation Rules
|
<policy id='urn:policy:banking-demo:getTransactions'>
<mechanism event='urn:action:banking-demo:get-transactions'>
<if>
<and>
<equals>
<constant:string value='Banker'/>
<pip:string method='urn:info:banking-demo:checkRole' default='' ttl="5m">
<parameter:number name='loggedUser'/>
</pip:string>
</equals>
<constant:true/>
</and>
<then>
<modify eventParameter='transactions' method='replace'>
<parameter:object name='replaceWith' value='XXX'/>
</modify>
</then>
</if>
</mechanism>
</policy>
Number Operators
Number operators are all operators that have a number as return value.
Basic Number Operators
The basic number operators are <variable:number>, <constant:number>, <parameter:number>, <event:number>, and <pip:number>.
Arithmetic functions
The functions <plus>, <minus>, <multiply> and <divide> are available to perform the arithmetical operations (addition, subtraction, multiplication, division). These four functions don’t have any attributes and have at least two number children (e.g. <constant:number>, <pip:number>, <size>).
The <size> function is used to count the number of elements in a list or the number of characters in a string. It doesn’t have any attributes, either. You can assign all child elements with a list or string return value.
Boolean Operators
Number operators are all operators that have a boolean as return value.
Basic Boolean Operators
The basic number operators are <variable:boolean>, <constant:boolean>, <parameter:boolean>, <event:boolean>, and <pip:boolean>.
Basic Boolean Functions
The elements <and>, <or>, <not>, <xor> and <implies> aggregate the values of the child elements according to Boolean logic.
The following attribute can be added:
Attribute | Type | Default Value | Required | Meaning |
---|---|---|---|---|
mode |
String (LAZY, EAGER) |
LAZY |
optional |
It is possible to choose the mode lazy or eager. Lazy evaluation means that an evaluation is stopped as soon as the result cannot change anymore. For example, as soon as the first child of an <and> is false, the other children are not evaluated. If you want to force the evalution of all children (e.g., to eventually execute a PXP), you have to set the mode to EAGER. |
Child elements can be all elements with boolean return value (e.g. <constant:true>, <event:boolean>) or elements of the boolean-functions.
Policy Specification Rules
|
<policy id='urn:policy:banking-demo:InhibitUser1Transaction'>
<mechanism event='urn:action:banking-demo:get-money'>
<if>
<and>
<equals>
<event:string eventParameter='sts' default='' jsonPathQuery='$.simpleusers.id'/>
<constant:string value='1'/>
</equals>
<greater>
<event:number eventParameter='sts' default='0' jsonPathQuery='$.transactions.amount.value'/>
<constant:number value='10000'/>
</greater>
</and>
<then>
<inhibit/>
</then>
</if>
</mechanism>
</policy>
Comparison Functions
The functions <less>, <lessEqual>, <greater> and <greaterEqual> are used to compare different numbers. For instance if you want to compare the number of usages with a constant number ("must not be used more than 3 times"). These functions don’t have attributes and child elements can be elements with a number return value (like <pip:number>) and the number-functions.
The function <equals> is different, because besides numbers other values can be compared with each other. For example, it is possible to compare strings like a constant string and a user name. <equals> doesn’t have an attribute, either. And besides child elements with a number return value, also elements with string, object, list and boolean return value as well as boolean-functions can be added to <equals>.
Policy Specification Rules
|
Regular Expressions
A regular expression (regex) is a formal language to describe a certain pattern or a sequence of characters. If the regex pattern matches to the child-elements value the <regex> element returns true otherwise it would return false. The <regex> element has the following attributes:
Attribute | Type | Default Value | Required | Meaning |
---|---|---|---|---|
regex |
String |
- |
required |
The String defines the regex that is applied for matching the values of child elements. Java notation is used. |
mode |
enum (ALL, EXACTLY_ONE, AT_LEAST_ONE, NONE) |
ALL |
optional |
The mode declares which or how many child element must match. |
A <regex> can have the child elements with string return value and elements from the string-functions.
Policy Specification Rules
|
Policy Evaluation Rules
|
<policy id='urn:policy:banking-demo:regexExample'>
<mechanism event='urn:action:banking-demo:get-transactions'>
<if>
<regex regex='(Lohn)|(Gehalt)|(salary)|(pay)'>
<event:string eventParameter='transactions' default='' jsonPathQuery='$.transactions.purpose'/>
</regex>
<then>
<modify eventParameter='transactions' method='replace' jsonPathQuery='$.transactions.amount.value'>
<parameter:object name='replaceWith' value='XXXX'/>
</modify>
</then>
</if>
</mechanism>
</policy>
Date functions
The date functions <date>, <time>, and <day> return true if the specified date / time / date matches the current date. Thus, you can check if the event occurred before, after or at a specific date.
<policy id='urn:policy:cs4:Datetime1' description='test date and time functions'>
<mechanism event='urn:action:cs4:example'>
<if>
<and>
<date is='before' value='15.05.2040'/>
<date is='after' value='15.05.2001'/>
<time is='before' value='20:30'/>
<time is='after' value='08:30'/>
<day value='Tuesday'/>
</and>
<then>
<allow/>
</then>
</if>
</mechanism>
</policy>
The <date> compares a specified date with the current date (of the event evaluation).
Attribute | Type | Default Value | Required | Meaning |
---|---|---|---|---|
is |
String |
- |
required |
The String defines the time expressions: Before, After, Exactly |
value |
date |
- |
required |
The date in the format of dd.mm.yyyy |
The <time> compares a specified time with the current time (of the event evaluation).
Attribute | Type | Default Value | Required | Meaning |
---|---|---|---|---|
is |
String |
- |
required |
The String defines the time expressions: Before, After, Exactly |
value |
time |
- |
required |
The time in the format of hh:mm |
The <day> compares a specified day with the current day (of the event evaluation).
Attribute | Type | Default Value | Required | Meaning |
---|---|---|---|---|
value |
String |
- |
required |
Or-linked, comma separated list of days that match: Tuesday,Friday,Sunday |
<policy id='urn:policy:cs4:Datetime'>
<mechanism event='urn:action:cs4:show-tasks'>
<if>
<and>
<date is='before' value='15.05.2020'/>
<time is='before' value='17:00'/>
<time is='after' value='08:30'/>
<day value='Tuesday'/>
</and>
<then>
<allow/>
</then>
</if>
</mechanism>
</policy>
Execution of external events
Execute Actions are actions that security policies can trigger in the system. They are specified using the <execute> tag. Execute actions return a Boolean value indicating the execution success.
Attribute | Type | Required | Meaning |
---|---|---|---|
action |
String |
required |
The name of action to be executed in an PXP. |
Child elements can be all elements of the parameter-group. They serve as input parameters for the corresponding execution function. The mandatory and optional parameters depend on the selected execute action.
<policy id='urn:policy:banking-demo:log_Message'>
<mechanism event='urn:action:banking-demo:get-accounts'>
<if>
<execute action='urn:action:banking-demo:notifyAdmin'>
<parameter:string name='message' value='Dear admin, user trying to access accounts.'/>
</execute>
<then>
<allow/>
<execute action='urn:action:banking-demo:logNotification'>
<parameter:string name='message' value='Granted access to accounts.'/>
</execute>
</then>
</if>
<else>
<inhibit/>
</else>
<execute action='urn:action:banking-demo:logNotification'>
<parameter:string name='message' value='Access to account'/>
</execute>
</mechanism>
</policy>
Checking if a list contains certain elements
<contains> can be used to verify whether a list contains a certain value. For instance, to verify whether the list "[Policy Language, Policy]" contains the string "Policy".
A <contains> element has a "mode" attribute that declares how many child element must match.
It must contain a list as first child and any number of arbitrary elements as further children.
Attribute | Type | Default Value | Required | Meaning |
---|---|---|---|---|
mode |
enum (ALL, EXACTLY_ONE, AT_LEAST_ONE, NONE) |
ALL |
optional |
The mode declares how many child element must match. |
<policy id='urn:policy:banking-demo:containsExample'>
<mechanism event='urn:action:banking-demo:get-accounts'>
<if>
<contains mode='EXACTLY_ONE'>
<event:list eventParameter='accounts' default='0' jsonPathQuery='$..iban'/>
<constant:string value='DE00999940000000000000'/>
<constant:string value='DE00999940000400000000'/>
</contains>
<then>
<inhibit/>
</then>
</if>
</mechanism>
</policy>
Policy Specification Rules
|
Policy Evaluation Rules
|
Checking whether an event has a specific parameter
To check whether an event has certain parameters the <eventHasParameter> element can be used. Like the <regex> and the <contains> element the <eventHasParameter> has the following mode attribute:
Attribute | Type | Default Value | Required | Meaning |
---|---|---|---|---|
mode |
enum (ALL, EXACTLY_ONE, AT_LEAST_ONE, NONE) |
ALL |
no |
The mode declares how many child element must match. |
Because <eventHasParameter> refers to a name of an event parameter, it can only have child elements which return string values.
<policy id='urn:policy:banking-demo:eventHasParameterExample'>
<mechanism event='urn:action:banking-demo:get-userForStats'>
<if>
<eventHasParameter mode='NONE'>
<event:string eventParameter='user' default='' jsonPathQuery='$.id'/>
</eventHasParameter>
<then>
<execute action='urn:action:banking-demo:logNotification'>
<parameter:string name='message' value='user id is empty'/>
</execute>
</then>
</if>
</mechanism>
</policy>
Policy Specification Rules
|
Policy Evaluation Rules
|
String Operators
Basic String Operators
The basic string operators are <variable:string>, <constant:string>, <parameter:string>, <event:string>, and <pip:string>.
String Concatenation (concat)
<concat> concatenates all values of child elements to a string. It is possible to add any number and kinds of children.
<policy id='urn:policy:cs4:showEmployees'>
<mechanism event='urn:action:cs4:showEmployees'>
<if>
<not>
<contains>
<pip:list method='urn:info:cs4:getAllPriviledgedEmployees' default='[]'/>
<concat>
<event:string eventParameter='user' default='' jsonPathQuery='$.firstName'/>
<constant:string value=''/>
<event:string eventParameter='user' default='' jsonPathQuery='$.lastName'/>
</concat>
</contains>
</not>
<then>
<inhibit/>
</then>
</if>
</mechanism>
</policy>
Policy Specification Rules
|
Policy Evaluation Rules
For lists and objects, the toString() method is called, which might result in unwanted effects. |
Object Operators
Object operators return a complex object that can be application specific (e.g. "com.example.Transaction" or "de.beispiel.User"). All operations on these objects are done on their Json representation, as we do not know the class declaration. To work with complex objects, you can use JsonPath. To simplify the handling of these objects, our policy editor supports auto completion to navigate the Json structure. Direct comparison can be done using <equals>.
The object operators are <variable:object>, <constant:object>, <parameter:object>, <event:object>, and <pip:object>.
List Operators
List operators return a list of values or objects, which can be of any type. Again, you can use JsonPath to work with lists. Furthermore, you can use the <contains> function to check if a list contains a certain value or object.
The list operators are <variable:list>, <constant:list>, <parameter:list>, <event:list>, and <pip:list>.
Working with Variables
If you are reusing the same value at different positions in the policy, you can use variables. Variables are declared using variableDeclarations and referenced by variables inside conditions or parameters. At runtime, a variable value is set once per policy and request. The value is then shared by all mechanisms of the policy.
VariableDeclarations are defined directly below the root element <policy>.
<policy id='urn:policy:banking-demo:getTransactions'>
<variableDeclaration:string name='RoleLoggedUser'>
<pip:string method='urn:info:banking-demo:checkRole' default=''>
<parameter:number name='loggedUser' value='1'/>
</pip:string>
</variableDeclaration:string>
<mechanism event='urn:action:banking-demo:get-bankusers'>
...
</mechanism>
</policy>
Based on the data types, the following variableDeclarations are available:
-
<variableDeclaration:string>
-
<variableDeclaration:number>
-
<variableDeclaration:object>
-
<variableDeclaration:list>
-
<variableDeclaration:boolean>
VariableDeclarations are basically key-value pairs. The name is used to refer to the variable and is defined as an attribute:
Attribute | Type | Required | Meaning |
---|---|---|---|
name |
String |
required |
The name of the variableDeclaration used to refer to it. Must be unique per policy. |
The variableDeclaration’s value stems from the child element of the variableDeclaration. The following example shows a declaration of a boolean variable RoleLoggedUser, that takes a PIP value. The benefit of this construct is, that the PIP is only called once per policy and not everytime it is referenced.
Policy Evaluation Rules
A variable declaration is only evaluated once per policy and event. This is especially important if you are using PIPs or PXPs that can change their value on repeated evaluation. This means for example: If a policy contains 5 mechanisms referencing a variable based on a PIP, this PIP is only queried once and the result is used by all mechanisms. |
-
<variable:string>
-
<variable:number>
-
<variable:object>
-
<variable:list>
-
<variable:boolean>
Every element has the reference attribute:
Attribute | Type | Required | Meaning |
---|---|---|---|
reference |
String |
required |
The reference name to a variableDeclaration. |
<policy id='urn:policy:banking-demo:getTransactions'>
<variableDeclaration:string name='RoleLoggedUser'>
<pip:string method='urn:info:banking-demo:checkRole' default=''>
<parameter:number name='loggedUser' value='1'/>
</pip:string>
</variableDeclaration:string>
<mechanism event='urn:action:banking-demo:get-bankusers'>
<if>
<or>
<equals>
<variable:string reference='RoleLoggedUser'/>
<constant:string value='Customer'/>
</equals>
<equals>
<variable:string reference='RoleLoggedUser'/>
<constant:string value='External'/>
</equals>
</or>
<then>
<inhibit/>
</then>
</if>
</mechanism>
</policy>
Working with the Event History
In order to express certain usage control obligations, it is necessary to refer to events that occurred in the past. For example, if you want to prevent a file to be printed more than 3 times, this information must be stored. For this purpose, we offer an event history with three basic query types:
-
counting specific events in a certain time range
-
checking if a value changed since the last evaluation
-
checking if an event occurs periodically
Policy Evaluation Rules
|
Counting of Events
With <count>, it is possible to express the cardinal and temporal aspects. It is used to count the number of event occurrences in a certain time interval. Thus, it has exactly two children:
-
<eventOccurrence> is used refer to certain event(s) you want to count
-
<when> is used to define a time range for the counting
In the following, you see an example counting the number of times the event "get-money" occurred this year for the customer with ID "5".
<policy id='urn:policy:banking-demo:getTransactionsExample'>
<mechanism event='urn:action:banking-demo:get-transactions'>
<if>
<greaterEqual>
<count>
<eventOccurrence event='urn:action:banking-demo:get-money'>
<parameter:number name="customerID" value="5"/>
<eventOccurrence>
<when>
<start time='1.1.* 00:00'/>
</when>
</count>
<constant:number value='15'/>
</greaterEqual>
<then>
<inhibit/>
</then>
</if>
</mechanism>
</policy>
Evaluation of Periodic Events
With the <continuousOccurrence> element it is possible to evaluate, if an event occurred periodically during a certain time interval. Just like <count>, it has exactly two children:
-
<eventOccurrence> is used refer to certain event(s) you want to count
-
<when> is used to define a time range for the counting
However, there are the following additional attributes:
Attribute | Type | Required | Meaning |
---|---|---|---|
interval |
String |
required |
The interval declares the time interval in which an event has to occur to fulfill the condition, for example "1 year". It has follow the following syntax: (([0-9]+y)?([0-9]+w)?([0-9]+d)?([0-9]+h)?([0-9]+m)?([0-9]+s)?) (e.g., 1y), where y = years, w = weeks, d = days, h = hours, m = minutes, s = seconds. |
minOccurrences |
number |
optional |
Declares the minimum number of occurrences until the condition is fulfilled. |
maxOccurrences |
number |
optional |
Declares the maximum number of Occurrences that the condition is fulfilled. |
The following example shows a policy that inhibits an event if the user was not notified at least once a day since the beginning of the year.
<policy id='urn:policy:banking-demo:continuousOccurrenceExample'>
<mechanism event='urn:action:banking-demo:get-transactions'>
<if>
<not>
<continuousOccurrence interval='1d' minOccurrences='1'>
<eventOccurrence event='urn:action:banking-demo:notify-user'/>
<when>
<start time='1.1.* 00:00"/>
</when>
</continuousOccurrence>
</not>
<then>
<inhibit/>
</then>
</if>
</mechanism>
</policy>
Evaluation of Changes over Time
When using the <valueChanged> function, the system checks if the return value of the child has changed between the last evaluation cycle and this evaluation cycle to the value defined in the attribute. The <valueChanged> element only returns true if the value is changed. The following valueChanged elements are available:
-
<valueChanged:string>
-
<valueChanged:number>
-
<valueChanged:object>
-
<valueChanged:list>
-
<valueChanged:boolean>
<valueChanged> has the following optional attribute:
Attribute | Type | Required | Meaning |
---|---|---|---|
to |
Boolean |
optional |
Defines if the value of the child element changed to true or false. |
id |
String (UUID) |
required |
Defines a UUID for the valueChanged block within the current policy. Automatically generated by our editor. |
Child elements can be all elements with matching return value (e.g. <constant:true>, <event:boolean> for valueChanged:boolean, <constant:string>, <event:string> for valueChanged:string) or elements of the <boolean-functions, <string-functions, number-functions.
Policy Specification Rules
|
<policy id='urn:policy:cs4:valueChanged'>
<variableDeclaration:number name='numberAccess'>
<count>
<eventOccurrence event='urn:action:cs4:show-user'/>
<when fixedTime='today'/>
</count>
</variableDeclaration:number>
<mechanism event='urn:action:cs4:show-project'>
<if>
<valueChanged to='true' id='vc1'>
<greater>
<variable:number reference='numberAccess'/>
<constant:number value='5'/>
</greater>
</valueChanged>
<then>
<execute action='urn:action:cs4:logNotification'>
<parameter:string name='message' value='Users where display more than 5 times today'/>
</execute>
</then>
</if>
</mechanism>
</policy>
Referring to an Event in the Event History
To refer to an event, the <eventOccurrence> element is used. It can be used inside a <count> or <continuousOccurrence> tag. The element has the following attributes:
Attribute | Type | Required | Meaning |
---|---|---|---|
event |
String |
required |
Declares the event. The event id follows this pattern: urn:action:<scope>:<identifier> |
mode |
String |
optional |
Possible values are "FIRST" or "LAST", to get the first or last eventOccurrence. |
<policy id='urn:policy:banking-demo:containsExample'>
<mechanism event='urn:action:banking-demo:get-transactions'>
<if>
<greater>
<count>
<eventOccurrence event='urn:action:banking-demo:get-transactions'/>
<thisMonth/>
</count>
<constant:number value='100'/>
</greater>
<then>
<inhibit/>
</then>
</if>
</mechanism>
</policy>
Working with Time Spans
To work with the event history, it is essential to define a time span in which you are looking for an event. For example, you might look for certain events yesterday, or in the last 45 minutes. <when> is used to express these time specifications inside <continuousOccurrence> and <count>.
Time spans can be defined using fixed (predefined) time spans as an attribute, or using custom time spans as children.
Policy Evaluation Rules
Fixed time spans override custom time spans. |
Fixed Time Spans
The easiest way to work with time spans is to use predefined or fixed time spans as an attribute of <when>. The following table shows you all available time spans, including an example for each.
Expression | Description | Event occurrance date (now) | Resulting start | Resulting end |
---|---|---|---|---|
thisMinute |
event occurred within this minute |
06.02.2018 10:35:30 |
06.02.2018 10:35:00 |
06.02.2018 10:35:30 |
lastMinute |
event occurred within the last 60 seconds |
06.02.2018 10:35:30 |
06.02.2018 10:34:00 |
06.02.2018 10:34:59 |
thisHour |
event occurred within this hour |
06.02.2018 10:35:30 |
06.02.2018 10:00:00 |
06.02.2018 10:35:30 |
lastHour |
event occurred within the last 60 minutes |
06.02.2018 10:35:30 |
06.02.2018 09:00:00 |
06.02.2018 09:59:59 |
today |
event occurred today |
06.02.2018 10:35:30 |
06.02.2018 00:00:00 |
06.02.2018 10:35:30 |
yesterday |
event occurred yesterday |
06.02.2018 10:35:30 |
05.02.2018 00:00:00 |
05.02.2018 23:59:59 |
thisMonth |
event occurred this month |
06.02.2018 10:35:30 |
01.02.2018 00:00:00 |
06.02.2018 10:35:30 |
lastMonth |
event occurred last month |
06.02.2018 10:35:30 |
01.01.2018 00:00:00 |
31.01.2018 23:59:59 |
thisYear |
event occurred this year |
06.02.2018 10:35:30 |
01.01.2018 00:00:00 |
06.02.2018 10:35:30 |
lastYear |
event occurred last year |
06.02.2018 10:35:30 |
01.01.2017 00:00:00 |
31.12.2017 23:59:59 |
thisWeek |
event occurred this week (Monday to Sunday) |
06.02.2018 10:35:30 |
05.02.2018 00:00:00 |
06.02.2018 10:35:30 |
lastWeek |
event occurred last week (Monday to Sunday) |
06.02.2018 10:35:30 |
29.01.2018 00:00:00 |
04.02.2018 23:59:59 |
thisSunWeek |
event occurred this week (Sunday to Saturday) |
06.02.2018 10:35:30 |
04.02.2018 00:00:00 |
06.02.2018 10:35:30 |
lastSunWeek |
event occurred last week (Sunday to Saturday) |
06.02.2018 10:35:30 |
28.01.2018 00:00:00 |
03.02.2018 23:59:59 |
always |
event occurred, no matter when |
06.02.2018 10:35:30 |
01.01.1970 00:00:00 |
06.02.2018 10:35:30 |
<policy id='urn:policy:banking-demo:ExamplePolicy'>
<mechanism event='urn:action:banking-demo:get-transactions'>
<if>
<greaterEqual>
<count>
<eventOccurrence event='urn:action:banking-demo:get-money'/>
<when fixedTime="thisMinute"/>
</count>
<constant:number value='15'/>
</greaterEqual>
<then>
<inhibit/>
</then>
</if>
</mechanism>
</policy>
Dynamic Time Spans
To define a custom time span, <start> and <end> can be used as children of <when>. With these to elements, you can define a time span based on absolute dates (e.g., 04.02.2018), or on dates that are relative to now or to a certain event (e.g., in the last 5 minutes).
The <start> and <end> elements have the following attribute:
Attribute | Type | Required | Meaning |
---|---|---|---|
time |
time reference |
required |
Declares the absolute or relative point in time for start or end. |
Absolute Dates
Time references follows the following syntax: DD.MM.YYYY hh:mm in 24 hour format. So, if you want to define a time span with absolute dates, you can just do like in the following example:
<when>
<start time="01.01.2018 00:00" />
<end time="31.06.2018 00:00" />
</when>
However, this is not sufficient to express flexible time spans like "in the last 5 minutes". To do this, we use a special notation to override the individual date parts (day, month, year, hour, minute):
Wildcard
Relacing a part with an asterisk * overwrites the value of the absolute date with the value of the current date.
<when>
<start time="*01.*.* 00:00" /> <!-- The first of the current month in the current year at 00:00 -->
</when>
Substraction
Replacing a part of the date with a -<n> subtracts n to the value of the current date*.
<when>
<start time="*.*.* *:-5" /> <!-- Five minutes ago -->
</when>
Addition
Replacing a part with a +<n> adds n to the value of the current date*.
<when>
<start time="*.*.* -1:+5" /> <!-- started 55 minutes ago -->
</when>
Event References
Both <start> and <end> can have a <eventOccurrence> child. In this case, the declared event is used as a reference for the time calculation, not the current one.
<when>
<start time="*.-1.* *:*:*"> <!-- started one month before the first occurrence of the event B -->
<eventOccurrence event="B" mode="FIRST"/>
</start>
<end time="*.*.* *:-5" /> <!-- ends five minutes ago from NOW -->
</when>
Policy Evaluation Rules
|
Working with Cron Jobs
Sometimes it is necessary to evaluate a policy independently of a system event, or in a regular manner. To stick with the Event-Condition-Action paradigm, timers can be set that regularly trigger events. These events are handled exactly like "normal" events.
These <timer> are NOT part of an actual policy, but are configured separately via our UI or API (as they might trigger several policies at the same time).
A <timer> can have the following attributes:
Attribute | Type | Required | Meaning |
---|---|---|---|
id |
URN |
required |
The unique ID of the timer. Syntax: urn:timer:<solution>:<id> |
cron |
cron |
required |
Describes the time interval to fire an event in cron syntax. |
description |
String |
optional |
Description of the timer. |
Support for specifying both a day-of-week and a day-of-month value is not complete (you’ll need to use the '?' character in one of these fields). |
A <timer> must contain at least one <event> child, declaring the event to be triggered. Like normal events, it has an event identifier (as parameter) and a list of parameters as children. The <event> has the following attribute:
Attribute | Type | Required | Meaning |
---|---|---|---|
action |
String |
required |
Defines the event id. |
The following example shows a timer that triggers the event "regular-check" every day at 1:01.
<timer cron='0 1 1 * * ?' id='urn:timer:banking-demo:check'>
<event action='urn:action:banking-demo:regular-check'>
<parameter:number name='processID' value='12'/>
</event>
</timer>