📄 permctrlinvocationhandler.java
字号:
package com.cownew.PIS.framework.server.permissionMgr;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Properties;
import java.util.Set;
import com.cownew.PIS.base.permission.common.PermissionException;
import com.cownew.PIS.base.permission.common.UserInfo;
import com.cownew.PIS.framework.server.helper.ThreadVariableManager;
public class PermCtrlInvocationHandler implements InvocationHandler
{
private IPermissionCtrlService realObj;
private Properties permAttributes;
public PermCtrlInvocationHandler(IPermissionCtrlService realObj)
{
super();
this.realObj = realObj;
permAttributes = realObj.getPermissionAttributes();
}
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
{
String methodName = method.getName();
if (permAttributes.containsKey(methodName))
{
String oprtName = permAttributes.get(methodName).toString();
ctrlPermission(oprtName);
}
return method.invoke(realObj, args);
}
protected void ctrlPermission(String oprtName)
{
ThreadVariableManager threadVarMgr = ThreadVariableManager.getInstance();
UserInfo curUserInfo = threadVarMgr.getCurrentServerUserContext()
.getCurUserInfo();
if (curUserInfo.getIsSuperAdmin())
{
//如果是预设超级管理员,则不进行权限控制
return;
}
Set permSet = threadVarMgr.getCurrentServerUserContext().getPermissonNameSet();
UserInfo user = curUserInfo;
if (!permSet.contains(oprtName))
{
throw new PermissionException(PermissionException.NOPERMISSION,
new Object[] { user.getNumber(), oprtName });
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -