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.core.Attribute;
26  import org.opensaml.saml2.metadata.AssertionIDRequestService;
27  import org.opensaml.saml2.metadata.AttributeAuthorityDescriptor;
28  import org.opensaml.saml2.metadata.AttributeProfile;
29  import org.opensaml.saml2.metadata.AttributeService;
30  import org.opensaml.saml2.metadata.Endpoint;
31  import org.opensaml.saml2.metadata.NameIDFormat;
32  import org.opensaml.xml.XMLObject;
33  import org.opensaml.xml.util.XMLObjectChildrenList;
34  
35  /**
36   * A concrete implementation of {@link org.opensaml.saml2.metadata.AttributeAuthorityDescriptor}.
37   */
38  public class AttributeAuthorityDescriptorImpl extends RoleDescriptorImpl implements AttributeAuthorityDescriptor {
39  
40      /** Attribte query endpoints. */
41      private final XMLObjectChildrenList<AttributeService> attributeServices;
42  
43      /** Assertion request endpoints. */
44      private final XMLObjectChildrenList<AssertionIDRequestService> assertionIDRequestServices;
45  
46      /** Supported NameID formats. */
47      private final XMLObjectChildrenList<NameIDFormat> nameFormats;
48  
49      /** Supported attribute profiles. */
50      private final XMLObjectChildrenList<AttributeProfile> attributeProfiles;
51  
52      /** Supported attribute. */
53      private final XMLObjectChildrenList<Attribute> attributes;
54  
55      /**
56       * Constructor.
57       * 
58       * @param namespaceURI the namespace the element is in
59       * @param elementLocalName the local name of the XML element this Object represents
60       * @param namespacePrefix the prefix for the given namespace
61       */
62      protected AttributeAuthorityDescriptorImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
63          super(namespaceURI, elementLocalName, namespacePrefix);
64          attributeServices = new XMLObjectChildrenList<AttributeService>(this);
65          assertionIDRequestServices = new XMLObjectChildrenList<AssertionIDRequestService>(this);
66          attributeProfiles = new XMLObjectChildrenList<AttributeProfile>(this);
67          nameFormats = new XMLObjectChildrenList<NameIDFormat>(this);
68          attributes = new XMLObjectChildrenList<Attribute>(this);
69      }
70  
71      /** {@inheritDoc} */
72      public List<AttributeService> getAttributeServices() {
73          return attributeServices;
74      }
75  
76      /** {@inheritDoc} */
77      public List<AssertionIDRequestService> getAssertionIDRequestServices() {
78          return assertionIDRequestServices;
79      }
80  
81      /** {@inheritDoc} */
82      public List<NameIDFormat> getNameIDFormats() {
83          return nameFormats;
84      }
85  
86      /** {@inheritDoc} */
87      public List<AttributeProfile> getAttributeProfiles() {
88          return attributeProfiles;
89      }
90  
91      /** {@inheritDoc} */
92      public List<Attribute> getAttributes() {
93          return attributes;
94      }
95      
96      /** {@inheritDoc} */
97      public List<Endpoint> getEndpoints() {
98          List<Endpoint> endpoints = new ArrayList<Endpoint>();
99          endpoints.addAll(attributeServices);
100         endpoints.addAll(assertionIDRequestServices);
101         return Collections.unmodifiableList(endpoints);
102     }
103     
104     /** {@inheritDoc} */
105     public List<Endpoint> getEndpoints(QName type) {
106         if(type.equals(AttributeService.DEFAULT_ELEMENT_NAME)){
107             return Collections.unmodifiableList(new ArrayList<Endpoint>(attributeServices));
108         }else if(type.equals(AssertionIDRequestService.DEFAULT_ELEMENT_NAME)){
109             return Collections.unmodifiableList(new ArrayList<Endpoint>(assertionIDRequestServices));
110         }
111         
112         return null;
113     }
114 
115     /** {@inheritDoc} */
116     public List<XMLObject> getOrderedChildren() {
117         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
118 
119         children.addAll(super.getOrderedChildren());
120         children.addAll(attributeServices);
121         children.addAll(assertionIDRequestServices);
122         children.addAll(nameFormats);
123         children.addAll(attributeProfiles);
124         children.addAll(attributes);
125 
126         return Collections.unmodifiableList(children);
127     }
128 }