use of org.eclipse.ecf.core.util.ProxyAddress in project ecf by eclipse.
the class ProxySetupHelper method getProxy.
public static Proxy getProxy(String url) {
Proxy proxy = null;
try {
IProxyService proxyService = Activator.getDefault().getProxyService();
// Only do this if platform service exists
if (proxyService != null && proxyService.isProxiesEnabled()) {
// Setup via proxyService entry
URI uri = new URI(url);
final IProxyData[] proxies = proxyService.select(uri);
IProxyData selectedProxy = selectProxyFromProxies(uri.getScheme(), proxies);
if (selectedProxy != null) {
proxy = new Proxy(((selectedProxy.getType().equalsIgnoreCase(IProxyData.SOCKS_PROXY_TYPE)) ? Proxy.Type.SOCKS : Proxy.Type.HTTP), new ProxyAddress(selectedProxy.getHost(), selectedProxy.getPort()), selectedProxy.getUserId(), selectedProxy.getPassword());
}
}
} catch (Exception e) {
// If we don't even have the classes for this (i.e. the org.eclipse.core.net plugin not available)
// then we simply log and ignore
Activator.logNoProxyWarning(e);
} catch (NoClassDefFoundError e) {
Activator.logNoProxyWarning(e);
}
return proxy;
}
use of org.eclipse.ecf.core.util.ProxyAddress in project ecf by eclipse.
the class HttpClientFileSystemBrowser method setupProxy.
protected void setupProxy(Proxy proxy) {
if (proxy.getType().equals(Proxy.Type.HTTP)) {
final ProxyAddress address = proxy.getAddress();
ConnRouteParams.setDefaultProxy(httpClient.getParams(), new HttpHost(address.getHostName(), address.getPort()));
} else if (proxy.getType().equals(Proxy.Type.SOCKS)) {
// $NON-NLS-1$
Trace.trace(Activator.PLUGIN_ID, "brows socksproxy=" + proxy.getAddress());
proxyHelper.setupProxy(proxy);
}
}
use of org.eclipse.ecf.core.util.ProxyAddress in project ecf by eclipse.
the class HttpClientRetrieveFileTransfer method setupProxy.
/* (non-Javadoc)
* @see org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer#setupProxy(org.eclipse.ecf.core.util.Proxy)
*/
protected void setupProxy(Proxy proxy) {
// $NON-NLS-1$
Trace.entering(Activator.PLUGIN_ID, DebugOptions.METHODS_ENTERING, HttpClientRetrieveFileTransfer.class, "setupProxy " + proxy);
if (proxy.getType().equals(Proxy.Type.HTTP)) {
final ProxyAddress address = proxy.getAddress();
ConnRouteParams.setDefaultProxy(httpClient.getParams(), new HttpHost(address.getHostName(), address.getPort()));
// getHostConfiguration().setProxy(address.getHostName(), address.getPort());
} else if (proxy.getType().equals(Proxy.Type.SOCKS)) {
// $NON-NLS-1$
Trace.trace(Activator.PLUGIN_ID, "retrieve socksproxy=" + proxy.getAddress());
proxyHelper.setupProxy(proxy);
}
}
use of org.eclipse.ecf.core.util.ProxyAddress in project ecf by eclipse.
the class URLRetrieveTestProxy method setUp.
// This test depends upon the setting of two system properties:
// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyHost=<proxy host name>
// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyPort=<proxy port>
// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyUsername=<username for proxy authentication>
// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyPassword=<password for proxy authentication>
// e.g.
// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyHost=myproxy.foo.com
// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyPort=8888
/*
* (non-Javadoc)
*
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
// "localhost", 909)));
try {
String proxyName = System.getProperty(this.getClass().getName() + ".proxyHost");
if (proxyName != null) {
String pPort = System.getProperty(this.getClass().getName() + ".proxyPort");
int proxyPort = ((pPort != null) ? Integer.parseInt(pPort) : 9808);
String username = System.getProperty(this.getClass().getName() + ".proxyUsername");
if (username != null) {
String password = System.getProperty(this.getClass().getName() + ".proxyPassword");
retrieveAdapter.setProxy(new Proxy(Proxy.Type.HTTP, new ProxyAddress(proxyName, proxyPort), username, password));
} else {
retrieveAdapter.setProxy(new Proxy(Proxy.Type.HTTP, new ProxyAddress(proxyName, proxyPort)));
}
}
} catch (Exception e) {
// Print out problems to system err
e.printStackTrace(System.err);
}
}
Aggregations