[POLICY-22] Reorganizing drools-apps
[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                    <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
8                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${actor}</AttributeValue>
9                         <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"/>
10                     </Match>
11                     <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
12                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${recipe}</AttributeValue>
13                         <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"/>
14                     </Match>
15                 </AllOf>
16             </AnyOf>
17         </Target>
18         <Rule RuleId="urn:com:att:xacml:rule:id:e1e8c5c0-e2ba-47d5-9289-6c015305ed21" Effect="Deny">
19             <Description>DENY - only if number of operations performed in the past is larger than the limit and the Guard is active.</Description>
20             <Condition>
21                 <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
22                         <VariableReference VariableId="isGuardActive"/>
23                         <VariableReference VariableId="isHistoryGreaterThanLimit"/>
24                 </Apply>
25             </Condition>
26         </Rule>
27         <VariableDefinition VariableId="isGuardActive"> 
28                 <Apply FunctionId="urn:oasis:names:tc:xacml:2.0:function:time-in-range">
29                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-one-and-only">
30                         <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"/>
31                                 </Apply>
32                                 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveStart}</AttributeValue>
33                                 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveEnd}</AttributeValue>
34                 </Apply>
35         </VariableDefinition> 
36         <VariableDefinition VariableId="isHistoryGreaterThanLimit">     
37                 <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than-or-equal">
38                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only">
39                                 <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"/>
40                         </Apply>
41                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">${limit}</AttributeValue>
42                 </Apply>        
43         </VariableDefinition>
44 </Policy>