|
|
@ -6,9 +6,13 @@ import com.fr.design.dialog.FineJOptionPane; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
|
|
|
|
import com.fr.design.mod.ModClassFilter; |
|
|
|
import com.fr.invoke.ClassHelper; |
|
|
|
import com.fr.invoke.ClassHelper; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
|
|
|
import com.fr.rpc.ExceptionHandler; |
|
|
|
|
|
|
|
import com.fr.rpc.RPCInvokerExceptionInfo; |
|
|
|
|
|
|
|
import com.fr.stable.Filter; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.server.authority.user.UserAuthority; |
|
|
|
import com.fr.workspace.server.authority.user.UserAuthority; |
|
|
|
|
|
|
|
|
|
|
@ -42,17 +46,19 @@ public class JTemplateAuthorityChecker { |
|
|
|
|
|
|
|
|
|
|
|
private void initAuthNames() { |
|
|
|
private void initAuthNames() { |
|
|
|
UserAuthority templateAuthority = WorkContext.getCurrent().get(UserAuthority.class); |
|
|
|
UserAuthority templateAuthority = WorkContext.getCurrent().get(UserAuthority.class); |
|
|
|
Map<String, Set<String>> allAuthNames = templateAuthority.getAuthServerDataSetAndConnectionNames(); |
|
|
|
Map<String, Set<String>> authNamesMap = templateAuthority.getAuthServerDataSetAndConnectionNames(); |
|
|
|
|
|
|
|
if (authNamesMap != null) { |
|
|
|
//有权限的数据连接名称
|
|
|
|
//有权限的数据连接名称
|
|
|
|
authConnectionNames = allAuthNames.get(UserAuthority.AUTH_CONNECTION_NAMES); |
|
|
|
authConnectionNames = authNamesMap.get(UserAuthority.AUTH_CONNECTION_NAMES); |
|
|
|
//有权限的数据集名称(模板数据集和服务器数据集)
|
|
|
|
//有权限的数据集名称(模板数据集和服务器数据集)
|
|
|
|
authDatasetNames = allAuthNames.get(UserAuthority.AUTH_SERVER_DATASET_NAMES); |
|
|
|
authDatasetNames = authNamesMap.get(UserAuthority.AUTH_SERVER_DATASET_NAMES); |
|
|
|
Iterator<String> iterator = jTemplate.getTarget().getTableDataNameIterator(); |
|
|
|
Iterator<String> iterator = jTemplate.getTarget().getTableDataNameIterator(); |
|
|
|
while (iterator.hasNext()) { |
|
|
|
while (iterator.hasNext()) { |
|
|
|
String datasetName = iterator.next(); |
|
|
|
String datasetName = iterator.next(); |
|
|
|
authDatasetNames.add(datasetName); |
|
|
|
authDatasetNames.add(datasetName); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initChecker() { |
|
|
|
private void initChecker() { |
|
|
|
registerChecker(new NameDatabaseConnectionAuthorityChecker()); |
|
|
|
registerChecker(new NameDatabaseConnectionAuthorityChecker()); |
|
|
@ -69,60 +75,57 @@ public class JTemplateAuthorityChecker { |
|
|
|
public boolean isAuthority() { |
|
|
|
public boolean isAuthority() { |
|
|
|
long s = System.currentTimeMillis(); |
|
|
|
long s = System.currentTimeMillis(); |
|
|
|
//遍历模板对象,根据checkerMap.keySet()把感兴趣的对象找出来
|
|
|
|
//遍历模板对象,根据checkerMap.keySet()把感兴趣的对象找出来
|
|
|
|
Map<String, Collection<Object>> targetObjects = ClassHelper.searchObject(jTemplate.getTarget(), checkerMap.keySet()); |
|
|
|
Map<String, Collection<Object>> targetObjects = ClassHelper.searchObject(jTemplate.getTarget(), checkerMap.keySet(), ClassFilter.getInstance()); |
|
|
|
|
|
|
|
|
|
|
|
//找到对应的checker,对对象进行检查
|
|
|
|
//找到对应的checker,对对象进行检查
|
|
|
|
for (String name : targetObjects.keySet()) { |
|
|
|
for (String name : targetObjects.keySet()) { |
|
|
|
ElementAuthorityChecker checker = checkerMap.get(name); |
|
|
|
ElementAuthorityChecker checker = checkerMap.get(name); |
|
|
|
for (Object object : targetObjects.get(name)) { |
|
|
|
for (Object object : targetObjects.get(name)) { |
|
|
|
String authFailName = checker.checkConnectionName(object, authConnectionNames); |
|
|
|
if (authConnectionNames != null) { |
|
|
|
if (authFailName != null) { |
|
|
|
Set<String> noAuthName = checker.getNoAuthConnectionNames(object, authConnectionNames); |
|
|
|
authFailConnectionNames.add(authFailName); |
|
|
|
if (noAuthName != null) { |
|
|
|
|
|
|
|
authFailConnectionNames.addAll(noAuthName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (authDatasetNames != null) { |
|
|
|
|
|
|
|
Set<String> noAuthName = checker.getNoAuthDatasetNames(object, authDatasetNames); |
|
|
|
|
|
|
|
if (noAuthName != null) { |
|
|
|
|
|
|
|
authFailDatasetNames.addAll(noAuthName); |
|
|
|
} |
|
|
|
} |
|
|
|
authFailName = checker.checkDatasetName(object, authDatasetNames); |
|
|
|
|
|
|
|
if (authFailName != null) { |
|
|
|
|
|
|
|
authFailDatasetNames.add(authFailName); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().info("JTemplateAuthorityChecker check time consume:" + (System.currentTimeMillis() - s)); |
|
|
|
FineLoggerFactory.getLogger().info("JTemplateAuthorityChecker check time consume:" + (System.currentTimeMillis() - s)); |
|
|
|
if (authFailConnectionNames.size() == 0 && authFailDatasetNames.size() == 0) { |
|
|
|
return authFailConnectionNames.size() == 0 && authFailDatasetNames.size() == 0; |
|
|
|
return true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//如果存在越权的,弹出弹框,并返回false
|
|
|
|
|
|
|
|
authorityFailPrompt(); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void authorityFailPrompt() { |
|
|
|
public void showAuthorityFailPromptDialog() { |
|
|
|
StringBuffer stringBuffer = new StringBuffer(); |
|
|
|
StringBuffer stringBuffer = new StringBuffer(); |
|
|
|
stringBuffer.append(Toolkit.i18nText("Fine-Design-Basic_Save_Failure")); |
|
|
|
stringBuffer.append(Toolkit.i18nText("Fine-Design-Basic_Save_Failure")); |
|
|
|
stringBuffer.append("\n"); |
|
|
|
stringBuffer.append("\n"); |
|
|
|
if (authFailDatasetNames.size() > 0) { |
|
|
|
stringBuffer.append(getPromptInfo(authFailDatasetNames, |
|
|
|
stringBuffer.append(Toolkit.i18nText("Fine-Design_Template_Authority_Check_Current_Operator_Miss")); |
|
|
|
Toolkit.i18nText("Fine-Design_Template_Authority_Check_Server_Dataset_Authority"))); |
|
|
|
stringBuffer.append(authFailDatasetNames.size()); |
|
|
|
stringBuffer.append(getPromptInfo(authFailConnectionNames, |
|
|
|
stringBuffer.append(Toolkit.i18nText("Fine-Design_Report_Ge")); |
|
|
|
Toolkit.i18nText("Fine-Design_Template_Authority_Check_Data_Connection_Authority"))); |
|
|
|
stringBuffer.append(Toolkit.i18nText("Fine-Design_Template_Authority_Check_Server_Dataset_Authority")); |
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
stringBuffer.append("\n"); |
|
|
|
DesignerContext.getDesignerFrame(), |
|
|
|
stringBuffer.append(getNoAuthNameSequence(authFailDatasetNames)); |
|
|
|
stringBuffer.toString(), |
|
|
|
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Alert"), |
|
|
|
|
|
|
|
WARNING_MESSAGE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (authFailConnectionNames.size() > 0) { |
|
|
|
private String getPromptInfo(Set<String> authFailNames, String message) { |
|
|
|
|
|
|
|
StringBuffer stringBuffer = new StringBuffer(); |
|
|
|
|
|
|
|
if (authFailNames.size() > 0) { |
|
|
|
stringBuffer.append(Toolkit.i18nText("Fine-Design_Template_Authority_Check_Current_Operator_Miss")); |
|
|
|
stringBuffer.append(Toolkit.i18nText("Fine-Design_Template_Authority_Check_Current_Operator_Miss")); |
|
|
|
stringBuffer.append(authFailConnectionNames.size()); |
|
|
|
stringBuffer.append(authFailNames.size()); |
|
|
|
stringBuffer.append(Toolkit.i18nText("Fine-Design_Report_Ge")); |
|
|
|
stringBuffer.append(Toolkit.i18nText("Fine-Design_Report_Ge")); |
|
|
|
stringBuffer.append(Toolkit.i18nText("Fine-Design_Template_Authority_Check_Data_Connection_Authority")); |
|
|
|
stringBuffer.append(message); |
|
|
|
stringBuffer.append("\n"); |
|
|
|
stringBuffer.append("\n"); |
|
|
|
stringBuffer.append(getNoAuthNameSequence(authFailConnectionNames)); |
|
|
|
stringBuffer.append(getNoAuthNameSequence(authFailNames)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return stringBuffer.toString(); |
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
|
|
|
|
DesignerContext.getDesignerFrame(), |
|
|
|
|
|
|
|
stringBuffer.toString(), |
|
|
|
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Alert"), |
|
|
|
|
|
|
|
WARNING_MESSAGE); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String getNoAuthNameSequence(Set<String> names) { |
|
|
|
private String getNoAuthNameSequence(Set<String> names) { |
|
|
@ -143,5 +146,39 @@ public class JTemplateAuthorityChecker { |
|
|
|
stringBuffer.append("\n"); |
|
|
|
stringBuffer.append("\n"); |
|
|
|
return stringBuffer.toString(); |
|
|
|
return stringBuffer.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class ClassFilter implements Filter<String> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final Set<String> FILTER_SET = new HashSet<>(); |
|
|
|
|
|
|
|
private static final Set<String> START_WITH_SET = new HashSet<>(); |
|
|
|
|
|
|
|
private static final Filter<String> INSTANCE = new ModClassFilter(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Filter<String> getInstance() { |
|
|
|
|
|
|
|
return INSTANCE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static { |
|
|
|
|
|
|
|
FILTER_SET.add("java.awt.image.BufferedImage"); |
|
|
|
|
|
|
|
FILTER_SET.add("sun.awt.AppContext"); |
|
|
|
|
|
|
|
FILTER_SET.add("com.fr.poly.creator.ECBlockCreator"); |
|
|
|
|
|
|
|
FILTER_SET.add("io.netty.channel.nio.SelectedSelectionKeySet"); |
|
|
|
|
|
|
|
FILTER_SET.add("com.fr.form.ui.ElementCaseImage"); |
|
|
|
|
|
|
|
FILTER_SET.add("this$0"); |
|
|
|
|
|
|
|
START_WITH_SET.add("com.fr.design"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean accept(String s) { |
|
|
|
|
|
|
|
if (FILTER_SET.contains(s)) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (String start : START_WITH_SET) { |
|
|
|
|
|
|
|
if (s.startsWith(start)) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|