001/**
002 * Copyright 2005-2018 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 */
016package org.kuali.rice.krad.uif.component;
017
018import org.kuali.rice.krad.datadictionary.parse.BeanTag;
019import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
020import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase;
021
022import java.io.Serializable;
023import java.util.HashMap;
024import 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")
041public 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        additionalPermissionDetails = new HashMap<String, String>();
056        additionalRoleQualifiers = new HashMap<String, String>();
057    }
058
059    /**
060     * Indicates whether the component has edit authorization and KIM should be consulted
061     *
062     * @return true if the component has edit authorization, false if not
063     */
064    @BeanTagAttribute(name="editAuthz")
065    public Boolean isEditAuthz() {
066        return editAuthz;
067    }
068
069    /**
070     * Setter for the edit authorization flag
071     *
072     * @param editAuthz
073     */
074    public void setEditAuthz(Boolean editAuthz) {
075        this.editAuthz = editAuthz;
076    }
077
078    /**
079     * Indicates whether the component has view authorization and KIM should be consulted
080     *
081     * @return true if the component has view authorization, false if not
082     */
083    @BeanTagAttribute(name="viewAuthz")
084    public Boolean isViewAuthz() {
085        return viewAuthz;
086    }
087
088    /**
089     * Setter for the view authorization flag
090     *
091     * @param viewAuthz
092     */
093    public void setViewAuthz(Boolean viewAuthz) {
094        this.viewAuthz = viewAuthz;
095    }
096
097    /**
098     * Namespace code that should be sent as permission detail when doing a permission check on this field
099     *
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}