Class AuthScope

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

public class AuthScope
extends Object
The class represents an authentication scope consisting of a host name, a port number, a realm name and an authentication scheme name which Credentials apply to.
Since:
4.0
Author:
Oleg Kalnichevski, Adrian Sutton
  • Field Summary

    Fields
    Modifier and Type Field Description
    static AuthScope ANY
    Default scope matching any host, port, realm and authentication scheme.
    static String ANY_HOST
    The null value represents any host.
    static int ANY_PORT
    The -1 value represents any port.
    static String ANY_REALM
    The null value represents any realm.
    static String ANY_SCHEME
    The null value represents any authentication scheme.
  • Constructor Summary

    Constructors
    Constructor Description
    AuthScope​(String host, int port)
    Creates a new credentials scope for the given host, port, any realm name, and any authentication scheme.
    AuthScope​(String host, int port, String realm)
    Creates a new credentials scope for the given host, port, realm, and any authentication scheme.
    AuthScope​(String host, int port, String realm, String scheme)
    Creates a new credentials scope for the given host, port, realm, and authentication scheme.
    AuthScope​(AuthScope authscope)
    Creates a copy of the given credentials scope.
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(Object o)
    Compares this instance with the specified object and indicates if they are equal.
    String getHost()  
    int getPort()  
    String getRealm()  
    String getScheme()  
    int hashCode()
    Returns an integer hash code for this object.
    int match​(AuthScope that)
    Tests if the authentication scopes match.
    String toString()
    Returns a string containing a concise, human-readable description of this object.

    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:
      Constant Field Values
    • 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.
  • Constructor Details

    • AuthScope

      public AuthScope​(String host, int port, String realm, String scheme)
      Creates a new credentials scope for the given host, port, realm, and authentication scheme.
      Parameters:
      host - the host the credentials apply to. May be set to null if credenticals are applicable to any host.
      port - the port the credentials apply to. May be set to negative value if credenticals are applicable to any port.
      realm - the realm the credentials apply to. May be set to null if credenticals are applicable to any realm.
      scheme - the authentication scheme the credentials apply to. May be set to null if credenticals are applicable to any authentication scheme.
    • AuthScope

      public AuthScope​(String host, int port, String realm)
      Creates a new credentials scope for the given host, port, realm, and any authentication scheme.
      Parameters:
      host - the host the credentials apply to. May be set to null if credenticals are applicable to any host.
      port - the port the credentials apply to. May be set to negative value if credenticals are applicable to any port.
      realm - the realm the credentials apply to. May be set to null if credenticals are applicable to any realm.
    • AuthScope

      public AuthScope​(String host, int port)
      Creates a new credentials scope for the given host, port, any realm name, and any authentication scheme.
      Parameters:
      host - the host the credentials apply to. May be set to null if credenticals are applicable to any host.
      port - the port the credentials apply to. May be set to negative value if credenticals are applicable to any port.
    • AuthScope

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

    • 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)
      Description copied from class: Object
      Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.

      The default implementation returns true only if this == o. See Writing a correct equals method if you intend implementing your own equals method.

      The general contract for the equals and Object.hashCode() methods is that if equals returns true for any two objects, then hashCode() must return the same value for these objects. This means that subclasses of Object usually override either both methods or neither of them.

      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare this instance with.
      Returns:
      true if the specified object is equal to this Object; false otherwise.
      See Also:
      Object.equals(Object)
    • toString

      public String toString()
      Description copied from class: Object
      Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
         getClass().getName() + '@' + Integer.toHexString(hashCode())

      See Writing a useful toString method if you intend implementing your own toString method.

      Overrides:
      toString in class Object
      Returns:
      a printable representation of this object.
      See Also:
      Object.toString()
    • hashCode

      public int hashCode()
      Description copied from class: Object
      Returns an integer hash code for this object. By contract, any two objects for which Object.equals(java.lang.Object) returns true must return the same hash code value. This means that subclasses of Object usually override both methods or neither method.

      Note that hash values must not change over time unless information used in equals comparisons also changes.

      See Writing a correct hashCode method if you intend implementing your own hashCode method.

      Overrides:
      hashCode in class Object
      Returns:
      this object's hash code.
      See Also:
      Object.hashCode()