* @param token the {@link HttpAuthRealm authentication realm token}
* @return the credentials
*
*/
private static Credentials matchCredentials(HashMap map, HttpAuthRealm token) {
HttpAuthRealm key = token;
Credentials creds = (Credentials) map.get(key);
if (creds == null && token.getScheme() != null) {
key = new HttpAuthRealm(token.getHost(), token.getPort(), token.getRealm());
creds = (Credentials) map.get(key);
}
if (creds == null && token.getRealm() != null) {
key = new HttpAuthRealm(token.getHost(), token.getPort());
creds = (Credentials) map.get(key);
}
if (creds == null && token.getPort() >= 0) {
key = new HttpAuthRealm(token.getHost(), -1);
creds = (Credentials) map.get(key);
}
if (creds == null && token.getHost() != null) {
key = new HttpAuthRealm();
creds = (Credentials) map.get(key);
}
return creds;
}