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  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 javax.xml.namespace.QName;
24  
25  import org.opensaml.saml2.metadata.AssertionIDRequestService;
26  import org.opensaml.saml2.metadata.AuthnAuthorityDescriptor;
27  import org.opensaml.saml2.metadata.AuthnQueryService;
28  import org.opensaml.saml2.metadata.Endpoint;
29  import org.opensaml.saml2.metadata.NameIDFormat;
30  import org.opensaml.xml.XMLObject;
31  import org.opensaml.xml.util.XMLObjectChildrenList;
32  
33  /**
34   * Concreate implementation of {@link org.opensaml.saml2.metadata.AuthnAuthorityDescriptor}
35   */
36  public class AuthnAuthorityDescriptorImpl extends RoleDescriptorImpl implements AuthnAuthorityDescriptor {
37  
38      /** AuthnQueryService endpoints. */
39      private final XMLObjectChildrenList<AuthnQueryService> authnQueryServices;
40  
41      /** AuthnQueryService endpoints. */
42      private final XMLObjectChildrenList<AssertionIDRequestService> assertionIDRequestServices;
43  
44      /** NameID formats supported by this descriptor. */
45      private final XMLObjectChildrenList<NameIDFormat> nameIDFormats;
46  
47      /**
48       * Constructor .
49       * 
50       * @param namespaceURI the namespace the element is in
51       * @param elementLocalName the local name of the XML element this Object represents
52       * @param namespacePrefix the prefix for the given namespace
53       */
54      protected AuthnAuthorityDescriptorImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
55          super(namespaceURI, elementLocalName, namespacePrefix);
56          authnQueryServices = new XMLObjectChildrenList<AuthnQueryService>(this);
57          assertionIDRequestServices = new XMLObjectChildrenList<AssertionIDRequestService>(this);
58          nameIDFormats = new XMLObjectChildrenList<NameIDFormat>(this);
59      }
60  
61      /** {@inheritDoc} */
62      public List<AuthnQueryService> getAuthnQueryServices() {
63          return authnQueryServices;
64      }
65  
66      /** {@inheritDoc} */
67      public List<AssertionIDRequestService> getAssertionIDRequestServices() {
68          return assertionIDRequestServices;
69      }
70  
71      /** {@inheritDoc} */
72      public List<NameIDFormat> getNameIDFormats() {
73          return nameIDFormats;
74      }
75      
76      /** {@inheritDoc} */
77      public List<Endpoint> getEndpoints() {
78          List<Endpoint> endpoints = new ArrayList<Endpoint>();
79          endpoints.addAll(authnQueryServices);
80          endpoints.addAll(assertionIDRequestServices);
81          return Collections.unmodifiableList(endpoints);
82      }
83      
84      /** {@inheritDoc} */
85      public List<Endpoint> getEndpoints(QName type) {
86          if(type.equals(AuthnQueryService.DEFAULT_ELEMENT_NAME)){
87              return Collections.unmodifiableList(new ArrayList<Endpoint>(authnQueryServices));
88          }else if(type.equals(AssertionIDRequestService.DEFAULT_ELEMENT_NAME)){
89              return Collections.unmodifiableList(new ArrayList<Endpoint>(assertionIDRequestServices));
90          }
91          
92          return null;
93      }
94  
95      /** {@inheritDoc} */
96      public List<XMLObject> getOrderedChildren() {
97          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
98  
99          children.addAll(super.getOrderedChildren());
100         children.addAll(authnQueryServices);
101         children.addAll(assertionIDRequestServices);
102         children.addAll(nameIDFormats);
103 
104         return Collections.unmodifiableList(children);
105     }
106 }