use of org.jkiss.dbeaver.registry.encode.EncryptionException in project dbeaver by serge-rider.
the class ExasolWizardPageSettings 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.getProperty(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.setProperty(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.registry.encode.EncryptionException in project dbeaver by dbeaver.
the class ExasolWizardPageSettings 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.getProperty(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.setProperty(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.registry.encode.EncryptionException in project dbeaver by dbeaver.
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, PostgreMessages.wizard_backup_page_setting_group_security, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
Label infoLabel = new Label(securityGroup, SWT.NONE);
infoLabel.setText(NLS.bind(PostgreMessages.wizard_backup_page_setting_group_security_label_info, wizard.getConnectionInfo().getUserName(), wizard.getObjectsName()));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
infoLabel.setLayoutData(gd);
Button authButton = new Button(securityGroup, SWT.PUSH);
authButton.setText(PostgreMessages.wizard_backup_page_setting_group_security_btn_authentication);
authButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BaseAuthDialog authDialog = new BaseAuthDialog(getShell(), PostgreMessages.wizard_backup_page_setting_group_security_btn_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(PostgreMessages.wizard_backup_page_setting_group_security_btn_reset_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.registry.encode.EncryptionException in project dbeaver by dbeaver.
the class PrefPageDrivers method performOk.
@Override
public boolean performOk() {
DBPPreferenceStore store = DBeaverCore.getGlobalPreferenceStore();
store.setValue(DBeaverPreferences.UI_DRIVERS_VERSION_UPDATE, versionUpdateCheck.getSelection());
store.setValue(DBeaverPreferences.UI_PROXY_HOST, proxyHostText.getText());
store.setValue(DBeaverPreferences.UI_PROXY_PORT, proxyPortSpinner.getSelection());
store.setValue(DBeaverPreferences.UI_PROXY_USER, proxyUserText.getText());
String password = proxyPasswordText.getText();
if (!CommonUtils.isEmpty(password) && encrypter != null) {
// Encrypt password
try {
password = encrypter.encrypt(password);
} catch (EncryptionException e) {
log.warn(e);
}
}
store.setValue(DBeaverPreferences.UI_PROXY_PASSWORD, password);
store.setValue(DBeaverPreferences.UI_DRIVERS_HOME, customDriversHome.getText());
{
StringBuilder sources = new StringBuilder();
for (String item : sourceList.getItems()) {
if (sources.length() > 0)
sources.append('|');
sources.append(item);
}
store.setValue(DBeaverPreferences.UI_DRIVERS_SOURCES, sources.toString());
}
PrefUtils.savePreferenceStore(store);
return super.performOk();
}
Aggregations