Class ProxyConfiguration

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class ProxyConfiguration
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Options for configuring the Proxy.
    See Also:
    Proxy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static ProxyConfiguration SYSTEM_DEFAULTS
      Gets the system defaults for proxy configuration and authentication.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProxyConfiguration​(ProxyAuthenticationType authentication, java.net.Proxy proxyAddress, java.lang.String username, java.lang.String password)
      Creates a proxy configuration that uses the proxyAddress and authenticates with provided username, password and authentication.
    • Field Detail

      • SYSTEM_DEFAULTS

        public static final ProxyConfiguration SYSTEM_DEFAULTS
        Gets the system defaults for proxy configuration and authentication.
    • Constructor Detail

      • ProxyConfiguration

        public ProxyConfiguration​(ProxyAuthenticationType authentication,
                                  java.net.Proxy proxyAddress,
                                  java.lang.String username,
                                  java.lang.String password)
        Creates a proxy configuration that uses the proxyAddress and authenticates with provided username, password and authentication.
        Parameters:
        authentication - Authentication method to preemptively use with proxy.
        proxyAddress - Proxy to use. If null is passed in, then the system configured Proxy is used.
        username - Optional. Username used to authenticate with proxy. If not specified, the system-wide Authenticator is used to fetch credentials.
        password - Optional. Password used to authenticate with proxy.
        Throws:
        java.lang.NullPointerException - if authentication is null.
        java.lang.IllegalArgumentException - if authentication is ProxyAuthenticationType.BASIC or ProxyAuthenticationType.DIGEST and username or password are null.
    • Method Detail

      • proxyAddress

        public java.net.Proxy proxyAddress()
        Gets the proxy address.
        Returns:
        The proxy address. Returns null if user creates proxy credentials with SYSTEM_DEFAULTS.
      • credentials

        public java.net.PasswordAuthentication credentials()
        Gets credentials to authenticate against proxy with.
        Returns:
        The credentials to authenticate against proxy with. Returns null if no credentials were set. This occurs when user uses SYSTEM_DEFAULTS.
      • authentication

        public ProxyAuthenticationType authentication()
        Gets the proxy authentication type to use.
        Returns:
        The proxy authentication type to use. returns null if no authentication type was set. This occurs when user uses SYSTEM_DEFAULTS.
      • hasUserDefinedCredentials

        public boolean hasUserDefinedCredentials()
        Gets whether the user has defined credentials.
        Returns:
        true if the user has defined the credentials to use, false otherwise.
      • isProxyAddressConfigured

        public boolean isProxyAddressConfigured()
        Gets whether the proxy address has been configured. Used to determine whether to use system-defined or user-defined proxy.
        Returns:
        true if the proxy url has been set, and false otherwise.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable