Class HttpBasicAuthentication

  • All Implemented Interfaces:
    Configurable, HttpAuthentication

    public class HttpBasicAuthentication
    extends Object
    implements HttpAuthentication, Configurable
    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
    Author:
    Matt Tencati
    • Constructor Detail

      • 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 form WWW-Authenticate: Basic realm="myrealm"
        Parameters:
        challenge - WWW-Authenticate header from web server
        conf - a populated Configuration
        Throws:
        HttpAuthenticationException - if the authentication fails or if the password or username is null
    • Method Detail

      • getCredentials

        public List<String> getCredentials()
        Gets the Basic credentials generated by this HttpBasicAuthentication object
        Specified by:
        getCredentials in interface HttpAuthentication
        Returns:
        Credentials in the form of Authorization: Basic <Base64 encoded userid:password>
      • getAuthentication

        public static HttpBasicAuthentication getAuthentication​(String challenge,
                                                                Configuration conf)
        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 populated Configuration
        Returns:
        An HttpBasicAuthentication object or null if unable to generate appropriate credentials.
      • getBasicPattern

        public static final Pattern 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.