Package com.azure.core.amqp
Class ProxyOptions
java.lang.Object
com.azure.core.amqp.ProxyOptions
- All Implemented Interfaces:
AutoCloseable
Properties for configuring proxies with Event Hubs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe configuration key for containing the authentication type to be used by the proxy.static final StringThe configuration key for containing the password for the username who authenticates with the proxy.static final StringThe configuration key for containing the username who authenticates with the proxy.static final ProxyOptionsGets the system defaults for proxy configuration and authentication. -
Constructor Summary
ConstructorsConstructorDescriptionProxyOptions(ProxyAuthenticationType authentication, Proxy proxyAddress, String username, String password) Creates a proxy configuration that uses theproxyAddressand authenticates with providedusername,passwordandauthentication. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Disposes of the configuration along with potential credentials.static ProxyOptionsfromConfiguration(Configuration configuration) Attempts to load a proxy from the configuration.Gets the proxy authentication type.Gets the credentials user provided for authentication of proxy server.Gets the proxy address.booleanGets whether the user has defined credentials.booleanGets whether the proxy address has been configured.
-
Field Details
-
PROXY_USERNAME
The configuration key for containing the username who authenticates with the proxy.- See Also:
-
PROXY_PASSWORD
The configuration key for containing the password for the username who authenticates with the proxy.- See Also:
-
PROXY_AUTHENTICATION_TYPE
The configuration key for containing the authentication type to be used by the proxy. This can one of three values - - NONE - BASIC - DIGEST as defined in ProxyAuthenticationType- See Also:
-
SYSTEM_DEFAULTS
Gets the system defaults for proxy configuration and authentication.
-
-
Constructor Details
-
ProxyOptions
public ProxyOptions(ProxyAuthenticationType authentication, Proxy proxyAddress, String username, String password) Creates a proxy configuration that uses theproxyAddressand authenticates with providedusername,passwordandauthentication.- Parameters:
authentication- Authentication method to preemptively use with proxy.proxyAddress- Proxy to use. Ifnullis passed in, then the system configuredProxyis used.username- Optional. Username used to authenticate with proxy. If not specified, the system-wideAuthenticatoris used to fetch credentials.password- Optional. Password used to authenticate with proxy.- Throws:
NullPointerException- ifauthenticationisnull.IllegalArgumentException- ifauthenticationisProxyAuthenticationType.BASICorProxyAuthenticationType.DIGESTandusernameorpasswordarenull.
-
-
Method Details
-
fromConfiguration
Attempts to load a proxy from the configuration.- Parameters:
configuration- TheConfigurationthat is used to load proxy configurations from the environment. Ifnullis passed thenConfiguration.getGlobalConfiguration()will be used.- Returns:
- A
ProxyOptionsreflecting a proxy loaded from the environment, if no proxy is foundnullwill be returned. - Throws:
RuntimeException- If passedConfigurationcontains invalid configuration options,RuntimeExceptionis thrown.
-
getAuthentication
Gets the proxy authentication type.- Returns:
- the proxy authentication type to use. Returns
nullif no authentication type was set. This occurs when user usesSYSTEM_DEFAULTS.
-
getProxyAddress
Gets the proxy address.- Returns:
- the proxy address. Return
nullif no proxy address was set This occurs when user usesSYSTEM_DEFAULTS.
-
getCredential
Gets the credentials user provided for authentication of proxy server.- Returns:
- the username and password to use. Return
nullif no credential was set. This occurs when user usesSYSTEM_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:
closein interfaceAutoCloseable
-