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