View Javadoc

1   /*
2    * Copyright [2005] [University Corporation for Advanced Internet Development, Inc.]
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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.core.Attribute;
30  import org.opensaml.saml2.metadata.AssertionIDRequestService;
31  import org.opensaml.saml2.metadata.AttributeProfile;
32  import org.opensaml.saml2.metadata.Endpoint;
33  import org.opensaml.saml2.metadata.IDPSSODescriptor;
34  import org.opensaml.saml2.metadata.NameIDMappingService;
35  import org.opensaml.saml2.metadata.SingleSignOnService;
36  import org.opensaml.xml.XMLObject;
37  import org.opensaml.xml.schema.XSBooleanValue;
38  import org.opensaml.xml.util.XMLObjectChildrenList;
39  
40  /**
41   * Concrete implementation of {@link org.opensaml.saml2.metadata.IDPSSODescriptor}.
42   */
43  public class IDPSSODescriptorImpl extends SSODescriptorImpl implements IDPSSODescriptor {
44  
45      /** wantAuthnRequestSigned attribute. */
46      private XSBooleanValue wantAuthnRequestsSigned;
47  
48      /** SingleSignOn services for this entity. */
49      private final XMLObjectChildrenList<SingleSignOnService> singleSignOnServices;
50  
51      /** NameID mapping services for this entity. */
52      private final XMLObjectChildrenList<NameIDMappingService> nameIDMappingServices;
53  
54      /** AssertionID request services for this entity. */
55      private final XMLObjectChildrenList<AssertionIDRequestService> assertionIDRequestServices;
56  
57      /** Attribute profiles supported by this entity. */
58      private final XMLObjectChildrenList<AttributeProfile> attributeProfiles;
59  
60      /** Attributes accepted by this entity. */
61      private final XMLObjectChildrenList<Attribute> attributes;
62      
63      /**
64       * Constructor.
65       * 
66       * @param namespaceURI the namespace the element is in
67       * @param elementLocalName the local name of the XML element this Object represents
68       * @param namespacePrefix the prefix for the given namespace
69       */
70      protected IDPSSODescriptorImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
71          super(namespaceURI, elementLocalName, namespacePrefix);
72          singleSignOnServices = new XMLObjectChildrenList<SingleSignOnService>(this);
73          nameIDMappingServices = new XMLObjectChildrenList<NameIDMappingService>(this);
74          assertionIDRequestServices = new XMLObjectChildrenList<AssertionIDRequestService>(this);
75          attributeProfiles = new XMLObjectChildrenList<AttributeProfile>(this);
76          attributes = new XMLObjectChildrenList<Attribute>(this);
77      }
78  
79      /** {@inheritDoc} */
80      public Boolean getWantAuthnRequestsSigned(){
81          if(wantAuthnRequestsSigned != null){
82              return wantAuthnRequestsSigned.getValue();
83          }
84          
85          return Boolean.FALSE;
86      }
87      
88      /** {@inheritDoc} */
89      public XSBooleanValue getWantAuthnRequestsSignedXSBoolean() {
90          return wantAuthnRequestsSigned;
91      }
92      
93      /** {@inheritDoc} */
94      public void setWantAuthnRequestsSigned(Boolean newWantSigned){
95          if(newWantSigned != null){
96              wantAuthnRequestsSigned = prepareForAssignment(wantAuthnRequestsSigned, new XSBooleanValue(newWantSigned, false));
97          }else{
98              wantAuthnRequestsSigned = prepareForAssignment(wantAuthnRequestsSigned, null);
99          }
100     }
101 
102     /** {@inheritDoc} */
103     public void setWantAuthnRequestsSigned(XSBooleanValue wantSigned) {
104         wantAuthnRequestsSigned = prepareForAssignment(wantAuthnRequestsSigned, wantSigned);
105     }
106 
107     /** {@inheritDoc} */
108     public List<SingleSignOnService> getSingleSignOnServices() {
109         return singleSignOnServices;
110     }
111 
112     /** {@inheritDoc} */
113     public List<NameIDMappingService> getNameIDMappingServices() {
114         return nameIDMappingServices;
115     }
116 
117     /** {@inheritDoc} */
118     public List<AssertionIDRequestService> getAssertionIDRequestServices() {
119         return assertionIDRequestServices;
120     }
121 
122     /** {@inheritDoc} */
123     public List<AttributeProfile> getAttributeProfiles() {
124         return attributeProfiles;
125     }
126 
127     /** {@inheritDoc} */
128     public List<Attribute> getAttributes() {
129         return attributes;
130     }
131     
132     /** {@inheritDoc} */
133     public List<Endpoint> getEndpoints() {
134         List<Endpoint> endpoints = new ArrayList<Endpoint>();
135         endpoints.addAll(super.getEndpoints());
136         endpoints.addAll(singleSignOnServices);
137         endpoints.addAll(nameIDMappingServices);
138         endpoints.addAll(assertionIDRequestServices);
139         return Collections.unmodifiableList(endpoints);
140     }
141     
142     /** {@inheritDoc} */
143     public List<Endpoint> getEndpoints(QName type) {
144         if(type.equals(SingleSignOnService.DEFAULT_ELEMENT_NAME)){
145             return Collections.unmodifiableList(new ArrayList<Endpoint>(singleSignOnServices));
146         }else if(type.equals(NameIDMappingService.DEFAULT_ELEMENT_NAME)){
147             return Collections.unmodifiableList(new ArrayList<Endpoint>(nameIDMappingServices));
148         }else if(type.equals(AssertionIDRequestService.DEFAULT_ELEMENT_NAME)){
149             return Collections.unmodifiableList(new ArrayList<Endpoint>(assertionIDRequestServices));
150         }else{
151             return super.getEndpoints(type);
152         }
153     }
154 
155     /** {@inheritDoc} */
156     public List<XMLObject> getOrderedChildren() {
157         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
158 
159         children.addAll(super.getOrderedChildren());
160         children.addAll(singleSignOnServices);
161         children.addAll(nameIDMappingServices);
162         children.addAll(assertionIDRequestServices);
163         children.addAll(attributeProfiles);
164         children.addAll(attributes);
165 
166         return Collections.unmodifiableList(children);
167     }
168 }