Class FirefoxProxySearchStrategy
java.lang.Object
com.github.markusbernhardt.proxy.search.browser.firefox.FirefoxProxySearchStrategy
- All Implemented Interfaces:
ProxySearchStrategy
Loads the Firefox3 proxy settings from the users Firefox3 settings. This will
load the file prefs.js that is located in the
.mozilla/firefox/(profile)/ folder.
See Mozilla_Networking_Preferences for an explanation of the proxy settings.The following settings are extracted from this file:
Some generic settings:- network.proxy.type -> n/a = use system settings, 0 = direct, 1 = Fixed proxy settings, 2 = proxy script (PAC), 3 = also direct , 4 = auto detect (WPAD)
- network.proxy.share_proxy_settings -> true = use same proxy for all protocols
- network.proxy.no_proxies_on -> a comma separated ignore list.
- network.proxy.autoconfig_url -> a URL to an proxy configuration script
- network.proxy.http
- network.proxy.http_port
- network.proxy.ssl
- network.proxy.ssl_port
- network.proxy.ftp
- network.proxy.ftp_port
- network.proxy.gopher
- network.proxy.gopher_port
- network.proxy.socks
- network.proxy.socks_port
- network.proxy.socks_version -> 4 or 5
Note that if there are more than one profile the first profile found will be used.
-
Field Summary
Fields -
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 firefox proxy settings.private void
installFtpProxy
(ProtocolDispatchSelector ps, Properties settings) private void
installHttpProxy
(ProtocolDispatchSelector ps, Properties settings) private void
installSecureProxy
(ProtocolDispatchSelector ps, Properties settings) private void
installSelectorForProtocol
(ProtocolDispatchSelector ps, Properties settings, String protocol) Installs a proxy selector for the given protocol when settings are available.private void
private void
installSocksProxy
(ProtocolDispatchSelector ps, Properties settings) private boolean
isProxyShared
(Properties settings) Checks if the "share proxy settings" option is setReads the settings file and stores all settings in a Properties map.private ProxySelector
setupFixedProxySelector
(Properties settings) Parse the fixed proxy settings and build an ProxySelector for this a chained configuration.
-
Field Details
-
profileScanner
-
settingsParser
-
-
Constructor Details
-
FirefoxProxySearchStrategy
public FirefoxProxySearchStrategy()ProxySelector- See Also:
-
-
Method Details
-
getProxySelector
Loads the proxy settings and initializes a proxy selector for the firefox 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
Reads the settings file and stores all settings in a Properties map.- Returns:
- the parsed settings.
- Throws:
ProxyException
- on read error.
-
setupFixedProxySelector
Parse the fixed proxy settings and build an ProxySelector for this a chained configuration.- Parameters:
settings
- the proxy settings to evaluate.
-
installFtpProxy
private void installFtpProxy(ProtocolDispatchSelector ps, Properties settings) throws NumberFormatException - Parameters:
ps
-settings
-- Throws:
NumberFormatException
-
installHttpProxy
private void installHttpProxy(ProtocolDispatchSelector ps, Properties settings) throws NumberFormatException - Parameters:
ps
-settings
-- Throws:
NumberFormatException
-
installSocksProxy
private void installSocksProxy(ProtocolDispatchSelector ps, Properties settings) throws NumberFormatException - Parameters:
ps
-settings
-- Throws:
NumberFormatException
-
installSecureProxy
private void installSecureProxy(ProtocolDispatchSelector ps, Properties settings) throws NumberFormatException - Parameters:
ps
-settings
-- Throws:
NumberFormatException
-
installSelectorForProtocol
private void installSelectorForProtocol(ProtocolDispatchSelector ps, Properties settings, String protocol) throws NumberFormatException Installs a proxy selector for the given protocol when settings are available.- Parameters:
ps
- a ProtocolDispatchSelector to configure.settings
- to read the config from.protocol
- to configure.- Throws:
NumberFormatException
-