View Javadoc

1   /*
2    * Copyright 2008 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.xacml.profile.saml.impl;
18  
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import org.opensaml.common.impl.AbstractSAMLObject;
24  import org.opensaml.xacml.policy.PolicySetType;
25  import org.opensaml.xacml.policy.PolicyType;
26  import org.opensaml.xacml.profile.saml.ReferencedPoliciesType;
27  import org.opensaml.xml.XMLObject;
28  import org.opensaml.xml.util.XMLObjectChildrenList;
29  
30  /**
31   * Implementation of {@link ReferencedPoliciesType}.
32   */
33  public class ReferencedPoliciesTypeImpl extends AbstractSAMLObject implements ReferencedPoliciesType {
34  
35      /**List of policies.*/
36      private XMLObjectChildrenList<PolicyType> policies;
37      
38      /**List of policieSets.*/
39      private XMLObjectChildrenList<PolicySetType> policieSets;
40      
41      /**
42       * Constructor.
43       * 
44       * @param namespaceURI the namespace the element is in
45       * @param elementLocalName the local name of the XML element this Object represents
46       * @param namespacePrefix the prefix for the given namespace
47       */
48      protected ReferencedPoliciesTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
49          super(namespaceURI, elementLocalName, namespacePrefix);
50          policies = new XMLObjectChildrenList<PolicyType>(this);
51          policieSets = new XMLObjectChildrenList<PolicySetType>(this); 
52      }
53      
54      /** {@inheritDoc} */
55      public List<PolicySetType> getPolicySets() {
56          return policieSets;
57      }
58  
59      /** {@inheritDoc} */
60      public List<PolicyType> getPolicies() {
61         return policies;
62      }
63  
64      /** {@inheritDoc} */
65      public List<XMLObject> getOrderedChildren() {
66          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
67          
68          if(!policies.isEmpty()) {
69              children.addAll(policies);
70          }
71          if(!policieSets.isEmpty()) {
72              children.addAll(policieSets);
73          }
74          return Collections.unmodifiableList(children);
75      }
76  }