Browse Source

REPORT-130762 feat:JNDI数据连接提供禁用配置

feature/x
Richard.Fang 3 months ago
parent
commit
d6e5cd8f31
  1. 7
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java
  2. 9
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  3. 19
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

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

@ -8,6 +8,7 @@ import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.data.metric.utils.DatabaseConnectionMetricHandler; import com.fr.data.metric.utils.DatabaseConnectionMetricHandler;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.decision.webservice.exception.security.SecurityRestrictionException;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.general.MapCompareUtils; import com.fr.general.MapCompareUtils;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
@ -24,7 +25,9 @@ import com.fr.general.NameObject;
import com.fr.license.database.DBTypes; import com.fr.license.database.DBTypes;
import com.fr.license.database.DataBaseTypePointManager; import com.fr.license.database.DataBaseTypePointManager;
import com.fr.license.exception.DataBaseNotSupportedException; import com.fr.license.exception.DataBaseNotSupportedException;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.security.SecurityConfig;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -233,6 +236,10 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
if (connection instanceof JDBCDatabaseConnection) { if (connection instanceof JDBCDatabaseConnection) {
DatabaseConnectionMetricHandler.handleSaveConnection((JDBCDatabaseConnection) connection, null); DatabaseConnectionMetricHandler.handleSaveConnection((JDBCDatabaseConnection) connection, null);
} }
// JNDI禁用提示
if (connection instanceof JNDIDatabaseConnection && SecurityConfig.getInstance().isDisableJNDI()) {
throw new SecurityRestrictionException(InterProviderFactory.getProvider().getLocText("Fine-Datasource_JNDI_Disabled"));
}
default: default:
break; break;
} }

9
designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java

@ -14,6 +14,7 @@ import com.fr.data.solution.entity.DriverPage;
import com.fr.data.solution.processor.ClassNotFoundExceptionSolutionProcessor; import com.fr.data.solution.processor.ClassNotFoundExceptionSolutionProcessor;
import com.fr.data.solution.processor.SolutionProcessor; import com.fr.data.solution.processor.SolutionProcessor;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
@ -22,9 +23,11 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.rpc.ExceptionHandler; import com.fr.rpc.ExceptionHandler;
import com.fr.rpc.RPCInvokerExceptionInfo; import com.fr.rpc.RPCInvokerExceptionInfo;
import com.fr.security.SecurityConfig;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -42,6 +45,7 @@ import javax.swing.SwingConstants;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.JOptionPane;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -95,7 +99,10 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
if(mainPanel instanceof JNDIDefPane && SecurityConfig.getInstance().isDisableJNDI()) {
FineJOptionPane.showMessageDialog(mainPanel, InterProviderFactory.getProvider().getLocText("Fine-Datasource_JNDI_Disabled"), Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE);
return;
}
// Try the java connection. // Try the java connection.
final SwingWorker<Void, Void> connectionThread = new TestConnectionWorker(); final SwingWorker<Void, Void> connectionThread = new TestConnectionWorker();
midPane.setVisible(false); midPane.setVisible(false);

19
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -7,10 +7,14 @@ import com.fr.base.TableData;
import com.fr.base.svg.IconUtils; import com.fr.base.svg.IconUtils;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.desensitize.base.DesensitizationTableData; import com.fr.data.desensitize.base.DesensitizationTableData;
import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.data.impl.NameDataModel; import com.fr.data.impl.NameDataModel;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.decision.webservice.exception.security.SecurityRestrictionException;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager; import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager;
@ -37,8 +41,10 @@ import com.fr.esd.query.StrategicTableData;
import com.fr.function.TIME; import com.fr.function.TIME;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.data.DataModel; import com.fr.general.data.DataModel;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.security.SecurityConfig;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -589,11 +595,24 @@ public class PreviewTablePane extends BasicPane {
if (tableData instanceof DBTableData) { if (tableData instanceof DBTableData) {
boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase()); boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase());
if (!status) { if (!status) {
validateJndiDisabled(((DBTableData) tableData).getDatabase());
throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));
} }
} }
} }
/**
* 校验下是否为JNDI连接且禁用该功能若是显示禁用信息提示
* @param connection
*/
private void validateJndiDisabled(Connection connection) throws SecurityRestrictionException {
if(connection instanceof NameDatabaseConnection && ((NameDatabaseConnection) connection).getConnection() instanceof JNDIDatabaseConnection) {
if(SecurityConfig.getInstance().isDisableJNDI()) {
throw new SecurityRestrictionException(InterProviderFactory.getProvider().getLocText("Fine-Datasource_JNDI_Disabled"));
}
}
}
/** /**
* 处理预览Model的列类型 * 处理预览Model的列类型
* *

Loading…
Cancel
Save