sebb 2005/06/04 17:09:33
Modified: src/protocol/http/org/apache/jmeter/protocol/http/sampler HTTPSampler2.java Log: Add NTCredentials - needs further work Revision Changes Path 1.19 +31 -23 jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java Index: HTTPSampler2.java =================================================================== RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- HTTPSampler2.java 26 May 2005 22:56:57 -0000 1.18 +++ HTTPSampler2.java 5 Jun 2005 00:09:32 -0000 1.19 @@ -29,6 +29,7 @@ import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpMethodBase; import org.apache.commons.httpclient.HttpState; +import org.apache.commons.httpclient.NTCredentials; import org.apache.commons.httpclient.methods.EntityEnclosingMethod; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; @@ -36,6 +37,7 @@ import org.apache.jmeter.config.Argument; import org.apache.jmeter.protocol.http.control.AuthManager; +import org.apache.jmeter.protocol.http.control.Authorization; import org.apache.jmeter.protocol.http.control.CookieManager; import org.apache.jmeter.protocol.http.control.HeaderManager; @@ -77,6 +79,12 @@ private transient HttpMethodBase httpMethod = null; private transient HttpState httpState = null; + private static boolean basicAuth = JMeterUtils.getPropDefault("httpsampler2.basicauth",false); + + static { + log.info("httpsampler2.basicauth="+basicAuth); + } + /** * Constructor for the HTTPSampler2 object. */ @@ -399,29 +407,29 @@ { if (authManager != null) { - // Old method - String authHeader= authManager.getAuthHeaderForURL(u); - if (authHeader != null) - { - method.setRequestHeader("Authorization", authHeader); - } - - //TODO: replace with something like this: -// Authorization auth= authManager.getAuthForURL(u); -// if (auth != null) -// { -// // TODO - set up realm, thishost and domain -// httpState.setCredentials( -// null, // "realm" -// auth.getURL(), -// new NTCredentials(// Includes other types of Credentials -// auth.getUser(), -// auth.getPass(), -// null, // "thishost", -// null // "targetdomain" -// ) -// ); -// } + if (basicAuth ) { + String authHeader = authManager.getAuthHeaderForURL(u); + if (authHeader != null) + { + method.setRequestHeader("Authorization", authHeader); + } + } else { + Authorization auth = authManager.getAuthForURL(u); + if (auth != null) + { + // TODO - set up realm, thishost and domain + httpState.setCredentials( + null, // "realm" + auth.getURL(), + new NTCredentials(// Includes other types of Credentials + auth.getUser(), + auth.getPass(), + null, // "thishost", + null // "targetdomain" + ) + ); + } + } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
Free forum by Nabble | Edit this page |