Class ProxySettings

java.lang.Object
com.fathzer.plugin.loader.utils.ProxySettings

public class ProxySettings extends Object
A class that represents a proxy setting.
  • Constructor Details

    • ProxySettings

      public ProxySettings(String host, int port, PasswordAuthentication login)
      Constructor.
      Parameters:
      host - The proxy's host name
      port - The proxy's port
      login - The login used for authentication (null if no authentication)
  • Method Details

    • fromString

      public static ProxySettings fromString(String proxy)
      Creates a proxy setting from a string.
      Parameters:
      proxy - The address in the format [user:[password]@]host:port
      Returns:
      A proxy setting or null if argument is null or empty
      Throws:
      IllegalArgumentException - if argument is incorrect
    • toProxy

      public Proxy toProxy()
      Converts this to a java.net.Proxy instance.
      Returns:
      a Proxy instance
    • getHost

      public String getHost()
      Gets the proxy's host name.
      Returns:
      a string
    • getPort

      public int getPort()
      Gets the proxy's port.
      Returns:
      a integer
    • getLogin

      public PasswordAuthentication getLogin()
      Gets the proxy's user login.
      Returns:
      a string or null if no authentication is set
    • getBase64Login

      public String getBase64Login()
      Gets the login converted to a Base64 string.
      The content is user:pwd encoded in base 64. It can be used with "Basic " prefix in "Proxy-Authorization" http header.
      Returns:
      a base64 string or null is no login is defined
    • toString

      public String toString()
      Overrides:
      toString in class Object