Search in sources :

Example 1 with SQLServerAuthentication

use of org.jkiss.dbeaver.ext.mssql.model.SQLServerAuthentication in project dbeaver by serge-rider.

the class SQLServerConnectionPage method updateSecurityControls.

private void updateSecurityControls() {
    SQLServerAuthentication authSchema = authSchemas[authCombo.getSelectionIndex()];
    boolean supportsUserName = authSchema.isAllowsUserName();
    boolean supportsPassword = authSchema.isAllowsPassword();
    userNameLabel.setEnabled(supportsUserName);
    userNameText.setEnabled(supportsUserName);
    passwordLabel.setEnabled(supportsPassword);
    passwordText.setEnabled(supportsPassword);
    savePasswordCheck.setEnabled(supportsPassword);
}
Also used : SQLServerAuthentication(org.jkiss.dbeaver.ext.mssql.model.SQLServerAuthentication)

Example 2 with SQLServerAuthentication

use of org.jkiss.dbeaver.ext.mssql.model.SQLServerAuthentication in project dbeaver by serge-rider.

the class SQLServerConnectionPage method saveSettings.

@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
    DBPConnectionConfiguration connectionInfo = dataSource.getConnectionConfiguration();
    if (hostText != null) {
        connectionInfo.setHostName(hostText.getText().trim());
    }
    if (portText != null) {
        connectionInfo.setHostPort(portText.getText().trim());
    }
    if (dbText != null) {
        connectionInfo.setDatabaseName(dbText.getText().trim());
    }
    if (userNameText != null) {
        connectionInfo.setUserName(userNameText.getText().trim());
    }
    if (passwordText != null) {
        connectionInfo.setUserPassword(passwordText.getText());
    }
    if (authCombo != null) {
        SQLServerAuthentication authSchema = authSchemas[authCombo.getSelectionIndex()];
        connectionInfo.setProviderProperty(SQLServerConstants.PROP_AUTHENTICATION, authSchema.name());
        if (SQLServerConstants.PROVIDER_GENERIC.equals(getSite().getDriver().getProviderId())) {
            if (authSchema == SQLServerAuthentication.WINDOWS_INTEGRATED) {
                connectionInfo.getProperties().put(SQLServerConstants.PROP_CONNECTION_INTEGRATED_SECURITY, String.valueOf(true));
            } else {
                connectionInfo.getProperties().remove(SQLServerConstants.PROP_CONNECTION_INTEGRATED_SECURITY);
            }
        }
    }
    /*
        if (windowsAuthenticationButton != null) {
            connectionInfo.getProperties().put(SQLServerConstants.PROP_CONNECTION_INTEGRATED_SECURITY,
                    String.valueOf(windowsAuthenticationButton.getSelection()));
        }
        if (adpAuthenticationButton != null) {
            if (adpAuthenticationButton.getSelection()) {
                connectionInfo.getProperties().put(SQLServerConstants.PROP_CONNECTION_AUTHENTICATION, SQLServerConstants.AUTH_ACTIVE_DIRECTORY_PASSWORD);
            } else {
                connectionInfo.getProperties().remove(SQLServerConstants.PROP_CONNECTION_AUTHENTICATION);
            }
        }
*/
    if (showAllSchemas != null) {
        connectionInfo.setProviderProperty(SQLServerConstants.PROP_SHOW_ALL_SCHEMAS, String.valueOf(showAllSchemas.getSelection()));
    }
    super.saveSettings(dataSource);
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) SQLServerAuthentication(org.jkiss.dbeaver.ext.mssql.model.SQLServerAuthentication)

Example 3 with SQLServerAuthentication

use of org.jkiss.dbeaver.ext.mssql.model.SQLServerAuthentication in project dbeaver by dbeaver.

the class SQLServerConnectionPage method saveSettings.

@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
    DBPConnectionConfiguration connectionInfo = dataSource.getConnectionConfiguration();
    if (hostText != null) {
        connectionInfo.setHostName(hostText.getText().trim());
    }
    if (portText != null) {
        connectionInfo.setHostPort(portText.getText().trim());
    }
    if (dbText != null) {
        connectionInfo.setDatabaseName(dbText.getText().trim());
    }
    if (userNameText != null) {
        connectionInfo.setUserName(userNameText.getText().trim());
    }
    if (passwordText != null) {
        connectionInfo.setUserPassword(passwordText.getText());
    }
    if (authCombo != null) {
        SQLServerAuthentication authSchema = authSchemas[authCombo.getSelectionIndex()];
        connectionInfo.setProviderProperty(SQLServerConstants.PROP_AUTHENTICATION, authSchema.name());
        if (SQLServerConstants.PROVIDER_GENERIC.equals(getSite().getDriver().getProviderId())) {
            if (authSchema == SQLServerAuthentication.WINDOWS_INTEGRATED) {
                connectionInfo.getProperties().put(SQLServerConstants.PROP_CONNECTION_INTEGRATED_SECURITY, String.valueOf(true));
            } else {
                connectionInfo.getProperties().remove(SQLServerConstants.PROP_CONNECTION_INTEGRATED_SECURITY);
            }
        }
    }
    /*
        if (windowsAuthenticationButton != null) {
            connectionInfo.getProperties().put(SQLServerConstants.PROP_CONNECTION_INTEGRATED_SECURITY,
                    String.valueOf(windowsAuthenticationButton.getSelection()));
        }
        if (adpAuthenticationButton != null) {
            if (adpAuthenticationButton.getSelection()) {
                connectionInfo.getProperties().put(SQLServerConstants.PROP_CONNECTION_AUTHENTICATION, SQLServerConstants.AUTH_ACTIVE_DIRECTORY_PASSWORD);
            } else {
                connectionInfo.getProperties().remove(SQLServerConstants.PROP_CONNECTION_AUTHENTICATION);
            }
        }
*/
    if (showAllSchemas != null) {
        connectionInfo.setProviderProperty(SQLServerConstants.PROP_SHOW_ALL_SCHEMAS, String.valueOf(showAllSchemas.getSelection()));
    }
    super.saveSettings(dataSource);
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) SQLServerAuthentication(org.jkiss.dbeaver.ext.mssql.model.SQLServerAuthentication)

Example 4 with SQLServerAuthentication

use of org.jkiss.dbeaver.ext.mssql.model.SQLServerAuthentication in project dbeaver by dbeaver.

the class SQLServerConnectionPage method createControl.

@Override
public void createControl(Composite composite) {
    boolean isSqlServer = isSqlServer();
    boolean isDriverAzure = isSqlServer && isDriverAzure();
    Composite settingsGroup = new Composite(composite, SWT.NONE);
    GridLayout gl = new GridLayout(4, false);
    gl.marginHeight = 10;
    gl.marginWidth = 10;
    settingsGroup.setLayout(gl);
    GridData gd = new GridData(GridData.FILL_BOTH);
    settingsGroup.setLayoutData(gd);
    {
        Label hostLabel = new Label(settingsGroup, SWT.NONE);
        hostLabel.setText(SQLServerUIMessages.dialog_connection_host_label);
        hostLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        hostText = new Text(settingsGroup, SWT.BORDER);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.grabExcessHorizontalSpace = true;
        hostText.setLayoutData(gd);
        if (isDriverAzure) {
            // no port number for Azure
            gd.horizontalSpan = 3;
        } else {
            Label portLabel = new Label(settingsGroup, SWT.NONE);
            portLabel.setText(SQLServerUIMessages.dialog_connection_port_label);
            portLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
            portText = new Text(settingsGroup, SWT.BORDER);
            gd = new GridData(GridData.CENTER);
            gd.widthHint = UIUtils.getFontHeight(portText) * 7;
            portText.setLayoutData(gd);
        }
    }
    {
        Label dbLabel = new Label(settingsGroup, SWT.NONE);
        dbLabel.setText(SQLServerUIMessages.dialog_connection_database_schema_label);
        dbLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        dbText = new Text(settingsGroup, SWT.BORDER);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.grabExcessHorizontalSpace = true;
        // gd.widthHint = 270;
        gd.horizontalSpan = 3;
        dbText.setLayoutData(gd);
    }
    {
        if (SQLServerUtils.isDriverSqlServer(getSite().getDriver())) {
            boolean isJtds = SQLServerUtils.isDriverJtds(getSite().getDriver());
            List<SQLServerAuthentication> supportedSchemas = new ArrayList<>();
            for (SQLServerAuthentication auth : SQLServerAuthentication.values()) {
                if (!isJtds || auth.isSupportsJTDS()) {
                    supportedSchemas.add(auth);
                }
            }
            authSchemas = supportedSchemas.toArray(new SQLServerAuthentication[0]);
            authCombo = UIUtils.createLabelCombo(settingsGroup, SQLServerUIMessages.dialog_connection_authentication_combo, SQLServerUIMessages.dialog_connection_authentication_combo_tip, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
            for (SQLServerAuthentication authentication : authSchemas) {
                authCombo.add(authentication.getTitle());
            }
            authCombo.select(0);
            authCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    updateSecurityControls();
                }
            });
            authCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
            UIUtils.createEmptyLabel(settingsGroup, 2, 1);
        /*
                if (!isDriverAzure) {
                    windowsAuthenticationButton = UIUtils.createLabelCheckbox(settingsGroup, SQLServerUIMessages.dialog_connection_windows_authentication_button, false);
                    windowsAuthenticationButton.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
                            enableTexts();
                        }
                    });
                    UIUtils.createEmptyLabel(settingsGroup, 2, 1);
                } else {
                    adpAuthenticationButton = UIUtils.createLabelCheckbox(settingsGroup, SQLServerUIMessages.dialog_connection_adp_authentication_button, false);
                    UIUtils.createEmptyLabel(settingsGroup, 2, 1);
                }
*/
        }
        userNameLabel = new Label(settingsGroup, SWT.NONE);
        userNameLabel.setText(SQLServerUIMessages.dialog_connection_user_name_label);
        userNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        userNameText = new Text(settingsGroup, SWT.BORDER);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.grabExcessHorizontalSpace = true;
        userNameText.setLayoutData(gd);
        UIUtils.createEmptyLabel(settingsGroup, 2, 1);
        passwordLabel = new Label(settingsGroup, SWT.NONE);
        passwordLabel.setText(SQLServerUIMessages.dialog_connection_password_label);
        passwordLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        passwordText = createPasswordText(settingsGroup, null);
        UIUtils.createEmptyLabel(settingsGroup, 2, 1);
    }
    {
        Group secureGroup = new Group(settingsGroup, SWT.NONE);
        secureGroup.setText(SQLServerUIMessages.dialog_setting_connection_settings);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 4;
        secureGroup.setLayoutData(gd);
        secureGroup.setLayout(new GridLayout(1, false));
        createPasswordControls(secureGroup);
        showAllSchemas = UIUtils.createCheckbox(secureGroup, SQLServerUIMessages.dialog_setting_show_all_schemas, SQLServerUIMessages.dialog_setting_show_all_schemas_tip, true, 2);
    }
    createDriverPanel(settingsGroup);
    setControl(settingsGroup);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) SQLServerAuthentication(org.jkiss.dbeaver.ext.mssql.model.SQLServerAuthentication)

Example 5 with SQLServerAuthentication

use of org.jkiss.dbeaver.ext.mssql.model.SQLServerAuthentication in project dbeaver by dbeaver.

the class SQLServerConnectionPage method updateSecurityControls.

private void updateSecurityControls() {
    SQLServerAuthentication authSchema = authSchemas[authCombo.getSelectionIndex()];
    boolean supportsUserName = authSchema.isAllowsUserName();
    boolean supportsPassword = authSchema.isAllowsPassword();
    userNameLabel.setEnabled(supportsUserName);
    userNameText.setEnabled(supportsUserName);
    passwordLabel.setEnabled(supportsPassword);
    passwordText.setEnabled(supportsPassword);
    savePasswordCheck.setEnabled(supportsPassword);
}
Also used : SQLServerAuthentication(org.jkiss.dbeaver.ext.mssql.model.SQLServerAuthentication)

Aggregations

SQLServerAuthentication (org.jkiss.dbeaver.ext.mssql.model.SQLServerAuthentication)6 ArrayList (java.util.ArrayList)2 List (java.util.List)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)2