Class ProxyOptions


  • public class ProxyOptions
    extends Object
    This represents proxy configuration to be used in http clients..
    • Constructor Detail

      • ProxyOptions

        public ProxyOptions​(ProxyOptions.Type type,
                            InetSocketAddress address)
        Creates ProxyOptions.
        Parameters:
        type - the proxy type
        address - the proxy address (ip and port number)
    • Method Detail

      • setCredentials

        public ProxyOptions setCredentials​(String username,
                                           String password)
        Set the proxy credentials.
        Parameters:
        username - proxy user name
        password - proxy password
        Returns:
        the updated ProxyOptions object
      • setNonProxyHosts

        public ProxyOptions setNonProxyHosts​(String nonProxyHosts)
        Sets the hosts which bypass the proxy.

        The expected format of the passed string is a '|' delimited list of hosts which should bypass the proxy. Individual host strings may contain regex characters such as '*'.

        Parameters:
        nonProxyHosts - Hosts that bypass the proxy.
        Returns:
        the updated ProxyOptions object
      • getAddress

        public InetSocketAddress getAddress()
        Returns:
        the address of the proxy.
      • getUsername

        public String getUsername()
        Returns:
        the proxy user name.
      • getPassword

        public String getPassword()
        Returns:
        the proxy password.
      • getNonProxyHosts

        public String getNonProxyHosts()
        Returns:
        the hosts that bypass the proxy.
      • fromConfiguration

        public static ProxyOptions fromConfiguration​(Configuration configuration)
        Attempts to load a proxy from the environment.

        If a proxy is found and loaded the proxy address is DNS resolved.

        Environment configurations are loaded in this order:

        1. Azure HTTPS
        2. Azure HTTP
        3. Java HTTPS
        4. Java HTTP
        Azure proxy configurations will be preferred over Java proxy configurations as they are more closely scoped to the purpose of the SDK. Additionally, more secure protocols, HTTPS vs HTTP, will be preferred.

        null will be returned if no proxy was found in the environment.

        Parameters:
        configuration - The Configuration that is used to load proxy configurations from the environment. If null is passed then Configuration.getGlobalConfiguration() will be used. If Configuration.NONE is passed IllegalArgumentException will be thrown.
        Returns:
        A ProxyOptions reflecting a proxy loaded from the environment, if no proxy is found null will be returned.
        Throws:
        IllegalArgumentException - If configuration is Configuration.NONE.
      • fromConfiguration

        public static ProxyOptions fromConfiguration​(Configuration configuration,
                                                     boolean createUnresolved)
        Attempts to load a proxy from the environment.

        If a proxy is found and loaded, the proxy address is DNS resolved based on createUnresolved. When createUnresolved is true resolving getAddress() may be required before using the address in network calls.

        Environment configurations are loaded in this order:

        1. Azure HTTPS
        2. Azure HTTP
        3. Java HTTPS
        4. Java HTTP
        Azure proxy configurations will be preferred over Java proxy configurations as they are more closely scoped to the purpose of the SDK. Additionally, more secure protocols, HTTPS vs HTTP, will be preferred.

        null will be returned if no proxy was found in the environment.

        Parameters:
        configuration - The Configuration that is used to load proxy configurations from the environment. If null is passed then Configuration.getGlobalConfiguration() will be used. If Configuration.NONE is passed IllegalArgumentException will be thrown.
        createUnresolved - Flag determining whether the returned ProxyOptions is unresolved.
        Returns:
        A ProxyOptions reflecting a proxy loaded from the environment, if no proxy is found null will be returned.
        Throws:
        IllegalArgumentException - If configuration is Configuration.NONE.