|
@@ -25,8 +25,10 @@ import java.security.PrivilegedExceptionAction;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.commons.logging.LogFactory;
|
|
@@ -363,7 +365,8 @@ public class NameNode implements ClientProtocol, DatanodeProtocol,
|
|
final String name = "SPNEGO";
|
|
final String name = "SPNEGO";
|
|
final String classname = AuthFilter.class.getName();
|
|
final String classname = AuthFilter.class.getName();
|
|
final String pathSpec = "/" + WebHdfsFileSystem.PATH_PREFIX + "/*";
|
|
final String pathSpec = "/" + WebHdfsFileSystem.PATH_PREFIX + "/*";
|
|
- defineFilter(webAppContext, name, classname, null,
|
|
|
|
|
|
+ Map<String, String> params = getAuthFilterParams(conf);
|
|
|
|
+ defineFilter(webAppContext, name, classname, params,
|
|
new String[]{pathSpec});
|
|
new String[]{pathSpec});
|
|
LOG.info("Added filter '" + name + "' (class=" + classname + ")");
|
|
LOG.info("Added filter '" + name + "' (class=" + classname + ")");
|
|
|
|
|
|
@@ -373,6 +376,30 @@ public class NameNode implements ClientProtocol, DatanodeProtocol,
|
|
+ ";" + Param.class.getPackage().getName(), pathSpec);
|
|
+ ";" + Param.class.getPackage().getName(), pathSpec);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private Map<String, String> getAuthFilterParams(Configuration conf)
|
|
|
|
+ throws IOException {
|
|
|
|
+ Map<String, String> params = new HashMap<String, String>();
|
|
|
|
+ String principalInConf = conf
|
|
|
|
+ .get(DFSConfigKeys.DFS_WEB_AUTHENTICATION_KERBEROS_PRINCIPAL_KEY);
|
|
|
|
+ if (principalInConf != null && !principalInConf.isEmpty()) {
|
|
|
|
+ params
|
|
|
|
+ .put(
|
|
|
|
+ DFSConfigKeys.DFS_WEB_AUTHENTICATION_KERBEROS_PRINCIPAL_KEY,
|
|
|
|
+ SecurityUtil.getServerPrincipal(principalInConf,
|
|
|
|
+ serverAddress.getHostName()));
|
|
|
|
+ }
|
|
|
|
+ String httpKeytab = conf
|
|
|
|
+ .get(DFSConfigKeys.DFS_WEB_AUTHENTICATION_KERBEROS_KEYTAB_KEY);
|
|
|
|
+ if (httpKeytab != null && !httpKeytab.isEmpty()) {
|
|
|
|
+ params.put(
|
|
|
|
+ DFSConfigKeys.DFS_WEB_AUTHENTICATION_KERBEROS_KEYTAB_KEY,
|
|
|
|
+ httpKeytab);
|
|
|
|
+ }
|
|
|
|
+ params.put("kerberos.name.rules",
|
|
|
|
+ conf.get("hadoop.security.auth_to_local", "DEFAULT"));
|
|
|
|
+ return params;
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
boolean certSSL = conf.getBoolean("dfs.https.enable", false);
|
|
boolean certSSL = conf.getBoolean("dfs.https.enable", false);
|