diff --git a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/AuthenticationFilter.java b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/AuthenticationFilter.java index 6a2a82003f0..dc7f0adeb3b 100644 --- a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/AuthenticationFilter.java +++ b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/AuthenticationFilter.java @@ -134,11 +134,15 @@ public class AuthenticationFilter implements Filter { String authHandlerName = config.getProperty(AUTH_TYPE, null); String authHandlerClassName; if (authHandlerName == null) { - throw new ServletException("Authentication type must be specified: simple|kerberos|"); + throw new ServletException("Authentication type must be specified: " + + PseudoAuthenticationHandler.TYPE + "|" + + KerberosAuthenticationHandler.TYPE + "|"); } - if (authHandlerName.equals("simple")) { + if (authHandlerName.toLowerCase(Locale.ENGLISH).equals( + PseudoAuthenticationHandler.TYPE)) { authHandlerClassName = PseudoAuthenticationHandler.class.getName(); - } else if (authHandlerName.equals("kerberos")) { + } else if (authHandlerName.toLowerCase(Locale.ENGLISH).equals( + KerberosAuthenticationHandler.TYPE)) { authHandlerClassName = KerberosAuthenticationHandler.class.getName(); } else { authHandlerClassName = authHandlerName; diff --git a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java index 322a50ce501..989025fbf87 100644 --- a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java +++ b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java @@ -74,6 +74,8 @@ public class TestAuthenticationFilter { Assert.fail(); } catch (ServletException ex) { // Expected + Assert.assertEquals("Authentication type must be specified: simple|kerberos|", + ex.getMessage()); } catch (Exception ex) { Assert.fail(); } finally { @@ -233,6 +235,27 @@ public class TestAuthenticationFilter { filter.destroy(); } } + + @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(Arrays.asList(AuthenticationFilter.AUTH_TYPE, + AuthenticationFilter.AUTH_TOKEN_VALIDITY)).elements()); + + filter.init(config); + Assert.assertEquals(PseudoAuthenticationHandler.class, + filter.getAuthenticationHandler().getClass()); + } finally { + filter.destroy(); + } + } @Test public void testGetRequestURL() throws Exception { diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 68f222ed548..0a786363a7c 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -97,6 +97,9 @@ Release 2.5.0 - UNRELEASED HADOOP-10659. Refactor AccessControlList to reuse utility functions and to improve performance. (Benoy Antony via Arpit Agarwal) + HADOOP-10665. Make Hadoop Authentication Handler loads case in-sensitive + (Benoy Antony via vinayakumarb) + OPTIMIZATIONS BUG FIXES