use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by serge-rider.
the class GlobalProxySelector method select.
@Override
public List<Proxy> select(URI uri) {
String scheme = uri.getScheme();
if (CommonUtils.isEmpty(scheme)) {
return parent.select(uri);
}
if (scheme.startsWith("http")) {
// 1. Check for drivers download proxy
}
if (SocksConstants.SOCKET_SCHEME.equals(scheme)) {
// 2. Check for connections' proxy config
DBCExecutionContext activeContext = DBExecUtils.findConnectionContext(uri.getHost(), uri.getPort(), uri.getPath());
if (activeContext != null) {
List<Proxy> proxies = null;
DBPDataSourceContainer container = activeContext.getDataSource().getContainer();
for (DBWHandlerConfiguration networkHandler : container.getConnectionConfiguration().getDeclaredHandlers()) {
if (networkHandler.isEnabled() && networkHandler.getType() == DBWHandlerType.PROXY) {
Map<String, String> proxyProps = networkHandler.getProperties();
String proxyHost = proxyProps.get(SocksConstants.PROP_HOST);
String proxyPort = proxyProps.get(SocksConstants.PROP_PORT);
if (!CommonUtils.isEmpty(proxyHost)) {
int portNumber = SocksConstants.DEFAULT_SOCKS_PORT;
if (!CommonUtils.isEmpty(proxyPort)) {
try {
portNumber = Integer.parseInt(proxyPort);
} catch (NumberFormatException e) {
log.warn("Bad proxy port number", e);
}
}
InetSocketAddress proxyAddr = new InetSocketAddress(proxyHost, portNumber);
Proxy proxy = new Proxy(Proxy.Type.SOCKS, proxyAddr);
if (proxies == null) {
proxies = new ArrayList<>();
}
proxies.add(proxy);
log.debug("Use SOCKS proxy [" + proxyAddr + "]");
}
}
}
if (proxies != null) {
return proxies;
}
}
}
return parent.select(uri);
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by serge-rider.
the class PropertySourceAbstract method collectProperties.
public boolean collectProperties() {
lazyValues.clear();
props.clear();
propValues.clear();
final Object editableValue = getEditableValue();
IPropertyFilter filter;
if (editableValue instanceof DBSObject) {
filter = new DataSourcePropertyFilter(((DBSObject) editableValue).getDataSource());
} else if (editableValue instanceof DBPContextProvider) {
DBCExecutionContext context = ((DBPContextProvider) editableValue).getExecutionContext();
filter = context == null ? new DataSourcePropertyFilter() : new DataSourcePropertyFilter(context.getDataSource());
} else {
filter = new DataSourcePropertyFilter();
}
List<ObjectPropertyDescriptor> annoProps = ObjectAttributeDescriptor.extractAnnotations(this, editableValue.getClass(), filter);
for (final ObjectPropertyDescriptor desc : annoProps) {
addProperty(desc);
}
if (editableValue instanceof DBPPropertySource) {
DBPPropertySource ownPropSource = (DBPPropertySource) editableValue;
DBPPropertyDescriptor[] ownProperties = ownPropSource.getPropertyDescriptors2();
if (!ArrayUtils.isEmpty(ownProperties)) {
for (DBPPropertyDescriptor prop : ownProperties) {
props.add(prop);
propValues.put(prop.getId(), ownPropSource.getPropertyValue(null, prop.getId()));
}
}
}
return !props.isEmpty();
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by serge-rider.
the class SQLLogFilter method belongsToEditor.
private boolean belongsToEditor(QMMSessionInfo session) {
String containerId = session.getContainerId();
String contextName = session.getContextName();
DBCExecutionContext executionContext = editor.getExecutionContext();
return executionContext != null && Objects.equals(executionContext.getDataSource().getContainer().getId(), containerId) && Objects.equals(executionContext.getContextName(), contextName);
}
Aggregations