Class EnvProxySearchStrategy

  • All Implemented Interfaces:
    ProxySearchStrategy

    public class EnvProxySearchStrategy
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String ftpEnv  
      private java.lang.String ftpProxy  
      private java.lang.String httpEnv  
      private java.lang.String httpProxy  
      private java.lang.String httpsEnv  
      private java.lang.String httpsProxy  
      private java.lang.String noProxy  
      private java.lang.String noProxyEnv  
    • Constructor Summary

      Constructors 
      Constructor Description
      EnvProxySearchStrategy()
      Constructor Will use the default environment variables.
      EnvProxySearchStrategy​(java.lang.String httpEnv, java.lang.String httpsEnv, java.lang.String ftpEnv, java.lang.String noProxyEnv)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getName()
      Gets the printable name of the search strategy.
      java.net.ProxySelector getProxySelector()
      Loads the proxy settings from environment variables.
      private void loadProxySettings()
      Loads the proxy settings from the system environment variables.
      java.util.Properties readSettings()
      Loads the settings and stores them in a properties map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • httpEnv

        private java.lang.String httpEnv
      • httpsEnv

        private java.lang.String httpsEnv
      • ftpEnv

        private java.lang.String ftpEnv
      • noProxyEnv

        private java.lang.String noProxyEnv
      • httpProxy

        private java.lang.String httpProxy
      • httpsProxy

        private java.lang.String httpsProxy
      • ftpProxy

        private java.lang.String ftpProxy
      • noProxy

        private java.lang.String noProxy
    • Constructor Detail

      • EnvProxySearchStrategy

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

        public EnvProxySearchStrategy​(java.lang.String httpEnv,
                                      java.lang.String httpsEnv,
                                      java.lang.String ftpEnv,
                                      java.lang.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 Detail

      • loadProxySettings

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

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

        public java.net.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 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