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.metadata.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.opensaml.saml2.metadata.AssertionConsumerService;
30 import org.opensaml.saml2.metadata.AttributeConsumingService;
31 import org.opensaml.saml2.metadata.Endpoint;
32 import org.opensaml.saml2.metadata.SPSSODescriptor;
33 import org.opensaml.xml.XMLObject;
34 import org.opensaml.xml.schema.XSBooleanValue;
35 import org.opensaml.xml.util.XMLObjectChildrenList;
36
37
38
39
40 public class SPSSODescriptorImpl extends SSODescriptorImpl implements SPSSODescriptor {
41
42
43 private XSBooleanValue authnRequestSigned;
44
45
46 private XSBooleanValue assertionSigned;
47
48
49 private final XMLObjectChildrenList<AssertionConsumerService> assertionConsumerServices;
50
51
52 private final XMLObjectChildrenList<AttributeConsumingService> attributeConsumingServices;
53
54
55
56
57
58
59
60
61 protected SPSSODescriptorImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
62 super(namespaceURI, elementLocalName, namespacePrefix);
63 assertionConsumerServices = new XMLObjectChildrenList<AssertionConsumerService>(this);
64 attributeConsumingServices = new XMLObjectChildrenList<AttributeConsumingService>(this);
65 }
66
67
68 public Boolean isAuthnRequestsSigned() {
69 if (authnRequestSigned == null) {
70 return Boolean.FALSE;
71 }
72 return authnRequestSigned.getValue();
73 }
74
75
76 public XSBooleanValue isAuthnRequestsSignedXSBoolean() {
77 return authnRequestSigned;
78 }
79
80
81 public void setAuthnRequestsSigned(Boolean newIsSigned) {
82 if(newIsSigned != null){
83 authnRequestSigned = prepareForAssignment(authnRequestSigned, new XSBooleanValue(newIsSigned, false));
84 }else{
85 authnRequestSigned = prepareForAssignment(authnRequestSigned, null);
86 }
87 }
88
89
90 public void setAuthnRequestsSigned(XSBooleanValue isSigned) {
91 authnRequestSigned = prepareForAssignment(authnRequestSigned, isSigned);
92 }
93
94
95 public Boolean getWantAssertionsSigned() {
96 if (assertionSigned == null) {
97 return Boolean.FALSE;
98 }
99 return assertionSigned.getValue();
100 }
101
102
103 public XSBooleanValue getWantAssertionsSignedXSBoolean() {
104 return assertionSigned;
105 }
106
107
108 public void setWantAssertionsSigned(Boolean wantAssestionSigned) {
109 if(wantAssestionSigned != null){
110 assertionSigned = prepareForAssignment(assertionSigned, new XSBooleanValue(wantAssestionSigned, false));
111 }else{
112 assertionSigned = prepareForAssignment(assertionSigned, null);
113 }
114 }
115
116
117 public void setWantAssertionsSigned(XSBooleanValue wantAssestionSigned) {
118 this.assertionSigned = prepareForAssignment(this.assertionSigned, wantAssestionSigned);
119 }
120
121
122 public List<AssertionConsumerService> getAssertionConsumerServices() {
123 return assertionConsumerServices;
124 }
125
126
127 public AssertionConsumerService getDefaultAssertionConsumerService() {
128 for (AssertionConsumerService service : assertionConsumerServices) {
129 if (service.isDefault()) {
130 return service;
131 }
132 }
133
134 if (assertionConsumerServices.size() > 0) {
135 return assertionConsumerServices.get(0);
136 } else {
137 System.err.println("FOOBAR");
138 }
139
140 return null;
141 }
142
143
144 public List<AttributeConsumingService> getAttributeConsumingServices() {
145 return attributeConsumingServices;
146 }
147
148
149 public AttributeConsumingService getDefaultAttributeConsumingService(){
150 for(AttributeConsumingService service : attributeConsumingServices){
151 if(service.isDefault()){
152 return service;
153 }
154 }
155
156 return null;
157 }
158
159
160 public List<Endpoint> getEndpoints() {
161 List<Endpoint> endpoints = new ArrayList<Endpoint>();
162 endpoints.addAll(super.getEndpoints());
163 endpoints.addAll(assertionConsumerServices);
164 return Collections.unmodifiableList(endpoints);
165 }
166
167
168 public List<Endpoint> getEndpoints(QName type) {
169 if(type.equals(AssertionConsumerService.DEFAULT_ELEMENT_NAME)){
170 return Collections.unmodifiableList(new ArrayList<Endpoint>(assertionConsumerServices));
171 }else{
172 return super.getEndpoints(type);
173 }
174 }
175
176
177 public List<XMLObject> getOrderedChildren() {
178 ArrayList<XMLObject> children = new ArrayList<XMLObject>();
179
180 children.addAll(super.getOrderedChildren());
181 children.addAll(assertionConsumerServices);
182 children.addAll(attributeConsumingServices);
183
184 return Collections.unmodifiableList(children);
185 }
186 }