AuthScopepublic 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
{@link Credentials Credentials} apply to. |
Fields Summary |
---|
public static final String | ANY_HOSTThe null value represents any host. In the future versions of
HttpClient the use of this parameter will be discontinued. | public static final int | ANY_PORTThe -1 value represents any port. | public static final String | ANY_REALMThe null value represents any realm. | public static final String | ANY_SCHEMEThe null value represents any authentication scheme. | public static final AuthScope | ANYDefault scope matching any host, port, realm and authentication scheme.
In the future versions of HttpClient the use of this parameter will be
discontinued. | private final String | schemeThe authentication scheme the credentials apply to. | private final String | realmThe realm the credentials apply to. | private final String | hostThe host the credentials apply to. | private final int | portThe port the credentials apply to. |
Constructors Summary |
---|
public AuthScope(String host, int port, String realm, String scheme)Creates a new credentials scope for the given
host, port, realm, and
authentication scheme.
this.host = (host == null) ? ANY_HOST: host.toLowerCase(Locale.ENGLISH);
this.port = (port < 0) ? ANY_PORT: port;
this.realm = (realm == null) ? ANY_REALM: realm;
this.scheme = (scheme == null) ? ANY_SCHEME: scheme.toUpperCase(Locale.ENGLISH);
| public AuthScope(String host, int port, String realm)Creates a new credentials scope for the given
host, port, realm, and any
authentication scheme.
this(host, port, realm, ANY_SCHEME);
| public AuthScope(String host, int port)Creates a new credentials scope for the given
host, port, any realm name, and any
authentication scheme.
this(host, port, ANY_REALM, ANY_SCHEME);
| public AuthScope(AuthScope authscope)Creates a copy of the given credentials scope.
super();
if (authscope == null) {
throw new IllegalArgumentException("Scope may not be null");
}
this.host = authscope.getHost();
this.port = authscope.getPort();
this.realm = authscope.getRealm();
this.scheme = authscope.getScheme();
|
Methods Summary |
---|
public boolean | equals(java.lang.Object o)
if (o == null) {
return false;
}
if (o == this) {
return true;
}
if (!(o instanceof AuthScope)) {
return super.equals(o);
}
AuthScope that = (AuthScope) o;
return
LangUtils.equals(this.host, that.host)
&& this.port == that.port
&& LangUtils.equals(this.realm, that.realm)
&& LangUtils.equals(this.scheme, that.scheme);
| public java.lang.String | getHost()
return this.host;
| public int | getPort()
return this.port;
| public java.lang.String | getRealm()
return this.realm;
| public java.lang.String | getScheme()
return this.scheme;
| public int | hashCode()
int hash = LangUtils.HASH_SEED;
hash = LangUtils.hashCode(hash, this.host);
hash = LangUtils.hashCode(hash, this.port);
hash = LangUtils.hashCode(hash, this.realm);
hash = LangUtils.hashCode(hash, this.scheme);
return hash;
| public int | match(org.apache.http.auth.AuthScope that)Tests if the authentication scopes match.
int factor = 0;
if (LangUtils.equals(this.scheme, that.scheme)) {
factor += 1;
} else {
if (this.scheme != ANY_SCHEME && that.scheme != ANY_SCHEME) {
return -1;
}
}
if (LangUtils.equals(this.realm, that.realm)) {
factor += 2;
} else {
if (this.realm != ANY_REALM && that.realm != ANY_REALM) {
return -1;
}
}
if (this.port == that.port) {
factor += 4;
} else {
if (this.port != ANY_PORT && that.port != ANY_PORT) {
return -1;
}
}
if (LangUtils.equals(this.host, that.host)) {
factor += 8;
} else {
if (this.host != ANY_HOST && that.host != ANY_HOST) {
return -1;
}
}
return factor;
| public java.lang.String | toString()
StringBuffer buffer = new StringBuffer();
if (this.scheme != null) {
buffer.append(this.scheme.toUpperCase(Locale.ENGLISH));
buffer.append(' ");
}
if (this.realm != null) {
buffer.append('\'");
buffer.append(this.realm);
buffer.append('\'");
} else {
buffer.append("<any realm>");
}
if (this.host != null) {
buffer.append('@");
buffer.append(this.host);
if (this.port >= 0) {
buffer.append(':");
buffer.append(this.port);
}
}
return buffer.toString();
|
|