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.policy.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.policy.ActionsType;
27  import org.opensaml.xacml.policy.EnvironmentsType;
28  import org.opensaml.xacml.policy.ResourcesType;
29  import org.opensaml.xacml.policy.SubjectsType;
30  import org.opensaml.xacml.policy.TargetType;
31  import org.opensaml.xml.XMLObject;
32  
33  /**
34   * Implementing {@link org.opensaml.xacml.policy.TargetType}.
35   */
36  public class TargetTypeImpl extends AbstractSAMLObject implements TargetType {
37  
38      /** The actions in the policy. */
39      private ActionsType actions;
40  
41      /** The environments in the policy. */
42      private EnvironmentsType environments;
43  
44      /** The subjects in the policy. */
45      private SubjectsType subjects;
46  
47      /** The resourcese in the policy. */
48      private ResourcesType resources;
49  
50      /**
51       * Constructor.
52       * 
53       * @param namespaceURI the namespace the element is in
54       * @param elementLocalName the local name of the XML element this Object represents
55       * @param namespacePrefix the prefix for the given namespace
56       */
57      protected TargetTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
58          super(namespaceURI, elementLocalName, namespacePrefix);       
59      }
60  
61  
62      /** {@inheritDoc} */
63      public List<XMLObject> getOrderedChildren() {
64          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
65  
66          if(subjects != null){
67              children.add(subjects);  
68          }
69          if(actions != null){
70              children.add(actions);  
71          }        
72          if(resources != null){
73              children.add(resources);  
74          }
75          if(environments != null){
76              children.add(environments);  
77          }
78          return Collections.unmodifiableList(children);
79      }
80  
81      /** {@inheritDoc}*/
82      public SubjectsType getSubjects() {
83          return subjects;
84      }
85          
86      /** {@inheritDoc}*/
87      public ResourcesType getResources() {
88          return resources;
89      }
90  
91      /** {@inheritDoc}*/
92      public ActionsType getActions() {
93          return actions;
94      }
95  
96      /**{@inheritDoc}*/
97      public EnvironmentsType getEnvironments() {
98          return environments;
99      }
100 
101     /**{@inheritDoc}*/
102     public void setActions(ActionsType newActions) {
103         this.actions = prepareForAssignment(this.actions,newActions);
104     }
105 
106     /**{@inheritDoc}*/
107     public void setEnvironments(EnvironmentsType newEnvironments) {
108         this.environments = prepareForAssignment(this.environments,newEnvironments);
109     }
110 
111     /**{@inheritDoc}*/
112     public void setResources(ResourcesType newResources) {
113         this.resources = prepareForAssignment(this.resources,newResources);
114     }
115 
116     /**{@inheritDoc}*/
117     public void setSubjects(SubjectsType newSubjects) {
118         this.subjects = prepareForAssignment(this.subjects,newSubjects);
119     }
120 }