// Look to see if this curi had rfc2617 avatars loaded. If so, are
// any of them for this realm? If so, then the credential failed
// if we got a 401 and it should be let die a natural 401 death.
Set<Credential> curiRfc2617Credentials = getCredentials(curi,
HttpAuthenticationCredential.class);
HttpAuthenticationCredential extant = HttpAuthenticationCredential.getByRealm(
curiRfc2617Credentials, realm, curi);
if (extant != null) {
// Then, already tried this credential. Remove ANY rfc2617
// credential since presence of a rfc2617 credential serves
// as flag to frontier to requeue this curi and let the curi
// die a natural death.
extant.detachAll(curi);
logger.warning("Auth failed (401) though supplied realm " + realm
+ " to " + curi.toString());
} else {
// Look see if we have a credential that corresponds to this
// realm in credential store. Filter by type and credential
// domain. If not, let this curi die. Else, add it to the
// curi and let it come around again. Add in the AuthScheme
// we got too. Its needed when we go to run the Auth on
// second time around.
String serverKey = getServerKey(curi);
CrawlServer server = serverCache.getServerFor(serverKey);
Set<Credential> storeRfc2617Credentials = getCredentialStore().subset(curi,
HttpAuthenticationCredential.class, server.getName());
if (storeRfc2617Credentials == null
|| storeRfc2617Credentials.size() <= 0) {
logger.fine("No rfc2617 credentials for " + curi);
} else {
HttpAuthenticationCredential found = HttpAuthenticationCredential.getByRealm(
storeRfc2617Credentials, realm, curi);
if (found == null) {
logger.fine("No rfc2617 credentials for realm " + realm
+ " in " + curi);
} else {
found.attach(curi);
logger.fine("Found credential for scheme " + authscheme
+ " realm " + realm + " in store for "
+ curi.toString());
}
}