View Javadoc

1   /*
2   Copyright 2008 Members of the EGEE Collaboration.
3   Copyright 2008 University Corporation for Advanced Internet Development,
4   Inc.
5   
6   Licensed under the Apache License, Version 2.0 (the "License");
7   you may not use this file except in compliance with the License.
8   You may obtain a copy of the License at
9   
10      http://www.apache.org/licenses/LICENSE-2.0
11  
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17   */
18  
19  package org.opensaml.xacml.profile.saml.impl;
20  
21  import java.util.ArrayList;
22  import java.util.Collections;
23  import java.util.List;
24  
25  import org.opensaml.common.impl.AbstractSAMLObject;
26  import org.opensaml.xacml.XACMLObject;
27  import org.opensaml.xacml.policy.PolicySetType;
28  import org.opensaml.xacml.policy.PolicyType;
29  import org.opensaml.xacml.profile.saml.ReferencedPoliciesType;
30  import org.opensaml.xacml.profile.saml.XACMLPolicyStatementType;
31  import org.opensaml.xml.XMLObject;
32  import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
33  
34  /** Concrete implementation of {@link XACMLPolicyStatementType}. */
35  public class XACMLPolicyStatementTypeImpl extends AbstractSAMLObject implements XACMLPolicyStatementType {
36  
37      /** Choice group in element. */
38      private IndexedXMLObjectChildrenList<XACMLObject> choiceGroup;
39  
40      /** ReferencedPolicie child. */
41      private ReferencedPoliciesType referencedPolicies;
42  
43      /**
44       * Constructor.
45       * 
46       * @param namespaceURI the namespace the element is in
47       * @param elementLocalName the local name of the XML element this Object represents
48       * @param namespacePrefix the prefix for the given namespace
49       */
50      protected XACMLPolicyStatementTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
51          super(namespaceURI, elementLocalName, namespacePrefix);
52          choiceGroup = new IndexedXMLObjectChildrenList<XACMLObject>(this);
53      }
54  
55      /** {@inheritDoc} */
56      public List<XMLObject> getOrderedChildren() {
57          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
58  
59          children.addAll(choiceGroup);
60  
61          if (referencedPolicies != null) {
62              children.add(referencedPolicies);
63          }
64  
65          return Collections.unmodifiableList(children);
66      }
67  
68      /** {@inheritDoc} */
69      public List<PolicyType> getPolicies() {
70          return (List<PolicyType>) choiceGroup.subList(PolicyType.DEFAULT_ELEMENT_NAME);
71      }
72  
73      /** {@inheritDoc} */
74      public List<PolicySetType> getPolicySets() {
75          return (List<PolicySetType>) choiceGroup.subList(PolicySetType.DEFAULT_ELEMENT_NAME);
76      }
77  
78      /** {@inheritDoc} */
79      public ReferencedPoliciesType getReferencedPolicies() {
80          return referencedPolicies;
81      }
82  
83      /** {@inheritDoc} */
84      public void setReferencedPolicies(ReferencedPoliciesType policies) {
85          referencedPolicies = prepareForAssignment(referencedPolicies, policies);
86      }
87  }