Merged revision(s) 1605049 from hadoop/common/trunk:
HADOOP-10665. Make Hadoop Authentication Handler loads case in-sensitive (Contributed by Benoy Antony) ........ git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1605050 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b86ac2279a
commit
8c19ff9192
|
@ -134,11 +134,15 @@ public class AuthenticationFilter implements Filter {
|
||||||
String authHandlerName = config.getProperty(AUTH_TYPE, null);
|
String authHandlerName = config.getProperty(AUTH_TYPE, null);
|
||||||
String authHandlerClassName;
|
String authHandlerClassName;
|
||||||
if (authHandlerName == null) {
|
if (authHandlerName == null) {
|
||||||
throw new ServletException("Authentication type must be specified: simple|kerberos|<class>");
|
throw new ServletException("Authentication type must be specified: " +
|
||||||
|
PseudoAuthenticationHandler.TYPE + "|" +
|
||||||
|
KerberosAuthenticationHandler.TYPE + "|<class>");
|
||||||
}
|
}
|
||||||
if (authHandlerName.equals("simple")) {
|
if (authHandlerName.toLowerCase(Locale.ENGLISH).equals(
|
||||||
|
PseudoAuthenticationHandler.TYPE)) {
|
||||||
authHandlerClassName = PseudoAuthenticationHandler.class.getName();
|
authHandlerClassName = PseudoAuthenticationHandler.class.getName();
|
||||||
} else if (authHandlerName.equals("kerberos")) {
|
} else if (authHandlerName.toLowerCase(Locale.ENGLISH).equals(
|
||||||
|
KerberosAuthenticationHandler.TYPE)) {
|
||||||
authHandlerClassName = KerberosAuthenticationHandler.class.getName();
|
authHandlerClassName = KerberosAuthenticationHandler.class.getName();
|
||||||
} else {
|
} else {
|
||||||
authHandlerClassName = authHandlerName;
|
authHandlerClassName = authHandlerName;
|
||||||
|
|
|
@ -74,6 +74,8 @@ public class TestAuthenticationFilter {
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
} catch (ServletException ex) {
|
} catch (ServletException ex) {
|
||||||
// Expected
|
// Expected
|
||||||
|
Assert.assertEquals("Authentication type must be specified: simple|kerberos|<class>",
|
||||||
|
ex.getMessage());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -234,6 +236,27 @@ public class TestAuthenticationFilter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitCaseSensitivity() throws Exception {
|
||||||
|
// minimal configuration & simple auth handler (Pseudo)
|
||||||
|
AuthenticationFilter filter = new AuthenticationFilter();
|
||||||
|
try {
|
||||||
|
FilterConfig config = Mockito.mock(FilterConfig.class);
|
||||||
|
Mockito.when(config.getInitParameter(AuthenticationFilter.AUTH_TYPE)).thenReturn("SimPle");
|
||||||
|
Mockito.when(config.getInitParameter(AuthenticationFilter.AUTH_TOKEN_VALIDITY)).thenReturn(
|
||||||
|
(new Long(TOKEN_VALIDITY_SEC)).toString());
|
||||||
|
Mockito.when(config.getInitParameterNames()).thenReturn(
|
||||||
|
new Vector<String>(Arrays.asList(AuthenticationFilter.AUTH_TYPE,
|
||||||
|
AuthenticationFilter.AUTH_TOKEN_VALIDITY)).elements());
|
||||||
|
|
||||||
|
filter.init(config);
|
||||||
|
Assert.assertEquals(PseudoAuthenticationHandler.class,
|
||||||
|
filter.getAuthenticationHandler().getClass());
|
||||||
|
} finally {
|
||||||
|
filter.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRequestURL() throws Exception {
|
public void testGetRequestURL() throws Exception {
|
||||||
AuthenticationFilter filter = new AuthenticationFilter();
|
AuthenticationFilter filter = new AuthenticationFilter();
|
||||||
|
|
|
@ -97,6 +97,9 @@ Release 2.5.0 - UNRELEASED
|
||||||
HADOOP-10659. Refactor AccessControlList to reuse utility functions
|
HADOOP-10659. Refactor AccessControlList to reuse utility functions
|
||||||
and to improve performance. (Benoy Antony via Arpit Agarwal)
|
and to improve performance. (Benoy Antony via Arpit Agarwal)
|
||||||
|
|
||||||
|
HADOOP-10665. Make Hadoop Authentication Handler loads case in-sensitive
|
||||||
|
(Benoy Antony via vinayakumarb)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
Loading…
Reference in New Issue