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.AttributeDesignatorType;
25 import org.opensaml.xacml.policy.AttributeSelectorType;
26 import org.opensaml.xacml.policy.AttributeValueType;
27 import org.opensaml.xacml.policy.EnvironmentMatchType;
28 import org.opensaml.xml.XMLObject;
29 import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
30 import org.opensaml.xml.validation.AbstractValidatingXMLObject;
31
32
33 public class EnvironmentMatchTypeImpl extends AbstractValidatingXMLObject implements EnvironmentMatchType {
34
35
36 private AttributeValueType attributeValue;
37
38
39 private IndexedXMLObjectChildrenList<XACMLObject> attributeChoice;
40
41
42 private String matchId;
43
44
45
46
47
48
49
50
51 public EnvironmentMatchTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
52 super(namespaceURI, elementLocalName, namespacePrefix);
53 attributeChoice = new IndexedXMLObjectChildrenList<XACMLObject>(this);
54 }
55
56
57 public AttributeSelectorType getAttributeSelector() {
58 List<XACMLObject> selectors = (List<XACMLObject>) attributeChoice
59 .subList(AttributeSelectorType.DEFAULT_ELEMENT_NAME);
60 if (selectors != null && !selectors.isEmpty()) {
61 return (AttributeSelectorType) selectors.get(0);
62 }
63
64 return null;
65 }
66
67
68 public AttributeValueType getAttributeValue() {
69 return attributeValue;
70 }
71
72
73 public AttributeDesignatorType getEnvironmentAttributeDesignator() {
74 List<XACMLObject> selectors = (List<XACMLObject>) attributeChoice
75 .subList(AttributeDesignatorType.ENVIRONMENT_ATTRIBUTE_DESIGNATOR_ELEMENT_NAME);
76 if (selectors != null && !selectors.isEmpty()) {
77 return (AttributeDesignatorType) selectors.get(0);
78 }
79
80 return null;
81 }
82
83
84 public String getMatchId() {
85 return matchId;
86 }
87
88
89 public void setAttributeSelector(AttributeSelectorType selector) {
90 AttributeSelectorType currentSelector = getAttributeSelector();
91 if (currentSelector != null) {
92 attributeChoice.remove(currentSelector);
93 }
94
95 attributeChoice.add(selector);
96 }
97
98
99 public void setAttributeValue(AttributeValueType value) {
100 attributeValue = prepareForAssignment(attributeValue, value);
101 }
102
103
104 public void setEnvironmentAttributeDesignator(AttributeDesignatorType attribute) {
105 AttributeDesignatorType currentDesignator = getEnvironmentAttributeDesignator();
106 if (currentDesignator != null) {
107 attributeChoice.remove(currentDesignator);
108 }
109
110 attributeChoice.add(attribute);
111 }
112
113
114 public void setMatchId(String id) {
115 matchId = prepareForAssignment(matchId, id);
116 }
117
118
119 public List<XMLObject> getOrderedChildren() {
120 ArrayList<XMLObject> children = new ArrayList<XMLObject>();
121 children.add(attributeValue);
122 if (!attributeChoice.isEmpty()) {
123 children.addAll(attributeChoice);
124 }
125
126 return children;
127 }
128 }