Class AuthScope

java.lang.Object
org.apache.http.auth.AuthScope

@Contract(threading=IMMUTABLE) public class AuthScope extends Object
AuthScope represents an authentication scope consisting of a host name, a port number, a realm name and an authentication scheme name.

This class can also optionally contain a host of origin, if created in response to authentication challenge from a specific host.

Since:
4.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final AuthScope
    Default scope matching any host, port, realm and authentication scheme.
    static final String
    The null value represents any host.
    static final int
    The -1 value represents any port.
    static final String
    The null value represents any realm.
    static final String
    The null value represents any authentication scheme.
    private final String
    The host the credentials apply to.
    private final org.apache.http.HttpHost
    The original host, if known
    private final int
    The port the credentials apply to.
    private final String
    The realm the credentials apply to.
    private final String
    The authentication scheme the credentials apply to.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AuthScope(String host, int port)
    Defines auth scope with the given host and port.
    AuthScope(String host, int port, String realm)
    Defines auth scope with the given host, port and realm.
    AuthScope(String host, int port, String realm, String schemeName)
    Defines auth scope with the given host, port, realm, and schemeName.
    AuthScope(AuthScope authscope)
    Creates a copy of the given credentials scope.
    AuthScope(org.apache.http.HttpHost origin)
    Defines auth scope for a specific host of origin.
    AuthScope(org.apache.http.HttpHost origin, String realm, String schemeName)
    Defines auth scope for a specific host of origin.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
     
    org.apache.http.HttpHost
     
    int
     
     
     
    int
     
    int
    Tests if the authentication scopes match.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • ANY_HOST

      public static final String ANY_HOST
      The null value represents any host. In the future versions of HttpClient the use of this parameter will be discontinued.
    • ANY_PORT

      public static final int ANY_PORT
      The -1 value represents any port.
      See Also:
    • ANY_REALM

      public static final String ANY_REALM
      The null value represents any realm.
    • ANY_SCHEME

      public static final String ANY_SCHEME
      The null value represents any authentication scheme.
    • ANY

      public static final AuthScope ANY
      Default scope matching any host, port, realm and authentication scheme. In the future versions of HttpClient the use of this parameter will be discontinued.
    • scheme

      private final String scheme
      The authentication scheme the credentials apply to.
    • realm

      private final String realm
      The realm the credentials apply to.
    • host

      private final String host
      The host the credentials apply to.
    • port

      private final int port
      The port the credentials apply to.
    • origin

      private final org.apache.http.HttpHost origin
      The original host, if known
  • Constructor Details

    • AuthScope

      public AuthScope(String host, int port, String realm, String schemeName)
      Defines auth scope with the given host, port, realm, and schemeName.
      Parameters:
      host - authentication host. May be ANY_HOST if applies to any host.
      port - authentication port. May be ANY_PORT if applies to any port of the host.
      realm - authentication realm. May be ANY_REALM if applies to any realm on the host.
      schemeName - authentication scheme. May be ANY_SCHEME if applies to any scheme supported by the host.
    • AuthScope

      public AuthScope(org.apache.http.HttpHost origin, String realm, String schemeName)
      Defines auth scope for a specific host of origin.
      Parameters:
      origin - host of origin
      realm - authentication realm. May be ANY_REALM if applies to any realm on the host.
      schemeName - authentication scheme. May be ANY_SCHEME if applies to any scheme supported by the host.
      Since:
      4.2
    • AuthScope

      public AuthScope(org.apache.http.HttpHost origin)
      Defines auth scope for a specific host of origin.
      Parameters:
      origin - host of origin
      Since:
      4.2
    • AuthScope

      public AuthScope(String host, int port, String realm)
      Defines auth scope with the given host, port and realm.
      Parameters:
      host - authentication host. May be ANY_HOST if applies to any host.
      port - authentication port. May be ANY_PORT if applies to any port of the host.
      realm - authentication realm. May be ANY_REALM if applies to any realm on the host.
    • AuthScope

      public AuthScope(String host, int port)
      Defines auth scope with the given host and port.
      Parameters:
      host - authentication host. May be ANY_HOST if applies to any host.
      port - authentication port. May be ANY_PORT if applies to any port of the host.
    • AuthScope

      public AuthScope(AuthScope authscope)
      Creates a copy of the given credentials scope.
  • Method Details

    • getOrigin

      public org.apache.http.HttpHost getOrigin()
      Returns:
      host of origin. If unknown returns @null,
      Since:
      4.4
    • getHost

      public String getHost()
      Returns:
      the host
    • getPort

      public int getPort()
      Returns:
      the port
    • getRealm

      public String getRealm()
      Returns:
      the realm name
    • getScheme

      public String getScheme()
      Returns:
      the scheme type
    • match

      public int match(AuthScope that)
      Tests if the authentication scopes match.
      Returns:
      the match factor. Negative value signifies no match. Non-negative signifies a match. The greater the returned value the closer the match.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also: