Class AuthConfig


  • public class AuthConfig
    extends java.lang.Object
    Encapsulates all configuration related to HTTP authentication methods.
    See Also:
    HTTPBuilder.getAuth()
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  AuthConfig.OAuthSigner
      This class is used to sign all requests via an HttpRequestInterceptor until the context-aware AuthScheme is released in HttpClient 4.1.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void basic​(java.lang.String host, int port, java.lang.String user, java.lang.String pass)
      Set authentication credentials to be used for the given host and port.
      void basic​(java.lang.String user, java.lang.String pass)
      Set authentication credentials to be used for the current default host.
      void certificate​(java.lang.String certURL, java.lang.String password)
      Sets a certificate to be used for SSL authentication.
      void ntlm​(java.lang.String host, int port, java.lang.String user, java.lang.String pass, java.lang.String workstation, java.lang.String domain)
      Set NTLM authentication credentials to be used for the given host and port.
      void ntlm​(java.lang.String user, java.lang.String pass, java.lang.String workstation, java.lang.String domain)
      Set NTLM authentication credentials to be used for the current default host.
      void oauth​(java.lang.String consumerKey, java.lang.String consumerSecret, java.lang.String accessToken, java.lang.String secretToken)
      OAuth sign all requests.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AuthConfig

        public AuthConfig​(HTTPBuilder builder)
    • Method Detail

      • basic

        public void basic​(java.lang.String user,
                          java.lang.String pass)
        Set authentication credentials to be used for the current default host. This method name is a bit of a misnomer, since these credentials will actually work for "digest" authentication as well.
        Parameters:
        user -
        pass -
      • basic

        public void basic​(java.lang.String host,
                          int port,
                          java.lang.String user,
                          java.lang.String pass)
        Set authentication credentials to be used for the given host and port.
        Parameters:
        host -
        port -
        user -
        pass -
      • ntlm

        public void ntlm​(java.lang.String user,
                         java.lang.String pass,
                         java.lang.String workstation,
                         java.lang.String domain)
        Set NTLM authentication credentials to be used for the current default host.
        Parameters:
        user -
        pass -
        workstation -
        domain -
      • ntlm

        public void ntlm​(java.lang.String host,
                         int port,
                         java.lang.String user,
                         java.lang.String pass,
                         java.lang.String workstation,
                         java.lang.String domain)
        Set NTLM authentication credentials to be used for the given host and port.
        Parameters:
        host -
        port -
        user -
        pass -
        workstation -
        domain -
      • certificate

        public void certificate​(java.lang.String certURL,
                                java.lang.String password)
                         throws java.security.GeneralSecurityException,
                                java.io.IOException
        Sets a certificate to be used for SSL authentication. See Class.getResource(String) for how to get a URL from a resource on the classpath.
        Parameters:
        certURL - URL to a JKS keystore where the certificate is stored.
        password - password to decrypt the keystore
        Throws:
        java.security.GeneralSecurityException
        java.io.IOException
      • oauth

        public void oauth​(java.lang.String consumerKey,
                          java.lang.String consumerSecret,
                          java.lang.String accessToken,
                          java.lang.String secretToken)

        OAuth sign all requests. Note that this currently does not wait for a WWW-Authenticate challenge before sending the the OAuth header. All requests to all domains will be signed for this instance.

        This assumes you've already generated an accessToken and secretToken for the site you're targeting. For More information on how to achieve this, see the Signpost documentation.

        Parameters:
        consumerKey - null if you want to unset OAuth handling and stop signing requests.
        consumerSecret -
        accessToken -
        secretToken -
        Since:
        0.5.1