* Test that the httpURL is the same with the client.
*
* @return true if the given httpURL is the client for this resource.
*/
protected synchronized boolean isTheClient() throws URIException {
HostConfiguration hostConfig = client.getHostConfiguration();
Credentials creds =
client.getState().getCredentials(null, hostConfig.getHost());
String userName = null;
String password = null;
if (creds instanceof UsernamePasswordCredentials) {
UsernamePasswordCredentials upc = (UsernamePasswordCredentials) creds;
userName = upc.getUserName();
password = upc.getPassword();
}
String ref = httpURL.getUser();
boolean userMatches = userName != null ? userName.equals(ref)
: ref == null;
if (userMatches) {
ref = httpURL.getPassword();
userMatches = password != null ? password.equals(ref)
: ref == null;
} else {
return false;
}
if (userMatches) {
return httpURL.getHost().equalsIgnoreCase(hostConfig.getHost())
&& httpURL.getPort()
== hostConfig.getProtocol().resolvePort(hostConfig.getPort());
}
return false;
}