Package org.apache.http.auth
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 AuthScopeANYDefault scope matching any host, port, realm and authentication scheme.static StringANY_HOSTThe null value represents any host.static intANY_PORTThe -1 value represents any port.static StringANY_REALMThe null value represents any realm.static StringANY_SCHEMEThe 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 booleanequals(Object o)Compares this instance with the specified object and indicates if they are equal.StringgetHost()intgetPort()StringgetRealm()StringgetScheme()inthashCode()Returns an integer hash code for this object.intmatch(AuthScope that)Tests if the authentication scopes match.StringtoString()Returns a string containing a concise, human-readable description of this object.
-
Field Details
-
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_PORTThe -1 value represents any port.- See Also:
- Constant Field Values
-
ANY_REALM
The null value represents any realm. -
ANY_SCHEME
The null value represents any authentication scheme. -
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
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
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
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
Creates a copy of the given credentials scope.
-
-
Method Details
-
getHost
- Returns:
- the host
-
getPort
public int getPort()- Returns:
- the port
-
getRealm
- Returns:
- the realm name
-
getScheme
- Returns:
- the scheme type
-
match
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
Description copied from class:ObjectCompares this instance with the specified object and indicates if they are equal. In order to be equal,omust 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
trueonly ifthis == o. See Writing a correctequalsmethod if you intend implementing your ownequalsmethod.The general contract for the
equalsandObject.hashCode()methods is that ifequalsreturnstruefor any two objects, thenhashCode()must return the same value for these objects. This means that subclasses ofObjectusually override either both methods or neither of them.- Overrides:
equalsin classObject- Parameters:
o- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.equals(Object)
-
toString
Description copied from class:ObjectReturns 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
toStringmethod if you intend implementing your owntoStringmethod.- Overrides:
toStringin classObject- Returns:
- a printable representation of this object.
- See Also:
Object.toString()
-
hashCode
public int hashCode()Description copied from class:ObjectReturns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually 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
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.hashCode()
-