View Javadoc
1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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  package org.kuali.rice.krad.uif.component;
17  
18  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20  import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase;
21  
22  import java.io.Serializable;
23  import java.util.HashMap;
24  import java.util.Map;
25  
26  /**
27   * Component security is used to flag permissions that exist in KIM for various component state (like edit and view)
28   *
29   * <p>
30   * In addition, properties such as additional role and permission details can be configured to use when
31   * checking the KIM permissions
32   * </p>
33   *
34   * <p>
35   * Security subclasses exist adding on flags apporiate for that component
36   * </p>
37   *
38   * @author Kuali Rice Team (rice.collab@kuali.org)
39   */
40  @BeanTag(name = "componentSecurity")
41  public class ComponentSecurity extends UifDictionaryBeanBase implements Serializable {
42      private static final long serialVersionUID = 726347449984853891L;
43  
44      private Boolean editAuthz;
45      private Boolean viewAuthz;
46  
47      private String namespaceAttribute;
48      private String componentAttribute;
49      private String idAttribute;
50  
51      private Map<String, String> additionalPermissionDetails;
52      private Map<String, String> additionalRoleQualifiers;
53  
54      public ComponentSecurity() {
55          additionalPermissionDetails = new HashMap<String, String>();
56          additionalRoleQualifiers = new HashMap<String, String>();
57      }
58  
59      /**
60       * Indicates whether the component has edit authorization and KIM should be consulted
61       *
62       * @return true if the component has edit authorization, false if not
63       */
64      @BeanTagAttribute(name="editAuthz")
65      public Boolean isEditAuthz() {
66          return editAuthz;
67      }
68  
69      /**
70       * Setter for the edit authorization flag
71       *
72       * @param editAuthz
73       */
74      public void setEditAuthz(Boolean editAuthz) {
75          this.editAuthz = editAuthz;
76      }
77  
78      /**
79       * Indicates whether the component has view authorization and KIM should be consulted
80       *
81       * @return true if the component has view authorization, false if not
82       */
83      @BeanTagAttribute(name="viewAuthz")
84      public Boolean isViewAuthz() {
85          return viewAuthz;
86      }
87  
88      /**
89       * Setter for the view authorization flag
90       *
91       * @param viewAuthz
92       */
93      public void setViewAuthz(Boolean viewAuthz) {
94          this.viewAuthz = viewAuthz;
95      }
96  
97      /**
98       * Namespace code that should be sent as permission detail when doing a permission check on this field
99       *
100      * <p>
101      * When the namespace code is a detail for a permission check, this property can be configured to override the
102      * namespace derived by the system
103      * </p>
104      *
105      * @return namespace code
106      */
107     @BeanTagAttribute(name="namespaceAttribute")
108     public String getNamespaceAttribute() {
109         return namespaceAttribute;
110     }
111 
112     /**
113      * Setter for the namespace code to use for details
114      *
115      * @param namespaceAttribute
116      */
117     public void setNamespaceAttribute(String namespaceAttribute) {
118         this.namespaceAttribute = namespaceAttribute;
119     }
120 
121     /**
122      * Component code that should be sent as permission detail when doing a permission check on this field
123      *
124      * <p>
125      * When the component code is a detail for a permission check, this property can be configured to override the
126      * component code derived by the system
127      * </p>
128      *
129      * @return component code
130      */
131     @BeanTagAttribute(name="componentAttribute")
132     public String getComponentAttribute() {
133         return componentAttribute;
134     }
135 
136     /**
137      * Setter for the component code to use for details
138      *
139      * @param componentAttribute
140      */
141     public void setComponentAttribute(String componentAttribute) {
142         this.componentAttribute = componentAttribute;
143     }
144 
145     /**
146      * Id that should be sent as permission detail when doing a permission check on this field
147      *
148      * <p>
149      * By default they system will send the component id as a permission detail, this property can be configured to
150      * send a different id for the permission check
151      * </p>
152      *
153      * @return id
154      */
155     @BeanTagAttribute(name="idAttribute")
156     public String getIdAttribute() {
157         return idAttribute;
158     }
159 
160     /**
161      * Setter for the id to use for details
162      *
163      * @param idAttribute
164      */
165     public void setIdAttribute(String idAttribute) {
166         this.idAttribute = idAttribute;
167     }
168 
169     /**
170      * Map of key value pairs that should be added as permission details when doing KIM permission checks for this
171      * component
172      *
173      * <p>
174      * Any details given here that will override details with the same key that were derived by the system
175      * </p>
176      *
177      * @return Map<String, String>
178      */
179     @BeanTagAttribute(name="additionalPermissionDetails",type= BeanTagAttribute.AttributeType.MAPVALUE)
180     public Map<String, String> getAdditionalPermissionDetails() {
181         return additionalPermissionDetails;
182     }
183 
184     /**
185      * Setter for the map of additional permission details
186      *
187      * @param additionalPermissionDetails
188      */
189     public void setAdditionalPermissionDetails(Map<String, String> additionalPermissionDetails) {
190         this.additionalPermissionDetails = additionalPermissionDetails;
191     }
192 
193     /**
194      * Map of key value pairs that should be added as role qualifiers when doing KIM permission checks for this
195      * component
196      *
197      * <p>
198      * Any qualifiers given here that will override qualifiers with the same key that were derived by the system
199      * </p>
200      *
201      * @return Map<String, String>
202      */
203     @BeanTagAttribute(name="additionalRoleQualifiers",type= BeanTagAttribute.AttributeType.MAPVALUE)
204     public Map<String, String> getAdditionalRoleQualifiers() {
205         return additionalRoleQualifiers;
206     }
207 
208     /**
209      * Setter for the map of additional role qualifiers
210      *
211      * @param additionalRoleQualifiers
212      */
213     public void setAdditionalRoleQualifiers(Map<String, String> additionalRoleQualifiers) {
214         this.additionalRoleQualifiers = additionalRoleQualifiers;
215     }
216 
217     @Override
218     protected void finalize() throws Throwable {
219         try {
220             idAttribute = null;
221             componentAttribute = null;
222             namespaceAttribute = null;
223             additionalRoleQualifiers = null;
224             additionalPermissionDetails = null;
225         } finally {
226             // don't call super.finalize() in attempt to avoid loop between maps.
227         }
228     }
229 }