1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.opensaml.saml2.core.impl;
22
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.List;
26
27 import javax.xml.namespace.QName;
28
29 import org.joda.time.DateTime;
30 import org.opensaml.common.impl.AbstractSAMLObject;
31 import org.opensaml.common.xml.SAMLConstants;
32 import org.opensaml.saml2.core.AudienceRestriction;
33 import org.opensaml.saml2.core.Condition;
34 import org.opensaml.saml2.core.Conditions;
35 import org.opensaml.saml2.core.OneTimeUse;
36 import org.opensaml.saml2.core.ProxyRestriction;
37 import org.opensaml.xml.XMLObject;
38 import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
39
40
41
42
43 public class ConditionsImpl extends AbstractSAMLObject implements Conditions {
44
45
46 private final IndexedXMLObjectChildrenList<Condition> conditions;
47
48
49 private DateTime notBefore;
50
51
52 private DateTime notOnOrAfter;
53
54
55
56
57
58
59
60
61 protected ConditionsImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
62 super(namespaceURI, elementLocalName, namespacePrefix);
63 conditions = new IndexedXMLObjectChildrenList<Condition>(this);
64 }
65
66
67 public List<Condition> getConditions() {
68 return conditions;
69 }
70
71
72 public List<AudienceRestriction> getAudienceRestrictions() {
73 QName conditionQName = new QName(SAMLConstants.SAML20_NS, AudienceRestriction.DEFAULT_ELEMENT_LOCAL_NAME,
74 SAMLConstants.SAML20_PREFIX);
75 return (List<AudienceRestriction>) conditions.subList(conditionQName);
76 }
77
78
79 public OneTimeUse getOneTimeUse() {
80 QName conditionQName = new QName(SAMLConstants.SAML20_NS, OneTimeUse.DEFAULT_ELEMENT_LOCAL_NAME,
81 SAMLConstants.SAML20_PREFIX);
82 List<OneTimeUse> list = (List<OneTimeUse>) conditions.subList(conditionQName);
83 if (list == null || list.size() == 0) {
84 return null;
85 } else {
86 return list.get(0);
87 }
88 }
89
90
91 public ProxyRestriction getProxyRestriction() {
92 QName conditionQName = new QName(SAMLConstants.SAML20_NS, ProxyRestriction.DEFAULT_ELEMENT_LOCAL_NAME,
93 SAMLConstants.SAML20_PREFIX);
94 List<ProxyRestriction> list = (List<ProxyRestriction>) conditions.subList(conditionQName);
95 if (list == null || list.size() == 0) {
96 return null;
97 } else {
98 return list.get(0);
99 }
100 }
101
102
103 public DateTime getNotBefore() {
104 return notBefore;
105 }
106
107
108 public void setNotBefore(DateTime newNotBefore) {
109 this.notBefore = prepareForAssignment(this.notBefore, newNotBefore);
110 }
111
112
113 public DateTime getNotOnOrAfter() {
114 return notOnOrAfter;
115 }
116
117
118 public void setNotOnOrAfter(DateTime newNotOnOrAfter) {
119 this.notOnOrAfter = prepareForAssignment(this.notOnOrAfter, newNotOnOrAfter);
120 }
121
122
123 public List<XMLObject> getOrderedChildren() {
124 ArrayList<XMLObject> children = new ArrayList<XMLObject>();
125
126 children.addAll(conditions);
127
128 return Collections.unmodifiableList(children);
129 }
130 }