2d73a1e6d973ab4ad99505e89e14c3df1f308f8c
[policy/drools-applications.git] / controlloop / templates / template.demo / src / main / resources / frequency_limiter_template.xml
1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:att:xacml:policy:id:25e12b06-11d5-4895-b2a2-6f6c594de069" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-unless-deny">
3         <Description>Policy for frequency limiter.</Description>
4         <Target>
5             <AnyOf>
6                 <AllOf>
7                 
8                         <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
9                         <!-- <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">.*</AttributeValue>-->
10                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${clname}</AttributeValue>
11                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="urn:oasis:names:tc:xacml:1.0:clname:clname-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
12                         </Match>
13              
14                         <!--  <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">-->
15                         <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
16                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${actor}</AttributeValue>
17                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="urn:oasis:names:tc:xacml:1.0:actor:actor-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
18                     </Match>
19                     <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
20                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${recipe}</AttributeValue>
21                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:operation:operation-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
22                     </Match>
23                     
24                     <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
25                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${targets}</AttributeValue>
26                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:target:target-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
27                     </Match>
28                     
29                 </AllOf>
30             </AnyOf>
31         </Target>
32         <Rule RuleId="urn:com:att:xacml:rule:id:e1e8c5c0-e2ba-47d5-9289-6c015305ed21" Effect="Deny">
33             <Description>DENY - only if number of operations performed in the past is larger than the limit and the Guard is active.</Description>
34             <Condition>
35                 <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
36                         <VariableReference VariableId="isGuardActive"/>
37                         <VariableReference VariableId="isHistoryGreaterThanLimit"/>
38                 </Apply>
39             </Condition>
40         </Rule>
41         <VariableDefinition VariableId="isGuardActive"> 
42                 <Apply FunctionId="urn:oasis:names:tc:xacml:2.0:function:time-in-range">
43                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-one-and-only">
44                         <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-time" DataType="http://www.w3.org/2001/XMLSchema#time" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" MustBePresent="false"/>
45                                 </Apply>
46                                 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveStart}</AttributeValue>
47                                 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveEnd}</AttributeValue>
48                 </Apply>
49         </VariableDefinition> 
50         <VariableDefinition VariableId="isHistoryGreaterThanLimit">     
51                 <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than-or-equal">
52                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only">
53                                 <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="com:att:research:xacml:test:sql:resource:operations:count" DataType="http://www.w3.org/2001/XMLSchema#integer" Issuer="com:att:research:xacml:guard:historydb:tw:${twValue}:${twUnits}" MustBePresent="false"/>
54                         </Apply>
55                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">${limit}</AttributeValue>
56                 </Apply>        
57         </VariableDefinition>
58 </Policy>