Class ProxyOptions

  • All Implemented Interfaces:
    AutoCloseable

    public class ProxyOptions
    extends Object
    implements AutoCloseable
    Properties for configuring proxies with Event Hubs.
    • Field Detail

      • PROXY_USERNAME

        public static final String PROXY_USERNAME
        The configuration key for containing the username who authenticates with the proxy.
        See Also:
        Constant Field Values
      • PROXY_PASSWORD

        public static final String PROXY_PASSWORD
        The configuration key for containing the password for the username who authenticates with the proxy.
        See Also:
        Constant Field Values
      • SYSTEM_DEFAULTS

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

      • ProxyOptions

        public ProxyOptions​(ProxyAuthenticationType authentication,
                            Proxy proxyAddress,
                            String username,
                            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:
        NullPointerException - if authentication is null.
        IllegalArgumentException - if authentication is ProxyAuthenticationType.BASIC or ProxyAuthenticationType.DIGEST and username or password are null.
    • Method Detail

      • getAuthentication

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

        public Proxy getProxyAddress()
        Gets the proxy address.
        Returns:
        the proxy address. Return null if no proxy address was set This occurs when user uses SYSTEM_DEFAULTS.
      • getCredential

        public PasswordAuthentication getCredential()
        Gets the credentials user provided for authentication of proxy server.
        Returns:
        the username and password to use. Return null if no credential 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()
        Disposes of the configuration along with potential credentials.
        Specified by:
        close in interface AutoCloseable