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.IDPList;
29  import org.opensaml.saml2.core.RequesterID;
30  import org.opensaml.saml2.core.Scoping;
31  import org.opensaml.xml.XMLObject;
32  import org.opensaml.xml.util.XMLObjectChildrenList;
33  
34  /**
35   * Concrete implementation of {@link org.opensaml.saml2.core.Scoping}.
36   */
37  public class ScopingImpl extends AbstractSAMLObject implements Scoping {
38  
39      /** IDPList child element. */
40      private IDPList idpList;
41  
42      /** List of RequesterID child elements. */
43      private final XMLObjectChildrenList<RequesterID> requesterIDs;
44  
45      /** ProxyCount attribute. */
46      private Integer proxyCount;
47  
48      /**
49       * Constructor.
50       * 
51       * @param namespaceURI the namespace the element is in
52       * @param elementLocalName the local name of the XML element this Object represents
53       * @param namespacePrefix the prefix for the given namespace
54       */
55      protected ScopingImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
56          super(namespaceURI, elementLocalName, namespacePrefix);
57          requesterIDs = new XMLObjectChildrenList<RequesterID>(this);
58      }
59  
60      /** {@inheritDoc} */
61      public Integer getProxyCount() {
62          return this.proxyCount;
63      }
64  
65      /** {@inheritDoc} */
66      public void setProxyCount(Integer newProxyCount) {
67          this.proxyCount = prepareForAssignment(this.proxyCount, newProxyCount);
68      }
69  
70      /** {@inheritDoc} */
71      public IDPList getIDPList() {
72          return idpList;
73      }
74  
75      /** {@inheritDoc} */
76      public void setIDPList(IDPList newIDPList) {
77          this.idpList = prepareForAssignment(this.idpList, newIDPList);
78  
79      }
80  
81      /** {@inheritDoc} */
82      public List<RequesterID> getRequesterIDs() {
83          return requesterIDs;
84      }
85  
86      /** {@inheritDoc} */
87      public List<XMLObject> getOrderedChildren() {
88          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
89  
90          if (idpList != null) {
91              children.add(idpList);
92          }
93  
94          children.addAll(requesterIDs);
95  
96          if (children.size() > 0) {
97              return Collections.unmodifiableList(children);
98          } else {
99              return null;
100         }
101     }
102 }