Menu

#95 Enable NTLM for non proxy access

closed
5
2012-10-21
2006-04-18
No

When I started to dig into HtmlUnit and wanted to test
a third source application, I realized, there is no
means to achieve NTLM-Authentication to an application,
only to a proxy. Whereas the underlying
org.apache.commons.HttpClient does NTLM. Therefore I
added a method

public void addCredentials(Credentials cred)
{
    credentials_.put( AuthScope.ANY, cred );
}

to the
com.gargoylesoftware.htmlunit.DefaultCredentialProvider.

You might consider this API "too open" or whatsoever,
but it allows HTMLUnit to use any Credential,
HTTPClient does, so you might want to include something
similar in a next HTMLUnit release. You probably want
to expose the "AuthScope" API of HTTPClient also HTMLUnit.

Cheers,
Frank

Discussion

  • Frank Nestel

    Frank Nestel - 2006-04-18

    (Micro) patched version of DefaultCredentialsProvider

     
  • Marc Guillemot

    Marc Guillemot - 2006-04-18

    Logged In: YES
    user_id=402164

    Wouldn't it make more sense to add
    public void addNTLCredentials( final String username,
    final String password, final String host,
    final int port, final String clientHost, final
    String clientDomain )

    This would better fit to the other methods of
    DefaultCredentialProvider.

    PS: please submit patches as patches
    (http://htmlunit.sourceforge.net/submittingPatches.html) and
    not as plain text

     
  • Frank Nestel

    Frank Nestel - 2006-04-18

    Logged In: YES
    user_id=392154

    Hi,

    1. the API must rather look like

    public void addNTLCredentials( final String username,
    final String password, final String clientHost, final
    String clientDomain )

    since those 4 arguments are the ones required to build an
    corresponding NTLMCrendential in Apache HttpClient.

    1. I wonder if it makes sense to add more and more special
      purpose addCredentialXYZ Methods (with and without AuthScope
      to multiply by 2). When there is a new authentication in
      HttpClient 3.1, you are behind again. I'd suggest to rather
      expose the HttpClient-API. Might be a matter of taste.

    2. I'm sorry I didn't consider this little hack of mine a
      true patch.

     
  • Marc Guillemot

    Marc Guillemot - 2006-04-18

    Logged In: YES
    user_id=402164

    to 1: sure. I've copied from the NTLM proxy version and
    forgotten to removed the unnecessary params

    to 2: perhaps. In fact this could be a job for a second
    time. I suppose that most of the time tests don't need to
    specify special host rules and therefore the priority would
    be now to make it working for something that seems to be
    quite basic: a normal (not proxy) NTLM credential.

     
  • Marc Guillemot

    Marc Guillemot - 2006-06-15

    Logged In: YES
    user_id=402164

    Now implemented in CVS

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.