public class

AuthScope

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

Class Overview

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.

Summary

Constants
AuthScope ANY Default scope matching any host, port, realm and authentication scheme.
String ANY_HOST The null value represents any host.
int ANY_PORT The -1 value represents any port.
String ANY_REALM The null value represents any realm.
String ANY_SCHEME The null value represents any authentication scheme.
Public Constructors
AuthScope(String host, int port, String realm, String scheme)
Creates a new credentials scope for the given host, port, realm, and 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)
Creates a new credentials scope for the given host, port, any realm name, and any authentication scheme.
AuthScope(AuthScope authscope)
Creates a copy of the given credentials scope.
Public Methods
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.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final AuthScope ANY

Since: API Level 1

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

public static final String ANY_HOST

Since: API Level 1

The null value represents any host. In the future versions of HttpClient the use of this parameter will be discontinued.

public static final int ANY_PORT

Since: API Level 1

The -1 value represents any port.

Constant Value: -1 (0xffffffff)

public static final String ANY_REALM

Since: API Level 1

The null value represents any realm.

public static final String ANY_SCHEME

Since: API Level 1

The null value represents any authentication scheme.

Public Constructors

public AuthScope (String host, int port, String realm, String scheme)

Since: API Level 1

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.

public AuthScope (String host, int port, String realm)

Since: API Level 1

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.

public AuthScope (String host, int port)

Since: API Level 1

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.

public AuthScope (AuthScope authscope)

Since: API Level 1

Creates a copy of the given credentials scope.

Public Methods

public boolean equals (Object o)

Since: API Level 1

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 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.

Parameters
o the object to compare this instance with.
Returns
  • true if the specified object is equal to this Object; false otherwise.
See Also

public String getHost ()

Since: API Level 1

Returns
  • the host

public int getPort ()

Since: API Level 1

Returns
  • the port

public String getRealm ()

Since: API Level 1

Returns
  • the realm name

public String getScheme ()

Since: API Level 1

Returns
  • the scheme type

public int hashCode ()

Since: API Level 1

Returns an integer hash code for this object. By contract, any two objects for which equals(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.

Returns
  • this object's hash code.
See Also

public int match (AuthScope that)

Since: API Level 1

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.

public String toString ()

Since: API Level 1

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.

Returns
  • a printable representation of this object.
See Also