2011-04-21 12:10:32 |
Stephane Mikaty (eCircle AG) |
description |
The problem is known, there are reasons for not having NTLM in the Apache HttpClient library, BUT
the jar file to support authentication to NTLM is just one click away, it could use Web.Session.User and
Web.Session.Pass
http://htmlunit.sourceforge.net/ntlm.html
Here is the diff that I think is relevant, the other classes are already in the mentioned web page
mikaty@clnt-qa-01:~/workspace/qa/trunk/testplan/src$ bzr diff share/testplan/auto/htmlunit/ResponseState.java
=== modified file 'src/share/testplan/auto/htmlunit/ResponseState.java'
--- src/share/testplan/auto/htmlunit/ResponseState.java 2010-11-18 20:14:10 +0000
+++ src/share/testplan/auto/htmlunit/ResponseState.java 2011-04-20 18:36:27 +0000
@@ -30,6 +30,9 @@
import java.text.SimpleDateFormat;
import javax.xml.transform.TransformerException;
+import ntlm.NTLMSchemeFactory;
+
+import org.apache.http.impl.client.AbstractHttpClient;
import org.w3c.dom.*;
import testplan.auto.*;
@@ -81,6 +84,17 @@
//WTF? why doesn't it use the java default, and why is it default to 0 (infinite), that's just plain retarded
wc.setTimeout( Integer.parseInt( System.getProperty( "sun.net.client.defaultConnectTimeout" ) ) );
wc.getPage(WebClient.URL_ABOUT_BLANK);
+ wc.setWebConnection(new HttpWebConnection(wc) {
+
+ protected synchronized AbstractHttpClient getHttpClient() {
+ AbstractHttpClient httpClient = super.getHttpClient();
+ httpClient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
+ return httpClient;
+ }
+ });
+ DefaultCredentialsProvider credentialProvider =
+ (DefaultCredentialsProvider) wc.getCredentialsProvider();
+ credentialProvider.addNTLMCredentials("ECIRCLE\\mikaty", "Stephan13", "ecmadmin.muc.ecircle.de", -1, "myStation", "ECIRCLE");
}
private SgmlPage getCurrentSgmlPage() { |
The problem is known, there are reasons for not having NTLM in the Apache HttpClient library, BUT
the jar file to support authentication to NTLM is just one click away, it could use Web.Session.User and
Web.Session.Pass
http://htmlunit.sourceforge.net/ntlm.html
Here is the diff that I think is relevant, the other classes are already in the mentioned web page
mikaty@clnt-qa-01:~/workspace/qa/trunk/testplan/src$ bzr diff share/testplan/auto/htmlunit/ResponseState.java
=== modified file 'src/share/testplan/auto/htmlunit/ResponseState.java'
--- src/share/testplan/auto/htmlunit/ResponseState.java 2010-11-18 20:14:10 +0000
+++ src/share/testplan/auto/htmlunit/ResponseState.java 2011-04-20 18:36:27 +0000
@@ -30,6 +30,9 @@
import java.text.SimpleDateFormat;
import javax.xml.transform.TransformerException;
+import ntlm.NTLMSchemeFactory;
+
+import org.apache.http.impl.client.AbstractHttpClient;
import org.w3c.dom.*;
import testplan.auto.*;
@@ -81,6 +84,17 @@
//WTF? why doesn't it use the java default, and why is it default to 0 (infinite), that's just plain retarded
wc.setTimeout( Integer.parseInt( System.getProperty( "sun.net.client.defaultConnectTimeout" ) ) );
wc.getPage(WebClient.URL_ABOUT_BLANK);
+ wc.setWebConnection(new HttpWebConnection(wc) {
+
+ protected synchronized AbstractHttpClient getHttpClient() {
+ AbstractHttpClient httpClient = super.getHttpClient();
+ httpClient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
+ return httpClient;
+ }
+ });
+ DefaultCredentialsProvider credentialProvider =
+ (DefaultCredentialsProvider) wc.getCredentialsProvider();
+ credentialProvider.addNTLMCredentials("...", "...", "...", -1, "...", "...");
}
private SgmlPage getCurrentSgmlPage() { |
|