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.core.impl;
22  
23  import java.util.ArrayList;
24  import java.util.Collections;
25  import java.util.List;
26  
27  import org.opensaml.common.impl.AbstractSAMLObject;
28  import org.opensaml.saml2.core.Attribute;
29  import org.opensaml.saml2.core.AttributeStatement;
30  import org.opensaml.saml2.core.EncryptedAttribute;
31  import org.opensaml.xml.XMLObject;
32  import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
33  
34  /**
35   * A concrete implementation of {@link org.opensaml.saml2.core.AttributeStatement}.
36   */
37  public class AttributeStatementImpl extends AbstractSAMLObject implements AttributeStatement {
38  
39      /** Attributes and EncryptedAttributes in this statement. */
40      private final IndexedXMLObjectChildrenList<XMLObject> indexedChildren;
41  
42      /**
43       * Constructor.
44       * 
45       * @param namespaceURI the namespace the element is in
46       * @param elementLocalName the local name of the XML element this Object represents
47       * @param namespacePrefix the prefix for the given namespace
48       */
49      protected AttributeStatementImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
50          super(namespaceURI, elementLocalName, namespacePrefix);
51          indexedChildren = new IndexedXMLObjectChildrenList<XMLObject>(this);
52      }
53  
54      /** {@inheritDoc} */
55      public List<Attribute> getAttributes() {
56          return (List<Attribute>) indexedChildren.subList(Attribute.DEFAULT_ELEMENT_NAME);
57      }
58      
59  
60      /** {@inheritDoc} */
61      public List<EncryptedAttribute> getEncryptedAttributes() {
62          return (List<EncryptedAttribute>) indexedChildren.subList(EncryptedAttribute.DEFAULT_ELEMENT_NAME);
63      }
64  
65      /** {@inheritDoc} */
66      public List<XMLObject> getOrderedChildren() {
67          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
68  
69          children.addAll(indexedChildren);
70          
71          return Collections.unmodifiableList(children);
72      }
73  }