1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.saml2.metadata.impl;
18
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.List;
22
23 import org.joda.time.DateTime;
24 import org.opensaml.common.SAMLObject;
25 import org.opensaml.common.impl.AbstractSignableSAMLObject;
26 import org.opensaml.saml2.common.Extensions;
27 import org.opensaml.saml2.metadata.EntitiesDescriptor;
28 import org.opensaml.saml2.metadata.EntityDescriptor;
29 import org.opensaml.xml.XMLObject;
30 import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
31
32
33
34
35 public class EntitiesDescriptorImpl extends AbstractSignableSAMLObject implements EntitiesDescriptor {
36
37
38 private String name;
39
40
41 private String id;
42
43
44 private DateTime validUntil;
45
46
47 private Long cacheDuration;
48
49
50 private Extensions extensions;
51
52
53 private final IndexedXMLObjectChildrenList<SAMLObject> orderedDescriptors;
54
55
56
57
58
59
60
61
62 protected EntitiesDescriptorImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
63 super(namespaceURI, elementLocalName, namespacePrefix);
64 orderedDescriptors = new IndexedXMLObjectChildrenList<SAMLObject>(this);
65 }
66
67
68 public String getName() {
69 return name;
70 }
71
72
73 public void setName(String newName) {
74 this.name = prepareForAssignment(this.name, newName);
75 }
76
77
78 public String getID() {
79 return id;
80 }
81
82
83 public void setID(String newID) {
84 String oldID = this.id;
85 this.id = prepareForAssignment(this.id, newID);
86 registerOwnID(oldID, this.id);
87 }
88
89
90 public boolean isValid() {
91 if (null == validUntil) {
92 return true;
93 }
94
95 DateTime now = new DateTime();
96 return now.isBefore(validUntil);
97 }
98
99
100 public DateTime getValidUntil() {
101 return validUntil;
102 }
103
104
105 public void setValidUntil(DateTime newValidUntil) {
106 validUntil = prepareForAssignment(validUntil, newValidUntil);
107 }
108
109
110 public Long getCacheDuration() {
111 return cacheDuration;
112 }
113
114
115 public void setCacheDuration(Long duration) {
116 cacheDuration = prepareForAssignment(cacheDuration, duration);
117 }
118
119
120 public Extensions getExtensions() {
121 return extensions;
122 }
123
124
125 public void setExtensions(Extensions newExtensions) {
126 extensions = prepareForAssignment(extensions, newExtensions);
127 }
128
129
130 public List<EntitiesDescriptor> getEntitiesDescriptors() {
131 return (List<EntitiesDescriptor>) orderedDescriptors.subList(EntitiesDescriptor.ELEMENT_QNAME);
132 }
133
134
135 public List<EntityDescriptor> getEntityDescriptors() {
136 return (List<EntityDescriptor>) orderedDescriptors.subList(EntityDescriptor.ELEMENT_QNAME);
137 }
138
139
140 public String getSignatureReferenceID(){
141 return id;
142 }
143
144
145 public List<XMLObject> getOrderedChildren() {
146 ArrayList<XMLObject> children = new ArrayList<XMLObject>();
147
148 if(getSignature() != null){
149 children.add(getSignature());
150 }
151
152 children.add(getExtensions());
153 children.addAll(orderedDescriptors);
154
155 return Collections.unmodifiableList(children);
156 }
157 }