Browse Source

Pull request #8876: REPORT-69285 数据连接安全关键字检查拦截,设计器

Merge in DESIGN/design from ~RINOUX/design:release/11.0 to release/11.0

* commit '04435927b963c0fd63af039fd671a5aa59431fd5':
  REPORT-69285 数据连接安全关键字检查拦截,设计器
newui
rinoux 3 years ago
parent
commit
ccb1dc82fd
  1. 10
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListDialogActionAdapter.java
  2. 23
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java
  3. 7
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java
  4. 2
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionShowPane.java

10
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListDialogActionAdapter.java

@ -2,11 +2,15 @@ package com.fr.design.data.datapane.connect;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.editlock.EditLockUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.file.ConnectionConfig;
import com.fr.report.LockItem;
import javax.swing.JOptionPane;
/**
* @author hades
* @version 11.0
@ -32,7 +36,13 @@ public class ConnectionListDialogActionAdapter extends DialogActionAdapter {
connectionListDialog.setDoOKSucceed(false);
return;
}
try {
connectionManagerPane.update(connectionConfig);
} catch (Exception e) {
connectionListDialog.setDoOKSucceed(false);
FineJOptionPane.showMessageDialog(connectionManagerPane, e.getMessage(), Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE);
return;
}
DesignerContext.getDesignerBean("databasename").refreshBeanElement();
// 关闭定义数据连接页面,为其解锁
EditLockUtils.unlock(LockItem.CONNECTION);

23
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

@ -1,6 +1,7 @@
package com.fr.design.data.datapane.connect;
import com.fr.config.RemoteConfigEvent;
import com.fr.data.core.db.JDBCSecurityChecker;
import com.fr.data.impl.Connection;
import com.fr.data.impl.ConnectionBean;
import com.fr.data.impl.JDBCDatabaseConnection;
@ -28,6 +29,7 @@ import com.fr.transaction.WorkerFacade;
import com.fr.workspace.WorkContext;
import java.awt.Window;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -166,7 +168,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
/**
* Update.
*/
public void update(ConnectionConfig connectionConfig) {
public void update(ConnectionConfig connectionConfig) throws Exception {
// Nameable[]居然不能强转成NameObject[],一定要这么写...
Nameable[] res = this.update();
Map<String, Connection> updatedMap = new LinkedHashMap<>();
@ -188,10 +190,27 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
}
});
this.checkSecurity(addedOrUpdatedConnections);
this.alterConnections(removedConnNames, addedOrUpdatedConnections);
}
private void checkSecurity(List<ConnectionBean> addedOrUpdatedConnections) throws Exception {
for (ConnectionBean connectionBean : addedOrUpdatedConnections) {
Connection connection = connectionBean.getConnection();
if (connection instanceof JDBCDatabaseConnection) {
try {
JDBCSecurityChecker.checkURL(((JDBCDatabaseConnection) connection).getURL());
JDBCSecurityChecker.checkValidationQuery(((JDBCDatabaseConnection) connection).getDbcpAttr().getValidationQuery());
} catch (SQLException e) {
throw new SQLException(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Invalid_Config", connectionBean.getName()) + ", " + e.getMessage(), e.getCause());
}
}
}
}
private void alterConnections(List<String> removedConnNames, List<ConnectionBean> addedOrUpdatedConnections) {
try {

7
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java

@ -4,9 +4,8 @@ import com.fr.design.gui.frpane.LoadingBasicPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.file.ConnectionConfig;
import javax.swing.*;
import java.awt.*;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.util.HashMap;
public class ConnectionManagerPane extends LoadingBasicPane implements ConnectionShowPane {
@ -39,7 +38,7 @@ public class ConnectionManagerPane extends LoadingBasicPane implements Connectio
this.connectionListPane.populate(datasourceManager);
}
public void update(ConnectionConfig datasourceManager) {
public void update(ConnectionConfig datasourceManager) throws Exception {
this.connectionListPane.update(datasourceManager);
}

2
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionShowPane.java

@ -7,7 +7,7 @@ import com.fr.file.ConnectionConfig;
* 数据链接显示面板
*/
public interface ConnectionShowPane {
void update(ConnectionConfig connectionConfig);
void update(ConnectionConfig connectionConfig) throws Exception;
void populate(ConnectionConfig connectionConfig);

Loading…
Cancel
Save