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