use of org.jkiss.dbeaver.model.DBPDataSourceProvider in project dbeaver by dbeaver.
the class PostgreDebugAdapterFactory method getAdapter.
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (adapterType == DBGController.class) {
if (adaptableObject instanceof DBPDataSourceContainer) {
DBPDataSourceContainer sourceContainer = (DBPDataSourceContainer) adaptableObject;
DBPDriver driver = sourceContainer.getDriver();
if (driver == null) {
return null;
}
DBPDataSourceProvider dataSourceProvider = driver.getDataSourceProvider();
if (dataSourceProvider instanceof PostgreDataSourceProvider) {
PostgreDebugController postgreDebugController = new PostgreDebugController(sourceContainer);
return (T) postgreDebugController;
}
}
} else if (adapterType == DBGResolver.class) {
if (adaptableObject instanceof DBPDataSourceContainer) {
DBPDataSourceContainer sourceContainer = (DBPDataSourceContainer) adaptableObject;
DBPDataSource dataSource = sourceContainer.getDataSource();
if (dataSource instanceof PostgreDataSource) {
PostgreDataSource postgeDataSource = (PostgreDataSource) dataSource;
return (T) new PostgreResolver(postgeDataSource);
}
}
}
return null;
}
use of org.jkiss.dbeaver.model.DBPDataSourceProvider in project dbeaver by serge-rider.
the class AuthModelDatabaseNative method loadCredentials.
@NotNull
@Override
public CREDENTIALS loadCredentials(@NotNull DBPDataSourceContainer dataSource, @NotNull DBPConnectionConfiguration configuration) {
CREDENTIALS credentials = createCredentials();
DBPDataSourceProvider dataSourceProvider = dataSource.getDriver().getDataSourceProvider();
if (dataSourceProvider instanceof DBAUserCredentialsProvider) {
credentials.setUserName(((DBAUserCredentialsProvider) dataSourceProvider).getConnectionUserName(configuration));
credentials.setUserPassword(((DBAUserCredentialsProvider) dataSourceProvider).getConnectionUserPassword(configuration));
} else {
credentials.setUserName(configuration.getUserName());
credentials.setUserPassword(configuration.getUserPassword());
}
boolean allowsEmptyPassword = dataSource.getDriver().isAllowsEmptyPassword();
if (credentials.getUserPassword() == null && allowsEmptyPassword) {
credentials.setUserPassword("");
}
return credentials;
}
use of org.jkiss.dbeaver.model.DBPDataSourceProvider in project dbeaver by serge-rider.
the class DataSourceUtils method getDataSourceAddressText.
@NotNull
public static String getDataSourceAddressText(DBPDataSourceContainer dataSourceContainer) {
DBPDataSourceProvider dataSourceProvider = dataSourceContainer.getDriver().getDataSourceProvider();
if (dataSourceProvider instanceof DBPInformationProvider) {
String objectInformation = ((DBPInformationProvider) dataSourceProvider).getObjectInformation(dataSourceContainer, DBPInformationProvider.INFO_TARGET_ADDRESS);
if (!CommonUtils.isEmpty(objectInformation)) {
return objectInformation;
}
}
DBPConnectionConfiguration cfg = dataSourceContainer.getConnectionConfiguration();
String hostText = getTargetTunnelHostName(cfg);
String hostPort = cfg.getHostPort();
if (!CommonUtils.isEmpty(hostPort)) {
return hostText + ":" + hostPort;
}
return hostText;
}
Aggregations