java.lang.Object
org.bzdev.swing.proxyconf.ProxyInfo
Proxy-configuration data.
This class is provided to encode the configurations
of proxies for HTTP, HTTPS, FTP, and SOCKS - the
protocols which java.net recognizes as ones where
proxies may be used.
The methods test if a an instance of this class is meant to configure a proxy for a protocol and if so, will information needed to use the proxy (typically its host name or IP address and its TCP or UDP port number). If not configured, the application is expected to use the preference database to look up the values.
There are two constructors. One takes a single argument, a preference-node name. The use of this constructor implies that a preference database should be used to configure proxies. The second takes 5 arguments: a preference-node name and 4 boolean values indicating which proxies are being configured.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determine if an FTP proxy is configured by this object.boolean
Determine if an HTTP proxy is configured by this objectboolean
Determine if an HTTPS proxy is configured by this object.boolean
Determine if a SOCKS proxy is configured by this object.Get the host name or IP addresses that should not use an FTP proxy.Get the host name or IP address of an FTP proxy.Get the TCP port of an FTP proxy.Get the host name or IP addresses that should not use an HTTP proxy.Get the host name or IP address of an HTTP proxy.Get the TCP port of an HTTP proxy.Get the host name or IP address of an HTTPS proxy.Get the TCP port of an HTTPS proxy.Get the host name or IP address of a SOCKS proxy.Get the TCP port of a SOCKS proxy.boolean
Get system-proxy mode.void
setFtpNonProxyHosts
(String value) Set the host name or IP addresses that should not use an FTP proxy.void
setFtpProxyHost
(String value) Set the host name or IP address of an FTP proxy.void
setFtpProxyPort
(String value) Set the TCP port of an FTP proxy.void
setHttpNonProxyHosts
(String value) Set the host name or IP addresses that should not use an HTTP proxy.void
setHttpProxyHost
(String value) Set the host name or IP address of an HTTP proxy.void
setHttpProxyPort
(String value) Set the TCP port of an HTTP proxy.void
setHttpsProxyHost
(String value) Set the host name or IP address of an HTTP proxy.void
setHttpsProxyPort
(String value) Set the TCP port of an HTTPS proxy.void
setSocksProxyHost
(String value) Set the host name or IP address of a SOCKS proxy.void
setSocksProxyPort
(String value) Set the TCP port of a SOCKS proxy.void
setUseSystemProxies
(boolean value) Set system-proxy mode.boolean
Determine if configuration data should be taken from the Java preferences database.
-
Field Details
-
DEFAULT_PREF_NODE
Default preference node name. This constant is provided as a convenience for use byProxyComponent.setPrefNodeName(String)
. Its value is "org/bzdev/swing/proxyconf".- See Also:
-
-
Constructor Details
-
ProxyInfo
public ProxyInfo()Constructor specifying use of preferences. Any values for proxies set by this class should be ignored as the values configured are expected to be those provided by preferences. -
ProxyInfo
public ProxyInfo(boolean configHttp, boolean configHttps, boolean configFtp, boolean configSocks) Constructor. Sets which proxies are of interest to the application and should be configured for it. When a boolean argument is false, this class does not configure the corresponding proxy and instead the preference database is used. To disable a proxy reliably, set the flag to true and set the values for the proxy to null.- Parameters:
configHttp
- true if an HTTP proxy is to be configured by this object; false otherwiseconfigHttps
- true if an HTTPS proxy is to be configured by this object; false otherwiseconfigFtp
- true if an FTP proxy is to be configured by this object; false otherwiseconfigSocks
- true if a SOCKS proxy is to be configured by this object; false otherwise
-
-
Method Details
-
usePreferences
public boolean usePreferences()Determine if configuration data should be taken from the Java preferences database.- Returns:
- true if Java preferences should be used; false if the configurations in this object should be used.
-
getConfigHttp
public boolean getConfigHttp()Determine if an HTTP proxy is configured by this object- Returns:
- true if an HTTP proxy is configured, false otherwise
-
getConfigHttps
public boolean getConfigHttps()Determine if an HTTPS proxy is configured by this object.- Returns:
- true if an HTTPS proxy is configured, false otherwise
-
getConfigFtp
public boolean getConfigFtp()Determine if an FTP proxy is configured by this object.- Returns:
- true if an FTP proxy is configured, false otherwise
-
getConfigSocks
public boolean getConfigSocks()Determine if a SOCKS proxy is configured by this object.- Returns:
- true if a SOCKS proxy is configured, false otherwise
-
setUseSystemProxies
public void setUseSystemProxies(boolean value) Set system-proxy mode.- Parameters:
value
- true if system proxies should be used; false otherwise
-
getUseSystemProxies
public boolean getUseSystemProxies()Get system-proxy mode.- Returns:
- true if system proxies should be used; false otherwise
-
setHttpProxyHost
Set the host name or IP address of an HTTP proxy.- Parameters:
value
- the IP address or host name of the HTTP proxy
-
getHttpProxyHost
Get the host name or IP address of an HTTP proxy.- Returns:
- the host name or IP address of the HTTP proxy
-
setHttpProxyPort
Set the TCP port of an HTTP proxy.- Parameters:
value
- the TCP port of the HTTP proxy
-
getHttpProxyPort
Get the TCP port of an HTTP proxy.- Returns:
- the TCP port the HTTP proxy
-
setHttpNonProxyHosts
Set the host name or IP addresses that should not use an HTTP proxy.- Parameters:
value
- the IP addresses or host names, separated by a '|'; null to indicate none.
-
getHttpNonProxyHosts
Get the host name or IP addresses that should not use an HTTP proxy.- Returns:
- the host names and IP addresses, separated by a '|'; null if none have been set.
-
setHttpsProxyHost
Set the host name or IP address of an HTTP proxy.- Parameters:
value
- the IP address or host name of the HTTP proxy; null if none
-
getHttpsProxyHost
Get the host name or IP address of an HTTPS proxy.- Returns:
- the host name or IP address of the HTTPS proxy
-
setHttpsProxyPort
Set the TCP port of an HTTPS proxy.- Parameters:
value
- the TCP port of the HTTPS proxy; null for no proxy
-
getHttpsProxyPort
Get the TCP port of an HTTPS proxy.- Returns:
- the TCP port the HTTPS proxy; null if one is has not been set
-
setFtpProxyHost
Set the host name or IP address of an FTP proxy.- Parameters:
value
- the IP address or host name of the FTP proxy; null indicates no proxy
-
getFtpProxyHost
Get the host name or IP address of an FTP proxy.- Returns:
- the host name or IP address of the FTP proxy; null if there is none
-
setFtpProxyPort
Set the TCP port of an FTP proxy.- Parameters:
value
- the TCP port of the FTP proxy; null for no proxy
-
getFtpProxyPort
Get the TCP port of an FTP proxy.- Returns:
- the TCP port the FTP proxy; null if no proxy was specified
-
setFtpNonProxyHosts
Set the host name or IP addresses that should not use an FTP proxy.- Parameters:
value
- the IP addresses or host names, separated by a '|'; null to indicate none.
-
getFtpNonProxyHosts
Get the host name or IP addresses that should not use an FTP proxy.- Returns:
- the host names and IP addresses, separated by a '|'; null if none have been set.
-
setSocksProxyHost
Set the host name or IP address of a SOCKS proxy.- Parameters:
value
- the IP address or host name of the SOCKS proxy; null if no SOCKS proxy is specified
-
getSocksProxyHost
Get the host name or IP address of a SOCKS proxy.- Returns:
- the host name or IP address of the SOCKS proxy; null if there is none
-
setSocksProxyPort
Set the TCP port of a SOCKS proxy.- Parameters:
value
- the TCP port of the SOCKS proxy; null for no proxy
-
getSocksProxyPort
Get the TCP port of a SOCKS proxy.- Returns:
- the TCP port the SOCKS proxy; null for no proxy specified
-