diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterHttpServer.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterHttpServer.java index 0cf884f15c..d223e2a2f8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterHttpServer.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterHttpServer.java @@ -89,8 +89,8 @@ protected void serviceStart() throws Exception { this.httpServer = builder.build(); - NameNodeHttpServer.initWebHdfs(conf, httpAddress.getHostName(), httpServer, - RouterWebHdfsMethods.class.getPackage().getName()); + NameNodeHttpServer.initWebHdfs(conf, httpAddress.getHostName(), null, + httpServer, RouterWebHdfsMethods.class.getPackage().getName()); this.httpServer.setAttribute(NAMENODE_ATTRIBUTE_KEY, this.router); this.httpServer.setAttribute(JspHelper.CURRENT_CONF, this.conf); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java index ae9c7feca7..1bc43b896a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java @@ -77,6 +77,7 @@ public class NameNodeHttpServer { } public static void initWebHdfs(Configuration conf, String hostname, + String httpKeytab, HttpServer2 httpServer2, String jerseyResourcePackage) throws IOException { // set user pattern based on configuration file @@ -94,7 +95,8 @@ public static void initWebHdfs(Configuration conf, String hostname, final String name = className; final String pathSpec = WebHdfsFileSystem.PATH_PREFIX + "/*"; - Map params = getAuthFilterParams(conf, hostname); + Map params = getAuthFilterParams(conf, hostname, + httpKeytab); HttpServer2.defineFilter(httpServer2.getWebAppContext(), name, className, params, new String[] { pathSpec }); HttpServer2.LOG.info("Added filter '" + name + "' (class=" + className @@ -167,8 +169,9 @@ void start() throws IOException { httpServer.setAttribute(DFSConfigKeys.DFS_DATANODE_HTTPS_PORT_KEY, datanodeSslPort.getPort()); } - - initWebHdfs(conf, bindAddress.getHostName(), httpServer, + String httpKeytab = conf.get(DFSUtil.getSpnegoKeytabKey(conf, + DFSConfigKeys.DFS_NAMENODE_KEYTAB_FILE_KEY)); + initWebHdfs(conf, bindAddress.getHostName(), httpKeytab, httpServer, NamenodeWebHdfsMethods.class.getPackage().getName()); httpServer.setAttribute(NAMENODE_ATTRIBUTE_KEY, nn); @@ -191,7 +194,7 @@ void start() throws IOException { } private static Map getAuthFilterParams(Configuration conf, - String hostname) throws IOException { + String hostname, String httpKeytab) throws IOException { Map params = new HashMap(); // Select configs beginning with 'dfs.web.authentication.' Iterator> iterator = conf.iterator(); @@ -214,8 +217,6 @@ private static Map getAuthFilterParams(Configuration conf, DFSConfigKeys.DFS_WEB_AUTHENTICATION_KERBEROS_PRINCIPAL_KEY + "' is not set."); } - String httpKeytab = conf.get(DFSUtil.getSpnegoKeytabKey(conf, - DFSConfigKeys.DFS_NAMENODE_KEYTAB_FILE_KEY)); if (httpKeytab != null && !httpKeytab.isEmpty()) { params.put( DFSConfigKeys.DFS_WEB_AUTHENTICATION_KERBEROS_KEYTAB_KEY,