Class FirefoxProxySearchStrategy

  • All Implemented Interfaces:
    ProxySearchStrategy

    public class FirefoxProxySearchStrategy
    extends java.lang.Object
    implements 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
    Host names and ports per protocol are stored in the following settings:
    • 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.

    • Constructor Detail

      • FirefoxProxySearchStrategy

        public FirefoxProxySearchStrategy()
        ProxySelector
        See Also:
        ProxySelector()
    • Method Detail

      • getProxySelector

        public java.net.ProxySelector getProxySelector()
                                                throws ProxyException
        Loads the proxy settings and initializes a proxy selector for the firefox proxy settings.
        Specified by:
        getProxySelector in interface ProxySearchStrategy
        Returns:
        a configured ProxySelector, null if none is found.
        Throws:
        ProxyException - on file reading error.
      • getName

        public java.lang.String getName()
        Gets the printable name of the search strategy.
        Specified by:
        getName in interface ProxySearchStrategy
        Returns:
        the printable name of the search strategy
      • readSettings

        public java.util.Properties readSettings()
                                          throws ProxyException
        Reads the settings file and stores all settings in a Properties map.
        Returns:
        the parsed settings.
        Throws:
        ProxyException - on read error.
      • setupFixedProxySelector

        private java.net.ProxySelector setupFixedProxySelector​(java.util.Properties settings)
        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,
                                     java.util.Properties settings)
                              throws java.lang.NumberFormatException
        Parameters:
        ps -
        settings -
        Throws:
        java.lang.NumberFormatException
      • installHttpProxy

        private void installHttpProxy​(ProtocolDispatchSelector ps,
                                      java.util.Properties settings)
                               throws java.lang.NumberFormatException
        Parameters:
        ps -
        settings -
        Throws:
        java.lang.NumberFormatException
      • isProxyShared

        private boolean isProxyShared​(java.util.Properties settings)
        Checks if the "share proxy settings" option is set
        Parameters:
        settings - to parse
        Returns:
        true if the option is set else false
      • installSocksProxy

        private void installSocksProxy​(ProtocolDispatchSelector ps,
                                       java.util.Properties settings)
                                throws java.lang.NumberFormatException
        Parameters:
        ps -
        settings -
        Throws:
        java.lang.NumberFormatException
      • installSecureProxy

        private void installSecureProxy​(ProtocolDispatchSelector ps,
                                        java.util.Properties settings)
                                 throws java.lang.NumberFormatException
        Parameters:
        ps -
        settings -
        Throws:
        java.lang.NumberFormatException
      • installSelectorForProtocol

        private void installSelectorForProtocol​(ProtocolDispatchSelector ps,
                                                java.util.Properties settings,
                                                java.lang.String protocol)
                                         throws java.lang.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:
        java.lang.NumberFormatException