Class NetProxyInfo

java.lang.Object
com.pnfsoftware.jeb.util.net.NetProxyInfo

public class NetProxyInfo extends Object
Network proxy information.

Immutable objects; safe comparison via hashCode/equals.

  • Field Details

    • INDEX_DIRECT

      public static final int INDEX_DIRECT
      Proxy type index for direct connections.
      See Also:
    • INDEX_HTTP

      public static final int INDEX_HTTP
      Proxy type index for HTTP proxies.
      See Also:
    • INDEX_SOCKS

      public static final int INDEX_SOCKS
      Proxy type index for SOCKS proxies.
      See Also:
    • TYPE_DIRECT

      public static final String TYPE_DIRECT
      Proxy type string for direct connections.
      See Also:
    • TYPE_HTTP

      public static final String TYPE_HTTP
      Proxy type string for HTTP proxies.
      See Also:
    • TYPE_SOCKS

      public static final String TYPE_SOCKS
      Proxy type string for SOCKS proxies.
      See Also:
  • Constructor Details

    • NetProxyInfo

      public NetProxyInfo(String typestr, String hostname, int port)
      Create proxy information without credentials or a whitelist.
      Parameters:
      typestr - proxy type string
      hostname - proxy host name
      port - proxy port
    • NetProxyInfo

      public NetProxyInfo(String typestr, String hostname, int port, String user, String password)
      Create proxy information with optional credentials and no whitelist.
      Parameters:
      typestr - proxy type string
      hostname - proxy host name
      port - proxy port
      user - optional proxy user name
      password - 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 string
      hostname - proxy host name
      port - proxy port
      user - optional proxy user name
      password - optional proxy password
      rawWhitelist - optional comma-separated whitelist patterns
  • Method Details

    • getProxyTypes

      public static List<String> getProxyTypes()
      Get supported proxy type strings.
      Returns:
      supported proxy type strings
    • getProxyTypesWithDescriptions

      public static List<String> getProxyTypesWithDescriptions()
      Get user-facing descriptions of supported proxy types.
      Returns:
      supported proxy type descriptions
    • getProxyTypeFromIndex

      public static String getProxyTypeFromIndex(int index)
      Convert a proxy type index to its type string.
      Parameters:
      index - proxy type index
      Returns:
      the matching type string, or TYPE_DIRECT for an invalid index
    • parse

      public static NetProxyInfo parse(String s)
      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

      public Proxy getProxy()
      Get the Java proxy object.
      Returns:
      the proxy object
    • getType

      public String 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

      public String 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

      public String getUser()
      Get the effective proxy user name.
      Returns:
      the user name, or null
    • getPassword

      public String 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

      public String getWhitelist()
      Get the effective whitelist.
      Returns:
      the comma-separated whitelist, or null
    • isWhitelisted

      public boolean isWhitelisted(String url)
      Determine whether a URL matches the proxy whitelist.
      Parameters:
      url - URL to test
      Returns:
      true if the URL host is whitelisted
    • getRecordedHostname

      public String 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

      public String getRecordedUser()
      Get the originally recorded user name.
      Returns:
      the recorded user name, or null
    • getRecordedPassword

      public String getRecordedPassword()
      Get the originally recorded password.
      Returns:
      the recorded password, or null
    • getRecordedWhitelist

      public String getRecordedWhitelist()
      Get the originally recorded whitelist.
      Returns:
      the recorded whitelist, or null
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object