Class ProxyInfo

java.lang.Object
org.bzdev.swing.proxyconf.ProxyInfo

public class ProxyInfo extends Object
Proxy-configuration data. This class is provided to encode the configurations of proxies for HTTP, HTTPS, FTP, and SOCKS - the protocols which java.net recognizes as ones where proxies may be used.

The methods test if a an instance of this class is meant to configure a proxy for a protocol and if so, will information needed to use the proxy (typically its host name or IP address and its TCP or UDP port number). If not configured, the application is expected to use the preference database to look up the values.

There are two constructors. One takes a single argument, a preference-node name. The use of this constructor implies that a preference database should be used to configure proxies. The second takes 5 arguments: a preference-node name and 4 boolean values indicating which proxies are being configured.

  • Field Details

  • Constructor Details

    • ProxyInfo

      public ProxyInfo()
      Constructor specifying use of preferences. Any values for proxies set by this class should be ignored as the values configured are expected to be those provided by preferences.
    • ProxyInfo

      public ProxyInfo(boolean configHttp, boolean configHttps, boolean configFtp, boolean configSocks)
      Constructor. Sets which proxies are of interest to the application and should be configured for it. When a boolean argument is false, this class does not configure the corresponding proxy and instead the preference database is used. To disable a proxy reliably, set the flag to true and set the values for the proxy to null.
      Parameters:
      configHttp - true if an HTTP proxy is to be configured by this object; false otherwise
      configHttps - true if an HTTPS proxy is to be configured by this object; false otherwise
      configFtp - true if an FTP proxy is to be configured by this object; false otherwise
      configSocks - true if a SOCKS proxy is to be configured by this object; false otherwise
  • Method Details

    • usePreferences

      public boolean usePreferences()
      Determine if configuration data should be taken from the Java preferences database.
      Returns:
      true if Java preferences should be used; false if the configurations in this object should be used.
    • getConfigHttp

      public boolean getConfigHttp()
      Determine if an HTTP proxy is configured by this object
      Returns:
      true if an HTTP proxy is configured, false otherwise
    • getConfigHttps

      public boolean getConfigHttps()
      Determine if an HTTPS proxy is configured by this object.
      Returns:
      true if an HTTPS proxy is configured, false otherwise
    • getConfigFtp

      public boolean getConfigFtp()
      Determine if an FTP proxy is configured by this object.
      Returns:
      true if an FTP proxy is configured, false otherwise
    • getConfigSocks

      public boolean getConfigSocks()
      Determine if a SOCKS proxy is configured by this object.
      Returns:
      true if a SOCKS proxy is configured, false otherwise
    • setUseSystemProxies

      public void setUseSystemProxies(boolean value)
      Set system-proxy mode.
      Parameters:
      value - true if system proxies should be used; false otherwise
    • getUseSystemProxies

      public boolean getUseSystemProxies()
      Get system-proxy mode.
      Returns:
      true if system proxies should be used; false otherwise
    • setHttpProxyHost

      public void setHttpProxyHost(String value)
      Set the host name or IP address of an HTTP proxy.
      Parameters:
      value - the IP address or host name of the HTTP proxy
    • getHttpProxyHost

      public String getHttpProxyHost()
      Get the host name or IP address of an HTTP proxy.
      Returns:
      the host name or IP address of the HTTP proxy
    • setHttpProxyPort

      public void setHttpProxyPort(String value)
      Set the TCP port of an HTTP proxy.
      Parameters:
      value - the TCP port of the HTTP proxy
    • getHttpProxyPort

      public String getHttpProxyPort()
      Get the TCP port of an HTTP proxy.
      Returns:
      the TCP port the HTTP proxy
    • setHttpNonProxyHosts

      public void setHttpNonProxyHosts(String value)
      Set the host name or IP addresses that should not use an HTTP proxy.
      Parameters:
      value - the IP addresses or host names, separated by a '|'; null to indicate none.
    • getHttpNonProxyHosts

      public String getHttpNonProxyHosts()
      Get the host name or IP addresses that should not use an HTTP proxy.
      Returns:
      the host names and IP addresses, separated by a '|'; null if none have been set.
    • setHttpsProxyHost

      public void setHttpsProxyHost(String value)
      Set the host name or IP address of an HTTP proxy.
      Parameters:
      value - the IP address or host name of the HTTP proxy; null if none
    • getHttpsProxyHost

      public String getHttpsProxyHost()
      Get the host name or IP address of an HTTPS proxy.
      Returns:
      the host name or IP address of the HTTPS proxy
    • setHttpsProxyPort

      public void setHttpsProxyPort(String value)
      Set the TCP port of an HTTPS proxy.
      Parameters:
      value - the TCP port of the HTTPS proxy; null for no proxy
    • getHttpsProxyPort

      public String getHttpsProxyPort()
      Get the TCP port of an HTTPS proxy.
      Returns:
      the TCP port the HTTPS proxy; null if one is has not been set
    • setFtpProxyHost

      public void setFtpProxyHost(String value)
      Set the host name or IP address of an FTP proxy.
      Parameters:
      value - the IP address or host name of the FTP proxy; null indicates no proxy
    • getFtpProxyHost

      public String getFtpProxyHost()
      Get the host name or IP address of an FTP proxy.
      Returns:
      the host name or IP address of the FTP proxy; null if there is none
    • setFtpProxyPort

      public void setFtpProxyPort(String value)
      Set the TCP port of an FTP proxy.
      Parameters:
      value - the TCP port of the FTP proxy; null for no proxy
    • getFtpProxyPort

      public String getFtpProxyPort()
      Get the TCP port of an FTP proxy.
      Returns:
      the TCP port the FTP proxy; null if no proxy was specified
    • setFtpNonProxyHosts

      public void setFtpNonProxyHosts(String value)
      Set the host name or IP addresses that should not use an FTP proxy.
      Parameters:
      value - the IP addresses or host names, separated by a '|'; null to indicate none.
    • getFtpNonProxyHosts

      public String getFtpNonProxyHosts()
      Get the host name or IP addresses that should not use an FTP proxy.
      Returns:
      the host names and IP addresses, separated by a '|'; null if none have been set.
    • setSocksProxyHost

      public void setSocksProxyHost(String value)
      Set the host name or IP address of a SOCKS proxy.
      Parameters:
      value - the IP address or host name of the SOCKS proxy; null if no SOCKS proxy is specified
    • getSocksProxyHost

      public String getSocksProxyHost()
      Get the host name or IP address of a SOCKS proxy.
      Returns:
      the host name or IP address of the SOCKS proxy; null if there is none
    • setSocksProxyPort

      public void setSocksProxyPort(String value)
      Set the TCP port of a SOCKS proxy.
      Parameters:
      value - the TCP port of the SOCKS proxy; null for no proxy
    • getSocksProxyPort

      public String getSocksProxyPort()
      Get the TCP port of a SOCKS proxy.
      Returns:
      the TCP port the SOCKS proxy; null for no proxy specified