1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.opensaml.xacml.policy.impl;
19
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import org.opensaml.xacml.XACMLObject;
24 import org.opensaml.xacml.policy.CombinerParametersType;
25 import org.opensaml.xacml.policy.DefaultsType;
26 import org.opensaml.xacml.policy.DescriptionType;
27 import org.opensaml.xacml.policy.ObligationsType;
28 import org.opensaml.xacml.policy.PolicyType;
29 import org.opensaml.xacml.policy.RuleCombinerParametersType;
30 import org.opensaml.xacml.policy.RuleType;
31 import org.opensaml.xacml.policy.TargetType;
32 import org.opensaml.xacml.policy.VariableDefinitionType;
33 import org.opensaml.xml.XMLObject;
34 import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
35 import org.opensaml.xml.validation.AbstractValidatingXMLObject;
36
37
38 public class PolicyTypeImpl extends AbstractValidatingXMLObject implements PolicyType {
39
40
41 private DescriptionType description;
42
43
44 private DefaultsType policyDefaults;
45
46
47 private TargetType target;
48
49
50 private IndexedXMLObjectChildrenList<? extends XACMLObject> choiceGroup;
51
52
53 private ObligationsType obligations;
54
55
56 private String policyId;
57
58
59 private String version;
60
61
62 private String ruleCombiningAlgo;
63
64
65
66
67
68
69
70
71 protected PolicyTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
72 super(namespaceURI, elementLocalName, namespacePrefix);
73 choiceGroup = new IndexedXMLObjectChildrenList<XACMLObject>(this);
74 }
75
76
77 public List<CombinerParametersType> getCombinerParameters() {
78 return (List<CombinerParametersType>) choiceGroup.subList(CombinerParametersType.DEFAULT_ELEMENT_NAME);
79 }
80
81
82 public DescriptionType getDescription() {
83 return description;
84 }
85
86
87 public ObligationsType getObligations() {
88 return obligations;
89 }
90
91
92 public DefaultsType getPolicyDefaults() {
93 return policyDefaults;
94 }
95
96
97 public String getPolicyId() {
98 return policyId;
99 }
100
101
102 public List<RuleCombinerParametersType> getRuleCombinerParameters() {
103 return (List<RuleCombinerParametersType>) choiceGroup.subList(RuleCombinerParametersType.DEFAULT_ELEMENT_NAME);
104 }
105
106
107 public String getRuleCombiningAlgoId() {
108 return ruleCombiningAlgo;
109 }
110
111
112 public List<RuleType> getRules() {
113 return (List<RuleType>) choiceGroup.subList(RuleType.DEFAULT_ELEMENT_NAME);
114 }
115
116
117 public TargetType getTarget() {
118 return target;
119 }
120
121
122 public List<VariableDefinitionType> getVariableDefinitions() {
123 return (List<VariableDefinitionType>) choiceGroup.subList(VariableDefinitionType.DEFAULT_ELEMENT_NAME);
124 }
125
126
127 public String getVersion() {
128 return version;
129 }
130
131
132 public void setDescription(DescriptionType newDescription) {
133 this.description = prepareForAssignment(this.description, newDescription);
134 }
135
136
137 public void setObligations(ObligationsType newObligations) {
138 this.obligations = prepareForAssignment(this.obligations, newObligations);
139 }
140
141
142 public void setPolicyDefaults(DefaultsType defaults) {
143 policyDefaults = prepareForAssignment(policyDefaults, defaults);
144 }
145
146
147 public void setPolicyId(String id) {
148 policyId = prepareForAssignment(policyId, id);
149 }
150
151
152 public void setRuleCombiningAlgoId(String id) {
153 ruleCombiningAlgo = prepareForAssignment(ruleCombiningAlgo, id);
154 }
155
156
157 public void setTarget(TargetType newTarget) {
158 this.target = prepareForAssignment(this.target, newTarget);
159 }
160
161
162 public void setVersion(String newVersion) {
163 this.version = prepareForAssignment(this.version, newVersion);
164 }
165
166
167 public List<XMLObject> getOrderedChildren() {
168 ArrayList<XMLObject> children = new ArrayList<XMLObject>();
169 if (description != null) {
170 children.add(description);
171 }
172
173 if (policyDefaults != null) {
174 children.add(policyDefaults);
175 }
176
177 children.add(target);
178
179 if (!choiceGroup.isEmpty()) {
180 children.addAll(choiceGroup);
181 }
182
183 if (obligations != null) {
184 children.add(obligations);
185 }
186
187 return children;
188 }
189 }