⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functionconstraint.java

📁 我在加拿大学习的一个比较复杂的在线银行程序.
💻 JAVA
字号:
package com.ebusiness.ebank.security;/** * <p>Title: </p> * <p>Description:  This class contains function 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 FunctionConstraint{    //Store roleID(key) and a list(value) of function constraints that apply to this role    private static Map policies;    //Store roleID(key) and a Restricted/Authorized indicator    private static Map roleIndicators;    public FunctionConstraint() {}    public static void init(Map funcPolicies, Map indicators)    {        policies = funcPolicies;        roleIndicators = indicators;    }    /**     * Check to see if the specified function is restricted on the specified roles.     */    public static boolean isRestrictedAccessOnFunction(String functionName, String[] roles)    {        Set funcPolicy;        String indicator;        for (int i = 0; i < roles.length; i++)        {            funcPolicy = (Set)policies.get(roles[i]);            indicator = (String)roleIndicators.get(roles[i]);            if ("restricted".equals(indicator))            {                if(funcPolicy != null)                {                    if (funcPolicy.contains("NONE")) //no restriction at all, function is NOT restricted                        return false;                    if (!funcPolicy.contains(functionName.substring(functionName.indexOf(".") + 1))                            && !funcPolicy.contains(functionName))                        return false;//no restriction on this function was found for the role, so the function is not restricted                }            }            else            {                if(funcPolicy != null)                {                    if (funcPolicy.contains("ALL")) //has ALL access, function is NOT restricted                        return false;                    if (funcPolicy.contains(functionName.substring(functionName.indexOf(".") + 1))                            || funcPolicy.contains(functionName))                        return false;//This function is authorized for the role, so the function is not restricted                }            }        }        //No found for the roles or found restrictions on all the specified roles,        //or no found for the authorization to the function, function is restricted        return true;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -