|
@@ -17,12 +17,11 @@
|
|
*/
|
|
*/
|
|
package org.apache.hadoop.hdfs.web;
|
|
package org.apache.hadoop.hdfs.web;
|
|
|
|
|
|
-import java.util.Map;
|
|
|
|
import java.util.Properties;
|
|
import java.util.Properties;
|
|
|
|
|
|
import javax.servlet.FilterConfig;
|
|
import javax.servlet.FilterConfig;
|
|
|
|
+import javax.servlet.ServletException;
|
|
|
|
|
|
-import org.apache.hadoop.conf.Configuration;
|
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
|
|
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
|
|
import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler;
|
|
import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler;
|
|
@@ -41,30 +40,21 @@ public class AuthFilter extends AuthenticationFilter {
|
|
* The prefix is removed from the returned property names.
|
|
* The prefix is removed from the returned property names.
|
|
*
|
|
*
|
|
* @param prefix parameter not used.
|
|
* @param prefix parameter not used.
|
|
- * @param config parameter not used.
|
|
|
|
|
|
+ * @param config parameter contains the initialization values.
|
|
* @return Hadoop-Auth configuration properties.
|
|
* @return Hadoop-Auth configuration properties.
|
|
|
|
+ * @throws ServletException
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- protected Properties getConfiguration(String prefix, FilterConfig config) {
|
|
|
|
- final Configuration conf = new Configuration();
|
|
|
|
- final Properties p = new Properties();
|
|
|
|
-
|
|
|
|
- //set authentication type
|
|
|
|
|
|
+ protected Properties getConfiguration(String prefix, FilterConfig config)
|
|
|
|
+ throws ServletException {
|
|
|
|
+ final Properties p = super.getConfiguration(CONF_PREFIX, config);
|
|
|
|
+ // set authentication type
|
|
p.setProperty(AUTH_TYPE, UserGroupInformation.isSecurityEnabled()?
|
|
p.setProperty(AUTH_TYPE, UserGroupInformation.isSecurityEnabled()?
|
|
KerberosAuthenticationHandler.TYPE: PseudoAuthenticationHandler.TYPE);
|
|
KerberosAuthenticationHandler.TYPE: PseudoAuthenticationHandler.TYPE);
|
|
//For Pseudo Authentication, allow anonymous.
|
|
//For Pseudo Authentication, allow anonymous.
|
|
p.setProperty(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED, "true");
|
|
p.setProperty(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED, "true");
|
|
//set cookie path
|
|
//set cookie path
|
|
p.setProperty(COOKIE_PATH, "/");
|
|
p.setProperty(COOKIE_PATH, "/");
|
|
-
|
|
|
|
- //set other configurations with CONF_PREFIX
|
|
|
|
- for (Map.Entry<String, String> entry : conf) {
|
|
|
|
- final String key = entry.getKey();
|
|
|
|
- if (key.startsWith(CONF_PREFIX)) {
|
|
|
|
- //remove prefix from the key and set property
|
|
|
|
- p.setProperty(key.substring(CONF_PREFIX.length()), conf.get(key));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return p;
|
|
|
|
|
|
+ return p;
|
|
}
|
|
}
|
|
}
|
|
}
|