提交 4180b187 编写于 作者: S serge-rider

Merge remote-tracking branch 'origin/devel' into devel


Former-commit-id: ced802c9
......@@ -166,6 +166,7 @@ public class RegistryConstants {
public static final String ATTR_DATABASE = "database"; //$NON-NLS-1$
public static final String ATTR_USER = "user"; //$NON-NLS-1$
public static final String ATTR_PASSWORD = "password"; //$NON-NLS-1$
public static final String ATTR_NATIVE_AUTH = "native-auth"; //$NON-NLS-1$
public static final String ATTR_HOME = "home"; //$NON-NLS-1$
public static final String ATTR_SHOW_PANEL = "show-panel"; //$NON-NLS-1$
public static final String ATTR_WAIT_PROCESS = "wait-process"; //$NON-NLS-1$
......
......@@ -17,6 +17,8 @@
*/
package org.jkiss.dbeaver.ext.mssql;
import org.jkiss.dbeaver.model.DBConstants;
public class SQLServerConstants {
public static final int DEFAULT_PORT = 1433;
......@@ -25,4 +27,6 @@ public class SQLServerConstants {
public static final String DRIVER_JTDS = "mssql_jdbc_jtds";
public static final String DRIVER_MS = "mssql_jdbc_ms";
public static final String PROP_CONNECTION_WINDOWS_AUTH = DBConstants.INTERNAL_PROP_PREFIX + "connection-windows-auth@";
}
......@@ -81,6 +81,9 @@ public class SQLServerDataSourceProvider extends JDBCDataSourceProvider implemen
url.append("databaseName=").append(connectionInfo.getDatabaseName());
}
}
if ("TRUE".equalsIgnoreCase(connectionInfo.getProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH))) {
url.append(";integratedSecurity=true");
}
return url.toString();
}
......
......@@ -32,7 +32,7 @@ public class SQLServerMessages extends NLS {
public static String dialog_connection_advanced_tab;
public static String dialog_connection_advanced_tab_tooltip;
public static String dialog_connection_browse_button;
public static String dialog_connection_windows_authentication_button;
public static String dialog_connection_database_schema_label;
public static String dialog_connection_general_tab;
public static String dialog_connection_general_tab_tooltip;
......
......@@ -10,7 +10,7 @@ dialog_setting_connection_user = User
dialog_connection_advanced_tab=Advanced
dialog_connection_advanced_tab_tooltip=Advanced/custom driver properties
dialog_connection_browse_button=Browse ...
dialog_connection_windows_authentication_button=Windows Authentication
dialog_connection_database_schema_label=Database/Schema:
dialog_connection_general_tab=General
dialog_connection_general_tab_tooltip=General connection properties
......
......@@ -19,10 +19,14 @@ package org.jkiss.dbeaver.ext.mssql.model;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.ext.generic.model.GenericDataSource;
import org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel;
import org.jkiss.dbeaver.ext.mssql.SQLServerConstants;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSDataType;
import java.sql.Connection;
import java.util.Locale;
public class SQLServerDataSource extends GenericDataSource {
......@@ -33,4 +37,21 @@ public class SQLServerDataSource extends GenericDataSource {
super(monitor, container, metaModel, new SQLServerDialect());
}
@Override
protected String getConnectionUserName(DBPConnectionConfiguration connectionInfo) {
if ("TRUE".equalsIgnoreCase(connectionInfo.getProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH))) {
return "";
} else {
return super.getConnectionUserName(connectionInfo);
}
}
@Override
protected String getConnectionUserPassword(DBPConnectionConfiguration connectionInfo) {
if ("TRUE".equalsIgnoreCase(connectionInfo.getProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH))) {
return "";
} else {
return super.getConnectionUserPassword(connectionInfo);
}
}
}
......@@ -20,6 +20,8 @@ package org.jkiss.dbeaver.ext.mssql.ui;
import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
......@@ -29,6 +31,7 @@ import org.jkiss.dbeaver.ext.mssql.SQLServerMessages;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.ui.ICompositeDialogPage;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.connection.ConnectionPageAbstract;
import org.jkiss.dbeaver.ui.dialogs.connection.DriverPropertiesDialogPage;
import org.jkiss.utils.CommonUtils;
......@@ -43,21 +46,20 @@ public class SQLServerConnectionPage extends ConnectionPageAbstract implements I
private Text hostText;
private Text portText;
private Text dbText;
private Label userNameLabel;
private Text userNameText;
private Label passwordLabel;
private Text passwordText;
private Button windowsAuthetticationButton;
private Composite settingsGroup;
private Map<String, List<Control>> propGroupMap = new HashMap<>();
private static final String GROUP_URL = "url"; //$NON-NLS-1$
private static final String GROUP_HOST = "host"; //$NON-NLS-1$
private static final String GROUP_SERVER = "server"; //$NON-NLS-1$
private static final String GROUP_DB = "db"; //$NON-NLS-1$
private static final String GROUP_PATH = "path"; //$NON-NLS-1$
private static final String GROUP_LOGIN = "login"; //$NON-NLS-1$
private boolean activated;
private Button createButton;
private static ImageDescriptor LOGO_IMG = SQLServerActivator.getImageDescriptor("icons/mssql_logo.png");
......@@ -124,7 +126,16 @@ public class SQLServerConnectionPage extends ConnectionPageAbstract implements I
}
{
Label userNameLabel = new Label(settingsGroup, SWT.NONE);
windowsAuthetticationButton = UIUtils.createLabelCheckbox(settingsGroup, SQLServerMessages.dialog_connection_windows_authentication_button, false);
addControlToGroup(GROUP_DB, windowsAuthetticationButton);
Control emptyLabel = new Label(settingsGroup, SWT.NONE);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
gd.horizontalSpan = 2;
gd.widthHint = 0;
emptyLabel.setLayoutData(gd);
userNameLabel = new Label(settingsGroup, SWT.NONE);
userNameLabel.setText(SQLServerMessages.dialog_connection_user_name_label);
userNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
......@@ -133,9 +144,9 @@ public class SQLServerConnectionPage extends ConnectionPageAbstract implements I
gd.grabExcessHorizontalSpace = true;
userNameText.setLayoutData(gd);
Control emptyLabel = createEmptyLabel(settingsGroup, 2);
emptyLabel = createEmptyLabel(settingsGroup, 2);
Label passwordLabel = new Label(settingsGroup, SWT.NONE);
passwordLabel = new Label(settingsGroup, SWT.NONE);
passwordLabel.setText(SQLServerMessages.dialog_connection_password_label);
passwordLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
......@@ -144,6 +155,13 @@ public class SQLServerConnectionPage extends ConnectionPageAbstract implements I
gd.grabExcessHorizontalSpace = true;
passwordText.setLayoutData(gd);
windowsAuthetticationButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
enableTexts();
}
});
addControlToGroup(GROUP_LOGIN, userNameLabel);
addControlToGroup(GROUP_LOGIN, userNameText);
addControlToGroup(GROUP_LOGIN, emptyLabel);
......@@ -155,6 +173,14 @@ public class SQLServerConnectionPage extends ConnectionPageAbstract implements I
setControl(settingsGroup);
}
private void enableTexts() {
boolean selection = windowsAuthetticationButton.getSelection();
userNameLabel.setEnabled(!selection);
userNameText.setEnabled(!selection);
passwordLabel.setEnabled(!selection);
passwordText.setEnabled(!selection);
}
private void addControlToGroup(String group, Control control)
{
List<Control> controlList = propGroupMap.get(group);
......@@ -224,6 +250,13 @@ public class SQLServerConnectionPage extends ConnectionPageAbstract implements I
if (passwordText != null) {
passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
}
if (windowsAuthetticationButton != null) {
String winAuthProperty = connectionInfo.getProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH);
if (winAuthProperty != null) {
windowsAuthetticationButton.setSelection(Boolean.parseBoolean(winAuthProperty));
}
enableTexts();
}
activated = true;
}
......@@ -247,6 +280,10 @@ public class SQLServerConnectionPage extends ConnectionPageAbstract implements I
if (passwordText != null) {
connectionInfo.setUserPassword(passwordText.getText());
}
if (windowsAuthetticationButton != null) {
connectionInfo.setProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH,
String.valueOf(windowsAuthetticationButton.getSelection()));
}
super.saveSettings(dataSource);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册