Package com.norconex.commons.lang.net
Class ProxySettings
- java.lang.Object
-
- com.norconex.commons.lang.net.ProxySettings
-
- All Implemented Interfaces:
IXMLConfigurable,Serializable
public class ProxySettings extends Object implements IXMLConfigurable, Serializable
Convenience class for implementation requiring proxy settings.
Password encryption:
Passwords can be encrypted using
EncryptionUtil(or command-line "encrypt.bat" or "encrypt.sh" if those are available to you). In order for the password to be decrypted properly, you need to specify the encryption key used to encrypt it. The key can obtained from a few supported locations. The combination of the password key "value" and "source" is used to properly locate the key. The supported sources are:keyThe actual encryption key. filePath to a file containing the encryption key. environmentName of an environment variable containing the key. propertyName of a JVM system property containing the key. XML configuration usage:
<host> <name>(host name)</name> <port>(host port)</port> </host> <scheme>(Default is "http")</scheme> <realm>(Authentication realm. Default is any.)</realm> <credentials> <username>(the username)</username> <password>(the optionally encrypted password)</password> <passwordKey> <value>(The actual password encryption key or a reference to it.)</value> <source>[key|file|environment|property]</source> <size>(Size in bits of encryption key. Default is 128.)</size> </passwordKey> </credentials>The above can be found under any parent tag. See consuming class documentation for exact usage.
- Since:
- 1.14.0
- Author:
- Pascal Essiembre
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ProxySettings()ProxySettings(Host host)ProxySettings(String name, int port)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcopyFrom(ProxySettings another)voidcopyTo(ProxySettings another)booleanequals(Object other)CredentialsgetCredentials()Gets the proxy credentials.HostgetHost()Gets the proxy host.StringgetProxyHost()Deprecated.Since 2.0.0, usegetHost().StringgetProxyPassword()Deprecated.Since 2.0.0, usegetCredentials().EncryptionKeygetProxyPasswordKey()Deprecated.Since 2.0.0, usegetCredentials().intgetProxyPort()Deprecated.Since 2.0.0, usegetHost().StringgetProxyRealm()Deprecated.Since 2.0.0, usegetRealm().StringgetProxyScheme()Deprecated.Since 2.0.0, usegetScheme().StringgetProxyUsername()Deprecated.Since 2.0.0, usegetCredentials().StringgetRealm()Gets the proxy realm.StringgetScheme()Gets the proxy scheme.inthashCode()booleanisSet()voidloadFromXML(XML xml)Load XML configuration values and initialized this object with them.voidsaveToXML(XML xml)Saves this object as XML.ProxySettingssetCredentials(Credentials credentials)Sets the proxy credentials.ProxySettingssetHost(Host host)Sets the proxy host.ProxySettingssetProxyHost(String proxyHost)Deprecated.Since 2.0.0, usesetHost(Host).ProxySettingssetProxyPassword(String proxyPassword)Deprecated.Since 2.0.0, usesetCredentials(Credentials).ProxySettingssetProxyPasswordKey(EncryptionKey proxyPasswordKey)Deprecated.Since 2.0.0, usesetCredentials(Credentials).ProxySettingssetProxyPort(int proxyPort)Deprecated.Since 2.0.0, usesetHost(Host).ProxySettingssetProxyRealm(String proxyRealm)Deprecated.Since 2.0.0, usesetRealm(String).ProxySettingssetProxyScheme(String proxyScheme)Deprecated.Since 2.0.0, usesetScheme(String).ProxySettingssetProxyUsername(String proxyUsername)Deprecated.Since 2.0.0, usesetCredentials(Credentials).ProxySettingssetRealm(String realm)Sets the proxy realm.ProxySettingssetScheme(String scheme)Sets the proxy scheme.StringtoString()
-
-
-
Method Detail
-
getHost
public Host getHost()
Gets the proxy host.- Returns:
- proxy host or
nullif not set - See Also:
isSet()
-
setHost
public ProxySettings setHost(Host host)
Sets the proxy host.- Parameters:
host- proxy host- Returns:
- this
-
getScheme
public String getScheme()
Gets the proxy scheme.- Returns:
- proxy scheme
- Since:
- 2.0.0
-
setScheme
public ProxySettings setScheme(String scheme)
Sets the proxy scheme.- Parameters:
scheme- proxy scheme- Returns:
- this
- Since:
- 2.0.0
-
getCredentials
public Credentials getCredentials()
Gets the proxy credentials.- Returns:
- proxy credentials (never
null) - Since:
- 2.0.0
-
setCredentials
public ProxySettings setCredentials(Credentials credentials)
Sets the proxy credentials.- Parameters:
credentials- proxy credentials- Returns:
- this
- Since:
- 2.0.0
-
getRealm
public String getRealm()
Gets the proxy realm.- Returns:
- proxy realm
- Since:
- 2.0.0
-
setRealm
public ProxySettings setRealm(String realm)
Sets the proxy realm.- Parameters:
realm- proxy realm- Returns:
- this
- Since:
- 2.0.0
-
getProxyHost
@Deprecated public String getProxyHost()
Deprecated.Since 2.0.0, usegetHost().Gets the proxy host.- Returns:
- proxy host
-
setProxyHost
@Deprecated public ProxySettings setProxyHost(String proxyHost)
Deprecated.Since 2.0.0, usesetHost(Host).Sets proxy host.- Parameters:
proxyHost- proxy host- Returns:
- this
-
getProxyPort
@Deprecated public int getProxyPort()
Deprecated.Since 2.0.0, usegetHost().Gets the proxy port.- Returns:
- proxy port
-
setProxyPort
@Deprecated public ProxySettings setProxyPort(int proxyPort)
Deprecated.Since 2.0.0, usesetHost(Host).Sets proxy port.- Parameters:
proxyPort- proxy port- Returns:
- this
-
getProxyScheme
@Deprecated public String getProxyScheme()
Deprecated.Since 2.0.0, usegetScheme().Gets the proxy scheme.- Returns:
- proxy scheme
-
setProxyScheme
@Deprecated public ProxySettings setProxyScheme(String proxyScheme)
Deprecated.Since 2.0.0, usesetScheme(String).Sets proxy scheme.- Parameters:
proxyScheme- proxy scheme- Returns:
- this
-
getProxyUsername
@Deprecated public String getProxyUsername()
Deprecated.Since 2.0.0, usegetCredentials().Gets proxy username.- Returns:
- proxy username
-
setProxyUsername
@Deprecated public ProxySettings setProxyUsername(String proxyUsername)
Deprecated.Since 2.0.0, usesetCredentials(Credentials).Sets proxy username.- Parameters:
proxyUsername- proxy username- Returns:
- this instance
-
getProxyPassword
@Deprecated public String getProxyPassword()
Deprecated.Since 2.0.0, usegetCredentials().Gets proxy password.- Returns:
- proxy password
-
setProxyPassword
@Deprecated public ProxySettings setProxyPassword(String proxyPassword)
Deprecated.Since 2.0.0, usesetCredentials(Credentials).Sets proxy password.- Parameters:
proxyPassword- proxy password- Returns:
- this instance
-
getProxyPasswordKey
@Deprecated public EncryptionKey getProxyPasswordKey()
Deprecated.Since 2.0.0, usegetCredentials().Gets proxy password key.- Returns:
- proxy password key
-
setProxyPasswordKey
@Deprecated public ProxySettings setProxyPasswordKey(EncryptionKey proxyPasswordKey)
Deprecated.Since 2.0.0, usesetCredentials(Credentials).Sets proxy password key.- Parameters:
proxyPasswordKey- proxy password key- Returns:
- this instance
-
getProxyRealm
@Deprecated public String getProxyRealm()
Deprecated.Since 2.0.0, usegetRealm().Gets proxy realm.- Returns:
- proxy realm
-
setProxyRealm
@Deprecated public ProxySettings setProxyRealm(String proxyRealm)
Deprecated.Since 2.0.0, usesetRealm(String).Sets proxy realm.- Parameters:
proxyRealm- proxy realm- Returns:
- this instance
-
isSet
public boolean isSet()
-
copyTo
public void copyTo(ProxySettings another)
-
copyFrom
public void copyFrom(ProxySettings another)
-
loadFromXML
public void loadFromXML(XML xml)
Description copied from interface:IXMLConfigurableLoad XML configuration values and initialized this object with them.- Specified by:
loadFromXMLin interfaceIXMLConfigurable- Parameters:
xml- the XML to load into this object
-
saveToXML
public void saveToXML(XML xml)
Description copied from interface:IXMLConfigurableSaves this object as XML.- Specified by:
saveToXMLin interfaceIXMLConfigurable- Parameters:
xml- the XML that will representing this object
-
-