From 059a029a504138b9d0395ea8fbb9dbf1be23ac23 Mon Sep 17 00:00:00 2001 From: Aleksandr Skoblikov Date: Fri, 29 Nov 2024 14:42:53 +0400 Subject: [PATCH] dbeaver/dbeaver-vscode#22 review fixes --- .../model/app/BaseServletApplication.java | 2 +- .../model/app/ServletAuthApplication.java | 2 +- ...ion.java => ServletAuthConfiguration.java} | 2 +- .../cloudbeaver/model/config/CBAppConfig.java | 6 ++- .../rm/RMControllerInvocationHandler.java | 51 ------------------- .../session/WebSessionAuthProcessor.java | 6 +-- .../io/cloudbeaver/utils/ServletAppUtils.java | 4 +- .../io/cloudbeaver/server/CBApplication.java | 4 +- .../src/io/cloudbeaver/server/CBPlatform.java | 12 ++--- ...WSObjectPermissionUpdatedEventHandler.java | 2 +- .../server/events/WSUserEventHandler.java | 3 +- .../server/servlets/CBStaticServlet.java | 2 +- .../service/core/CECoreModelExtender.java | 3 ++ .../src/io/cloudbeaver/WebServiceUtils.java | 2 +- .../cloudbeaver/server/BaseWebPlatform.java | 2 - .../service/WebServiceBindingBase.java | 8 +-- .../service/core/WebServiceBindingCore.java | 4 +- .../service/core/impl/WebServiceCore.java | 8 +-- .../service/auth/RPSessionHandler.java | 7 ++- .../auth/local/LocalServletHandler.java | 3 +- .../auth/model/user/WebAuthProviderInfo.java | 4 +- .../CBEmbeddedSecurityController.java | 8 +-- 22 files changed, 47 insertions(+), 98 deletions(-) rename server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/{WebAuthConfiguration.java => ServletAuthConfiguration.java} (96%) delete mode 100644 server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/rm/RMControllerInvocationHandler.java diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/BaseServletApplication.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/BaseServletApplication.java index 7bc4266d1c..0c767a8bff 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/BaseServletApplication.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/BaseServletApplication.java @@ -45,7 +45,7 @@ import java.util.Map; /** - * Web application + * Servlet application */ public abstract class BaseServletApplication extends BaseApplicationImpl implements ServletApplication { diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/ServletAuthApplication.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/ServletAuthApplication.java index 8c63602503..699d604670 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/ServletAuthApplication.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/ServletAuthApplication.java @@ -21,7 +21,7 @@ import org.jkiss.dbeaver.DBException; public interface ServletAuthApplication extends ServletApplication { - WebAuthConfiguration getAuthConfiguration(); + ServletAuthConfiguration getAuthConfiguration(); String getAuthServiceURL(); diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/WebAuthConfiguration.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/ServletAuthConfiguration.java similarity index 96% rename from server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/WebAuthConfiguration.java rename to server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/ServletAuthConfiguration.java index 367d53377d..749cb51353 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/WebAuthConfiguration.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/app/ServletAuthConfiguration.java @@ -25,7 +25,7 @@ /** * Application authentication configuration */ -public interface WebAuthConfiguration { +public interface ServletAuthConfiguration { String getDefaultAuthProvider(); diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/config/CBAppConfig.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/config/CBAppConfig.java index b90421289e..4dfdb1000a 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/config/CBAppConfig.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/config/CBAppConfig.java @@ -20,7 +20,7 @@ import io.cloudbeaver.auth.provider.local.LocalAuthProviderConstants; import io.cloudbeaver.model.app.BaseWebAppConfiguration; import io.cloudbeaver.model.app.WebAppConfiguration; -import io.cloudbeaver.model.app.WebAuthConfiguration; +import io.cloudbeaver.model.app.ServletAuthConfiguration; import io.cloudbeaver.registry.WebAuthProviderDescriptor; import io.cloudbeaver.registry.WebAuthProviderRegistry; import org.jkiss.code.NotNull; @@ -37,7 +37,7 @@ /** * Application configuration */ -public class CBAppConfig extends BaseWebAppConfiguration implements WebAuthConfiguration, WebAppConfiguration { +public class CBAppConfig extends BaseWebAppConfiguration implements ServletAuthConfiguration, WebAppConfiguration { private static final Log log = Log.getLog(CBAppConfig.class); public static final DataSourceNavigatorSettings DEFAULT_VIEW_SETTINGS = PRESET_WEB.getSettings(); @@ -162,6 +162,7 @@ public boolean isRedirectOnFederatedAuth() { return redirectOnFederatedAuth; } + @NotNull public String[] getEnabledDrivers() { return enabledDrivers; } @@ -170,6 +171,7 @@ public void setEnabledDrivers(String[] enabledDrivers) { this.enabledDrivers = enabledDrivers; } + @NotNull public String[] getDisabledDrivers() { return disabledDrivers; } diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/rm/RMControllerInvocationHandler.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/rm/RMControllerInvocationHandler.java deleted file mode 100644 index 02cf3f9374..0000000000 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/rm/RMControllerInvocationHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2024 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.cloudbeaver.model.rm; - -import io.cloudbeaver.model.app.ServletApplication; -import org.jkiss.dbeaver.DBException; -import org.jkiss.dbeaver.model.rm.RMController; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -public class RMControllerInvocationHandler implements InvocationHandler { - private final ServletApplication servletApplication; - private final RMController rmController; - - public RMControllerInvocationHandler(RMController rmController, ServletApplication servletApplication) { - this.servletApplication = servletApplication; - this.rmController = rmController; - } - - private void checkIsRmEnabled() throws DBException { - if (!servletApplication.getAppConfiguration().isResourceManagerEnabled()) { - throw new DBException("Resource Manager disabled"); - } - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - try { - checkIsRmEnabled(); - return method.invoke(rmController, args); - } catch (InvocationTargetException e) { - throw e.getCause(); - } - } -} diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSessionAuthProcessor.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSessionAuthProcessor.java index d9c41f2c58..c89ad41e3b 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSessionAuthProcessor.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSessionAuthProcessor.java @@ -20,7 +20,7 @@ import io.cloudbeaver.DBWUserIdentity; import io.cloudbeaver.DBWebException; import io.cloudbeaver.auth.SMAuthProviderExternal; -import io.cloudbeaver.model.app.WebAuthConfiguration; +import io.cloudbeaver.model.app.ServletAuthConfiguration; import io.cloudbeaver.model.user.WebUser; import io.cloudbeaver.registry.WebAuthProviderDescriptor; import io.cloudbeaver.registry.WebAuthProviderRegistry; @@ -127,7 +127,7 @@ private List finishWebSessionAuthorization(SMAuthInfo authInfo) thr DBWUserIdentity userIdentity = null; var providerConfigId = authConfiguration.getAuthProviderConfigurationId(); - var providerConfig = ServletAppUtils.getWebAuthApplication() + var providerConfig = ServletAppUtils.getAuthApplication() .getAuthConfiguration() .getAuthProviderConfiguration(providerConfigId); if (authProviderExternal != null) { @@ -194,7 +194,7 @@ private WebAuthProviderDescriptor getAuthProvider(String providerId) throws DBWe } private boolean isProviderEnabled(@NotNull String providerId) { - WebAuthConfiguration appConfiguration = (WebAuthConfiguration) ServletAppUtils.getServletApplication() + ServletAuthConfiguration appConfiguration = (ServletAuthConfiguration) ServletAppUtils.getServletApplication() .getAppConfiguration(); return appConfiguration.isAuthProviderEnabled(providerId); } diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/ServletAppUtils.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/ServletAppUtils.java index 93bd1af2b6..45d42e6728 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/ServletAppUtils.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/ServletAppUtils.java @@ -59,7 +59,7 @@ public static ServletApplication getServletApplication() { return (ServletApplication) DBWorkbench.getPlatform().getApplication(); } - public static ServletAuthApplication getWebAuthApplication() throws DBException { + public static ServletAuthApplication getAuthApplication() throws DBException { ServletApplication application = getServletApplication(); if (!ServletAuthApplication.class.isAssignableFrom(application.getClass())) { throw new DBException("The current application doesn't contain authorization configuration"); @@ -169,7 +169,7 @@ public static String removeSideSlashes(String action) { @NotNull public static StringBuilder getAuthApiPrefix(String serviceId) throws DBException { - return getAuthApiPrefix(getWebAuthApplication(), serviceId); + return getAuthApiPrefix(getAuthApplication(), serviceId); } @NotNull diff --git a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/CBApplication.java b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/CBApplication.java index 2b8561247f..ebe007cceb 100644 --- a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/CBApplication.java +++ b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/CBApplication.java @@ -22,7 +22,7 @@ import io.cloudbeaver.model.WebServerConfig; import io.cloudbeaver.model.app.BaseServletApplication; import io.cloudbeaver.model.app.ServletAuthApplication; -import io.cloudbeaver.model.app.WebAuthConfiguration; +import io.cloudbeaver.model.app.ServletAuthConfiguration; import io.cloudbeaver.model.config.CBAppConfig; import io.cloudbeaver.model.config.CBServerConfig; import io.cloudbeaver.model.config.SMControllerConfiguration; @@ -177,7 +177,7 @@ public T getServerConfiguration() { } @Override - public WebAuthConfiguration getAuthConfiguration() { + public ServletAuthConfiguration getAuthConfiguration() { return getAppConfiguration(); } diff --git a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/CBPlatform.java b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/CBPlatform.java index bfb95b8eb7..1fd68e3073 100644 --- a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/CBPlatform.java +++ b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/CBPlatform.java @@ -84,13 +84,13 @@ protected synchronized void initialize() { } protected void scheduleServerJobs() { - new WebSessionMonitorJob(this, getSessionManager()) + new WebSessionMonitorJob(this, application.getSessionManager()) .scheduleMonitor(); - new SessionStateJob(this, getSessionManager()) + new SessionStateJob(this, application.getSessionManager()) .scheduleMonitor(); - new WebDataSourceMonitorJob(this, getSessionManager()) + new WebDataSourceMonitorJob(this, application.getSessionManager()) .scheduleMonitor(); new AbstractJob("Delete temp folder") { @@ -120,7 +120,7 @@ public synchronized void dispose() { @NotNull @Override - public WebApplication getApplication() { + public CBApplication getApplication() { return application; } @@ -140,10 +140,6 @@ public boolean isShuttingDown() { return false; } - public CBSessionManager getSessionManager() { - return application.getSessionManager(); - } - public void refreshApplicableDrivers() { this.applicableDrivers.clear(); diff --git a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/events/WSObjectPermissionUpdatedEventHandler.java b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/events/WSObjectPermissionUpdatedEventHandler.java index 1f22b8246a..32d9a7a88f 100644 --- a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/events/WSObjectPermissionUpdatedEventHandler.java +++ b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/events/WSObjectPermissionUpdatedEventHandler.java @@ -66,7 +66,7 @@ public void handleEvent(@NotNull WSObjectPermissionEvent event) { return; } log.debug(event.getTopicId() + " event handled"); - Collection allSessions = CBPlatform.getInstance().getSessionManager().getAllActiveSessions(); + Collection allSessions = CBApplication.getInstance().getSessionManager().getAllActiveSessions(); for (var activeUserSession : allSessions) { if (!isAcceptableInSession(activeUserSession, event)) { log.debug("Cannot handle %s event '%s' in session %s".formatted( diff --git a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/events/WSUserEventHandler.java b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/events/WSUserEventHandler.java index 03f8601ef9..4ed0e17124 100644 --- a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/events/WSUserEventHandler.java +++ b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/events/WSUserEventHandler.java @@ -16,6 +16,7 @@ */ package io.cloudbeaver.server.events; +import io.cloudbeaver.server.CBApplication; import io.cloudbeaver.server.CBPlatform; import org.jkiss.code.NotNull; import org.jkiss.dbeaver.model.websocket.WSEventHandler; @@ -31,7 +32,7 @@ public void handleEvent(@NotNull EVENT event) { if (eventType == null) { return; } - var sessionManager = CBPlatform.getInstance().getSessionManager(); + var sessionManager = CBApplication.getInstance().getSessionManager(); switch (eventType) { case CLOSE_USER_SESSIONS: if (event instanceof WSUserCloseSessionsEvent closeSessionsEvent) { diff --git a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/servlets/CBStaticServlet.java b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/servlets/CBStaticServlet.java index d5d59d4ba7..3c8f643b4b 100644 --- a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/servlets/CBStaticServlet.java +++ b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/server/servlets/CBStaticServlet.java @@ -83,7 +83,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t } String uri = request.getPathInfo(); try { - WebSession webSession = CBPlatform.getInstance().getSessionManager().getWebSession( + WebSession webSession = CBApplication.getInstance().getSessionManager().getWebSession( request, response, false); performAutoLoginIfNeeded(request, webSession); WebActionParameters webActionParameters = WebActionParameters.fromSession(webSession, false); diff --git a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/core/CECoreModelExtender.java b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/core/CECoreModelExtender.java index eafbceeef5..4b5bf1f11d 100644 --- a/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/core/CECoreModelExtender.java +++ b/server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/core/CECoreModelExtender.java @@ -20,6 +20,9 @@ import io.cloudbeaver.service.DBWBindingContext; import io.cloudbeaver.service.WebServiceBindingBase; +/** + * extends the base gql model, to avoid unnecessary fields in other applications + */ public class CECoreModelExtender extends WebServiceBindingBase { public CECoreModelExtender() { super(DBWVoidService.class, new DBWVoidService(), "schema/service.core.graphqls"); diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java index 2b5061dc1d..a74ff5bafd 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java @@ -346,7 +346,7 @@ public static List getEnabledAuthProviders() { List result = new ArrayList<>(); String[] authProviders = null; try { - authProviders = ServletAppUtils.getWebAuthApplication().getAuthConfiguration().getEnabledAuthProviders(); + authProviders = ServletAppUtils.getAuthApplication().getAuthConfiguration().getEnabledAuthProviders(); } catch (DBException e) { log.error(e.getMessage(), e); return List.of(); diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/BaseWebPlatform.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/BaseWebPlatform.java index 2fa641be37..9d8cca6ad2 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/BaseWebPlatform.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/BaseWebPlatform.java @@ -132,8 +132,6 @@ private void initTempFolder(@NotNull DBRProgressMonitor monitor) { @NotNull public abstract WebApplication getApplication(); - public abstract WebAppSessionManager getSessionManager(); - protected abstract void scheduleServerJobs(); @Override diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/WebServiceBindingBase.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/WebServiceBindingBase.java index a07e8dbe12..ef883e09e8 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/WebServiceBindingBase.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/WebServiceBindingBase.java @@ -104,12 +104,12 @@ protected static DBWBindingContext getBindingContext(DataFetchingEnvironment env } protected static WebSession getWebSession(DataFetchingEnvironment env) throws DBWebException { - return WebAppUtils.getWebPlatform().getSessionManager().getWebSession( + return WebAppUtils.getWebApplication().getSessionManager().getWebSession( getServletRequest(env), getServletResponse(env)); } protected static WebSession getWebSession(DataFetchingEnvironment env, boolean errorOnNotFound) throws DBWebException { - return WebAppUtils.getWebPlatform().getSessionManager().getWebSession( + return WebAppUtils.getWebApplication().getSessionManager().getWebSession( getServletRequest(env), getServletResponse(env), errorOnNotFound); } @@ -127,12 +127,12 @@ protected static WebConnectionInfo getWebConnection(DataFetchingEnvironment env) */ @Nullable public static WebSession findWebSession(DataFetchingEnvironment env) { - return WebAppUtils.getWebPlatform().getSessionManager().findWebSession( + return WebAppUtils.getWebApplication().getSessionManager().findWebSession( getServletRequest(env)); } public static WebSession findWebSession(DataFetchingEnvironment env, boolean errorOnNotFound) throws DBWebException { - return WebAppUtils.getWebPlatform().getSessionManager().findWebSession( + return WebAppUtils.getWebApplication().getSessionManager().findWebSession( getServletRequest(env), errorOnNotFound); } diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/WebServiceBindingCore.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/WebServiceBindingCore.java index f91e78ca49..6f416ec19b 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/WebServiceBindingCore.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/WebServiceBindingCore.java @@ -25,6 +25,7 @@ import io.cloudbeaver.model.WebNetworkHandlerConfigInput; import io.cloudbeaver.model.session.WebSession; import io.cloudbeaver.server.BaseWebPlatform; +import io.cloudbeaver.server.WebAppSessionManager; import io.cloudbeaver.server.WebAppUtils; import io.cloudbeaver.server.graphql.GraphQLEndpoint; import io.cloudbeaver.service.DBWBindingContext; @@ -49,8 +50,7 @@ public WebServiceBindingCore() { @Override public void bindWiring(DBWBindingContext model) throws DBWebException { - BaseWebPlatform platform = WebAppUtils.getWebPlatform(); - var sessionManager = platform.getSessionManager(); + WebAppSessionManager sessionManager = WebAppUtils.getWebApplication().getSessionManager(); model.getQueryType() .dataFetcher("serverConfig", env -> getService(env).getServerConfig()) .dataFetcher("productSettings", env -> getService(env).getProductSettings(getWebSession(env))) diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java index a1fe2f59c8..60f4edbb33 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java @@ -267,7 +267,7 @@ public List readSessionLog( @Override public boolean closeSession(HttpServletRequest request) throws DBWebException { try { - var baseWebSession = WebAppUtils.getWebPlatform().getSessionManager().closeSession(request); + var baseWebSession = WebAppUtils.getWebApplication().getSessionManager().closeSession(request); if (baseWebSession instanceof WebSession webSession) { for (WebSessionHandlerDescriptor hd : WebHandlerRegistry.getInstance().getSessionHandlers()) { try { @@ -288,14 +288,14 @@ public boolean closeSession(HttpServletRequest request) throws DBWebException { @Override @Deprecated public boolean touchSession(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws DBWebException { - return WebAppUtils.getWebPlatform().getSessionManager().touchSession(request, response); + return WebAppUtils.getWebApplication().getSessionManager().touchSession(request, response); } @Override @Deprecated public WebSession updateSession(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws DBWebException { - var sessionManager = WebAppUtils.getWebPlatform().getSessionManager(); + var sessionManager = WebAppUtils.getWebApplication().getSessionManager(); sessionManager.touchSession(request, response); return sessionManager.getWebSession(request, response, true); } @@ -303,7 +303,7 @@ public WebSession updateSession(@NotNull HttpServletRequest request, @NotNull Ht @Override public boolean refreshSessionConnections(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws DBWebException { - WebSession session = WebAppUtils.getWebPlatform().getSessionManager().getWebSession(request, response); + WebSession session = WebAppUtils.getWebApplication().getSessionManager().getWebSession(request, response); if (session == null) { return false; } else { diff --git a/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPSessionHandler.java b/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPSessionHandler.java index 244e113e6d..7544f4ad8a 100644 --- a/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPSessionHandler.java +++ b/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPSessionHandler.java @@ -19,7 +19,7 @@ import io.cloudbeaver.DBWebException; import io.cloudbeaver.auth.SMAuthProviderExternal; import io.cloudbeaver.auth.provider.rp.RPAuthProvider; -import io.cloudbeaver.model.app.WebAuthConfiguration; +import io.cloudbeaver.model.app.ServletAuthConfiguration; import io.cloudbeaver.model.session.WebSession; import io.cloudbeaver.model.session.WebSessionAuthProcessor; import io.cloudbeaver.registry.WebAuthProviderDescriptor; @@ -46,7 +46,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; public class RPSessionHandler implements DBWSessionHandler { @@ -57,7 +56,7 @@ public class RPSessionHandler implements DBWSessionHandler { public boolean handleSessionOpen(WebSession webSession, HttpServletRequest request, HttpServletResponse response) throws DBException, IOException { boolean configMode = CBApplication.getInstance().isConfigurationMode(); //checks if the app is not in configuration mode and reverse proxy auth is enabled in the config file - WebAuthConfiguration appConfiguration = (WebAuthConfiguration) ServletAppUtils.getServletApplication() + ServletAuthConfiguration appConfiguration = (ServletAuthConfiguration) ServletAppUtils.getServletApplication() .getAppConfiguration(); boolean isReverseProxyAuthEnabled = appConfiguration.isAuthProviderEnabled(RPAuthProvider.AUTH_PROVIDER); if (!configMode && isReverseProxyAuthEnabled) { @@ -73,7 +72,7 @@ public void reverseProxyAuthentication(@NotNull HttpServletRequest request, @Not throw new DBWebException("Auth provider " + RPAuthProvider.AUTH_PROVIDER + " not found"); } SMAuthProviderExternal authProviderExternal = (SMAuthProviderExternal) authProvider.getInstance(); - SMAuthProviderCustomConfiguration configuration = ServletAppUtils.getWebAuthApplication() + SMAuthProviderCustomConfiguration configuration = ServletAppUtils.getAuthApplication() .getAuthConfiguration() .getAuthCustomConfigurations() .stream() diff --git a/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/local/LocalServletHandler.java b/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/local/LocalServletHandler.java index 9ac458c5dd..4771f6a417 100644 --- a/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/local/LocalServletHandler.java +++ b/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/local/LocalServletHandler.java @@ -17,6 +17,7 @@ package io.cloudbeaver.service.auth.local; import io.cloudbeaver.model.session.WebSession; +import io.cloudbeaver.server.CBApplication; import io.cloudbeaver.server.CBPlatform; import io.cloudbeaver.server.actions.AbstractActionServletHandler; import io.cloudbeaver.utils.ServletAppUtils; @@ -42,7 +43,7 @@ public class LocalServletHandler extends AbstractActionServletHandler { public boolean handleRequest(Servlet servlet, HttpServletRequest request, HttpServletResponse response) throws DBException, IOException { if (URI_PREFIX.equals(ServletAppUtils.removeSideSlashes(request.getServletPath()))) { try { - WebSession webSession = CBPlatform.getInstance().getSessionManager().getWebSession(request, response, true); + WebSession webSession = CBApplication.getInstance().getSessionManager().getWebSession(request, response, true); createActionFromParams(webSession, request, response); return true; } catch (Exception e) { diff --git a/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/model/user/WebAuthProviderInfo.java b/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/model/user/WebAuthProviderInfo.java index 0fff30ee68..90257b64e6 100644 --- a/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/model/user/WebAuthProviderInfo.java +++ b/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/model/user/WebAuthProviderInfo.java @@ -19,7 +19,7 @@ import io.cloudbeaver.WebServiceUtils; import io.cloudbeaver.auth.SMAuthProviderFederated; import io.cloudbeaver.auth.provisioning.SMProvisioner; -import io.cloudbeaver.model.app.WebAuthConfiguration; +import io.cloudbeaver.model.app.ServletAuthConfiguration; import io.cloudbeaver.registry.WebAuthProviderConfiguration; import io.cloudbeaver.registry.WebAuthProviderDescriptor; import io.cloudbeaver.server.CBApplication; @@ -65,7 +65,7 @@ public String getDescription() { } public boolean isDefaultProvider() { - if (WebAppUtils.getWebApplication().getAppConfiguration() instanceof WebAuthConfiguration authConfiguration) { + if (WebAppUtils.getWebApplication().getAppConfiguration() instanceof ServletAuthConfiguration authConfiguration) { return descriptor.getId().equals(authConfiguration.getDefaultAuthProvider()); } return false; diff --git a/server/bundles/io.cloudbeaver.service.security/src/io/cloudbeaver/service/security/CBEmbeddedSecurityController.java b/server/bundles/io.cloudbeaver.service.security/src/io/cloudbeaver/service/security/CBEmbeddedSecurityController.java index 64d1d8eb43..ee21cd8165 100644 --- a/server/bundles/io.cloudbeaver.service.security/src/io/cloudbeaver/service/security/CBEmbeddedSecurityController.java +++ b/server/bundles/io.cloudbeaver.service.security/src/io/cloudbeaver/service/security/CBEmbeddedSecurityController.java @@ -22,7 +22,7 @@ import io.cloudbeaver.DBWConstants; import io.cloudbeaver.auth.*; import io.cloudbeaver.model.app.ServletAuthApplication; -import io.cloudbeaver.model.app.WebAuthConfiguration; +import io.cloudbeaver.model.app.ServletAuthConfiguration; import io.cloudbeaver.model.config.SMControllerConfiguration; import io.cloudbeaver.registry.WebAuthProviderDescriptor; import io.cloudbeaver.registry.WebAuthProviderRegistry; @@ -1082,7 +1082,7 @@ public SMPropertyDescriptor[] getMetaParametersBySubjectType(SMSubjectType subje WebMetaParametersRegistry.getInstance().getMetaParameters(subjectType)); // Add metas from enabled auth providers - WebAuthConfiguration authConfiguration = application.getAuthConfiguration(); + ServletAuthConfiguration authConfiguration = application.getAuthConfiguration(); for (String apId : authConfiguration.getEnabledAuthProviders()) { WebAuthProviderDescriptor ap = WebAuthProviderRegistry.getInstance().getAuthProvider(apId); if (ap != null) { @@ -2650,7 +2650,7 @@ private SMAuthPermissions getTokenPermissions(@NotNull String token) throws DBEx @Override public SMAuthProviderDescriptor[] getAvailableAuthProviders() throws DBException { - WebAuthConfiguration appConfiguration = application.getAuthConfiguration(); + ServletAuthConfiguration appConfiguration = application.getAuthConfiguration(); Set customConfigurations = appConfiguration.getAuthCustomConfigurations(); List providers = WebAuthProviderRegistry.getInstance().getAuthProviders().stream() .filter(ap -> @@ -3217,7 +3217,7 @@ protected String getUserIdOrNull() { } private boolean isProviderDisabled(@NotNull String providerId, @Nullable String authConfigurationId) { - WebAuthConfiguration appConfiguration = application.getAuthConfiguration(); + ServletAuthConfiguration appConfiguration = application.getAuthConfiguration(); if (!appConfiguration.isAuthProviderEnabled(providerId)) { return true; }