Class PasswordAuthenticationURLConnectionProcessor

java.lang.Object
org.faceless.publisher.type.AbstractURLConnectionProcessor
org.faceless.publisher.type.PasswordAuthenticationURLConnectionProcessor
All Implemented Interfaces:
URLConnectionProcessor

public class PasswordAuthenticationURLConnectionProcessor extends AbstractURLConnectionProcessor
A URLConnectionProcessor that handles password authentication. Basic and Digest challenges are supported, anything else is passed to "challengeUnknown" which could be overridden if required.
  • Constructor Details

    • PasswordAuthenticationURLConnectionProcessor

      public PasswordAuthenticationURLConnectionProcessor()
      Create a new PasswordAuthenticationURLConnectionProcessor that will call the CallbackHandler from Report.getCallbackHandler()
    • PasswordAuthenticationURLConnectionProcessor

      public PasswordAuthenticationURLConnectionProcessor(CallbackHandler handler)
      Create a new PasswordAuthenticationURLConnectionProcessor that will call the specified CallbackHandler to retrieve the password. The handler should expect a NameCallback and PasswordCallback in normal use.
      Parameters:
      handler - the handler to ask for name/password
    • PasswordAuthenticationURLConnectionProcessor

      public PasswordAuthenticationURLConnectionProcessor(String name, char[] password)
      Create a new PasswordAuthenticationURLConnectionProcessor.
      Parameters:
      name - the name
      password - the password
  • Method Details

    • getRealmMatches

      public List<Pattern> getRealmMatches()
      Return the list of patterns which will be matched to the Realm of the password before this password is applied. If the list is left empty (the default) then it always matches
    • after

      public URL2Connection after(URL2Connection con) throws IOException
      Description copied from interface: URLConnectionProcessor
      If this processer matches, this method is called after the supplied URL connection is made. It can act on the response headers, modify them for the next processor, and if it returns non-null, the request headers and URI of the returned value will be used for another request. For example to implement a redirect on a return code of 301
      
        if (con.getCode() == 301) {
            con.setURI(parse(con.getResponseHeader("location")));
            return con;
        } else {
            return null;
        }
       
      Specified by:
      after in interface URLConnectionProcessor
      Overrides:
      after in class AbstractURLConnectionProcessor
      Parameters:
      con - the connection
      Returns:
      the next connection to make, or null to accept this response
      Throws:
      IOException
    • challengeBasic

      public String challengeBasic(URL2Connection con, Map<String,String> props, CallbackHandler handler) throws IOException
      Handle a Basic challenge
      Parameters:
      con - the connection
      props - the properties
      handler - the handler to call for the name and password
      Returns:
      the value of the Authentication header, or null to set no header
      Throws:
      IOException
    • challengeDigest

      public String challengeDigest(URL2Connection con, Map<String,String> props, CallbackHandler handler) throws IOException
      Handle a Digest challenge
      Parameters:
      con - the connection
      props - the properties
      handler - the handler to call for the name and password
      Returns:
      the value of the Authentication header, or null to set no header
      Throws:
      IOException
    • challengeUnknown

      public String challengeUnknown(URL2Connection con, String type, Map<String,String> props, CallbackHandler handler) throws IOException
      Handle an unrecognised challenge type
      Parameters:
      con - the connection
      type - the challenge
      props - the properties
      handler - the handler to call for the name and password
      Returns:
      the value of the Authentication header, or null to set no header
      Throws:
      IOException