001    /**
002     * Copyright 2005-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krad.uif.component;
017    
018    import org.kuali.rice.krad.datadictionary.parse.BeanTag;
019    import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
020    import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase;
021    
022    import java.io.Serializable;
023    import java.util.HashMap;
024    import java.util.Map;
025    
026    /**
027     * Component security is used to flag permissions that exist in KIM for various component state (like edit and view)
028     *
029     * <p>
030     * In addition, properties such as additional role and permission details can be configured to use when
031     * checking the KIM permissions
032     * </p>
033     *
034     * <p>
035     * Security subclasses exist adding on flags apporiate for that component
036     * </p>
037     *
038     * @author Kuali Rice Team (rice.collab@kuali.org)
039     */
040    @BeanTag(name="componentSecurity")
041    public class ComponentSecurity extends UifDictionaryBeanBase implements Serializable {
042        private static final long serialVersionUID = 726347449984853891L;
043    
044        private boolean editAuthz;
045        private boolean viewAuthz;
046    
047        private String namespaceAttribute;
048        private String componentAttribute;
049        private String idAttribute;
050    
051        private Map<String, String> additionalPermissionDetails;
052        private Map<String, String> additionalRoleQualifiers;
053    
054        public ComponentSecurity() {
055            editAuthz = false;
056            viewAuthz = false;
057    
058            additionalPermissionDetails = new HashMap<String, String>();
059            additionalRoleQualifiers = new HashMap<String, String>();
060        }
061    
062        /**
063         * Indicates whether the component has edit authorization and KIM should be consulted
064         *
065         * @return boolean true if the component has edit authorization, false if not
066         */
067        @BeanTagAttribute(name="editAuthz")
068        public boolean isEditAuthz() {
069            return editAuthz;
070        }
071    
072        /**
073         * Setter for the edit authorization flag
074         *
075         * @param editAuthz
076         */
077        public void setEditAuthz(boolean editAuthz) {
078            this.editAuthz = editAuthz;
079        }
080    
081        /**
082         * Indicates whether the component has view authorization and KIM should be consulted
083         *
084         * @return boolean true if the component has view authorization, false if not
085         */
086        @BeanTagAttribute(name="viewAuthz")
087        public boolean isViewAuthz() {
088            return viewAuthz;
089        }
090    
091        /**
092         * Setter for the view authorization flag
093         *
094         * @param viewAuthz
095         */
096        public void setViewAuthz(boolean viewAuthz) {
097            this.viewAuthz = viewAuthz;
098        }
099    
100        /**
101         * Namespace code that should be sent as permission detail when doing a permission check on this field
102         *
103         * <p>
104         * When the namespace code is a detail for a permission check, this property can be configured to override the
105         * namespace derived by the system
106         * </p>
107         *
108         * @return String namespace code
109         */
110        @BeanTagAttribute(name="namespaceAttribute")
111        public String getNamespaceAttribute() {
112            return namespaceAttribute;
113        }
114    
115        /**
116         * Setter for the namespace code to use for details
117         *
118         * @param namespaceAttribute
119         */
120        public void setNamespaceAttribute(String namespaceAttribute) {
121            this.namespaceAttribute = namespaceAttribute;
122        }
123    
124        /**
125         * Component code that should be sent as permission detail when doing a permission check on this field
126         *
127         * <p>
128         * When the component code is a detail for a permission check, this property can be configured to override the
129         * component code derived by the system
130         * </p>
131         *
132         * @return String component code
133         */
134        @BeanTagAttribute(name="componentAttribute")
135        public String getComponentAttribute() {
136            return componentAttribute;
137        }
138    
139        /**
140         * Setter for the component code to use for details
141         *
142         * @param componentAttribute
143         */
144        public void setComponentAttribute(String componentAttribute) {
145            this.componentAttribute = componentAttribute;
146        }
147    
148        /**
149         * Id that should be sent as permission detail when doing a permission check on this field
150         *
151         * <p>
152         * By default they system will send the component id as a permission detail, this property can be configured to
153         * send a different id for the permission check
154         * </p>
155         *
156         * @return String id
157         */
158        @BeanTagAttribute(name="idAttribute")
159        public String getIdAttribute() {
160            return idAttribute;
161        }
162    
163        /**
164         * Setter for the id to use for details
165         *
166         * @param idAttribute
167         */
168        public void setIdAttribute(String idAttribute) {
169            this.idAttribute = idAttribute;
170        }
171    
172        /**
173         * Map of key value pairs that should be added as permission details when doing KIM permission checks for this
174         * component
175         *
176         * <p>
177         * Any details given here that will override details with the same key that were derived by the system
178         * </p>
179         *
180         * @return Map<String, String>
181         */
182        @BeanTagAttribute(name="additionalPermissionDetails",type= BeanTagAttribute.AttributeType.MAPVALUE)
183        public Map<String, String> getAdditionalPermissionDetails() {
184            return additionalPermissionDetails;
185        }
186    
187        /**
188         * Setter for the map of additional permission details
189         *
190         * @param additionalPermissionDetails
191         */
192        public void setAdditionalPermissionDetails(Map<String, String> additionalPermissionDetails) {
193            this.additionalPermissionDetails = additionalPermissionDetails;
194        }
195    
196        /**
197         * Map of key value pairs that should be added as role qualifiers when doing KIM permission checks for this
198         * component
199         *
200         * <p>
201         * Any qualifiers given here that will override qualifiers with the same key that were derived by the system
202         * </p>
203         *
204         * @return Map<String, String>
205         */
206        @BeanTagAttribute(name="additionalRoleQualifiers",type= BeanTagAttribute.AttributeType.MAPVALUE)
207        public Map<String, String> getAdditionalRoleQualifiers() {
208            return additionalRoleQualifiers;
209        }
210    
211        /**
212         * Setter for the map of additional role qualifiers
213         *
214         * @param additionalRoleQualifiers
215         */
216        public void setAdditionalRoleQualifiers(Map<String, String> additionalRoleQualifiers) {
217            this.additionalRoleQualifiers = additionalRoleQualifiers;
218        }
219    
220        @Override
221        protected void finalize() throws Throwable {
222            try {
223                idAttribute = null;
224                componentAttribute = null;
225                namespaceAttribute = null;
226                additionalRoleQualifiers = null;
227                additionalPermissionDetails = null;
228            } finally {
229                // don't call super.finalize() in attempt to avoid loop between maps.
230            }
231        }
232    }