mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-4211. Disable embedded drivers in TM (#2217)
* CB-4211. Disable embedded drivers in TM * CB-4211. Fixed checkstyle --------- Co-authored-by: Evgenia Bezborodova <139753579+EvgeniaBzzz@users.noreply.github.com>
This commit is contained in:
co-authored by
Evgenia Bezborodova
parent
9eb32a0428
commit
89df586a6e
@@ -33,6 +33,7 @@ Export-Package: io.cloudbeaver,
|
||||
io.cloudbeaver.model.rm.lock,
|
||||
io.cloudbeaver.model.session,
|
||||
io.cloudbeaver.model.user,
|
||||
io.cloudbeaver.model.utils,
|
||||
io.cloudbeaver.registry,
|
||||
io.cloudbeaver.server,
|
||||
io.cloudbeaver.service,
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package io.cloudbeaver.model;
|
||||
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
|
||||
import org.jkiss.dbeaver.model.DBPDataSourceHandler;
|
||||
import org.jkiss.dbeaver.model.connection.DBPDriver;
|
||||
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
|
||||
|
||||
public abstract class BaseDatasourceAccessCheckHandler implements DBPDataSourceHandler {
|
||||
@Override
|
||||
public void beforeConnect(
|
||||
DBRProgressMonitor monitor,
|
||||
@NotNull DBPDataSourceContainer dataSourceContainer
|
||||
) throws DBException {
|
||||
if (isDriverDisabled(dataSourceContainer.getDriver())) {
|
||||
throw new DBException("Driver disabled");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDisconnect(
|
||||
DBRProgressMonitor monitor,
|
||||
@NotNull DBPDataSourceContainer dataSourceContainer
|
||||
) throws DBException {
|
||||
|
||||
}
|
||||
|
||||
protected abstract boolean isDriverDisabled(DBPDriver driver);
|
||||
}
|
||||
+7
-4
@@ -14,9 +14,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.cloudbeaver.server;
|
||||
package io.cloudbeaver.model.utils;
|
||||
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.Nullable;
|
||||
import org.jkiss.dbeaver.model.connection.DBPDriver;
|
||||
import org.jkiss.utils.ArrayUtils;
|
||||
|
||||
@@ -24,12 +25,14 @@ public class ConfigurationUtils {
|
||||
private ConfigurationUtils() {
|
||||
}
|
||||
|
||||
public static boolean isDriverEnabled(@NotNull DBPDriver driver) {
|
||||
String[] enabledDrivers = CBApplication.getInstance().getAppConfiguration().getEnabledDrivers();
|
||||
public static boolean isDriverEnabled(
|
||||
@NotNull DBPDriver driver,
|
||||
@Nullable String[] enabledDrivers,
|
||||
@Nullable String[] disabledDrivers
|
||||
) {
|
||||
if (ArrayUtils.contains(enabledDrivers, driver.getFullId())) {
|
||||
return true;
|
||||
}
|
||||
String[] disabledDrivers = CBApplication.getInstance().getAppConfiguration().getDisabledDrivers();
|
||||
if (ArrayUtils.contains(disabledDrivers, driver.getFullId())) {
|
||||
return false;
|
||||
}
|
||||
+9
-2
@@ -19,7 +19,9 @@ package io.cloudbeaver.model;
|
||||
import io.cloudbeaver.DBWebException;
|
||||
import io.cloudbeaver.WebServiceUtils;
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import io.cloudbeaver.server.ConfigurationUtils;
|
||||
import io.cloudbeaver.model.utils.ConfigurationUtils;
|
||||
import io.cloudbeaver.server.CBAppConfig;
|
||||
import io.cloudbeaver.server.CBApplication;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.Log;
|
||||
import org.jkiss.dbeaver.model.DBConstants;
|
||||
@@ -236,7 +238,12 @@ public class WebDatabaseDriverInfo {
|
||||
|
||||
@Property
|
||||
public boolean isEnabled() {
|
||||
return ConfigurationUtils.isDriverEnabled(driver);
|
||||
CBAppConfig config = CBApplication.getInstance().getAppConfiguration();
|
||||
return ConfigurationUtils.isDriverEnabled(
|
||||
driver,
|
||||
config.getEnabledDrivers(),
|
||||
config.getDisabledDrivers()
|
||||
);
|
||||
}
|
||||
|
||||
@Property
|
||||
|
||||
+11
-16
@@ -17,23 +17,18 @@
|
||||
|
||||
package io.cloudbeaver.model;
|
||||
|
||||
import io.cloudbeaver.server.ConfigurationUtils;
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
|
||||
import org.jkiss.dbeaver.model.DBPDataSourceHandler;
|
||||
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
|
||||
import io.cloudbeaver.model.utils.ConfigurationUtils;
|
||||
import io.cloudbeaver.server.CBAppConfig;
|
||||
import io.cloudbeaver.server.CBApplication;
|
||||
import org.jkiss.dbeaver.model.connection.DBPDriver;
|
||||
|
||||
public class WebDatasourceAccessCheckHandler implements DBPDataSourceHandler {
|
||||
public class WebDatasourceAccessCheckHandler extends BaseDatasourceAccessCheckHandler {
|
||||
@Override
|
||||
public void beforeConnect(DBRProgressMonitor monitor, @NotNull DBPDataSourceContainer dataSourceContainer) throws DBException {
|
||||
if (!ConfigurationUtils.isDriverEnabled(dataSourceContainer.getDriver())) {
|
||||
throw new DBException("Driver disabled");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDisconnect(DBRProgressMonitor monitor, @NotNull DBPDataSourceContainer dataSourceContainer) throws DBException {
|
||||
|
||||
protected boolean isDriverDisabled(DBPDriver driver) {
|
||||
CBAppConfig config = CBApplication.getInstance().getAppConfiguration();
|
||||
return !ConfigurationUtils.isDriverEnabled(
|
||||
driver,
|
||||
config.getEnabledDrivers(),
|
||||
config.getDisabledDrivers());
|
||||
}
|
||||
}
|
||||
|
||||
+9
-2
@@ -17,8 +17,10 @@
|
||||
package io.cloudbeaver.service.admin.impl;
|
||||
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import io.cloudbeaver.model.utils.ConfigurationUtils;
|
||||
import io.cloudbeaver.server.CBAppConfig;
|
||||
import io.cloudbeaver.server.CBApplication;
|
||||
import io.cloudbeaver.server.CBPlatform;
|
||||
import io.cloudbeaver.server.ConfigurationUtils;
|
||||
import io.cloudbeaver.service.admin.AdminConnectionSearchInfo;
|
||||
import org.jkiss.dbeaver.model.connection.DBPDriver;
|
||||
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
|
||||
@@ -124,7 +126,12 @@ public class ConnectionSearcher implements DBRRunnableWithProgress {
|
||||
}
|
||||
|
||||
private void updatePortInfo(Map<Integer, AdminConnectionSearchInfo> portCache, String hostName, String displayName, DBPDriver driver, int timeout) {
|
||||
if (!ConfigurationUtils.isDriverEnabled(driver)) {
|
||||
CBAppConfig config = CBApplication.getInstance().getAppConfiguration();
|
||||
if (!ConfigurationUtils.isDriverEnabled(
|
||||
driver,
|
||||
config.getEnabledDrivers(),
|
||||
config.getDisabledDrivers())
|
||||
) {
|
||||
return;
|
||||
}
|
||||
int driverPort = CommonUtils.toInt(driver.getDefaultPort());
|
||||
|
||||
Reference in New Issue
Block a user