CB-3098 filter auth model properties fix (#1873)

* CB-3098 filter auth model properties fix

* CB-3098 do not fill session credentials in connection info

* CB-3098 default value fix

---------

Co-authored-by: EvgeniaBzzz <139753579+EvgeniaBzzz@users.noreply.github.com>
This commit is contained in:
Ainur
2023-08-16 22:39:53 +03:00
committed by GitHub
co-authored by EvgeniaBzzz
parent d6d99f5e9c
commit aa1edf0e29
3 changed files with 11 additions and 4 deletions
@@ -322,9 +322,8 @@ public class WebConnectionInfo {
return new WebPropertyInfo[0];
}
// Fill session and user provided credentials
// Fill user provided credentials
DBPConnectionConfiguration configWithAuth = new DBPConnectionConfiguration(dataSourceContainer.getConnectionConfiguration());
session.provideAuthParameters(session.getProgressMonitor(), dataSourceContainer, configWithAuth);
// show all properties if it is a manual connection
Predicate<DBPPropertyDescriptor> predicate = CommonUtils.isEmpty(getRequiredAuth())
@@ -116,7 +116,8 @@ public class WebPropertyInfo {
@Property
public Object getDefaultValue() throws DBException {
return property.getDefaultValue();
var defaultValue = property.getDefaultValue();
return defaultValue == null ? getValue() : defaultValue;
}
@Property
@@ -19,12 +19,15 @@ package io.cloudbeaver.model;
import io.cloudbeaver.DBWebException;
import io.cloudbeaver.WebServiceUtils;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.utils.WebCommonUtils;
import org.jkiss.dbeaver.model.connection.DBPAuthModelDescriptor;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.preferences.DBPPropertySource;
import org.jkiss.utils.CommonUtils;
import java.util.Arrays;
import java.util.function.Predicate;
/**
* WebDatabaseAuthModel
@@ -73,8 +76,12 @@ public class WebDatabaseAuthModel {
public WebPropertyInfo[] getProperties() throws DBWebException {
DBPPropertySource credentialsSource = model.createCredentialsSource(null, null);
Predicate<DBPPropertyDescriptor> predicate = CommonUtils.isEmpty(getRequiredAuth())
? p -> true
: p -> WebCommonUtils.isAuthPropertyApplicable(p, webSession.getContextCredentialsProviders());
return Arrays.stream(credentialsSource.getProperties())
.filter(p -> WebServiceUtils.isAuthPropertyApplicable(p, webSession.getContextCredentialsProviders()))
.filter(predicate)
.map(p -> new WebPropertyInfo(webSession, p, credentialsSource)).toArray(WebPropertyInfo[]::new);
}