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:key
The actual encryption key. file
Path to a file containing the encryption key. environment
Name of an environment variable containing the key. property
Name 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 void
copyFrom(ProxySettings another)
void
copyTo(ProxySettings another)
boolean
equals(Object other)
Credentials
getCredentials()
Gets the proxy credentials.Host
getHost()
Gets the proxy host.String
getProxyHost()
Deprecated.Since 2.0.0, usegetHost()
.String
getProxyPassword()
Deprecated.Since 2.0.0, usegetCredentials()
.EncryptionKey
getProxyPasswordKey()
Deprecated.Since 2.0.0, usegetCredentials()
.int
getProxyPort()
Deprecated.Since 2.0.0, usegetHost()
.String
getProxyRealm()
Deprecated.Since 2.0.0, usegetRealm()
.String
getProxyScheme()
Deprecated.Since 2.0.0, usegetScheme()
.String
getProxyUsername()
Deprecated.Since 2.0.0, usegetCredentials()
.String
getRealm()
Gets the proxy realm.String
getScheme()
Gets the proxy scheme.int
hashCode()
boolean
isSet()
void
loadFromXML(XML xml)
Load XML configuration values and initialized this object with them.void
saveToXML(XML xml)
Saves this object as XML.ProxySettings
setCredentials(Credentials credentials)
Sets the proxy credentials.ProxySettings
setHost(Host host)
Sets the proxy host.ProxySettings
setProxyHost(String proxyHost)
Deprecated.Since 2.0.0, usesetHost(Host)
.ProxySettings
setProxyPassword(String proxyPassword)
Deprecated.Since 2.0.0, usesetCredentials(Credentials)
.ProxySettings
setProxyPasswordKey(EncryptionKey proxyPasswordKey)
Deprecated.Since 2.0.0, usesetCredentials(Credentials)
.ProxySettings
setProxyPort(int proxyPort)
Deprecated.Since 2.0.0, usesetHost(Host)
.ProxySettings
setProxyRealm(String proxyRealm)
Deprecated.Since 2.0.0, usesetRealm(String)
.ProxySettings
setProxyScheme(String proxyScheme)
Deprecated.Since 2.0.0, usesetScheme(String)
.ProxySettings
setProxyUsername(String proxyUsername)
Deprecated.Since 2.0.0, usesetCredentials(Credentials)
.ProxySettings
setRealm(String realm)
Sets the proxy realm.ProxySettings
setScheme(String scheme)
Sets the proxy scheme.String
toString()
-
-
-
Method Detail
-
getHost
public Host getHost()
Gets the proxy host.- Returns:
- proxy host or
null
if 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:IXMLConfigurable
Load XML configuration values and initialized this object with them.- Specified by:
loadFromXML
in interfaceIXMLConfigurable
- Parameters:
xml
- the XML to load into this object
-
saveToXML
public void saveToXML(XML xml)
Description copied from interface:IXMLConfigurable
Saves this object as XML.- Specified by:
saveToXML
in interfaceIXMLConfigurable
- Parameters:
xml
- the XML that will representing this object
-
-