6dee0cb977718908726dd8f40f7f6df2952106ff
[policy/engine.git] / ONAP-PAP-REST / src / main / resources / Decision_GuardPolicyTemplate.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:xacml:policy:id:d56af069-6cf1-430c-ba07-e26602e06a52" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-unless-deny"> 
3     <Description>${description}</Description>
4     <Target>
5         <AnyOf>
6             <AllOf>
7                 <Match MatchId="org.onap.function.regex-match">
8                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${PolicyName}</AttributeValue>
9                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
10                 </Match>
11             </AllOf>
12             <AllOf>
13                 <Match MatchId="org.onap.function.regex-match">
14                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${ONAPName}</AttributeValue>
15                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ONAPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
16                 </Match>
17                 <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
18                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">(?i)${actor}</AttributeValue>
19                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="actor" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
20                 </Match>
21                 <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
22                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">(?i)${recipe}</AttributeValue>
23                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="recipe" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
24                 </Match>
25                 <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
26                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${targets}</AttributeValue>
27                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="target" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
28                 </Match>
29                 <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
30                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">${clname}</AttributeValue>
31                     <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="clname" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
32                 </Match>
33             </AllOf>
34         </AnyOf>
35     </Target>
36     <Rule RuleId="urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a" Effect="Permit">
37         <Target>
38             <AnyOf>
39                 <AllOf>
40                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
41                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DECIDE</AttributeValue>
42                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
43                     </Match>
44                 </AllOf>
45             </AnyOf>
46         </Target>
47         <Condition>
48                 <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
49                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
50                     <Apply FunctionId="urn:oasis:names:tc:xacml:2.0:function:time-in-range">
51                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-one-and-only">
52                             <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"/>
53                         </Apply>
54                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveStart}</AttributeValue>
55                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveEnd}</AttributeValue>
56                     </Apply>
57                     <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than-or-equal">
58                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only">
59                                 <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="count" DataType="http://www.w3.org/2001/XMLSchema#integer" Issuer="org:onap:xacml:guard:historydb:tw:${twValue}:${twUnits}" MustBePresent="false"/>
60                         </Apply>
61                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">${limit}</AttributeValue>
62                         </Apply>
63                 </Apply>
64             </Apply>
65         </Condition>
66     </Rule>
67     <Rule RuleId="urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a" Effect="Deny">
68         <Target>
69             <AnyOf>
70                 <AllOf>
71                     <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
72                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DECIDE</AttributeValue>
73                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
74                     </Match>
75                 </AllOf>
76             </AnyOf>
77         </Target>
78         <Condition>
79             <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
80                 <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
81                                 <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
82                         <Apply FunctionId="urn:oasis:names:tc:xacml:2.0:function:time-in-range">
83                                 <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-one-and-only">
84                                 <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"/>
85                                 </Apply>
86                                 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveStart}</AttributeValue>
87                                 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">${guardActiveEnd}</AttributeValue>
88                         </Apply>
89                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than-or-equal">
90                                 <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only">
91                                         <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="count" DataType="http://www.w3.org/2001/XMLSchema#integer" Issuer="org:onap:xacml:guard:historydb:tw:${twValue}:${twUnits}" MustBePresent="false"/>
92                                 </Apply>
93                                 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">${limit}</AttributeValue>
94                                 </Apply>
95                         </Apply>
96                 </Apply>
97             </Apply>
98         </Condition>
99         <AdviceExpressions>
100             <AdviceExpression AdviceId="GUARD_YAML" AppliesTo="Deny">
101                 <AttributeAssignmentExpression AttributeId="guard.response" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
102                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Denied!</AttributeValue>
103                 </AttributeAssignmentExpression>
104             </AdviceExpression>
105         </AdviceExpressions>
106     </Rule>
107 </Policy>