Java Code Examples for org.eclipse.core.net.proxy.IProxyService#select()
The following examples show how to use
org.eclipse.core.net.proxy.IProxyService#select() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProxyFactory.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@VisibleForTesting public Proxy createProxy(URI uri) { Preconditions.checkNotNull(uri, "uri is null"); Preconditions.checkArgument(!"http".equals(uri.getScheme()), "http is not a supported schema"); IProxyService proxyServiceCopy = proxyService; if (proxyServiceCopy == null) { return Proxy.NO_PROXY; } IProxyData[] proxyDataForUri = proxyServiceCopy.select(uri); for (final IProxyData iProxyData : proxyDataForUri) { switch (iProxyData.getType()) { case IProxyData.HTTPS_PROXY_TYPE: return new Proxy(Type.HTTP, new InetSocketAddress(iProxyData.getHost(), iProxyData.getPort())); case IProxyData.SOCKS_PROXY_TYPE: return new Proxy(Type.SOCKS, new InetSocketAddress(iProxyData.getHost(), iProxyData.getPort())); default: logger.warning("Unsupported proxy type: " + iProxyData.getType()); break; } } return Proxy.NO_PROXY; }
Example 2
Source File: HttpUtil.java From thym with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("restriction") private static CachingHttpClientBuilder setupProxy(CachingHttpClientBuilder builder, URI url){ final IProxyService proxyService = HybridCore.getDefault().getProxyService(); if(proxyService != null ){ IProxyData[] proxies = proxyService.select(url); if(proxies != null && proxies.length > 0){ IProxyData proxy = proxies[0]; CredentialsProvider credsProvider = new BasicCredentialsProvider(); if(proxy.isRequiresAuthentication()){ credsProvider.setCredentials(new AuthScope(proxy.getHost(), proxy.getPort()), new UsernamePasswordCredentials(proxy.getUserId(), proxy.getPassword())); } builder.setDefaultCredentialsProvider(credsProvider); builder.setProxy(new HttpHost(proxy.getHost(), proxy.getPort())); } } return builder; }
Example 3
Source File: HttpClientService.java From cppcheclipse with Apache License 2.0 | 5 votes |
private IProxyData getProxyData(URI uri) { IProxyService proxyService = getProxyService(); if (proxyService != null && proxyService.isProxiesEnabled()) { if (!proxyService.isSystemProxiesEnabled()) { IProxyData[] proxies = proxyService.select(uri); if (proxies.length > 0) { return proxies[0]; } } } return null; }