Class ProxyHandler


  • public class ProxyHandler
    extends java.lang.Object
    • Constructor Detail

      • ProxyHandler

        public ProxyHandler()
      • ProxyHandler

        public ProxyHandler​(ProxyType proxyType,
                            java.lang.String host,
                            int port)
      • ProxyHandler

        public ProxyHandler​(ProxyType proxyType,
                            java.lang.String host,
                            int port,
                            @Nullable
                            java.lang.String username,
                            @Nullable
                            java.lang.String password)
      • ProxyHandler

        public ProxyHandler​(ProxyType proxyType,
                            java.net.SocketAddress address)
      • ProxyHandler

        public ProxyHandler​(ProxyType proxyType,
                            java.net.SocketAddress address,
                            @Nullable
                            java.lang.String username,
                            @Nullable
                            java.lang.String password)
    • Method Detail

      • setProxy

        public ProxyHandler setProxy​(ProxyType type,
                                     java.lang.String host,
                                     int port)
        Set the proxy to use.
        Parameters:
        type - The type of the proxy
        host - The host of the proxy
        port - The port of the proxy
        Returns:
        This instance for chaining
      • setProxy

        public ProxyHandler setProxy​(ProxyType type,
                                     java.net.SocketAddress address)
        Set the proxy to use.
        Parameters:
        type - The type of the proxy
        address - The address of the proxy
        Returns:
        This instance for chaining
      • unsetProxy

        public ProxyHandler unsetProxy()
        Unset the proxy.
        Returns:
        This instance for chaining
      • isProxySet

        public boolean isProxySet()
        Returns:
        If the proxy is set
      • getProxyType

        @Nullable
        public ProxyType getProxyType()
        Returns:
        The type of the proxy
      • setProxyType

        public ProxyHandler setProxyType​(@Nonnull
                                         ProxyType type)
        Set the type of the proxy.
        Parameters:
        type - The type of the proxy
        Returns:
        This instance for chaining
      • getAddress

        @Nullable
        public java.net.SocketAddress getAddress()
        Returns:
        The proxy address
      • setAddress

        public ProxyHandler setAddress​(@Nonnull
                                       java.net.SocketAddress address)
        Set the proxy address.
        Parameters:
        address - The proxy address
        Returns:
        This instance for chaining
      • isAuthenticationSet

        public boolean isAuthenticationSet()
        Returns:
        If the authentication is set
      • getUsername

        @Nullable
        public java.lang.String getUsername()
        Returns:
        The username for the proxy
      • setUsername

        public ProxyHandler setUsername​(@Nullable
                                        java.lang.String username)
        Set the username for the proxy.
        Parameters:
        username - The username for the proxy
        Returns:
        This instance for chaining
      • getPassword

        @Nullable
        public java.lang.String getPassword()
        Returns:
        The password for the proxy
      • setPassword

        public ProxyHandler setPassword​(@Nullable
                                        java.lang.String password)
        Set the password for the proxy.
        Parameters:
        password - The password for the proxy
        Returns:
        This instance for chaining
      • getProxySelector

        public SingleProxySelector getProxySelector()
        Returns:
        The SingleProxySelector for this proxy
        Throws:
        java.lang.IllegalStateException - If the proxy is not set
      • getProxyAuthenticator

        public SingleProxyAuthenticator getProxyAuthenticator()
        Returns:
        The SingleProxyAuthenticator for this proxy
        Throws:
        java.lang.IllegalStateException - If the proxy or the username/password is not set
      • toJavaProxy

        public java.net.Proxy toJavaProxy()
        Create a Proxy object from this proxy.
        The Proxy might not support all proxy types.
        Returns:
        The created Proxy object