mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-422 AWS cloud configuration
This commit is contained in:
@@ -90,12 +90,26 @@ public class CBAppConfig {
|
||||
return defaultAuthProvider;
|
||||
}
|
||||
|
||||
public Map<String, Object> getPlugins() {
|
||||
return plugins;
|
||||
}
|
||||
|
||||
public Map<String, Object> getPluginConfig(String pluginId) {
|
||||
return getPluginConfig(pluginId, false);
|
||||
}
|
||||
|
||||
public Map<String, Object> getPluginConfig(String pluginId, boolean create) {
|
||||
Object config = plugins.get(pluginId);
|
||||
if (config instanceof Map) {
|
||||
return (Map<String, Object>) config;
|
||||
} else {
|
||||
return Collections.emptyMap();
|
||||
if (create) {
|
||||
Map<String, Object> newConfig = new LinkedHashMap<>();
|
||||
plugins.put(pluginId, newConfig);
|
||||
return newConfig;
|
||||
} else {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -554,6 +554,7 @@ public class CBApplication extends BaseApplicationImpl {
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
try (JsonWriter json = gson.newJsonWriter(out)) {
|
||||
json.setLenient(true);
|
||||
json.beginObject();
|
||||
{
|
||||
json.name("server");
|
||||
@@ -572,6 +573,11 @@ public class CBApplication extends BaseApplicationImpl {
|
||||
JSONUtils.field(json, "anonymousAccessEnabled", appConfig.isAnonymousAccessEnabled());
|
||||
JSONUtils.field(json, "authenticationEnabled", appConfig.isAuthenticationEnabled());
|
||||
JSONUtils.field(json, "supportsCustomConnections", appConfig.isSupportsCustomConnections());
|
||||
|
||||
if (!CommonUtils.isEmpty(appConfig.getPlugins())) {
|
||||
JSONUtils.serializeProperties(json, "plugins", appConfig.getPlugins());
|
||||
}
|
||||
|
||||
json.endObject();
|
||||
}
|
||||
json.endObject();
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* DBeaver - Universal Database Manager
|
||||
* Copyright (C) 2010-2020 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.service;
|
||||
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import io.cloudbeaver.server.CBAppConfig;
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.Nullable;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.model.app.DBPApplication;
|
||||
|
||||
/**
|
||||
* Web service implementation
|
||||
*/
|
||||
public interface DBWServiceServerConfigurator extends DBWServiceBinding {
|
||||
|
||||
void configureServer(@NotNull DBPApplication application, @Nullable WebSession session, @NotNull CBAppConfig appConfig) throws DBException;
|
||||
|
||||
}
|
||||
+12
@@ -32,6 +32,7 @@ import io.cloudbeaver.registry.WebServiceRegistry;
|
||||
import io.cloudbeaver.server.CBAppConfig;
|
||||
import io.cloudbeaver.server.CBApplication;
|
||||
import io.cloudbeaver.server.CBPlatform;
|
||||
import io.cloudbeaver.service.DBWServiceServerConfigurator;
|
||||
import io.cloudbeaver.service.admin.*;
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.dbeaver.Log;
|
||||
@@ -306,12 +307,23 @@ public class WebServiceAdmin implements DBWServiceAdmin {
|
||||
adminName = curUser == null ? null : curUser.getUserId();
|
||||
adminPassword = null;
|
||||
}
|
||||
|
||||
// Patch configuration by services
|
||||
for (DBWServiceServerConfigurator wsc : WebServiceRegistry.getInstance().getWebServices(DBWServiceServerConfigurator.class)) {
|
||||
try {
|
||||
wsc.configureServer(CBApplication.getInstance(), webSession, appConfig);
|
||||
} catch (Exception e) {
|
||||
log.warn("Error configuring server by web service " + wsc.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
CBApplication.getInstance().finishConfiguration(
|
||||
config.getServerName(),
|
||||
adminName,
|
||||
adminPassword,
|
||||
config.getSessionExpireTime(),
|
||||
appConfig);
|
||||
|
||||
// Refresh active session
|
||||
webSession.forceUserRefresh(null);
|
||||
} catch (Throwable e) {
|
||||
|
||||
Reference in New Issue
Block a user