Class EnvProxySearchStrategy

java.lang.Object
com.github.markusbernhardt.proxy.search.env.EnvProxySearchStrategy
All Implemented Interfaces:
ProxySearchStrategy

public class EnvProxySearchStrategy extends Object implements ProxySearchStrategy
Reads some environment variables and extracts the proxy settings from them. These variables are mainly set on linux / unix environments. The following variables are read per default:
  • http_proxy -> This will be used for http / https
  • https_proxy -> Will be used for https, if not set then http_proxy is used instead.
  • ftp_proxy -> Used for FTP.
  • no_proxy -> a no proxy white list.
  • Field Details

    • httpEnv

      private String httpEnv
    • httpsEnv

      private String httpsEnv
    • ftpEnv

      private String ftpEnv
    • noProxyEnv

      private String noProxyEnv
    • httpProxy

      private String httpProxy
    • httpsProxy

      private String httpsProxy
    • ftpProxy

      private String ftpProxy
    • noProxy

      private String noProxy
  • Constructor Details

    • EnvProxySearchStrategy

      public EnvProxySearchStrategy()
      Constructor Will use the default environment variables.
    • EnvProxySearchStrategy

      public EnvProxySearchStrategy(String httpEnv, String httpsEnv, String ftpEnv, String noProxyEnv)
      Constructor
      Parameters:
      httpEnv - name of environment variable
      httpsEnv - name of environment variable
      ftpEnv - name of environment variable
      noProxyEnv - name of environment variable
  • Method Details

    • loadProxySettings

      private void loadProxySettings()
      Loads the proxy settings from the system environment variables.
    • readSettings

      public Properties readSettings()
      Loads the settings and stores them in a properties map.
      Returns:
      the settings.
    • getProxySelector

      public ProxySelector getProxySelector()
      Loads the proxy settings from environment variables.
      Specified by:
      getProxySelector in interface ProxySearchStrategy
      Returns:
      a configured ProxySelector, null if none is found.
    • getName

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