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.common.xml.SAMLConstants;
24  import org.opensaml.saml1.core.Action;
25  import org.opensaml.saml1.core.AuthorizationDecisionQuery;
26  import org.opensaml.saml1.core.Evidence;
27  import org.opensaml.xml.XMLObject;
28  import org.opensaml.xml.util.XMLObjectChildrenList;
29  
30  /**
31   * Concrete implementation of the {@link org.opensaml.saml1.core.AuthorizationDecisionQuery} interface
32   */
33  public class AuthorizationDecisionQueryImpl extends SubjectQueryImpl implements AuthorizationDecisionQuery {
34  
35      /** Contains the resource attribute */
36      private String resource;
37  
38      /** Contains all the Action child elements */
39      private final XMLObjectChildrenList<Action> actions;
40  
41      /** Contains the Evidence child element */
42      private Evidence evidence;
43      
44      /**
45       * Constructor.
46       * 
47       * @param namespaceURI the namespace the element is in
48       * @param elementLocalName the local name of the XML element this Object represents
49       * @param namespacePrefix the prefix for the given namespace
50       */
51      protected AuthorizationDecisionQueryImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
52          super(namespaceURI, elementLocalName, namespacePrefix);
53          setElementNamespacePrefix(SAMLConstants.SAML1P_PREFIX);
54          actions = new XMLObjectChildrenList<Action>(this);
55      }
56  
57      /** {@inheritDoc} */
58      public String getResource() {
59          return resource;
60      }
61  
62      /** {@inheritDoc} */
63      public void setResource(String resource) {
64          this.resource = prepareForAssignment(this.resource, resource);
65      }
66  
67      /** {@inheritDoc} */
68      public List<Action> getActions() {
69          return actions;
70      }
71  
72      /** {@inheritDoc} */
73      public Evidence getEvidence() {
74          return evidence;
75      }
76  
77      /** {@inheritDoc} */
78      public void setEvidence(Evidence evidence) {
79          this.evidence = prepareForAssignment(this.evidence, evidence);
80      }
81  
82      /** {@inheritDoc} */
83      public List<XMLObject> getOrderedChildren() {
84          List<XMLObject> list = new ArrayList<XMLObject>(actions.size() + 2);
85          
86          if (super.getOrderedChildren() != null) {
87              list.addAll(super.getOrderedChildren());
88          }
89          
90          list.addAll(actions);
91          if (evidence != null) {
92              list.add(evidence);
93          }
94          
95          if (list.size() == 0) {
96              return null;
97          }
98          
99          return Collections.unmodifiableList(list);
100     }
101 }