Commit 026821c3 authored by hanson.yao's avatar hanson.yao

210菜单权限修复

parent b93919a9
FilterUser=SJY-kabuda
FilterUser=AUDITADMIN:kabuda;SYSADMIN:wcadmin;SAFEADMIN:Administrator
\ No newline at end of file
package com.yonde.access;
import org.apache.commons.lang.StringUtils;
import wt.inf.container.WTContainerRef;
import wt.org.WTUser;
import wt.util.WTProperties;
......@@ -19,38 +18,56 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class AccessFilter {
public static final String SAFEADMIN = "SAFEADMIN";
public static final String AUDITADMIN = "AUDITADMIN";
public static final String SYSADMIN = "SYSADMIN";
public static ConcurrentHashMap filter(WTContainerRef containerRef, WTUser currentUser, ConcurrentHashMap concurrentHashMap) throws IOException {
Map<String, String> accessModuleMap = initFilter();
System.out.println("accessModuleMap:" + accessModuleMap);
String userName = currentUser.getName();
String orDefault = accessModuleMap.get(userName);
if (orDefault == null) {
String role = accessModuleMap.get(userName);
System.out.println("role:" + role + " userName:" + userName);
if (role == null) {
return concurrentHashMap;
} else {
return getAllConcurrentHashMap();
return getAllConcurrentHashMap(role);
}
}
public static ConcurrentHashMap getAllConcurrentHashMap() {
public static ConcurrentHashMap getAllConcurrentHashMap(String role) {
ConcurrentHashMap showUtility = new ConcurrentHashMap();
if (SAFEADMIN.equals(role)) {
showUtility.put("AUDITING_PURGE", "Enable");
showUtility.put("AUDITING_LICENSE_USAGE", "Enable");
showUtility.put("AUDITING_SECURITY_REPORT_QUERIES", "Enable");
showUtility.put("AUDITING_SECURITY_REPORTS", "Enable");
showUtility.put("EXT_USER_MANAGE", "Enable");
}
if (AUDITADMIN.equals(role)) {
showUtility.put("AUDITING_PURGE", "Enable");
showUtility.put("AUDITING_LICENSE_USAGE", "Enable");
showUtility.put("AUDITING_SECURITY_REPORT_QUERIES", "Enable");
showUtility.put("AUDITING_SECURITY_REPORTS", "Enable");
}
if (SYSADMIN.equals(role)) {
showUtility.put("PRINCIPAL_ADMIN", "Enable");
}
System.out.println(">>>getAllConcurrentHashMap:" + showUtility);
return showUtility;
}
public static Map<String, String> initFilter() throws IOException {
Map<String, String> filterUserMap = new HashMap<String, String>();
Map<String, String> filterUserMap = new HashMap();
String filterUser = File.separator + "codebase"
+ File.separator + "com" + File.separator + "yonde" + File.separator+"access"
+ File.separator + "com" + File.separator + "yonde" + File.separator + "access"
+ File.separator + "access.properties";
Properties properties = new Properties();
try {
WTProperties wtproperties = WTProperties.getLocalProperties();
String fullPath = wtproperties.getProperty("wt.home") +filterUser;
String fullPath = wtproperties.getProperty("wt.home") + filterUser;
InputStream inputStream = null;
try {
inputStream = new FileInputStream(new File(fullPath));
......@@ -61,12 +78,10 @@ public class AccessFilter {
}
}
String property = properties.getProperty("FilterUser");
String[] split = property.split("-");
for (String item:split) {
String value = filterUserMap.get(item);
if (StringUtils.isBlank(value)){
filterUserMap.put(item, item);
}
String[] split = property.split(";");
for (String item : split) {
String[] kv = item.split(":");
filterUserMap.put(kv[1], kv[0]);
}
} catch (IOException e) {
e.printStackTrace();
......
package com.yonde.access;
import com.ptc.core.ui.validation.*;
import org.apache.commons.lang.StringUtils;
import wt.org.WTPrincipal;
import wt.session.SessionHelper;
......@@ -18,10 +17,9 @@ public class CustomActionValidator implements SimpleValidationFilter {
try {
principal = SessionHelper.manager.getPrincipal();
String name = principal.getName();
System.out.println(">>>CustomActionValidator name..." + name);
Map<String, String> filterMap = AccessFilter.initFilter();
String value = filterMap.get(name);
if (!StringUtils.isBlank(value)) {
boolean containsKey = filterMap.containsKey(name);
if (containsKey) {
return UIValidationStatus.HIDDEN;
}
} catch (Exception e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment