HADOOP-8512. AuthenticatedURL should reset the Token when the server returns other than OK on authentication (tucu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1351408 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alejandro Abdelnur 2012-06-18 16:28:52 +00:00
parent 0e7214933d
commit 3dd40a70ca
3 changed files with 9 additions and 1 deletions

View File

@ -266,6 +266,7 @@ public class AuthenticatedURL {
} }
} }
} else { } else {
token.set(null);
throw new AuthenticationException("Authentication failed, status: " + conn.getResponseCode() + throw new AuthenticationException("Authentication failed, status: " + conn.getResponseCode() +
", message: " + conn.getResponseMessage()); ", message: " + conn.getResponseMessage());
} }

View File

@ -13,6 +13,7 @@
*/ */
package org.apache.hadoop.security.authentication.client; package org.apache.hadoop.security.authentication.client;
import junit.framework.Assert;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.mockito.Mockito; import org.mockito.Mockito;
@ -100,11 +101,14 @@ public class TestAuthenticatedURL extends TestCase {
headers.put("Set-Cookie", cookies); headers.put("Set-Cookie", cookies);
Mockito.when(conn.getHeaderFields()).thenReturn(headers); Mockito.when(conn.getHeaderFields()).thenReturn(headers);
AuthenticatedURL.Token token = new AuthenticatedURL.Token();
token.set("bar");
try { try {
AuthenticatedURL.extractToken(conn, new AuthenticatedURL.Token()); AuthenticatedURL.extractToken(conn, token);
fail(); fail();
} catch (AuthenticationException ex) { } catch (AuthenticationException ex) {
// Expected // Expected
Assert.assertFalse(token.isSet());
} catch (Exception ex) { } catch (Exception ex) {
fail(); fail();
} }

View File

@ -261,6 +261,9 @@ Branch-2 ( Unreleased changes )
HADOOP-8509. JarFinder duplicate entry: META-INF/MANIFEST.MF exception (tucu) HADOOP-8509. JarFinder duplicate entry: META-INF/MANIFEST.MF exception (tucu)
HADOOP-8512. AuthenticatedURL should reset the Token when the server returns
other than OK on authentication (tucu)
BREAKDOWN OF HDFS-3042 SUBTASKS BREAKDOWN OF HDFS-3042 SUBTASKS
HADOOP-8220. ZKFailoverController doesn't handle failure to become active HADOOP-8220. ZKFailoverController doesn't handle failure to become active