mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-11-15 18:34:03 +00:00
Rename Rrc2617Credential to HttpAuthenticationCredential
* (multiple)
use more-familiar name for HTTP authentication
This commit is contained in:
1 parent
56b31490c8
commit
4583ff7306
7 files changed
+24
-22
No files matched your search
@@ -79,7 +79,7 @@ import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.archive.modules.ModuleAttributeConstants;
|
||||
import org.archive.modules.ProcessorURI;
|
||||
import org.archive.modules.credential.CredentialAvatar;
|
||||
import org.archive.modules.credential.Rfc2617Credential;
|
||||
import org.archive.modules.credential.HttpAuthenticationCredential;
|
||||
import org.archive.modules.extractor.HTMLLinkContext;
|
||||
import org.archive.modules.extractor.Hop;
|
||||
import org.archive.modules.extractor.Link;
|
||||
@@ -983,7 +983,7 @@ implements ProcessorURI, MultiReporter, Serializable, OverlayContext {
|
||||
if (avatars != null && avatars.size() > 0) {
|
||||
for (Iterator<CredentialAvatar> i = avatars.iterator(); i.hasNext();) {
|
||||
if (((CredentialAvatar)i.next()).
|
||||
match(Rfc2617Credential.class)) {
|
||||
match(HttpAuthenticationCredential.class)) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class HttpAuthSelfTest
|
||||
" <property name=\"credentials\">\n" +
|
||||
" <map>\n" +
|
||||
" <entry key=\"test\">\n" +
|
||||
" <bean class=\"org.archive.modules.credential.Rfc2617Credential\">\n" +
|
||||
" <bean class=\"org.archive.modules.credential.HttpAuthenticationCredential\">\n" +
|
||||
" <property name=\"domain\" value=\"127.0.0.1:7777\"/>\n" +
|
||||
" <property name=\"realm\" value=\"Hyrule\"/>\n" +
|
||||
" <property name=\"login\" value=\"Mr. Happy Pants\"/>\n" +
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.archive.modules.credential.CredentialAvatar;
|
||||
import org.archive.modules.credential.Rfc2617Credential;
|
||||
import org.archive.modules.credential.HttpAuthenticationCredential;
|
||||
import org.archive.modules.deciderules.AcceptDecideRule;
|
||||
import org.archive.modules.deciderules.DecideResult;
|
||||
import org.archive.modules.deciderules.DecideRule;
|
||||
@@ -207,7 +207,7 @@ implements Serializable, HasKeyedProperties, Lifecycle {
|
||||
boolean result = false;
|
||||
int statusCode = puri.getFetchStatus();
|
||||
if (statusCode == HttpStatus.SC_UNAUTHORIZED &&
|
||||
hasRfc2617CredentialAvatar(puri)) {
|
||||
hasHttpAuthenticationCredentialAvatar(puri)) {
|
||||
result = false;
|
||||
} else {
|
||||
result = (statusCode > 0);
|
||||
@@ -226,12 +226,12 @@ implements Serializable, HasKeyedProperties, Lifecycle {
|
||||
|
||||
|
||||
/**
|
||||
* @return True if we have an rfc2617 payload.
|
||||
* @return True if we have an HttpAuthentication (rfc2617) payload.
|
||||
*/
|
||||
public static boolean hasRfc2617CredentialAvatar(ProcessorURI puri) {
|
||||
public static boolean hasHttpAuthenticationCredentialAvatar(ProcessorURI puri) {
|
||||
Set<CredentialAvatar> avatars = puri.getCredentialAvatars();
|
||||
for (CredentialAvatar ca: avatars) {
|
||||
if (ca.match(Rfc2617Credential.class)) {
|
||||
if (ca.match(HttpAuthenticationCredential.class)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class CredentialStore implements Serializable, HasKeyedProperties {
|
||||
// Initialize the credentialType data member.
|
||||
static {
|
||||
// Array of all known credential types.
|
||||
Class<?> [] tmp = {HtmlFormCredential.class, Rfc2617Credential.class};
|
||||
Class<?> [] tmp = {HtmlFormCredential.class, HttpAuthenticationCredential.class};
|
||||
credentialTypes = Collections.unmodifiableList(Arrays.asList(tmp));
|
||||
}
|
||||
|
||||
|
||||
+9
-7
@@ -31,16 +31,18 @@ import org.apache.commons.httpclient.auth.AuthScope;
|
||||
import org.archive.modules.ProcessorURI;
|
||||
|
||||
/**
|
||||
* A Basic/Digest auth RFC2617 credential.
|
||||
* A Basic/Digest HTTP Authentication (RFC2617) credential.
|
||||
*
|
||||
* (Previously named "Rfc2617Credential".)
|
||||
*
|
||||
* @author stack
|
||||
* @version $Revision$, $Date$
|
||||
*/
|
||||
public class Rfc2617Credential extends Credential {
|
||||
public class HttpAuthenticationCredential extends Credential {
|
||||
private static final long serialVersionUID = 3L;
|
||||
|
||||
private static Logger logger =
|
||||
Logger.getLogger(Rfc2617Credential.class.getName());
|
||||
Logger.getLogger(HttpAuthenticationCredential.class.getName());
|
||||
|
||||
|
||||
/** Basic/Digest Auth realm. */
|
||||
@@ -73,7 +75,7 @@ public class Rfc2617Credential extends Credential {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Rfc2617Credential() {
|
||||
public HttpAuthenticationCredential() {
|
||||
}
|
||||
|
||||
public boolean isPrerequisite(ProcessorURI curi) {
|
||||
@@ -158,16 +160,16 @@ public class Rfc2617Credential extends Credential {
|
||||
* credential w/ passed realm name, and there shouldn't be, we return first
|
||||
* found.
|
||||
*/
|
||||
public static Rfc2617Credential getByRealm(Set<Credential> rfc2617Credentials,
|
||||
public static HttpAuthenticationCredential getByRealm(Set<Credential> rfc2617Credentials,
|
||||
String realm, ProcessorURI context) {
|
||||
|
||||
Rfc2617Credential result = null;
|
||||
HttpAuthenticationCredential result = null;
|
||||
if (rfc2617Credentials == null || rfc2617Credentials.size() <= 0) {
|
||||
return result;
|
||||
}
|
||||
if (rfc2617Credentials != null && rfc2617Credentials.size() > 0) {
|
||||
for (Iterator<Credential> i = rfc2617Credentials.iterator(); i.hasNext();) {
|
||||
Rfc2617Credential c = (Rfc2617Credential)i.next();
|
||||
HttpAuthenticationCredential c = (HttpAuthenticationCredential)i.next();
|
||||
if (c.getRealm().equals(realm)) {
|
||||
result = c;
|
||||
break;
|
||||
@@ -94,7 +94,7 @@ import org.archive.modules.ProcessorURI;
|
||||
import org.archive.modules.credential.Credential;
|
||||
import org.archive.modules.credential.CredentialAvatar;
|
||||
import org.archive.modules.credential.CredentialStore;
|
||||
import org.archive.modules.credential.Rfc2617Credential;
|
||||
import org.archive.modules.credential.HttpAuthenticationCredential;
|
||||
import org.archive.modules.deciderules.AcceptDecideRule;
|
||||
import org.archive.modules.deciderules.DecideResult;
|
||||
import org.archive.modules.deciderules.DecideRule;
|
||||
@@ -1120,8 +1120,8 @@ public class FetchHTTP extends Processor implements Lifecycle {
|
||||
// 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,
|
||||
Rfc2617Credential.class);
|
||||
Rfc2617Credential extant = Rfc2617Credential.getByRealm(
|
||||
HttpAuthenticationCredential.class);
|
||||
HttpAuthenticationCredential extant = HttpAuthenticationCredential.getByRealm(
|
||||
curiRfc2617Credentials, realm, curi);
|
||||
if (extant != null) {
|
||||
// Then, already tried this credential. Remove ANY rfc2617
|
||||
@@ -1141,12 +1141,12 @@ public class FetchHTTP extends Processor implements Lifecycle {
|
||||
String serverKey = getServerKey(curi);
|
||||
CrawlServer server = serverCache.getServerFor(serverKey);
|
||||
Set<Credential> storeRfc2617Credentials = getCredentialStore().subset(curi,
|
||||
Rfc2617Credential.class, server.getName());
|
||||
HttpAuthenticationCredential.class, server.getName());
|
||||
if (storeRfc2617Credentials == null
|
||||
|| storeRfc2617Credentials.size() <= 0) {
|
||||
logger.info("No rfc2617 credentials for " + curi);
|
||||
} else {
|
||||
Rfc2617Credential found = Rfc2617Credential.getByRealm(
|
||||
HttpAuthenticationCredential found = HttpAuthenticationCredential.getByRealm(
|
||||
storeRfc2617Credentials, realm, curi);
|
||||
if (found == null) {
|
||||
logger.info("No rfc2617 credentials for realm " + realm
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import org.archive.state.ModuleTestBase;
|
||||
* @author pjack
|
||||
*
|
||||
*/
|
||||
public class Rfc2617CredentialTest extends ModuleTestBase {
|
||||
public class HttpAuthenticationCredentialTest extends ModuleTestBase {
|
||||
|
||||
//TODO: add tests
|
||||
|
||||
Reference in new issue
Block a user