HADOOP-12103. Small refactoring of DelegationTokenAuthenticationFilter to allow code sharing. Contributed by Yongjun Zhang.

(cherry picked from commit 49f5d20efe)
This commit is contained in:
Yongjun Zhang 2015-06-19 14:06:17 -07:00
parent 2e13e5b253
commit 430ba669cc
2 changed files with 18 additions and 1 deletions

View File

@ -391,6 +391,9 @@ Release 2.7.1 - UNRELEASED
IMPROVEMENTS IMPROVEMENTS
HADOOP-12103. Small refactoring of DelegationTokenAuthenticationFilter to
allow code sharing. (Yongjun Zhang)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -115,7 +115,22 @@ public class DelegationTokenAuthenticationFilter
protected Properties getConfiguration(String configPrefix, protected Properties getConfiguration(String configPrefix,
FilterConfig filterConfig) throws ServletException { FilterConfig filterConfig) throws ServletException {
Properties props = super.getConfiguration(configPrefix, filterConfig); 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); String authType = props.getProperty(AUTH_TYPE);
if (authType == null) {
throw new ServletException("Config property "
+ AUTH_TYPE + " doesn't exist");
}
if (authType.equals(PseudoAuthenticationHandler.TYPE)) { if (authType.equals(PseudoAuthenticationHandler.TYPE)) {
props.setProperty(AUTH_TYPE, props.setProperty(AUTH_TYPE,
PseudoDelegationTokenAuthenticationHandler.class.getName()); PseudoDelegationTokenAuthenticationHandler.class.getName());
@ -123,7 +138,6 @@ public class DelegationTokenAuthenticationFilter
props.setProperty(AUTH_TYPE, props.setProperty(AUTH_TYPE,
KerberosDelegationTokenAuthenticationHandler.class.getName()); KerberosDelegationTokenAuthenticationHandler.class.getName());
} }
return props;
} }
/** /**