Search in sources :

Example 6 with SSHImplementationDescriptor

use of org.jkiss.dbeaver.model.net.ssh.registry.SSHImplementationDescriptor in project dbeaver by serge-rider.

the class SSHTunnelConfiguratorUI method createControl.

@Override
public void createControl(Composite parent, Runnable propertyChangeListener) {
    final Composite composite = new Composite(parent, SWT.NONE);
    // gd.minimumHeight = 200;
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(new GridLayout(1, false));
    {
        Group settingsGroup = UIUtils.createControlGroup(composite, SSHUIMessages.model_ssh_configurator_group_settings, 2, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, SWT.DEFAULT);
        UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_host_ip);
        Composite hostPortComp = UIUtils.createComposite(settingsGroup, 3);
        hostPortComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        // $NON-NLS-2$
        hostText = new Text(hostPortComp, SWT.BORDER);
        hostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        portText = UIUtils.createLabelSpinner(hostPortComp, SSHUIMessages.model_ssh_configurator_label_port, SSHConstants.DEFAULT_SSH_PORT, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
        GridData gdt = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
        gdt.widthHint = UIUtils.getFontHeight(portText) * 7;
        portText.setLayoutData(gdt);
        // $NON-NLS-2$
        userNameText = UIUtils.createLabelText(settingsGroup, SSHUIMessages.model_ssh_configurator_label_user_name, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
        authMethodCombo = UIUtils.createLabelCombo(settingsGroup, SSHUIMessages.model_ssh_configurator_combo_auth_method, SWT.DROP_DOWN | SWT.READ_ONLY);
        authMethodCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_password);
        authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_pub_key);
        authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_agent);
        privateKeyLabel = UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_private_key);
        privateKeyLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        privateKeyText = new TextWithOpenFile(settingsGroup, SSHUIMessages.model_ssh_configurator_dialog_choose_private_key, new String[] { "*", "*.ssh", "*.pem", "*.*" });
        privateKeyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        {
            pwdLabel = UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_password);
            Composite passComp = UIUtils.createComposite(settingsGroup, 2);
            passComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            passwordText = new Text(passComp, SWT.BORDER | SWT.PASSWORD);
            passwordText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            savePasswordCheckbox = UIUtils.createCheckbox(passComp, SSHUIMessages.model_ssh_configurator_checkbox_save_pass, false);
            savePasswordCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        }
    }
    {
        Group advancedGroup = UIUtils.createControlGroup(composite, SSHUIMessages.model_ssh_configurator_group_advanced, 4, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, SWT.DEFAULT);
        tunnelImplCombo = UIUtils.createLabelCombo(advancedGroup, SSHUIMessages.model_ssh_configurator_label_implementation, SWT.DROP_DOWN | SWT.READ_ONLY);
        GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
        gd.horizontalSpan = 3;
        tunnelImplCombo.setLayoutData(gd);
        for (SSHImplementationDescriptor it : SSHImplementationRegistry.getInstance().getDescriptors()) {
            tunnelImplCombo.add(it.getLabel());
        }
        localHostText = UIUtils.createLabelText(advancedGroup, SSHUIMessages.model_ssh_configurator_label_local_host, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
        localHostText.setToolTipText(SSHUIMessages.model_ssh_configurator_label_local_host_description);
        localHostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        remoteHostText = UIUtils.createLabelText(advancedGroup, SSHUIMessages.model_ssh_configurator_label_remote_host, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
        remoteHostText.setToolTipText(SSHUIMessages.model_ssh_configurator_label_remote_host_description);
        remoteHostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        localPortSpinner = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_local_port, 0, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
        localPortSpinner.setToolTipText(SSHUIMessages.model_ssh_configurator_label_local_port_description);
        localPortSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        remotePortSpinner = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_remote_port, 0, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
        remotePortSpinner.setToolTipText(SSHUIMessages.model_ssh_configurator_label_remote_port_description);
        remotePortSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        UIUtils.createHorizontalLine(advancedGroup, 4, 0);
        keepAliveText = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_keep_alive, 0, 0, Integer.MAX_VALUE);
        keepAliveText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        tunnelTimeout = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_tunnel_timeout, SSHConstants.DEFAULT_CONNECT_TIMEOUT, 0, 300000);
        tunnelTimeout.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }
    {
        Composite controlGroup = UIUtils.createComposite(composite, 2);
        controlGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        UIUtils.createDialogButton(controlGroup, SSHUIMessages.model_ssh_configurator_button_test_tunnel, new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                testTunnelConnection();
            }
        });
        String hint = "You can use variables in SSH parameters.";
        variablesHintLabel = new VariablesHintLabel(controlGroup, hint, hint, DataSourceDescriptor.CONNECT_VARIABLES, false);
    }
    authMethodCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateAuthMethodVisibility();
        }
    });
}
Also used : SSHImplementationDescriptor(org.jkiss.dbeaver.model.net.ssh.registry.SSHImplementationDescriptor) GridLayout(org.eclipse.swt.layout.GridLayout) VariablesHintLabel(org.jkiss.dbeaver.ui.controls.VariablesHintLabel) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextWithOpenFile(org.jkiss.dbeaver.ui.controls.TextWithOpenFile)

Example 7 with SSHImplementationDescriptor

use of org.jkiss.dbeaver.model.net.ssh.registry.SSHImplementationDescriptor 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()));
    }
}
Also used : SSHImplementationDescriptor(org.jkiss.dbeaver.model.net.ssh.registry.SSHImplementationDescriptor) DBWHandlerConfiguration(org.jkiss.dbeaver.model.net.DBWHandlerConfiguration) SSHConstants(org.jkiss.dbeaver.model.net.ssh.SSHConstants) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) DataSourceVariableResolver(org.jkiss.dbeaver.model.connection.DataSourceVariableResolver)

Example 8 with SSHImplementationDescriptor

use of org.jkiss.dbeaver.model.net.ssh.registry.SSHImplementationDescriptor in project dbeaver by dbeaver.

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()));
    }
}
Also used : SSHImplementationDescriptor(org.jkiss.dbeaver.model.net.ssh.registry.SSHImplementationDescriptor) DBWHandlerConfiguration(org.jkiss.dbeaver.model.net.DBWHandlerConfiguration) SSHConstants(org.jkiss.dbeaver.model.net.ssh.SSHConstants) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) DataSourceVariableResolver(org.jkiss.dbeaver.model.connection.DataSourceVariableResolver)

Example 9 with SSHImplementationDescriptor

use of org.jkiss.dbeaver.model.net.ssh.registry.SSHImplementationDescriptor in project dbeaver by dbeaver.

the class SSHTunnelConfiguratorUI method createControl.

@Override
public void createControl(Composite parent, Runnable propertyChangeListener) {
    final Composite composite = new Composite(parent, SWT.NONE);
    // gd.minimumHeight = 200;
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(new GridLayout(1, false));
    {
        Group settingsGroup = UIUtils.createControlGroup(composite, SSHUIMessages.model_ssh_configurator_group_settings, 2, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, SWT.DEFAULT);
        UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_host_ip);
        Composite hostPortComp = UIUtils.createComposite(settingsGroup, 3);
        hostPortComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        // $NON-NLS-2$
        hostText = new Text(hostPortComp, SWT.BORDER);
        hostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        portText = UIUtils.createLabelSpinner(hostPortComp, SSHUIMessages.model_ssh_configurator_label_port, SSHConstants.DEFAULT_SSH_PORT, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
        GridData gdt = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
        gdt.widthHint = UIUtils.getFontHeight(portText) * 7;
        portText.setLayoutData(gdt);
        // $NON-NLS-2$
        userNameText = UIUtils.createLabelText(settingsGroup, SSHUIMessages.model_ssh_configurator_label_user_name, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
        authMethodCombo = UIUtils.createLabelCombo(settingsGroup, SSHUIMessages.model_ssh_configurator_combo_auth_method, SWT.DROP_DOWN | SWT.READ_ONLY);
        authMethodCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_password);
        authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_pub_key);
        authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_agent);
        privateKeyLabel = UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_private_key);
        privateKeyLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        privateKeyText = new TextWithOpenFile(settingsGroup, SSHUIMessages.model_ssh_configurator_dialog_choose_private_key, new String[] { "*", "*.ssh", "*.pem", "*.*" });
        privateKeyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        {
            pwdLabel = UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_password);
            Composite passComp = UIUtils.createComposite(settingsGroup, 2);
            passComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            passwordText = new Text(passComp, SWT.BORDER | SWT.PASSWORD);
            passwordText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            savePasswordCheckbox = UIUtils.createCheckbox(passComp, SSHUIMessages.model_ssh_configurator_checkbox_save_pass, false);
            savePasswordCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        }
    }
    {
        Group advancedGroup = UIUtils.createControlGroup(composite, SSHUIMessages.model_ssh_configurator_group_advanced, 4, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, SWT.DEFAULT);
        tunnelImplCombo = UIUtils.createLabelCombo(advancedGroup, SSHUIMessages.model_ssh_configurator_label_implementation, SWT.DROP_DOWN | SWT.READ_ONLY);
        GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
        gd.horizontalSpan = 3;
        tunnelImplCombo.setLayoutData(gd);
        for (SSHImplementationDescriptor it : SSHImplementationRegistry.getInstance().getDescriptors()) {
            tunnelImplCombo.add(it.getLabel());
        }
        localHostText = UIUtils.createLabelText(advancedGroup, SSHUIMessages.model_ssh_configurator_label_local_host, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
        localHostText.setToolTipText(SSHUIMessages.model_ssh_configurator_label_local_host_description);
        localHostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        remoteHostText = UIUtils.createLabelText(advancedGroup, SSHUIMessages.model_ssh_configurator_label_remote_host, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
        remoteHostText.setToolTipText(SSHUIMessages.model_ssh_configurator_label_remote_host_description);
        remoteHostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        localPortSpinner = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_local_port, 0, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
        localPortSpinner.setToolTipText(SSHUIMessages.model_ssh_configurator_label_local_port_description);
        localPortSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        remotePortSpinner = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_remote_port, 0, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
        remotePortSpinner.setToolTipText(SSHUIMessages.model_ssh_configurator_label_remote_port_description);
        remotePortSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        UIUtils.createHorizontalLine(advancedGroup, 4, 0);
        keepAliveText = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_keep_alive, 0, 0, Integer.MAX_VALUE);
        keepAliveText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        tunnelTimeout = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_tunnel_timeout, SSHConstants.DEFAULT_CONNECT_TIMEOUT, 0, 300000);
        tunnelTimeout.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }
    {
        Composite controlGroup = UIUtils.createComposite(composite, 2);
        controlGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        UIUtils.createDialogButton(controlGroup, SSHUIMessages.model_ssh_configurator_button_test_tunnel, new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                testTunnelConnection();
            }
        });
        String hint = "You can use variables in SSH parameters.";
        variablesHintLabel = new VariablesHintLabel(controlGroup, hint, hint, DataSourceDescriptor.CONNECT_VARIABLES, false);
    }
    authMethodCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateAuthMethodVisibility();
        }
    });
}
Also used : SSHImplementationDescriptor(org.jkiss.dbeaver.model.net.ssh.registry.SSHImplementationDescriptor) GridLayout(org.eclipse.swt.layout.GridLayout) VariablesHintLabel(org.jkiss.dbeaver.ui.controls.VariablesHintLabel) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextWithOpenFile(org.jkiss.dbeaver.ui.controls.TextWithOpenFile)

Example 10 with SSHImplementationDescriptor

use of org.jkiss.dbeaver.model.net.ssh.registry.SSHImplementationDescriptor in project dbeaver by dbeaver.

the class SSHTunnelImpl method initializeHandler.

@Override
public DBPConnectionConfiguration initializeHandler(DBRProgressMonitor monitor, DBPPlatform platform, DBWHandlerConfiguration configuration, DBPConnectionConfiguration connectionInfo) throws DBException, IOException {
    this.configuration = configuration;
    String implId = configuration.getStringProperty(SSHConstants.PROP_IMPLEMENTATION);
    if (CommonUtils.isEmpty(implId)) {
        // Backward compatibility
        implId = DEF_IMPLEMENTATION;
    }
    try {
        SSHImplementationDescriptor implDesc = SSHImplementationRegistry.getInstance().getDescriptor(implId);
        if (implDesc == null) {
            implDesc = SSHImplementationRegistry.getInstance().getDescriptor(DEF_IMPLEMENTATION);
        }
        if (implDesc == null) {
            throw new DBException("Can't find SSH tunnel implementation '" + implId + "'");
        }
        if (implementation == null || implementation.getClass() != implDesc.getImplClass().getObjectClass()) {
            implementation = implDesc.getImplClass().createInstance(SSHImplementation.class);
        }
    } catch (Throwable e) {
        throw new DBException("Can't create SSH tunnel implementation '" + implId + "'", e);
    }
    return implementation.initTunnel(monitor, platform, configuration, connectionInfo);
}
Also used : SSHImplementationDescriptor(org.jkiss.dbeaver.model.net.ssh.registry.SSHImplementationDescriptor) DBException(org.jkiss.dbeaver.DBException)

Aggregations

SSHImplementationDescriptor (org.jkiss.dbeaver.model.net.ssh.registry.SSHImplementationDescriptor)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 DBException (org.jkiss.dbeaver.DBException)3 TextWithOpenFile (org.jkiss.dbeaver.ui.controls.TextWithOpenFile)3 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)2 DataSourceVariableResolver (org.jkiss.dbeaver.model.connection.DataSourceVariableResolver)2 DBWHandlerConfiguration (org.jkiss.dbeaver.model.net.DBWHandlerConfiguration)2 SSHConstants (org.jkiss.dbeaver.model.net.ssh.SSHConstants)2 VariablesHintLabel (org.jkiss.dbeaver.ui.controls.VariablesHintLabel)2