Class ProxyUtil


  • public class ProxyUtil
    extends java.lang.Object
    Small helper class for some common utility methods.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_PROXY_PORT  
      private static java.util.List<java.net.Proxy> noProxyList  
    • Constructor Summary

      Constructors 
      Constructor Description
      ProxyUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static PacProxySelector buildPacSelectorForUrl​(java.lang.String url)
      Build a PAC proxy selector for the given URL.
      static java.lang.String cleanIPv6​(java.lang.String hostOrIP)
      This method can be used to cleanup an IPv6 address.
      static java.util.List<java.net.Proxy> noProxyList()
      Gets an unmodifiable proxy list that will have as it's only entry an DIRECT proxy.
      static FixedProxySelector parseProxySettings​(java.lang.String proxyVar)
      Parse host and port out of a proxy variable.
      • Methods inherited from class java.lang.Object

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

      • noProxyList

        private static java.util.List<java.net.Proxy> noProxyList
    • Constructor Detail

      • ProxyUtil

        public ProxyUtil()
    • Method Detail

      • parseProxySettings

        public static FixedProxySelector parseProxySettings​(java.lang.String proxyVar)
        Parse host and port out of a proxy variable.
        Parameters:
        proxyVar - the proxy string. example: http://192.168.10.9:8080/
        Returns:
        a FixedProxySelector using this settings, null on parse error.
      • noProxyList

        public static java.util.List<java.net.Proxy> noProxyList()
        Gets an unmodifiable proxy list that will have as it's only entry an DIRECT proxy.
        Returns:
        a list with a DIRECT proxy in it.
      • buildPacSelectorForUrl

        public static PacProxySelector buildPacSelectorForUrl​(java.lang.String url)
        Build a PAC proxy selector for the given URL.
        Parameters:
        url - to fetch the PAC script from.
        Returns:
        a PacProxySelector or null if it is not possible to build a working selector.
      • cleanIPv6

        public static java.lang.String cleanIPv6​(java.lang.String hostOrIP)
        This method can be used to cleanup an IPv6 address. It will remove the surrounding square brackets if found. e.g. [2001:4860:0:2001::68] will be returned as 2001:4860:0:2001::68
        Parameters:
        hostOrIP - to cleanup
        Returns:
        the raw host or IP without any IPv6 brackets.