use of org.jkiss.dbeaver.model.net.ssh.SSHTunnelImpl in project dbeaver by serge-rider.
the class SSHTunnelConfiguratorUI method testTunnelConnection.
private void testTunnelConnection() {
DBWHandlerConfiguration configuration = new DBWHandlerConfiguration(savedConfiguration);
configuration.setProperties(Collections.emptyMap());
saveSettings(configuration);
DBPDataSourceContainer dataSource = configuration.getDataSource();
if (dataSource != null) {
configuration.resolveDynamicVariables(new DataSourceVariableResolver(dataSource, dataSource.getConnectionConfiguration()));
} else {
configuration.resolveDynamicVariables(SystemVariablesResolver.INSTANCE);
}
try {
final String[] tunnelVersions = new String[2];
UIUtils.runInProgressDialog(monitor -> {
monitor.beginTask("Instantiate SSH tunnel", 2);
SSHTunnelImpl tunnel = new SSHTunnelImpl();
DBPConnectionConfiguration connectionConfig = new DBPConnectionConfiguration();
connectionConfig.setHostName("localhost");
connectionConfig.setHostPort(configuration.getStringProperty(DBWHandlerConfiguration.PROP_PORT));
try {
monitor.subTask("Initialize tunnel");
tunnel.initializeHandler(monitor, DBWorkbench.getPlatform(), configuration, connectionConfig);
monitor.worked(1);
// Get info
tunnelVersions[0] = tunnel.getImplementation().getClientVersion();
tunnelVersions[1] = tunnel.getImplementation().getServerVersion();
// Close it
monitor.subTask("Close tunnel");
tunnel.closeTunnel(monitor);
monitor.worked(1);
} catch (Exception e) {
throw new InvocationTargetException(e);
}
monitor.done();
});
MessageDialog.openInformation(hostText.getShell(), ModelMessages.dialog_connection_wizard_start_connection_monitor_success, "Connected!\n\nClient version: " + tunnelVersions[0] + "\nServer version: " + tunnelVersions[1]);
} catch (InvocationTargetException ex) {
DBWorkbench.getPlatformUI().showError(CoreMessages.dialog_connection_wizard_start_dialog_error_title, null, GeneralUtils.makeExceptionStatus(ex.getTargetException()));
}
}
use of org.jkiss.dbeaver.model.net.ssh.SSHTunnelImpl in project dbeaver by dbeaver.
the class SSHTunnelConfiguratorUI method testTunnelConnection.
private void testTunnelConnection() {
DBWHandlerConfiguration configuration = new DBWHandlerConfiguration(savedConfiguration);
configuration.setProperties(Collections.emptyMap());
saveSettings(configuration);
DBPDataSourceContainer dataSource = configuration.getDataSource();
if (dataSource != null) {
configuration.resolveDynamicVariables(new DataSourceVariableResolver(dataSource, dataSource.getConnectionConfiguration()));
} else {
configuration.resolveDynamicVariables(SystemVariablesResolver.INSTANCE);
}
try {
final String[] tunnelVersions = new String[2];
UIUtils.runInProgressDialog(monitor -> {
monitor.beginTask("Instantiate SSH tunnel", 2);
SSHTunnelImpl tunnel = new SSHTunnelImpl();
DBPConnectionConfiguration connectionConfig = new DBPConnectionConfiguration();
connectionConfig.setHostName("localhost");
connectionConfig.setHostPort(configuration.getStringProperty(DBWHandlerConfiguration.PROP_PORT));
try {
monitor.subTask("Initialize tunnel");
tunnel.initializeHandler(monitor, DBWorkbench.getPlatform(), configuration, connectionConfig);
monitor.worked(1);
// Get info
tunnelVersions[0] = tunnel.getImplementation().getClientVersion();
tunnelVersions[1] = tunnel.getImplementation().getServerVersion();
// Close it
monitor.subTask("Close tunnel");
tunnel.closeTunnel(monitor);
monitor.worked(1);
} catch (Exception e) {
throw new InvocationTargetException(e);
}
monitor.done();
});
MessageDialog.openInformation(hostText.getShell(), ModelMessages.dialog_connection_wizard_start_connection_monitor_success, "Connected!\n\nClient version: " + tunnelVersions[0] + "\nServer version: " + tunnelVersions[1]);
} catch (InvocationTargetException ex) {
DBWorkbench.getPlatformUI().showError(CoreMessages.dialog_connection_wizard_start_dialog_error_title, null, GeneralUtils.makeExceptionStatus(ex.getTargetException()));
}
}
Aggregations