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.saml1.core.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.common.impl.AbstractSAMLObject;
26  import org.opensaml.common.xml.SAMLConstants;
27  import org.opensaml.saml1.core.Assertion;
28  import org.opensaml.saml1.core.AssertionIDReference;
29  import org.opensaml.saml1.core.Evidence;
30  import org.opensaml.saml1.core.Evidentiary;
31  import org.opensaml.xml.XMLObject;
32  import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
33  
34  /**
35   * Concrete implementation of the {@link org.opensaml.saml1.core.Evidence} interface.
36   */
37  public class EvidenceImpl extends AbstractSAMLObject implements Evidence {
38  
39      /** The Evidentiary child elements. */
40      private final IndexedXMLObjectChildrenList<Evidentiary> evidence;
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 EvidenceImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
50          super(namespaceURI, elementLocalName, namespacePrefix);
51          evidence = new IndexedXMLObjectChildrenList<Evidentiary>(this);
52      }
53  
54      /** {@inheritDoc} */
55      public List<AssertionIDReference> getAssertionIDReferences() {
56          QName qname = new QName(SAMLConstants.SAML1_NS, AssertionIDReference.DEFAULT_ELEMENT_LOCAL_NAME);
57          return (List<AssertionIDReference>) evidence.subList(qname);
58      }
59  
60      /** {@inheritDoc} */
61      public List<Assertion> getAssertions() {
62          QName qname = new QName(SAMLConstants.SAML1_NS, Assertion.DEFAULT_ELEMENT_LOCAL_NAME);
63          return (List<Assertion>) evidence.subList(qname);
64      }
65  
66      /** {@inheritDoc} */
67      public List<Evidentiary> getEvidence() {
68          return evidence;
69      }
70  
71      /** {@inheritDoc} */
72      public List<XMLObject> getOrderedChildren() {
73          if (evidence.size() == 0) {
74              return null;
75          }
76  
77          ArrayList<XMLObject> list = new ArrayList<XMLObject>();
78          list.addAll(evidence);
79  
80          return Collections.unmodifiableList(list);
81      }
82  }