diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java index 5ca711678b..ac154189aa 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java @@ -26,7 +26,6 @@ import io.cloudbeaver.server.jetty.CBJettyServer; import io.cloudbeaver.service.DBWServiceInitializer; import io.cloudbeaver.service.DBWServiceServerConfigurator; -import io.cloudbeaver.service.security.CBEmbeddedSecurityController; import io.cloudbeaver.service.security.SMControllerConfiguration; import io.cloudbeaver.service.session.WebSessionManager; import io.cloudbeaver.utils.WebDataSourceUtils; @@ -95,7 +94,8 @@ public abstract class CBApplication extends BaseWebApp public static CBApplication getInstance() { return (CBApplication) BaseApplicationImpl.getInstance(); } - private File homeDirectory; + + private final File homeDirectory; // Persistence protected SMAdminController securityController; @@ -109,6 +109,7 @@ public static CBApplication getInstance() { private WebSessionManager sessionManager; public CBApplication() { + this.homeDirectory = new File(initHomeFolder()); } public String getServerURL() { @@ -185,7 +186,7 @@ public Map getProductConfiguration() { } public SMControllerConfiguration getSecurityManagerConfiguration() { - return getServerConfigurationController().getSecurityManagerConfiguration(); + return getServerConfiguration().getSecurityManagerConfiguration(); } public SMAdminController getSecurityController() { @@ -195,7 +196,6 @@ public SMAdminController getSecurityController() { @Override protected void startServer() { CBPlatform.setApplication(this); - initHomeFolder(); try { if (!loadServerConfiguration()) { return; @@ -466,14 +466,9 @@ protected String initHomeFolder() { if (CommonUtils.isEmpty(homeFolder)) { homeFolder = "."; } - homeDirectory = new File(homeFolder); return homeFolder; } - protected void validateConfiguration(Map appConfig) throws DBException { - - } - private void runWebServer() { log.debug( String.format("Starting Jetty server (%d on %s) ", diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplicationCE.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplicationCE.java index 0e732b3b2d..7a00e3474c 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplicationCE.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplicationCE.java @@ -42,34 +42,35 @@ public class CBApplicationCE extends CBApplication { private final CBServerConfigurationControllerEmbedded serverConfigController; public CBApplicationCE() { - serverConfigController = new CBServerConfigurationControllerEmbedded<>(new CBServerConfig()); + super(); + this.serverConfigController = new CBServerConfigurationControllerEmbedded<>(new CBServerConfig(), getHomeDirectory()); } @Override public SMController createSecurityController(@NotNull SMCredentialsProvider credentialsProvider) throws DBException { - return new EmbeddedSecurityControllerFactory().createSecurityService( + return new EmbeddedSecurityControllerFactory<>().createSecurityService( this, getServerConfiguration().getDatabaseConfiguration(), credentialsProvider, - getServerConfigurationController().getSecurityManagerConfiguration() + getServerConfiguration().getSecurityManagerConfiguration() ); } @Override public SMAdminController getAdminSecurityController(@NotNull SMCredentialsProvider credentialsProvider) throws DBException { - return new EmbeddedSecurityControllerFactory().createSecurityService( + return new EmbeddedSecurityControllerFactory<>().createSecurityService( this, getServerConfiguration().getDatabaseConfiguration(), credentialsProvider, - getServerConfigurationController().getSecurityManagerConfiguration() + getServerConfiguration().getSecurityManagerConfiguration() ); } protected SMAdminController createGlobalSecurityController() throws DBException { - return new EmbeddedSecurityControllerFactory().createSecurityService( + return new EmbeddedSecurityControllerFactory<>().createSecurityService( this, getServerConfiguration().getDatabaseConfiguration(), new NoAuthCredentialsProvider(), - getServerConfigurationController().getSecurityManagerConfiguration() + getServerConfiguration().getSecurityManagerConfiguration() ); } @@ -94,8 +95,8 @@ public CBServerConfigurationControllerEmbedded getServerConfigur protected void shutdown() { try { - if (securityController instanceof CBEmbeddedSecurityController) { - ((CBEmbeddedSecurityController) securityController).shutdown(); + if (securityController instanceof CBEmbeddedSecurityController embeddedSecurityController) { + embeddedSecurityController.shutdown(); } } catch (Exception e) { log.error(e); @@ -108,8 +109,8 @@ protected void finishSecurityServiceConfiguration( @Nullable String adminPassword, @NotNull List authInfoList ) throws DBException { - if (securityController instanceof CBEmbeddedSecurityController) { - ((CBEmbeddedSecurityController) securityController).finishConfiguration(adminName, adminPassword, authInfoList); + if (securityController instanceof CBEmbeddedSecurityController embeddedSecurityController) { + embeddedSecurityController.finishConfiguration(adminName, adminPassword, authInfoList); } } diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfig.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfig.java index 2b0b6d0bf7..d914fa08dd 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfig.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfig.java @@ -19,6 +19,7 @@ import com.google.gson.annotations.SerializedName; import io.cloudbeaver.auth.CBAuthConstants; import io.cloudbeaver.model.app.WebServerConfiguration; +import io.cloudbeaver.service.security.SMControllerConfiguration; import io.cloudbeaver.service.security.db.WebDatabaseConfig; import org.jkiss.code.NotNull; import org.jkiss.dbeaver.Log; @@ -50,6 +51,8 @@ public class CBServerConfig implements WebServerConfiguration { private boolean enableSecurityManager = false; private final Map productSettings = new HashMap<>(); + @SerializedName("sm") + protected final SMControllerConfiguration securityManagerConfiguration = new SMControllerConfiguration(); @SerializedName("database") private WebDatabaseConfig databaseConfiguration = new WebDatabaseConfig(); private String staticContent = ""; @@ -191,4 +194,8 @@ public boolean isEnableSecurityManager() { public Map getProductSettings() { return productSettings; } + + public SMControllerConfiguration getSecurityManagerConfiguration() { + return securityManagerConfiguration; + } } diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfigurationController.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfigurationController.java index ab8ea29ad9..9dfbab44c1 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfigurationController.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfigurationController.java @@ -56,14 +56,17 @@ public abstract class CBServerConfigurationController private static final Log log = Log.getLog(CBServerConfigurationController.class); // Configurations - protected final SMControllerConfiguration securityManagerConfiguration = new SMControllerConfiguration(); + @NotNull private final T serverConfiguration; private final CBAppConfig appConfiguration = new CBAppConfig(); - private Map externalProperties = new LinkedHashMap<>(); - private Map originalConfigurationProperties = new LinkedHashMap<>(); + @NotNull + protected final Path homeDirectory; + private final Map externalProperties = new LinkedHashMap<>(); + private final Map originalConfigurationProperties = new LinkedHashMap<>(); - protected CBServerConfigurationController(T serverConfiguration) { + protected CBServerConfigurationController(@NotNull T serverConfiguration, @NotNull Path homeDirectory) { this.serverConfiguration = serverConfiguration; + this.homeDirectory = homeDirectory; } public String getAuthServiceURL() { @@ -159,7 +162,7 @@ public T parseServerConfiguration() { } config.setServerURL("http://" + hostName + ":" + config.getServerPort()); } - var homeDirectory = CBApplication.getInstance().getHomeDirectory().toString(); + config.setContentRoot(WebAppUtils.getRelativePath(config.getContentRoot(), homeDirectory)); config.setRootURI(readRootUri(config.getRootURI())); config.setDriversLocation(WebAppUtils.getRelativePath(config.getDriversLocation(), homeDirectory)); @@ -223,7 +226,7 @@ protected void readProductConfiguration(Map serverConfig, Gson g CBConstants.PARAM_PRODUCT_CONFIGURATION, CBConstants.DEFAULT_PRODUCT_CONFIGURATION ), - CBApplication.getInstance().getHomeDirectory().toString() + homeDirectory ); if (!CommonUtils.isEmpty(productConfigPath)) { File productConfigFile = new File(productConfigPath); @@ -300,6 +303,7 @@ protected GsonBuilder getGsonBuilder() { // Stupid way to populate existing objects but ok google (https://github.com/google/gson/issues/431) InstanceCreator appConfigCreator = type -> appConfiguration; InstanceCreator navSettingsCreator = type -> (DataSourceNavigatorSettings) appConfiguration.getDefaultNavigatorSettings(); + var securityManagerConfiguration = getServerConfiguration().getSecurityManagerConfiguration(); InstanceCreator smConfigCreator = type -> securityManagerConfiguration; InstanceCreator serverConfigCreator = type -> serverConfiguration; InstanceCreator smPasswordPoliceConfigCreator = @@ -602,10 +606,6 @@ public Map getProductConfiguration() { return getServerConfiguration().getProductSettings(); } - public SMControllerConfiguration getSecurityManagerConfiguration() { - return securityManagerConfiguration; - } - private String readRootUri(String uri) { //slashes are needed to correctly display static resources on ui if (!uri.endsWith("/")) { diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfigurationControllerEmbedded.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfigurationControllerEmbedded.java index c15ef7c49d..6c6ed695a6 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfigurationControllerEmbedded.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBServerConfigurationControllerEmbedded.java @@ -25,6 +25,7 @@ import org.jkiss.dbeaver.model.data.json.JSONUtils; import org.jkiss.utils.CommonUtils; +import java.nio.file.Path; import java.util.LinkedHashMap; import java.util.Map; @@ -35,8 +36,8 @@ public class CBServerConfigurationControllerEmbedded e private static final Log log = Log.getLog(CBServerConfigurationControllerEmbedded.class); - public CBServerConfigurationControllerEmbedded(T serverConfig) { - super(serverConfig); + public CBServerConfigurationControllerEmbedded(@NotNull T serverConfig, @NotNull Path homeDirectory) { + super(serverConfig, homeDirectory); } @NotNull @@ -79,7 +80,7 @@ private void savePasswordPolicyConfig(Map originServerConfig, Ma ); Gson gson = getGson(); Map passwordPolicyConfig = gson.fromJson( - gson.toJsonTree(securityManagerConfiguration.getPasswordPolicyConfiguration()), + gson.toJsonTree(getServerConfiguration().getSecurityManagerConfiguration().getPasswordPolicyConfiguration()), JSONUtils.MAP_TYPE_TOKEN ); if (!CommonUtils.isEmpty(passwordPolicyConfig)) { @@ -98,10 +99,8 @@ protected GsonBuilder getGsonBuilder() { GsonBuilder gsonBuilder = super.getGsonBuilder(); var databaseConfiguration = getServerConfiguration().getDatabaseConfiguration(); InstanceCreator dbConfigCreator = type -> databaseConfiguration; - InstanceCreator dbPoolConfigCreator = type -> databaseConfiguration.getPool(); return gsonBuilder - .registerTypeAdapter(WebDatabaseConfig.class, dbConfigCreator) - .registerTypeAdapter(WebDatabaseConfig.Pool.class, dbPoolConfigCreator); + .registerTypeAdapter(WebDatabaseConfig.class, dbConfigCreator); } diff --git a/webapp/packages/core-blocks/public/icons/timer.svg b/webapp/packages/core-blocks/public/icons/timer.svg index ddc6e7703c..e958ee947f 100644 --- a/webapp/packages/core-blocks/public/icons/timer.svg +++ b/webapp/packages/core-blocks/public/icons/timer.svg @@ -1,7 +1,6 @@ - diff --git a/webapp/packages/core-blocks/public/icons/timer_m.svg b/webapp/packages/core-blocks/public/icons/timer_m.svg index 619f55d315..32d1a40037 100644 --- a/webapp/packages/core-blocks/public/icons/timer_m.svg +++ b/webapp/packages/core-blocks/public/icons/timer_m.svg @@ -1,7 +1,6 @@ - diff --git a/webapp/packages/core-blocks/public/icons/timer_sm.svg b/webapp/packages/core-blocks/public/icons/timer_sm.svg index c5afcc280b..6fa1d70385 100644 --- a/webapp/packages/core-blocks/public/icons/timer_sm.svg +++ b/webapp/packages/core-blocks/public/icons/timer_sm.svg @@ -5,7 +5,6 @@ -