use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class MySQLWizardPageSettings method createSecurityGroup.
public void createSecurityGroup(Composite parent) {
try {
final SecuredPasswordEncrypter encrypter = new SecuredPasswordEncrypter();
final DBPConnectionConfiguration connectionInfo = wizard.getConnectionInfo();
final String authProperty = DBConstants.INTERNAL_PROP_PREFIX + "-auth-" + wizard.getObjectsName() + "@";
String authUser = null;
String authPassword = null;
{
String authValue = connectionInfo.getProviderProperty(authProperty);
if (authValue != null) {
String authCredentials = encrypter.decrypt(authValue);
int divPos = authCredentials.indexOf(':');
if (divPos != -1) {
authUser = authCredentials.substring(0, divPos);
authPassword = authCredentials.substring(divPos + 1);
}
}
}
wizard.setToolUserName(authUser == null ? connectionInfo.getUserName() : authUser);
wizard.setToolUserPassword(authPassword == null ? connectionInfo.getUserPassword() : authPassword);
final boolean savePassword = authUser != null;
Group securityGroup = UIUtils.createControlGroup(parent, "Security", 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
Label infoLabel = new Label(securityGroup, SWT.NONE);
infoLabel.setText("Override user credentials (" + wizard.getConnectionInfo().getUserName() + ") for objects '" + wizard.getObjectsName() + "'.\nExternal tools like 'mysqldump' may require different set of permissions.");
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
infoLabel.setLayoutData(gd);
Button authButton = new Button(securityGroup, SWT.PUSH);
authButton.setText("Authentication");
authButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BaseAuthDialog authDialog = new BaseAuthDialog(getShell(), "Authentication", false);
authDialog.setUserName(wizard.getToolUserName());
authDialog.setUserPassword(wizard.getToolUserPassword());
authDialog.setSavePassword(savePassword);
if (authDialog.open() == IDialogConstants.OK_ID) {
wizard.setToolUserName(authDialog.getUserName());
wizard.setToolUserPassword(authDialog.getUserPassword());
if (authDialog.isSavePassword()) {
try {
connectionInfo.setProviderProperty(authProperty, encrypter.encrypt(wizard.getToolUserName() + ':' + wizard.getToolUserPassword()));
} catch (EncryptionException e1) {
// Never be here
}
}
}
}
});
Button resetButton = new Button(securityGroup, SWT.PUSH);
resetButton.setText("Reset to default");
resetButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
connectionInfo.getProperties().remove(authProperty);
wizard.setToolUserName(connectionInfo.getUserName());
wizard.setToolUserPassword(connectionInfo.getUserPassword());
}
});
} catch (EncryptionException e) {
// Never be here
}
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class DB2ConnectionPage 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());
}
super.saveSettings(dataSource);
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class MySQLConnectionPage method loadSettings.
@Override
public void loadSettings() {
super.loadSettings();
DBPDriver driver = getSite().getDriver();
if (!activated) {
// There is a bug in Eclipse which leads to SWTException after wizard image change
if (driver != null && driver.getId().equalsIgnoreCase(MySQLConstants.DRIVER_ID_MARIA_DB)) {
setImageDescriptor(MARIADB_LOGO_IMG);
} else {
setImageDescriptor(MYSQL_LOGO_IMG);
}
}
// Load values from new connection info
DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration();
if (hostText != null) {
if (!CommonUtils.isEmpty(connectionInfo.getHostName())) {
hostText.setText(connectionInfo.getHostName());
} else {
hostText.setText(MySQLConstants.DEFAULT_HOST);
}
}
if (portText != null) {
if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
portText.setText(String.valueOf(connectionInfo.getHostPort()));
} else if (site.getDriver().getDefaultPort() != null) {
portText.setText(site.getDriver().getDefaultPort());
} else {
portText.setText("");
}
}
if (dbText != null) {
dbText.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
}
if (usernameText != null) {
usernameText.setText(CommonUtils.notEmpty(connectionInfo.getUserName()));
}
if (passwordText != null) {
passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
}
homesSelector.populateHomes(site.getDriver(), connectionInfo.getClientHomeId());
activated = true;
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class OracleConnectionExtraPage method loadSettings.
@Override
public void loadSettings() {
//oraHomeSelector.setVisible(isOCI);
// Load values from new connection info
DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration();
Map<String, String> providerProperties = connectionInfo.getProviderProperties();
// Settings
final Object nlsLanguage = providerProperties.get(OracleConstants.PROP_SESSION_LANGUAGE);
if (nlsLanguage != null) {
languageCombo.setText(nlsLanguage.toString());
}
final Object nlsTerritory = providerProperties.get(OracleConstants.PROP_SESSION_TERRITORY);
if (nlsTerritory != null) {
territoryCombo.setText(nlsTerritory.toString());
}
final Object dateFormat = providerProperties.get(OracleConstants.PROP_SESSION_NLS_DATE_FORMAT);
if (dateFormat != null) {
nlsDateFormat.setText(dateFormat.toString());
}
final Object checkSchemaContent = providerProperties.get(OracleConstants.PROP_CHECK_SCHEMA_CONTENT);
if (checkSchemaContent != null) {
hideEmptySchemasCheckbox.setSelection(CommonUtils.getBoolean(checkSchemaContent, false));
}
showDBAAlwaysCheckbox.setSelection(CommonUtils.getBoolean(providerProperties.get(OracleConstants.PROP_ALWAYS_SHOW_DBA), false));
useRuleHint.setSelection(CommonUtils.getBoolean(providerProperties.get(OracleConstants.PROP_USE_RULE_HINT), false));
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class OracleConnectionPage method saveSettings.
@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
DBPConnectionConfiguration connectionInfo = dataSource.getConnectionConfiguration();
connectionInfo.setClientHomeId(oraHomeSelector.getSelectedHome());
connectionInfo.setProviderProperty(OracleConstants.PROP_CONNECTION_TYPE, connectionType.name());
switch(connectionType) {
case BASIC:
connectionInfo.setHostName(hostText.getText().trim());
connectionInfo.setHostPort(portText.getText().trim());
connectionInfo.setDatabaseName(serviceNameCombo.getText().trim());
break;
case TNS:
connectionInfo.setDatabaseName(tnsNameCombo.getText().trim());
connectionInfo.setProviderProperty(OracleConstants.PROP_TNS_PATH, tnsPathText.getText());
break;
case CUSTOM:
connectionInfo.setUrl(connectionUrlText.getText());
break;
}
if (osAuthCheck.getSelection()) {
connectionInfo.setUserName(OracleConstants.OS_AUTH_USER_NAME);
//$NON-NLS-1$
connectionInfo.setUserPassword("");
} else {
connectionInfo.setUserName(userNameText.getText());
connectionInfo.setUserPassword(passwordText.getText());
}
connectionInfo.setProviderProperty(OracleConstants.PROP_SID_SERVICE, OracleConnectionType.getTypeForTitle(sidServiceCombo.getText()).name());
if (userRoleCombo.getSelectionIndex() > 0) {
connectionInfo.setProviderProperty(OracleConstants.PROP_INTERNAL_LOGON, userRoleCombo.getText().toLowerCase(Locale.ENGLISH));
} else {
connectionInfo.getProviderProperties().remove(OracleConstants.PROP_INTERNAL_LOGON);
}
saveConnectionURL(connectionInfo);
}
Aggregations