Class GnomeDConfProxySearchStrategy
java.lang.Object
com.github.markusbernhardt.proxy.search.desktop.gnome.GnomeDConfProxySearchStrategy
- All Implemented Interfaces:
ProxySearchStrategy
Loads the Gnome proxy settings from the Gnome GConf settings.
"none" -> No proxy is used
"manual" -> The user's configuration values are used (org.gnome.system.http_proxy/{host,port,etc.})
"auto" -> The "org.gnome.system.proxy/autoconfig_url" key is used
The following settings are extracted from the configuration that is stored in .gconf folder found in the user's home directory:
- org.gnome.system.proxy.http enabled -> bool used only by gnome-vfs
- org.gnome.system.proxy.http host -> string "my-proxy.example.com" without "http://"
- org.gnome.system.proxy.http port -> int
- org.gnome.system.proxy.http use-authentication -> bool
- org.gnome.system.proxy.http authentication-user -> string
- org.gnome.system.proxy.http authentication-password -> string
- org.gnome.system.proxy ignore-hosts -> list-of-string
- org.gnome.system.proxy mode -> string THIS IS THE CANONICAL KEY; SEE BELOW
- org.gnome.system.proxy use-same-proxy -> bool
- org.gnome.system.proxy.https host -> string "proxy-for-https.example.com"
- org.gnome.system.proxy.https port -> int
- org.gnome.system.proxy.ftp host -> string "proxy-for-ftp.example.com"
- org.gnome.system.proxy.ftp port -> int
- org.gnome.system.proxy.socks host -> string "proxy-for-socks.example.com"
- org.gnome.system.proxy.socks port -> int
- org.gnome.system.proxy autoconfig-url -> string "http://proxy-autoconfig.example.com"
"none" -> No proxy is used
"manual" -> The user's configuration values are used (org.gnome.system.http_proxy/{host,port,etc.})
"auto" -> The "org.gnome.system.proxy/autoconfig_url" key is used
GNOME Proxy_configuration settings are explained here in detail
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetName()
Gets the printable name of the search strategy.Loads the proxy settings and initializes a proxy selector for the Gnome proxy settings.private boolean
hasProxySettings
(Properties settings) Checks if we have Proxy configuration settings in the properties.private void
installFtpSelector
(Properties settings, ProtocolDispatchSelector ps) private void
installHttpSelector
(Properties settings, ProtocolDispatchSelector ps) Install a http proxy from the given settings.private void
installSecureSelector
(Properties settings, ProtocolDispatchSelector ps) private void
installSocksSelector
(Properties settings, ProtocolDispatchSelector ps) Install a socks proxy from the given settings.private Properties
parseSettings
(Properties settings) Parse the settings file and extract all network.proxy.* settings from it.Load the proxy settings from the gconf settings XML file.private ProxySelector
setupFixedProxySelector
(Properties settings) Parse the fixed proxy settings and build an ProxySelector for this a chained configuration.private boolean
useForAllProtocols
(Properties settings) Check if the http proxy should also be used for all other protocols.
-
Constructor Details
-
GnomeDConfProxySearchStrategy
public GnomeDConfProxySearchStrategy()ProxySelector- See Also:
-
-
Method Details
-
getProxySelector
Loads the proxy settings and initializes a proxy selector for the Gnome proxy settings.- Specified by:
getProxySelector
in interfaceProxySearchStrategy
- Returns:
- a configured ProxySelector, null if none is found.
- Throws:
ProxyException
- on file reading error.
-
getName
Gets the printable name of the search strategy.- Specified by:
getName
in interfaceProxySearchStrategy
- Returns:
- the printable name of the search strategy
-
readSettings
Load the proxy settings from the gconf settings XML file.- Returns:
- the loaded settings stored in a properties object.
- Throws:
ProxyException
- on processing error.
-
setupFixedProxySelector
Parse the fixed proxy settings and build an ProxySelector for this a chained configuration.- Parameters:
settings
- the proxy settings to evaluate.
-
useForAllProtocols
Check if the http proxy should also be used for all other protocols.- Parameters:
settings
- to inspect.- Returns:
- true if only one proxy is configured else false.
-
hasProxySettings
Checks if we have Proxy configuration settings in the properties.- Parameters:
settings
- to inspect.- Returns:
- true if we have found Proxy settings.
-
installHttpSelector
private void installHttpSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException Install a http proxy from the given settings.- Parameters:
settings
- to inspectps
- the dispatch selector to configure.- Throws:
NumberFormatException
-
installSocksSelector
private void installSocksSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException Install a socks proxy from the given settings.- Parameters:
settings
- to inspectps
- the dispatch selector to configure.- Throws:
NumberFormatException
-
installFtpSelector
private void installFtpSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException - Parameters:
settings
-ps
-- Throws:
NumberFormatException
-
installSecureSelector
private void installSecureSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException - Parameters:
settings
-ps
-- Throws:
NumberFormatException
-
parseSettings
Parse the settings file and extract all network.proxy.* settings from it.- Parameters:
settings
- the settings object to fill.context
- the gconf context to parse.- Returns:
- the parsed properties.
- Throws:
IOException
- on read error.
-