Package com.pnfsoftware.jeb.util.net
Class NetProxyInfo
java.lang.Object
com.pnfsoftware.jeb.util.net.NetProxyInfo
Network proxy information.
Immutable objects; safe comparison via hashCode/equals.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intProxy type index for direct connections.static final intProxy type index for HTTP proxies.static final intProxy type index for SOCKS proxies.static final StringProxy type string for direct connections.static final StringProxy type string for HTTP proxies.static final StringProxy type string for SOCKS proxies. -
Constructor Summary
ConstructorsConstructorDescriptionNetProxyInfo(String typestr, String hostname, int port) Create proxy information without credentials or a whitelist.NetProxyInfo(String typestr, String hostname, int port, String user, String password) Create proxy information with optional credentials and no whitelist.NetProxyInfo(String typestr, String hostname, int port, String user, String password, String rawWhitelist) Create proxy information. -
Method Summary
Modifier and TypeMethodDescriptionbooleanokhttp3.AuthenticatorGet an OkHttp proxy authenticator.Get the effective proxy host name.Get the effective proxy password.intgetPort()Get the effective proxy port.getProxy()Get the Java proxy object.static StringgetProxyTypeFromIndex(int index) Convert a proxy type index to its type string.Get supported proxy type strings.Get user-facing descriptions of supported proxy types.Get the originally recorded host name.Get the originally recorded password.intGet the originally recorded port.Get the originally recorded user name.Get the originally recorded whitelist.getType()Get the proxy type string.intGet the proxy type index.getUser()Get the effective proxy user name.Get the effective whitelist.booleanDetermine whether proxy credentials are available.inthashCode()booleanisProxy()Determine whether this object describes a real proxy.booleanisWhitelisted(String url) Determine whether a URL matches the proxy whitelist.static NetProxyInfoParse proxy information from its string representation.toString()
-
Field Details
-
INDEX_DIRECT
public static final int INDEX_DIRECTProxy type index for direct connections.- See Also:
-
INDEX_HTTP
public static final int INDEX_HTTPProxy type index for HTTP proxies.- See Also:
-
INDEX_SOCKS
public static final int INDEX_SOCKSProxy type index for SOCKS proxies.- See Also:
-
TYPE_DIRECT
Proxy type string for direct connections.- See Also:
-
TYPE_HTTP
Proxy type string for HTTP proxies.- See Also:
-
TYPE_SOCKS
Proxy type string for SOCKS proxies.- See Also:
-
-
Constructor Details
-
NetProxyInfo
Create proxy information without credentials or a whitelist.- Parameters:
typestr- proxy type stringhostname- proxy host nameport- proxy port
-
NetProxyInfo
Create proxy information with optional credentials and no whitelist.- Parameters:
typestr- proxy type stringhostname- proxy host nameport- proxy portuser- optional proxy user namepassword- optional proxy password
-
NetProxyInfo
public NetProxyInfo(String typestr, String hostname, int port, String user, String password, String rawWhitelist) Create proxy information.- Parameters:
typestr- proxy type stringhostname- proxy host nameport- proxy portuser- optional proxy user namepassword- optional proxy passwordrawWhitelist- optional comma-separated whitelist patterns
-
-
Method Details
-
getProxyTypes
Get supported proxy type strings.- Returns:
- supported proxy type strings
-
getProxyTypesWithDescriptions
Get user-facing descriptions of supported proxy types.- Returns:
- supported proxy type descriptions
-
getProxyTypeFromIndex
Convert a proxy type index to its type string.- Parameters:
index- proxy type index- Returns:
- the matching type string, or
TYPE_DIRECTfor an invalid index
-
parse
Parse proxy information from its string representation.- Parameters:
s- serialized proxy information- Returns:
- a proxy information object, or null if parsing failed
-
isProxy
public boolean isProxy()Determine whether this object describes a real proxy.- Returns:
- true for HTTP or SOCKS proxy types
-
getProxy
Get the Java proxy object.- Returns:
- the proxy object
-
getType
Get the proxy type string.- Returns:
- one of the
TYPE_*constants
-
getTypeIndex
public int getTypeIndex()Get the proxy type index.- Returns:
- one of the
INDEX_*constants
-
getHostname
Get the effective proxy host name.- Returns:
- the host name, or null for direct connections
-
getPort
public int getPort()Get the effective proxy port.- Returns:
- the proxy port, or 0 for direct connections
-
getUser
Get the effective proxy user name.- Returns:
- the user name, or null
-
getPassword
Get the effective proxy password.- Returns:
- the password, or null
-
hasCredentials
public boolean hasCredentials()Determine whether proxy credentials are available.- Returns:
- true if a user name is available
-
getAuthenticator
public okhttp3.Authenticator getAuthenticator()Get an OkHttp proxy authenticator.- Returns:
- an authenticator, or null if no credentials are available
-
getWhitelist
Get the effective whitelist.- Returns:
- the comma-separated whitelist, or null
-
isWhitelisted
Determine whether a URL matches the proxy whitelist.- Parameters:
url- URL to test- Returns:
- true if the URL host is whitelisted
-
getRecordedHostname
Get the originally recorded host name.- Returns:
- the recorded host name, or null
-
getRecordedPort
public int getRecordedPort()Get the originally recorded port.- Returns:
- the recorded port
-
getRecordedUser
Get the originally recorded user name.- Returns:
- the recorded user name, or null
-
getRecordedPassword
Get the originally recorded password.- Returns:
- the recorded password, or null
-
getRecordedWhitelist
Get the originally recorded whitelist.- Returns:
- the recorded whitelist, or null
-
hashCode
public int hashCode() -
equals
-
toString
-