diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 1099a3984ef..894aa945f49 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -391,6 +391,9 @@ Release 2.7.1 - UNRELEASED IMPROVEMENTS + HADOOP-12103. Small refactoring of DelegationTokenAuthenticationFilter to + allow code sharing. (Yongjun Zhang) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticationFilter.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticationFilter.java index b6e1a766383..af66ee56776 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticationFilter.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticationFilter.java @@ -115,7 +115,22 @@ public class DelegationTokenAuthenticationFilter protected Properties getConfiguration(String configPrefix, FilterConfig filterConfig) throws ServletException { Properties props = super.getConfiguration(configPrefix, filterConfig); + setAuthHandlerClass(props); + return props; + } + + /** + * Set AUTH_TYPE property to the name of the corresponding authentication + * handler class based on the input properties. + * @param props input properties. + */ + protected void setAuthHandlerClass(Properties props) + throws ServletException { String authType = props.getProperty(AUTH_TYPE); + if (authType == null) { + throw new ServletException("Config property " + + AUTH_TYPE + " doesn't exist"); + } if (authType.equals(PseudoAuthenticationHandler.TYPE)) { props.setProperty(AUTH_TYPE, PseudoDelegationTokenAuthenticationHandler.class.getName()); @@ -123,7 +138,6 @@ protected Properties getConfiguration(String configPrefix, props.setProperty(AUTH_TYPE, KerberosDelegationTokenAuthenticationHandler.class.getName()); } - return props; } /**