Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 97582 Details for
Bug 226462
[Proxy] Use system values for proxy settings on Linux
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Get env not using native code
226462_20080425.txt (text/plain), 6.39 KB, created by
Szymon Brandys
on 2008-04-25 05:39:50 EDT
(
hide
)
Description:
Get env not using native code
Filename:
MIME Type:
Creator:
Szymon Brandys
Created:
2008-04-25 05:39:50 EDT
Size:
6.39 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.net >Index: src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java,v >retrieving revision 1.1 >diff -u -r1.1 UnixProxyProvider.java >--- src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java 22 Apr 2008 10:04:18 -0000 1.1 >+++ src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java 25 Apr 2008 09:38:40 -0000 >@@ -7,23 +7,36 @@ > * > * Contributors: > * Oakland Software Incorporated - initial API and implementation >+ * IBM Corporation - implementation > *******************************************************************************/ > package org.eclipse.core.internal.net.proxy.unix; > >+import java.io.IOException; > import java.net.URI; >-import java.net.URISyntaxException; >+import java.util.Locale; >+import java.util.Properties; > > import org.eclipse.core.internal.net.AbstractProxyProvider; >+import org.eclipse.core.internal.net.Activator; > import org.eclipse.core.internal.net.ProxyData; > import org.eclipse.core.net.proxy.IProxyData; > > public class UnixProxyProvider extends AbstractProxyProvider { > >+ public static boolean DEBUG = false; >+ > static { > try { >- System.loadLibrary("libproxysupport"); //$NON-NLS-1$ >+ System.loadLibrary("proxygnome"); //$NON-NLS-1$ >+ // Start it up on the main thread, it seems to hand sometimes >+ // otherwise >+ gconfInit(); >+ if (DEBUG) >+ System.out.println("Loaded (Gnome) libraries"); //$NON-NLS-1$ > } catch (UnsatisfiedLinkError ex) { >- // This will happen on systems that are missing Gnome libraries >+ // Expected on systems that are missing Gnome libraries >+ if (DEBUG) >+ System.out.println("Missing gconf (Gnome) libraries"); //$NON-NLS-1$ > } > } > >@@ -45,15 +58,33 @@ > return new IProxyData[0]; > } > >- protected String[] getNonProxiedHosts() { >+ public String[] getNonProxiedHosts() { >+ String[] npHosts; >+ >+ // First try the environment variable which is a URL >+ String npEnv = null; >+ npEnv = getEnv("no_proxy"); //$NON-NLS-1$ >+ if (npEnv != null) { >+ if (DEBUG) >+ System.out.println("got env no_proxy: " + npEnv); //$NON-NLS-1$ >+ npHosts = npEnv.split(","); //$NON-NLS-1$ >+ for (int i = 0; i < npHosts.length; i++) >+ npHosts[i] = npHosts[i].trim(); >+ return debugPrint(npHosts); >+ } >+ > try { >- String[] npHosts = getGConfNonProxyHosts(); >- if (npHosts != null && npHosts.length > 0) >- return npHosts; >- return getKdeNonProxyHosts(); >+ npHosts = getGConfNonProxyHosts(); >+ if (npHosts != null && npHosts.length > 0) { >+ if (DEBUG) >+ System.out.println("got gnome no_proxy"); //$NON-NLS-1$ >+ return debugPrint(npHosts); >+ } > } catch (UnsatisfiedLinkError ex) { >+ // Expected on systems that are missing Gnome libraries > // This has already been reported (the native code did not load) > } >+ > return new String[] {}; > } > >@@ -61,49 +92,90 @@ > protected ProxyData getSystemProxyInfo(String protocol) { > ProxyData pd = null; > >- // First try the environment variable which is a URL >- // TODO: native calls for system properties, since System#getenx is >- // deprecated in 1.4 >- String sysHttp = null; >- // System.getenv(protocol.toLowerCase() + "_proxy"); //$NON-NLS-1$ >- if (sysHttp != null) { >- URI uri = null; >- try { >- uri = new URI(sysHttp); >- } catch (URISyntaxException e) { >- return null; >- } >+ String envName = null; >+ String proxyEnv = null; >+ URI uri = null; > >- pd = new ProxyData(protocol); >- pd.setHost(uri.getHost()); >- pd.setPort(uri.getPort()); >- return pd; >+ try { >+ if (DEBUG) >+ System.out.println("getting ProxyData for: " + protocol); //$NON-NLS-1$ >+ >+ // protocol schemes are ISO 8859 (ASCII) >+ protocol = protocol.toLowerCase(Locale.ENGLISH); >+ >+ // First try the environment variable which is a URL >+ envName = protocol + "_proxy"; //$NON-NLS-1$ >+ proxyEnv = getEnv(envName); >+ if (DEBUG) >+ System.out.println("got proxyEnv: " + proxyEnv); //$NON-NLS-1$ >+ >+ if (proxyEnv != null) { >+ uri = new URI(proxyEnv); >+ pd = new ProxyData(protocol); >+ pd.setHost(uri.getHost()); >+ pd.setPort(uri.getPort()); >+ String userInfo = uri.getUserInfo(); >+ if (userInfo != null) { >+ String user = null; >+ String password = null; >+ int pwInd = userInfo.indexOf(':'); >+ if (pwInd >= 0) { >+ user = userInfo.substring(0, pwInd); >+ password = userInfo.substring(pwInd + 1); >+ } else { >+ user = userInfo; >+ } >+ pd.setUserid(user); >+ pd.setPassword(password); >+ } >+ >+ if (DEBUG) >+ System.out.println("env proxy data: " + pd); //$NON-NLS-1$ >+ return pd; >+ } >+ } catch (Exception ex) { >+ Activator.logError( >+ "Problem during accessing system variable: " + envName, ex); //$NON-NLS-1$ > } > > try { > // Then ask Gnome > pd = getGConfProxyInfo(protocol); >+ if (DEBUG) >+ System.out.println("Gnome proxy data: " + pd); //$NON-NLS-1$ >+ return pd; > >- if (pd != null) >- return pd; >- >- // Then ask KDE >- pd = getKdeProxyInfo(protocol); >- if (pd != null) >- return pd; > } catch (UnsatisfiedLinkError ex) { >- // This has already been reported when the native code did not load >+ // Expected on systems that are missing Gnome libraries >+ // This has already been reported (the native code did not load) > } > > return null; > } > >- protected static native ProxyData getGConfProxyInfo(String protocol); >+ private String getEnv(String env) { >+ Properties props = new Properties(); >+ try { >+ props.load(Runtime.getRuntime().exec("env").getInputStream()); //$NON-NLS-1$ >+ } catch (IOException e) { >+ Activator.logError( >+ "Problem during accessing system variable: " + env, e); //$NON-NLS-1$ >+ } >+ return props.getProperty(env); >+ } > >- protected static native String[] getGConfNonProxyHosts(); >+ private String[] debugPrint(String[] strs) { >+ if (DEBUG) { >+ System.out.println("npHosts: "); //$NON-NLS-1$ >+ for (int i = 0; i < strs.length; i++) >+ System.out.println(i + ": " + strs[i]); //$NON-NLS-1$ >+ } >+ return strs; >+ } > >- protected static native ProxyData getKdeProxyInfo(String protocol); >+ protected static native void gconfInit(); > >- protected static native String[] getKdeNonProxyHosts(); >+ protected static native ProxyData getGConfProxyInfo(String protocol); > >+ protected static native String[] getGConfNonProxyHosts(); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 226462
:
96832
|
96833
|
96835
|
96991
|
97178
|
97179
|
97399
|
97400
|
97566
|
97567
| 97582