📄 columnconstraint.java
字号:
package com.ebusiness.ebank.security;/** * <p>Title: </p> * <p>Description: This class contains database table's column constraint information. It's * an application level and role-based security constraint. A security constraint * can be a function constraint or a column constraint * depending on business or security implementation structure. * </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: eBusiness Inc., All right reserved</p> * @author unascribed * @version 1.0 */import java.util.Set;import java.util.Map;public class ColumnConstraint{ //Store roleID(key) and a set(value) of table column controls that apply to this role private static Map policies; private static Map roleIndicators; public ColumnConstraint() {} public static void init(Map colPolicies, Map indicators) { policies = colPolicies; roleIndicators = indicators; } /** * Check to see if the specified column is restricted on the specified roles. * * As long as the column is not restricted on one role, the column is not restricted */ public static boolean isRestrictedAccessOnColumn(String columnName, String[] roles) { Set colPolicy; String indicator; for (int i = 0; i < roles.length; i++) { colPolicy = (Set)policies.get(roles[i]); indicator = (String)roleIndicators.get(roles[i]); if ("restricted".equals(indicator)) { if(colPolicy != null) { if (colPolicy.contains("NONE")) //no restriction at all, column is NOT restricted return false; if (!colPolicy.contains(columnName)) //no restriction was found for the role, so the column is NOT restricted return false; } } else { if(colPolicy != null) { if (colPolicy.contains("ALL")) //no restriction at all, column is NOT restricted return false; if (colPolicy.contains(columnName)) //no restriction was found for the role, so the column is NOT restricted return false; } } } //No found for the roles or found restrictions on all the specified roles, column is restricted return true; } /** * Check to see if the specified column is restricted for edit on the specified roles. * * As long as the column is not restricted on one role, the column is not restricted */ public static boolean isRestrictedEditOnColumn(String columnName, String[] roles) { Set colPolicy; String indicator; for (int i = 0; i < roles.length; i++) { colPolicy = (Set)policies.get(roles[i]); indicator = (String)roleIndicators.get(roles[i]); if ("restricted".equals(indicator)) { if(colPolicy != null) { if (colPolicy.contains("NONE")) //no restriction at all, column is NOT restricted return false; if (!colPolicy.contains(columnName + ".Edit") && !colPolicy.contains(columnName)) //no restriction was found for the role, so the column is editable return false; } } else { if(colPolicy != null) { if (colPolicy.contains("ALL")) //has ALL access, function is NOT restricted return false; if (colPolicy.contains(columnName + ".Edit") || colPolicy.contains(columnName)) //no restriction was found for the role, so the column is editable return false; } } } //No found for the roles or found restrictions on all the specified roles, column is restricted return true; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -