Class HttpBasicAuthentication
java.lang.Object
org.apache.nutch.protocol.httpclient.HttpBasicAuthentication
- All Implemented Interfaces:
Configurable,HttpAuthentication
Implementation of RFC 2617 Basic Authentication. Usernames and passwords are
stored in standard Nutch configuration files using the following properties:
http.auth.basic.<realm>.user http.auth.basic.<realm>.pass
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHttpBasicAuthentication(String challenge, Configuration conf) Construct an HttpBasicAuthentication for the given challenge parameters. -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpBasicAuthenticationgetAuthentication(String challenge, Configuration conf) This method is responsible for providing Basic authentication information.static final PatternProvides a pattern which can be used by an outside resource to determine if this class can provide credentials based on simple header information.getConf()Gets the Basic credentials generated by this HttpBasicAuthentication objectgetRealm()Gets the realm attribute of the HttpBasicAuthentication object.voidsetConf(Configuration conf)
-
Constructor Details
-
HttpBasicAuthentication
protected HttpBasicAuthentication(String challenge, Configuration conf) throws HttpAuthenticationException Construct an HttpBasicAuthentication for the given challenge parameters. The challenge parameters are returned by the web server using a WWW-Authenticate header. This will typically be represented by single line of the formWWW-Authenticate: Basic realm="myrealm"- Parameters:
challenge- WWW-Authenticate header from web serverconf- a populatedConfiguration- Throws:
HttpAuthenticationException- if the authentication fails or if the password or username is null
-
-
Method Details
-
setConf
- Specified by:
setConfin interfaceConfigurable
-
getConf
- Specified by:
getConfin interfaceConfigurable
-
getCredentials
Gets the Basic credentials generated by this HttpBasicAuthentication object- Specified by:
getCredentialsin interfaceHttpAuthentication- Returns:
- Credentials in the form of
Authorization: Basic <Base64 encoded userid:password>
-
getRealm
Gets the realm attribute of the HttpBasicAuthentication object. This should have been supplied to thegetAuthentication(String, Configuration)static method- Specified by:
getRealmin interfaceHttpAuthentication- Returns:
- The realm
-
getAuthentication
This method is responsible for providing Basic authentication information. The method caches authentication information for each realm so that the required authentication information does not need to be regenerated for every request.- Parameters:
challenge- The challenge string provided by the webserver. This is the text which follows the WWW-Authenticate header, including the Basic tag.conf- a populatedConfiguration- Returns:
- An HttpBasicAuthentication object or null if unable to generate appropriate credentials.
-
getBasicPattern
Provides a pattern which can be used by an outside resource to determine if this class can provide credentials based on simple header information. It does not calculate any information regarding realms or challenges.- Returns:
- Returns a Pattern which will match a Basic WWW-Authenticate header.
-