use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class DB2ConnectionTracePage method loadSettings.
@Override
public void loadSettings() {
// Load values from new connection info
DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration();
Map<String, String> providerProperties = connectionInfo.getProviderProperties();
// Settings
enableTraceCheck.setSelection(CommonUtils.getBoolean(providerProperties.get(DB2Constants.PROP_TRACE_ENABLED), false));
if (!enableTraceCheck.getSelection()) {
traceEnableState = ControlEnableState.disable(traceGroup);
}
if (providerProperties.containsKey(DB2Constants.PROP_TRACE_FOLDER)) {
folderText.setText(CommonUtils.toString(providerProperties.get(DB2Constants.PROP_TRACE_FOLDER)));
}
if (providerProperties.containsKey(DB2Constants.PROP_TRACE_FILE)) {
fileNameText.setText(CommonUtils.toString(providerProperties.get(DB2Constants.PROP_TRACE_FILE)));
}
traceAppendCheck.setSelection(CommonUtils.getBoolean(providerProperties.get(DB2Constants.PROP_TRACE_APPEND), false));
int traceLevel = CommonUtils.toInt(providerProperties.get(DB2Constants.PROP_TRACE_LEVEL));
for (LevelConfig level : levels) {
level.checkbox.setSelection((traceLevel & level.level) != 0);
}
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class PostgreWizardPageSettings 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 pg_dump'.");
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.getProviderProperties().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 WMIDataSource method initialize.
@Override
public void initialize(@NotNull DBRProgressMonitor monitor) throws DBException {
final DBPConnectionConfiguration connectionInfo = container.getActualConnectionConfiguration();
try {
WMIService service = WMIService.connect(connectionInfo.getServerName(), connectionInfo.getHostName(), connectionInfo.getUserName(), connectionInfo.getUserPassword(), null, connectionInfo.getDatabaseName());
this.rootNamespace = new WMINamespace(null, this, connectionInfo.getDatabaseName(), service);
} catch (UnsatisfiedLinkError e) {
throw new DBException("Can't link with WMI native library", e);
} catch (Throwable e) {
throw new DBException("Can't connect to WMI service", e);
}
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class WMIConnectionPage method loadSettings.
@Override
public void loadSettings() {
// Load values from new connection info
DBPDataSourceContainer activeDataSource = site.getActiveDataSource();
DBPConnectionConfiguration connectionInfo = activeDataSource.getConnectionConfiguration();
if (connectionInfo.getHostName() == null) {
connectionInfo.setHostName(DEFAULT_HOST);
}
if (connectionInfo.getDatabaseName() == null) {
connectionInfo.setDatabaseName(DEFAULT_NAMESPACE);
}
if (hostText != null) {
hostText.setText(CommonUtils.notEmpty(connectionInfo.getHostName()));
}
if (domainText != null) {
domainText.setText(CommonUtils.notEmpty(connectionInfo.getServerName()));
}
if (usernameText != null) {
usernameText.setText(CommonUtils.notEmpty(connectionInfo.getUserName()));
}
if (passwordText != null) {
passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
}
if (namespaceCombo != null) {
namespaceCombo.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
}
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class DataSourceDescriptor method processEvents.
private void processEvents(DBRProgressMonitor monitor, DBPConnectionEventType eventType) {
DBPConnectionConfiguration info = getActualConnectionConfiguration();
DBRShellCommand command = info.getEvent(eventType);
if (command != null && command.isEnabled()) {
Map<String, Object> variables = new HashMap<>();
for (Map.Entry<String, String> entry : info.getProperties().entrySet()) {
variables.put(CommonUtils.toString(entry.getKey()), entry.getValue());
}
variables.put(RegistryConstants.VARIABLE_HOST, info.getHostName());
variables.put(RegistryConstants.VARIABLE_PORT, info.getHostPort());
variables.put(RegistryConstants.VARIABLE_SERVER, info.getServerName());
variables.put(RegistryConstants.VARIABLE_DATABASE, info.getDatabaseName());
variables.put(RegistryConstants.VARIABLE_USER, info.getUserName());
variables.put(RegistryConstants.VARIABLE_PASSWORD, info.getUserPassword());
variables.put(RegistryConstants.VARIABLE_URL, info.getUrl());
final DBRProcessDescriptor processDescriptor = new DBRProcessDescriptor(command, variables);
monitor.subTask("Execute process " + processDescriptor.getName());
DBUserInterface.getInstance().executeProcess(processDescriptor);
if (command.isWaitProcessFinish()) {
processDescriptor.waitFor();
}
addChildProcess(processDescriptor);
}
}
Aggregations