mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-511 Credentials save fixes. Password value render fix
This commit is contained in:
@@ -141,8 +141,7 @@ public class WebServiceUtils {
|
||||
navSettings.setShowSystemObjects(false);
|
||||
((DataSourceDescriptor)newDataSource).setNavigatorSettings(navSettings);
|
||||
|
||||
saveAuthProperties(newDataSource, newDataSource.getConnectionConfiguration(), config.getCredentials());
|
||||
newDataSource.setSavePassword(config.isSaveCredentials());
|
||||
saveAuthProperties(newDataSource, newDataSource.getConnectionConfiguration(), config.getCredentials(), config.isSaveCredentials());
|
||||
|
||||
return newDataSource;
|
||||
}
|
||||
@@ -169,8 +168,18 @@ public class WebServiceUtils {
|
||||
dsConfig.setAuthModelId(config.getAuthModelId());
|
||||
}
|
||||
|
||||
public static void saveAuthProperties(DBPDataSourceContainer dataSourceContainer, DBPConnectionConfiguration configuration, Map<String, Object> authProperties) {
|
||||
if (!CommonUtils.isEmpty(authProperties)) {
|
||||
public static void saveAuthProperties(DBPDataSourceContainer dataSourceContainer, DBPConnectionConfiguration configuration, Map<String, Object> authProperties, boolean saveCredentials) {
|
||||
dataSourceContainer.setSavePassword(saveCredentials);
|
||||
if (!saveCredentials) {
|
||||
// Reset credentials
|
||||
authProperties = new LinkedHashMap<>();
|
||||
} else {
|
||||
if (authProperties == null) {
|
||||
// No changes
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
// Read save credentials
|
||||
DBAAuthCredentials credentials = configuration.getAuthModel().loadCredentials(dataSourceContainer, configuration);
|
||||
|
||||
@@ -194,10 +203,7 @@ public class WebServiceUtils {
|
||||
setConnectionConfiguration(dataSource.getDriver(), dataSource.getConnectionConfiguration(), config);
|
||||
dataSource.setName(config.getName());
|
||||
dataSource.setDescription(config.getDescription());
|
||||
if (config.getCredentials() != null) {
|
||||
saveAuthProperties(dataSource, dataSource.getConnectionConfiguration(), config.getCredentials());
|
||||
}
|
||||
dataSource.setSavePassword(config.isSaveCredentials());
|
||||
saveAuthProperties(dataSource, dataSource.getConnectionConfiguration(), config.getCredentials(), config.isSaveCredentials());
|
||||
}
|
||||
|
||||
public static DBNBrowseSettings parseNavigatorSettings(Map<String, Object> settingsMap) {
|
||||
|
||||
@@ -113,13 +113,16 @@ public class WebPropertyInfo {
|
||||
|
||||
@Property
|
||||
public Object getValue() throws DBException {
|
||||
Object value = propertySource == null ? null : propertySource.getPropertyValue(session.getProgressMonitor(), property.getId());
|
||||
if (property instanceof ObjectPropertyDescriptor) {
|
||||
ObjectPropertyDescriptor opd = (ObjectPropertyDescriptor)property;
|
||||
if (!showProtected && opd.isPassword() || opd.isHidden()) {
|
||||
if (value == null || value.toString().isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return "******";
|
||||
}
|
||||
}
|
||||
Object value = propertySource == null ? null : propertySource.getPropertyValue(session.getProgressMonitor(), property.getId());
|
||||
return value == null ? null : makePropertyValue(value);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -324,7 +324,7 @@ public class WebServiceCore implements DBWServiceCore {
|
||||
if (dataSource != null) {
|
||||
testDataSource = dataSource.createCopy(dataSource.getRegistry());
|
||||
WebServiceUtils.setConnectionConfiguration(testDataSource.getDriver(), testDataSource.getConnectionConfiguration(), connectionConfig);
|
||||
WebServiceUtils.saveAuthProperties(testDataSource, testDataSource.getConnectionConfiguration(), connectionConfig.getCredentials());
|
||||
WebServiceUtils.saveAuthProperties(testDataSource, testDataSource.getConnectionConfiguration(), connectionConfig.getCredentials(), connectionConfig.isSaveCredentials());
|
||||
} else {
|
||||
testDataSource = WebServiceUtils.createConnectionFromConfig(connectionConfig, sessionRegistry);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user