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 org.opensaml.saml1.core.Assertion;
24  import org.opensaml.saml1.core.Response;
25  import org.opensaml.saml1.core.Status;
26  import org.opensaml.xml.XMLObject;
27  import org.opensaml.xml.util.XMLObjectChildrenList;
28  
29  /**
30   * Implementation of the {@link org.opensaml.saml1.core.Response} Object
31   */
32  public class ResponseImpl extends ResponseAbstractTypeImpl implements Response {
33  
34      /** Status associated with this element */
35      private Status status = null;
36  
37      /** List of all the Assertions */
38      private final XMLObjectChildrenList<Assertion> assertions;
39  
40      /**
41       * Constructor
42       * 
43       * @param namespaceURI the namespace the element is in
44       * @param elementLocalName the local name of the XML element this Object represents
45       * @param namespacePrefix the prefix for the given namespace
46       */
47      protected ResponseImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
48          super(namespaceURI, elementLocalName, namespacePrefix);
49          assertions = new XMLObjectChildrenList<Assertion>(this);
50      }
51  
52      /** {@inheritDoc} */
53      public List<Assertion> getAssertions() {
54          return assertions;
55      }
56  
57      /** {@inheritDoc} */
58      public Status getStatus() {
59          return status;
60      }
61  
62      /** {@inheritDoc} */
63      public void setStatus(Status status) throws IllegalArgumentException {
64          this.status = prepareForAssignment(this.status, status);
65      }
66  
67      /** {@inheritDoc} */
68      public List<XMLObject> getOrderedChildren() {
69          ArrayList<XMLObject> children = new ArrayList<XMLObject>(1 + assertions.size());
70  
71          if (super.getOrderedChildren() != null) {
72              children.addAll(super.getOrderedChildren());
73          }
74  
75          if (status != null) {
76              children.add(status);
77          }
78  
79          children.addAll(assertions);
80  
81          if (children.size() == 0) {
82              return null;
83          }
84  
85          return Collections.unmodifiableList(children);
86      }
87  }