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.common.impl.AbstractSAMLObject;
28  import org.opensaml.saml2.core.Action;
29  import org.opensaml.saml2.core.AuthzDecisionStatement;
30  import org.opensaml.saml2.core.DecisionTypeEnumeration;
31  import org.opensaml.saml2.core.Evidence;
32  import org.opensaml.xml.XMLObject;
33  import org.opensaml.xml.util.XMLObjectChildrenList;
34  
35  /**
36   * A concrete implementation of {@link org.opensaml.saml2.core.AuthzDecisionStatement}.
37   */
38  public class AuthzDecisionStatementImpl extends AbstractSAMLObject implements AuthzDecisionStatement {
39  
40      /** URI of the resource to which authorization is sought. */
41      private String resource;
42  
43      /** Decision of the authorization request. */
44      private DecisionTypeEnumeration decision;
45  
46      /** Actions authorized to be performed. */
47      private final XMLObjectChildrenList<Action> actions;
48  
49      /** SAML assertion the authority relied on when making the authorization decision. */
50      private Evidence evidence;
51  
52      /**
53       * Constructor.
54       * 
55       * @param namespaceURI the namespace the element is in
56       * @param elementLocalName the local name of the XML element this Object represents
57       * @param namespacePrefix the prefix for the given namespace
58       */
59      protected AuthzDecisionStatementImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
60          super(namespaceURI, elementLocalName, namespacePrefix);
61          actions = new XMLObjectChildrenList<Action>(this);
62      }
63  
64      /** {@inheritDoc} */
65      public String getResource() {
66          return resource;
67      }
68  
69      /** {@inheritDoc} */
70      public void setResource(String newResourceURI) {
71          this.resource = prepareForAssignment(this.resource, newResourceURI);
72      }
73  
74      /** {@inheritDoc} */
75      public DecisionTypeEnumeration getDecision() {
76          return decision;
77      }
78  
79      /** {@inheritDoc} */
80      public void setDecision(DecisionTypeEnumeration newDecision) {
81          this.decision = prepareForAssignment(this.decision, newDecision);
82      }
83  
84      /** {@inheritDoc} */
85      public List<Action> getActions() {
86          return actions;
87      }
88  
89      /** {@inheritDoc} */
90      public Evidence getEvidence() {
91          return evidence;
92      }
93  
94      /** {@inheritDoc} */
95      public void setEvidence(Evidence newEvidence) {
96          this.evidence = prepareForAssignment(this.evidence, newEvidence);
97      }
98  
99      /** {@inheritDoc} */
100     public List<XMLObject> getOrderedChildren() {
101         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
102 
103         children.addAll(actions);
104         children.add(evidence);
105         return Collections.unmodifiableList(children);
106     }
107 }