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.ResourceMatchType;
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 ResourceMatchTypeImpl extends AbstractValidatingXMLObject implements ResourceMatchType {
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 ResourceMatchTypeImpl(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.subList(AttributeSelectorType.DEFAULT_ELEMENT_NAME);
59 if (selectors != null && !selectors.isEmpty()) {
60 return (AttributeSelectorType) selectors.get(0);
61 }
62
63 return null;
64 }
65
66
67 public AttributeValueType getAttributeValue() {
68 return attributeValue;
69 }
70
71
72 public AttributeDesignatorType getResourceAttributeDesignator() {
73 List<XACMLObject> selectors = (List<XACMLObject>) attributeChoice
74 .subList(AttributeDesignatorType.RESOURCE_ATTRIBUTE_DESIGNATOR_ELEMENT_NAME);
75 if (selectors != null && !selectors.isEmpty()) {
76 return (AttributeDesignatorType) selectors.get(0);
77 }
78
79 return null;
80 }
81
82
83 public String getMatchId() {
84 return matchId;
85 }
86
87
88 public void setAttributeSelector(AttributeSelectorType selector) {
89 AttributeSelectorType currentSelector = getAttributeSelector();
90 if (currentSelector != null) {
91 attributeChoice.remove(currentSelector);
92 }
93
94 attributeChoice.add(selector);
95 }
96
97
98 public void setAttributeValue(AttributeValueType value) {
99 attributeValue = prepareForAssignment(attributeValue, value);
100 }
101
102
103 public void setResourceAttributeDesignator(AttributeDesignatorType attribute) {
104 AttributeDesignatorType currentDesignator = getResourceAttributeDesignator();
105 if (currentDesignator != null) {
106 attributeChoice.remove(currentDesignator);
107 }
108
109 attributeChoice.add(attribute);
110 }
111
112
113 public void setMatchId(String id) {
114 matchId = prepareForAssignment(matchId, id);
115 }
116
117
118 public List<XMLObject> getOrderedChildren() {
119 ArrayList<XMLObject> children = new ArrayList<XMLObject>();
120 children.add(attributeValue);
121 if (!attributeChoice.isEmpty()) {
122 children.addAll(attributeChoice);
123 }
124
125 return children;
126 }
127 }