use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by serge-rider.
the class SSHTunnelConfiguratorUI method loadSettings.
@Override
public void loadSettings(DBWHandlerConfiguration configuration) {
hostText.setText(CommonUtils.notEmpty(configuration.getStringProperty(DBWHandlerConfiguration.PROP_HOST)));
int portString = configuration.getIntProperty(DBWHandlerConfiguration.PROP_PORT);
if (portString != 0) {
portText.setSelection(portString);
} else {
portText.setSelection(SSHConstants.DEFAULT_SSH_PORT);
}
userNameText.setText(CommonUtils.notEmpty(configuration.getUserName()));
SSHConstants.AuthType authType = SSHConstants.AuthType.PASSWORD;
String authTypeName = configuration.getStringProperty(SSHConstants.PROP_AUTH_TYPE);
if (!CommonUtils.isEmpty(authTypeName)) {
authType = SSHConstants.AuthType.valueOf(authTypeName);
}
if (SSHConstants.AuthType.PASSWORD.equals(authType)) {
authMethodCombo.select(0);
} else if (SSHConstants.AuthType.PUBLIC_KEY.equals(authType)) {
authMethodCombo.select(1);
} else {
authMethodCombo.select(2);
}
privateKeyText.setText(CommonUtils.notEmpty(configuration.getStringProperty(SSHConstants.PROP_KEY_PATH)));
passwordText.setText(CommonUtils.notEmpty(configuration.getPassword()));
savePasswordCheckbox.setSelection(configuration.isSavePassword());
String implType = configuration.getStringProperty(SSHConstants.PROP_IMPLEMENTATION);
if (CommonUtils.isEmpty(implType)) {
tunnelImplCombo.select(0);
} else {
SSHImplementationDescriptor desc = SSHImplementationRegistry.getInstance().getDescriptor(implType);
if (desc != null) {
tunnelImplCombo.setText(desc.getLabel());
} else {
tunnelImplCombo.select(0);
}
}
localHostText.setText(CommonUtils.notEmpty(configuration.getStringProperty(SSHConstants.PROP_LOCAL_HOST)));
int lpValue = configuration.getIntProperty(SSHConstants.PROP_LOCAL_PORT);
if (lpValue != 0) {
localPortSpinner.setSelection(lpValue);
}
remoteHostText.setText(CommonUtils.notEmpty(configuration.getStringProperty(SSHConstants.PROP_REMOTE_HOST)));
int rpValue = configuration.getIntProperty(SSHConstants.PROP_REMOTE_PORT);
if (rpValue != 0) {
remotePortSpinner.setSelection(rpValue);
}
int kaValue = configuration.getIntProperty(SSHConstants.PROP_ALIVE_INTERVAL);
if (kaValue != 0) {
keepAliveText.setSelection(kaValue);
}
int timeoutValue = configuration.getIntProperty(SSHConstants.PROP_CONNECT_TIMEOUT);
if (timeoutValue != 0) {
tunnelTimeout.setSelection(timeoutValue);
}
updateAuthMethodVisibility();
savedConfiguration = new DBWHandlerConfiguration(configuration);
DBPDataSourceContainer dataSource = savedConfiguration.getDataSource();
if (dataSource != null) {
variablesHintLabel.setResolver(new DataSourceVariableResolver(dataSource, dataSource.getConnectionConfiguration()));
}
}
use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by dbeaver.
the class DBExecUtils method startContextInitiation.
public static void startContextInitiation(DBPDataSourceContainer context) {
ACTIVE_CONTEXT.set(context);
synchronized (ACTIVE_CONTEXTS) {
ACTIVE_CONTEXTS.add(context);
}
// Set proxy auth (if required)
// Note: authenticator may be changed by Eclipse frameword on startup or later.
// That's why we set new default authenticator on connection initiation
boolean hasProxy = false;
for (DBWHandlerConfiguration handler : context.getConnectionConfiguration().getHandlers()) {
if (handler.isEnabled() && handler.getType() == DBWHandlerType.PROXY) {
hasProxy = true;
break;
}
}
if (hasProxy) {
Authenticator.setDefault(new GlobalProxyAuthenticator());
}
}
use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by dbeaver.
the class DBPConnectionConfiguration method resolveDynamicVariables.
public void resolveDynamicVariables(IVariableResolver variableResolver) {
hostName = GeneralUtils.replaceVariables(hostName, variableResolver);
hostPort = GeneralUtils.replaceVariables(hostPort, variableResolver);
serverName = GeneralUtils.replaceVariables(serverName, variableResolver);
databaseName = GeneralUtils.replaceVariables(databaseName, variableResolver);
userName = GeneralUtils.replaceVariables(userName, variableResolver);
userPassword = GeneralUtils.replaceVariables(userPassword, variableResolver);
url = GeneralUtils.replaceVariables(url, variableResolver);
resolveDynamicVariablesInMap(this.properties, variableResolver);
resolveDynamicVariablesInMap(this.authProperties, variableResolver);
resolveDynamicVariablesInMap(this.providerProperties, variableResolver);
for (DBWHandlerConfiguration handler : handlers) {
if (handler.isEnabled()) {
handler.resolveDynamicVariables(variableResolver);
}
}
bootstrap.resolveDynamicVariables(variableResolver);
}
use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by dbeaver.
the class DataSourceSerializerModern method parseNetworkHandlerConfig.
@Nullable
private DBWHandlerConfiguration parseNetworkHandlerConfig(@Nullable DataSourceDescriptor dataSource, @Nullable DBWNetworkProfile profile, @NotNull Map.Entry<String, Map<String, Object>> handlerObject) {
String handlerId = handlerObject.getKey();
Map<String, Object> handlerCfg = handlerObject.getValue();
NetworkHandlerDescriptor handlerDescriptor = NetworkHandlerRegistry.getInstance().getDescriptor(handlerId);
if (handlerDescriptor == null) {
log.warn("Can't find network handler '" + handlerId + "'");
return null;
} else {
DBWHandlerConfiguration curNetworkHandler = new DBWHandlerConfiguration(handlerDescriptor, dataSource);
curNetworkHandler.setEnabled(JSONUtils.getBoolean(handlerCfg, RegistryConstants.ATTR_ENABLED));
curNetworkHandler.setSavePassword(JSONUtils.getBoolean(handlerCfg, RegistryConstants.ATTR_SAVE_PASSWORD));
if (!passwordReadCanceled) {
final SecureCredentials creds = readSecuredCredentials(dataSource, profile, "network/" + handlerId + (profile == null ? "" : "/profile/" + profile.getProfileName()));
curNetworkHandler.setUserName(creds.getUserName());
if (curNetworkHandler.isSavePassword()) {
curNetworkHandler.setPassword(creds.getUserPassword());
}
}
{
// Still try to read credentials directly from configuration (#6564)
String userName = JSONUtils.getString(handlerCfg, RegistryConstants.ATTR_USER);
if (!CommonUtils.isEmpty(userName))
curNetworkHandler.setUserName(userName);
String userPassword = JSONUtils.getString(handlerCfg, RegistryConstants.ATTR_PASSWORD);
if (!CommonUtils.isEmpty(userPassword))
curNetworkHandler.setPassword(userPassword);
}
Map<String, Object> properties = JSONUtils.deserializeProperties(handlerCfg, RegistryConstants.TAG_PROPERTIES);
if (properties != null) {
curNetworkHandler.setProperties(properties);
}
return curNetworkHandler;
}
}
use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by dbeaver.
the class PostgreDataSource method getInternalConnectionProperties.
@Override
protected Map<String, String> getInternalConnectionProperties(DBRProgressMonitor monitor, DBPDriver driver, JDBCExecutionContext context, String purpose, DBPConnectionConfiguration connectionInfo) throws DBCException {
Map<String, String> props = new LinkedHashMap<>(PostgreDataSourceProvider.getConnectionsProps());
final DBWHandlerConfiguration sslConfig = getContainer().getActualConnectionConfiguration().getHandler(PostgreConstants.HANDLER_SSL);
if (sslConfig != null && sslConfig.isEnabled()) {
try {
boolean useProxy = sslConfig.getBooleanProperty(PostgreConstants.PROP_SSL_PROXY);
if (useProxy) {
initProxySSL(props, sslConfig);
} else {
initServerSSL(props, sslConfig);
}
} catch (Exception e) {
throw new DBCException("Error configuring SSL certificates", e);
}
} else {
getServerType().initDefaultSSLConfig(connectionInfo, props);
}
return props;
}
Aggregations