You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.6 KiB

package com.fr.plugin.fg.auth;
import com.fr.log.FineLoggerFactory;
import com.ytec.authAPI.interFace.AuthIF;
import com.ytec.authAPI.interFace.bean.AuthObjDtl;
import java.util.*;
public class FGAuthApi {
private static final String DMNS_TYPE_ALL = "d_pf_all";
public static Map<String, Map<String, Set<String>>> tempAuth = null;
static {
FineLoggerFactory.getLogger().info("FGAuth:报表工程启动,开始获取模板权限");
updateTempAuth();
}
public static boolean updateTempAuth(){
Map<String, Map<String, Set<String>>> menuAuthMap = new HashMap<String, Map<String, Set<String>>>();
try {
AuthIF authIF_ = AuthIF.getInstance();
List<AuthObjDtl> objList = authIF_.getAuthedDmnsVlByDmnsTyp(DMNS_TYPE_ALL);//AuthObjDtl为权限详细
if (objList.size() > 0) {
for (AuthObjDtl authObj : objList) {
Set<String> objIDList = menuAuthMap.get(authObj.getDmnsDtl().getDmnsVlCd()) == null ? null:
menuAuthMap.get(authObj.getDmnsDtl().getDmnsVlCd()).get(authObj.getObjTyp());//authObj.getDmnsDtl()为维度值详细,包括报表ID和报表名称
if (objIDList == null) {
Map<String, Set<String>> objAuthMap = new HashMap<String, Set<String>>();
objAuthMap.put(AuthObjDtl.OBJ_TYP_ROLE, new HashSet<String>()); // role
objAuthMap.put(AuthObjDtl.OBJ_TYP_USR, new HashSet<String>()); // usr
menuAuthMap.put(authObj.getDmnsDtl().getDmnsVlCd(), objAuthMap);
objIDList = objAuthMap.get(authObj.getObjTyp());//authObj.getObjTyp()为授权对象类型,包括role和usr两种类型,平台可以针对用户或者角色进行权限设置
}
objIDList.add(authObj.getObjId());//authObj.getObjId()既对应的授权对象ID,根据对象类型,是用户ID或者角色ID
}
//objAuthMap_ = menuAuthMap;
} else {
FineLoggerFactory.getLogger().error("FGAuth:从权限API取得菜单权限失败");
return false;
}
//lastUpdateTime_ = typeInfo.getLatestUpdateTime();
} catch (Exception e) {
FineLoggerFactory.getLogger().error("FGAuth:从权限API更新·权限设置失败", e);
return false;
}
FineLoggerFactory.getLogger().info("FGAuth:读取到的模板权限为 " + menuAuthMap);
tempAuth = menuAuthMap;
return true;
}
}