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.saml1.core.Action;
24  import org.opensaml.saml1.core.AuthorizationDecisionStatement;
25  import org.opensaml.saml1.core.DecisionTypeEnumeration;
26  import org.opensaml.saml1.core.Evidence;
27  import org.opensaml.xml.XMLObject;
28  import org.opensaml.xml.util.XMLObjectChildrenList;
29  
30  /**
31   * A concrete implementation of {@link org.opensaml.saml1.core.AuthorizationDecisionStatement}
32   */
33  public class AuthorizationDecisionStatementImpl extends SubjectStatementImpl implements AuthorizationDecisionStatement {
34  
35      /** Contains the Resource attribute */
36      private String resource;
37  
38      /** Contains the Decision attribute */
39      private DecisionTypeEnumeration decision;
40  
41      /** Contains the list of Action elements */
42      private final XMLObjectChildrenList<Action> actions;
43  
44      /** Contains the (single) Evidence element */
45      private Evidence evidence;
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 AuthorizationDecisionStatementImpl(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 resource;
62      }
63  
64      /** {@inheritDoc} */
65      public void setResource(String resource) {
66          this.resource = prepareForAssignment(this.resource, resource);
67      }
68  
69      /** {@inheritDoc} */
70      public DecisionTypeEnumeration getDecision() {
71          return decision;
72      }
73  
74      /** {@inheritDoc} */
75      public void setDecision(DecisionTypeEnumeration decision) {
76          this.decision = prepareForAssignment(this.decision, decision);
77      }
78  
79      /** {@inheritDoc} */
80      public List<Action> getActions() {
81          return actions;
82      }
83  
84      /** {@inheritDoc} */
85      public Evidence getEvidence() {
86          return evidence;
87      }
88  
89      /** {@inheritDoc} */
90      public void setEvidence(Evidence evidence) throws IllegalArgumentException {
91          this.evidence = prepareForAssignment(this.evidence, evidence);
92      }
93  
94      /** {@inheritDoc} */
95      public List<XMLObject> getOrderedChildren() {
96          List<XMLObject> list = new ArrayList<XMLObject>(actions.size() + 2);
97  
98          if (super.getOrderedChildren() != null) {
99              list.addAll(super.getOrderedChildren());
100         }
101         list.addAll(actions);
102         if (evidence != null) {
103             list.add(evidence);
104         }
105         if (list.size() == 0) {
106             return null;
107         }
108         return Collections.unmodifiableList(list);
109     }
110 }