olegk 2003/03/28 08:37:50 Modified: httpclient/src/java/org/apache/commons/httpclient Authenticator.java httpclient/src/test/org/apache/commons/httpclient TestAuthenticator.java Log: org.apache.commons.httpclient.Authenticator class deprecated in favour of org.apache.commons.httpclient.auth.HttpAuthenticator Contributed by Oleg Kalnichevski Revision Changes Path 1.41 +9 -3 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Authenticator.java Index: Authenticator.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Authenticator.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- Authenticator.java 27 Mar 2003 20:58:27 -0000 1.40 +++ Authenticator.java 28 Mar 2003 16:37:49 -0000 1.41 @@ -86,6 +86,8 @@ * </blockquote> * </p> * + * @deprecated use [EMAIL PROTECTED] org.apache.commons.httpclient.auth.HttpAuthenticator} + * * @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a> * @author Rodney Waldhoff * @author <a href="mailto:[EMAIL PROTECTED]">Jeff Dever</a> @@ -141,6 +143,8 @@ * @throws UnsupportedOperationException when the challenge type is not * supported * @see HttpState#setCredentials(String,Credentials) + * + * @deprecated use [EMAIL PROTECTED] HttpAuthenticator#authenticate(AuthScheme, HttpMethod, HttpState)} */ public static boolean authenticate(HttpMethod method, HttpState state) throws HttpException, UnsupportedOperationException { @@ -162,6 +166,8 @@ * @throws UnsupportedOperationException when the given challenge type is * not supported * @see HttpState#setProxyCredentials(String,Credentials) + * + * @deprecated use [EMAIL PROTECTED] HttpAuthenticator#authenticateProxy(AuthScheme, HttpMethod, HttpState)} */ public static boolean authenticateProxy(HttpMethod method, HttpState state) throws HttpException, UnsupportedOperationException { 1.23 +113 -97 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java Index: TestAuthenticator.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- TestAuthenticator.java 27 Mar 2003 20:58:28 -0000 1.22 +++ TestAuthenticator.java 28 Mar 2003 16:37:50 -0000 1.23 @@ -124,10 +124,12 @@ // ---------------------------------- Test Methods for BasicScheme Authentication public void testBasicAuthenticationWithNoCreds() { + String challenge = "Basic realm=\"realm1\""; HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Basic realm=\"realm1\"")); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); try { - Authenticator.authenticate(method,state); + AuthScheme authscheme = new BasicScheme(challenge); + HttpAuthenticator.authenticate(authscheme, method, state); fail("Should have thrown HttpException"); } catch(HttpException e) { // expected @@ -135,10 +137,12 @@ } public void testBasicAuthenticationWithNoRealm() { + String challenge = "Basic"; HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Basic")); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); try { - Authenticator.authenticate(method,state); + AuthScheme authscheme = new BasicScheme(challenge); + HttpAuthenticator.authenticate(authscheme, method, state); fail("Should have thrown HttpException"); } catch(HttpException e) { // expected @@ -146,27 +150,24 @@ } public void testBasicAuthenticationWithNoRealm2() { + String challenge = "Basic "; HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Basic ")); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); try { - Authenticator.authenticate(method,state); + AuthScheme authscheme = new BasicScheme(challenge); + HttpAuthenticator.authenticate(authscheme, method, state); fail("Should have thrown HttpException"); } catch(HttpException e) { // expected } } - public void testBasicAuthenticationWithNoChallenge() throws Exception { - HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(); - - assertEquals(false, Authenticator.authenticate(method,state)); - } - public void testBasicAuthenticationWithNullHttpState() throws Exception { - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Basic realm=\"realm1\"")); + String challenge = "Basic realm=\"realm1\""; + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); try { - Authenticator.authenticate(method,(HttpState)null); + AuthScheme authscheme = new BasicScheme(challenge); + HttpAuthenticator.authenticate(authscheme, method,(HttpState)null); fail("Should have thrown IllegalArgumentException"); } catch(IllegalArgumentException e) { // expected @@ -174,11 +175,10 @@ } public void testInvalidAuthenticationScheme() throws Exception { - HttpState state = new HttpState(); - state.setCredentials(null,new UsernamePasswordCredentials("username","password")); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","invalid realm=\"realm1\"")); + String challenge = "invalid realm=\"realm1\""; try{ - assertTrue(Authenticator.authenticate(method, state)); + HttpAuthenticator.selectAuthScheme( + new Header[] { new Header("WWW-Authenticate", challenge) }); fail("Should have thrown UnsupportedOperationException"); }catch (UnsupportedOperationException uoe){ // expected @@ -186,10 +186,12 @@ } public void testBasicAuthenticationCaseInsensitivity() throws Exception { + String challenge = "bAsIc ReAlM=\"realm1\""; HttpState state = new HttpState(); state.setCredentials(null,new UsernamePasswordCredentials("username","password")); - HttpMethod method = new SimpleHttpMethod(new Header("WwW-AuThEnTiCaTe","bAsIc ReAlM=\"realm1\"")); - assertTrue(Authenticator.authenticate(method,state)); + HttpMethod method = new SimpleHttpMethod(new Header("WwW-AuThEnTiCaTe", challenge)); + AuthScheme authscheme = new BasicScheme(challenge); + assertTrue(HttpAuthenticator.authenticate(authscheme, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); String expected = "Basic " + HttpConstants.getString(Base64.encode(HttpConstants.getBytes("username:password"))); assertEquals(expected,method.getRequestHeader("Authorization").getValue()); @@ -200,17 +202,19 @@ HttpState state = new HttpState(); state.setCredentials(null,new UsernamePasswordCredentials("username","password")); HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Basic realm=\"realm1\"")); - assertTrue(Authenticator.authenticate(method,state)); + assertTrue(HttpAuthenticator.authenticateDefault(method, state)); assertTrue(null != method.getRequestHeader("Authorization")); String expected = "Basic " + HttpConstants.getString(Base64.encode(HttpConstants.getBytes("username:password"))); assertEquals(expected,method.getRequestHeader("Authorization").getValue()); } public void testBasicAuthentication() throws Exception { + String challenge = "Basic realm=\"realm\""; HttpState state = new HttpState(); state.setCredentials("realm", new UsernamePasswordCredentials("username","password")); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Basic realm=\"realm\"")); - assertTrue(Authenticator.authenticate(method,state)); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); + AuthScheme authscheme = new BasicScheme(challenge); + assertTrue(HttpAuthenticator.authenticate(authscheme, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); String expected = "Basic " + HttpConstants.getString(Base64.encode(HttpConstants.getBytes("username:password"))); assertEquals(expected,method.getRequestHeader("Authorization").getValue()); @@ -218,40 +222,35 @@ public void testBasicAuthenticationWithMutlipleRealms() throws Exception { + String challenge1 = "Basic realm=\"realm1\""; + String challenge2 = "Basic realm=\"realm2\""; HttpState state = new HttpState(); state.setCredentials("realm1",new UsernamePasswordCredentials("username","password")); state.setCredentials("realm2",new UsernamePasswordCredentials("uname2","password2")); + AuthScheme authscheme1 = new BasicScheme(challenge1); + AuthScheme authscheme2 = new BasicScheme(challenge2); { - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Basic realm=\"realm1\"")); - assertTrue(Authenticator.authenticate(method,state)); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate",challenge1)); + assertTrue(HttpAuthenticator.authenticate(authscheme1, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); String expected = "Basic " + HttpConstants.getString(Base64.encode(HttpConstants.getBytes("username:password"))); assertEquals(expected,method.getRequestHeader("Authorization").getValue()); } { - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Basic realm=\"realm2\"")); - assertTrue(Authenticator.authenticate(method,state)); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge2)); + assertTrue(HttpAuthenticator.authenticate(authscheme2, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); String expected = "Basic " + HttpConstants.getString(Base64.encode(HttpConstants.getBytes("uname2:password2"))); assertEquals(expected,method.getRequestHeader("Authorization").getValue()); } } - public void testPreemptiveAuthorizationDefault() throws Exception { - HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(); - state.setCredentials(null, new UsernamePasswordCredentials("username","password")); - - assertTrue(! Authenticator.authenticate(method,state)); - assertTrue(null == method.getRequestHeader("Authorization")); - } - public void testPreemptiveAuthorizationTrueNoCreds() throws Exception { HttpState state = new HttpState(); HttpMethod method = new SimpleHttpMethod(); state.setAuthenticationPreemptive(true); - assertTrue(! Authenticator.authenticate(method,state)); + assertTrue(!HttpAuthenticator.authenticateDefault(method, state)); assertTrue(null == method.getRequestHeader("Authorization")); } @@ -261,29 +260,21 @@ state.setCredentials(null, new UsernamePasswordCredentials("username","password")); state.setAuthenticationPreemptive(true); - assertTrue(Authenticator.authenticate(method,state)); + assertTrue(HttpAuthenticator.authenticateDefault(method, state)); assertTrue(null != method.getRequestHeader("Authorization")); String expected = "Basic " + HttpConstants.getString(Base64.encode(HttpConstants.getBytes("username:password"))); assertEquals(expected, method.getRequestHeader("Authorization").getValue()); } - public void testPreemptiveAuthorizationFalse() throws Exception { - HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(); - - state.setAuthenticationPreemptive(false); - state.setCredentials(null, new UsernamePasswordCredentials("username","password")); - assertTrue(! Authenticator.authenticate(method,state)); - assertTrue(null == method.getRequestHeader("Authorization")); - } - // --------------------------------- Test Methods for DigestScheme Authentication public void testDigestAuthenticationWithNoCreds() { + String challenge = "Digest realm=\"realm1\""; HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Digest realm=\"realm1\"")); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); try { - Authenticator.authenticate(method,state); + AuthScheme authscheme = new DigestScheme(challenge); + HttpAuthenticator.authenticate(authscheme, method, state); fail("Should have thrown HttpException"); } catch(HttpException e) { // expected @@ -291,10 +282,12 @@ } public void testDigestAuthenticationWithNoRealm() { + String challenge = "Digest"; HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Digest")); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); try { - Authenticator.authenticate(method,state); + AuthScheme authscheme = new DigestScheme(challenge); + HttpAuthenticator.authenticate(authscheme, method, state); fail("Should have thrown HttpException"); } catch(HttpException e) { // expected @@ -302,10 +295,12 @@ } public void testDigestAuthenticationWithNoRealm2() { + String challenge = "Digest "; HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Digest ")); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); try { - Authenticator.authenticate(method,state); + AuthScheme authscheme = new DigestScheme(challenge); + HttpAuthenticator.authenticate(authscheme, method, state); fail("Should have thrown HttpException"); } catch(HttpException e) { // expected @@ -313,9 +308,11 @@ } public void testDigestAuthenticationWithNullHttpState() throws Exception { - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Digest realm=\"realm1\"")); + String challenge = "Digest realm=\"realm1\""; + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); try { - Authenticator.authenticate(method,(HttpState)null); + AuthScheme authscheme = new DigestScheme(challenge); + HttpAuthenticator.authenticate(authscheme, method, (HttpState)null); fail("Should have thrown IllegalArgumentException"); } catch(IllegalArgumentException e) { // expected @@ -323,50 +320,60 @@ } public void testDigestAuthenticationCaseInsensitivity() throws Exception { + String challenge = "dIgEsT ReAlM=\"realm1\""; HttpState state = new HttpState(); UsernamePasswordCredentials cred = new UsernamePasswordCredentials("username","password"); state.setCredentials(null, cred); - HttpMethod method = new SimpleHttpMethod(new Header("WwW-AuThEnTiCaTe","dIgEsT ReAlM=\"realm1\"")); - assertTrue(Authenticator.authenticate(method,state)); + HttpMethod method = new SimpleHttpMethod(new Header("WwW-AuThEnTiCaTe", challenge)); + AuthScheme authscheme = new DigestScheme(challenge); + assertTrue(HttpAuthenticator.authenticate(authscheme, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); } public void testDigestAuthenticationWithDefaultCreds() throws Exception { + String challenge = "Digest realm=\"realm1\""; HttpState state = new HttpState(); UsernamePasswordCredentials cred = new UsernamePasswordCredentials("username","password"); state.setCredentials(null, cred); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Digest realm=\"realm1\"")); - assertTrue(Authenticator.authenticate(method,state)); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); + AuthScheme authscheme = new DigestScheme(challenge); + assertTrue(HttpAuthenticator.authenticate(authscheme, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); checkAuthorization(cred, method.getName(), method.getRequestHeader("Authorization").getValue()); } public void testDigestAuthentication() throws Exception { + String challenge = "Digest realm=\"realm1\""; HttpState state = new HttpState(); UsernamePasswordCredentials cred = new UsernamePasswordCredentials("username","password"); state.setCredentials(null, cred); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Digest realm=\"realm1\"")); - assertTrue(Authenticator.authenticate(method,state)); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); + AuthScheme authscheme = new DigestScheme(challenge); + assertTrue(HttpAuthenticator.authenticate(authscheme, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); checkAuthorization(cred, method.getName(), method.getRequestHeader("Authorization").getValue()); } public void testDigestAuthenticationWithMultipleRealms() throws Exception { + String challenge1 = "Digest realm=\"realm1\""; + String challenge2 = "Digest realm=\"realm2\""; HttpState state = new HttpState(); UsernamePasswordCredentials cred = new UsernamePasswordCredentials("username","password"); state.setCredentials("realm1", cred); UsernamePasswordCredentials cred2 = new UsernamePasswordCredentials("uname2","password2"); state.setCredentials("realm2", cred2); + AuthScheme authscheme1 = new DigestScheme(challenge1); + AuthScheme authscheme2 = new DigestScheme(challenge2); { - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Digest realm=\"realm1\"")); - assertTrue(Authenticator.authenticate(method,state)); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate",challenge1)); + assertTrue(HttpAuthenticator.authenticate(authscheme1, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); checkAuthorization(cred, method.getName(), method.getRequestHeader("Authorization").getValue()); } { - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Digest realm=\"realm2\"")); - assertTrue(Authenticator.authenticate(method,state)); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate",challenge2)); + assertTrue(HttpAuthenticator.authenticate(authscheme2, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); checkAuthorization(cred2, method.getName(), method.getRequestHeader("Authorization").getValue()); } @@ -375,12 +382,13 @@ // --------------------------------- Test Methods for NTLM Authentication public void testNTLMAuthenticationWithNoCreds() { + String challenge = "NTLM"; HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", - "NTLM")); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); method.addRequestHeader("Host", "host"); try { - Authenticator.authenticate(method,state); + AuthScheme authscheme = new NTLMScheme(challenge); + HttpAuthenticator.authenticate(authscheme, method, state); fail("Should have thrown HttpException"); } catch(HttpException e) { // expected @@ -388,11 +396,12 @@ } public void testNTLMAuthenticationWithNullHttpState() throws Exception { - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", - "NTLM")); + String challenge = "NTLM"; + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); method.addRequestHeader("Host", "host"); try { - Authenticator.authenticate(method,(HttpState)null); + AuthScheme authscheme = new NTLMScheme(challenge); + HttpAuthenticator.authenticate(authscheme, method,(HttpState)null); fail("Should have thrown IllegalArgumentException"); } catch(IllegalArgumentException e) { // expected @@ -400,34 +409,43 @@ } public void testNTLMAuthenticationCaseInsensitivity() throws Exception { + String challenge = "nTlM"; HttpState state = new HttpState(); NTCredentials cred = new NTCredentials("username","password", "host", "domain"); state.setCredentials("host", cred); - HttpMethod method = new SimpleHttpMethod(new Header("WwW-AuThEnTiCaTe", - "nTlM")); + HttpMethod method = new SimpleHttpMethod(new Header("WwW-AuThEnTiCaTe", challenge)); method.addRequestHeader("Host", "host"); - assertTrue(Authenticator.authenticate(method,state)); + AuthScheme authscheme = new NTLMScheme(challenge); + assertTrue(HttpAuthenticator.authenticate(authscheme, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); } public void testNTLMAuthenticationResponse1() throws Exception { + String challenge = "NTLM"; String expected = "NTLM TlRMTVNTUAABAAAABlIAAAYABgAkAAAABAAEACAAAABIT" + "1NURE9NQUlO"; HttpState state = new HttpState(); NTCredentials cred = new NTCredentials("username","password", "host", "domain"); state.setCredentials("host", cred); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", - "NTLM")); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); method.addRequestHeader("Host", "host"); - assertTrue(Authenticator.authenticate(method,state)); + AuthScheme authscheme = new NTLMScheme(challenge); + assertTrue(HttpAuthenticator.authenticate(authscheme, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); assertEquals(expected, method.getRequestHeader("Authorization").getValue()); } public void testNTLMAuthenticationResponse2() throws Exception { + String challenge = + "NTLM TlRMTVNTUAACAAAACgAKADAAAAAGgoEAPc4kP4LtCV8AAAAAAAAAAJ4AngA" + + "6AAAASU5UUkFFUEhPWAIAFABJAE4AVABSAEEARQBQAEgATwBYAAEAEgBCAE8AQQB" + + "SAEQAUgBPAE8ATQAEACgAaQBuAHQAcgBhAGUAcABoAG8AeAAuAGUAcABoAG8AeAA" + + "uAGMAbwBtAAMAPABCAG8AYQByAGQAcgBvAG8AbQAuAGkAbgB0AHIAYQBlAHAAaAB" + + "vAHgALgBlAHAAaABvAHgALgBjAG8AbQAAAAAA"; + String expected = "NTLM TlRMTVNTUAADAAAAGAAYAFIAAAAAAAAAagAAAAYABgB" + "AAAAACAAIAEYAAAAEAAQATgAAAAAAAABqAAAABlIAAERPTUFJTlVTRVJOQU1FSE" + "9TVAaC+vLxUEHnUtpItj9Dp4kzwQfd61Lztg=="; @@ -435,20 +453,22 @@ NTCredentials cred = new NTCredentials("username","password", "host", "domain"); state.setCredentials("host", cred); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", - "NTLM TlRMTVNTUAACAAAACgAKADAAAAAGgoEAPc4kP4LtCV8AAAAAAAAAAJ4AngA" + - "6AAAASU5UUkFFUEhPWAIAFABJAE4AVABSAEEARQBQAEgATwBYAAEAEgBCAE8AQQB" + - "SAEQAUgBPAE8ATQAEACgAaQBuAHQAcgBhAGUAcABoAG8AeAAuAGUAcABoAG8AeAA" + - "uAGMAbwBtAAMAPABCAG8AYQByAGQAcgBvAG8AbQAuAGkAbgB0AHIAYQBlAHAAaAB" + - "vAHgALgBlAHAAaABvAHgALgBjAG8AbQAAAAAA")); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); method.addRequestHeader("Host", "host"); - assertTrue(Authenticator.authenticate(method,state)); + AuthScheme authscheme = new NTLMScheme(challenge); + assertTrue(HttpAuthenticator.authenticate(authscheme, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); assertEquals(expected, method.getRequestHeader("Authorization").getValue()); } public void testNTLMAuthenticationWithDefaultCreds() throws Exception { + String challenge = + "NTLM TlRMTVNTUAACAAAACgAKADAAAAAGgoEAPc4kP4LtCV8AAAAAAAAAAJ4AngA" + + "6AAAASU5UUkFFUEhPWAIAFABJAE4AVABSAEEARQBQAEgATwBYAAEAEgBCAE8AQQB" + + "SAEQAUgBPAE8ATQAEACgAaQBuAHQAcgBhAGUAcABoAG8AeAAuAGUAcABoAG8AeAA" + + "uAGMAbwBtAAMAPABCAG8AYQByAGQAcgBvAG8AbQAuAGkAbgB0AHIAYQBlAHAAaAB" + + "vAHgALgBlAHAAaABvAHgALgBjAG8AbQAAAAAA"; String expected = "NTLM TlRMTVNTUAADAAAAGAAYAFIAAAAAAAAAagAAAAYABgB" + "AAAAACAAIAEYAAAAEAAQATgAAAAAAAABqAAAABlIAAERPTUFJTlVTRVJOQU1FSE" + "9TVAaC+vLxUEHnUtpItj9Dp4kzwQfd61Lztg=="; @@ -456,14 +476,10 @@ NTCredentials cred = new NTCredentials("username","password", "host", "domain"); state.setCredentials(null, cred); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", - "NTLM TlRMTVNTUAACAAAACgAKADAAAAAGgoEAPc4kP4LtCV8AAAAAAAAAAJ4AngA" + - "6AAAASU5UUkFFUEhPWAIAFABJAE4AVABSAEEARQBQAEgATwBYAAEAEgBCAE8AQQB" + - "SAEQAUgBPAE8ATQAEACgAaQBuAHQAcgBhAGUAcABoAG8AeAAuAGUAcABoAG8AeAA" + - "uAGMAbwBtAAMAPABCAG8AYQByAGQAcgBvAG8AbQAuAGkAbgB0AHIAYQBlAHAAaAB" + - "vAHgALgBlAHAAaABvAHgALgBjAG8AbQAAAAAA")); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); method.addRequestHeader("Host", "host"); - assertTrue(Authenticator.authenticate(method,state)); + AuthScheme authscheme = new NTLMScheme(challenge); + assertTrue(HttpAuthenticator.authenticate(authscheme, method, state)); assertTrue(null != method.getRequestHeader("Authorization")); assertEquals(expected, method.getRequestHeader("Authorization").getValue());
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]