|
@@ -17,17 +17,19 @@
|
|
*/
|
|
*/
|
|
package org.apache.hadoop.security;
|
|
package org.apache.hadoop.security;
|
|
|
|
|
|
-import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
|
|
|
|
-import org.apache.hadoop.conf.Configuration;
|
|
|
|
-import org.apache.hadoop.http.FilterContainer;
|
|
|
|
-import org.apache.hadoop.http.FilterInitializer;
|
|
|
|
-
|
|
|
|
import java.io.FileReader;
|
|
import java.io.FileReader;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.Reader;
|
|
import java.io.Reader;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
+import org.apache.hadoop.conf.Configuration;
|
|
|
|
+import org.apache.hadoop.http.FilterContainer;
|
|
|
|
+import org.apache.hadoop.http.FilterInitializer;
|
|
|
|
+import org.apache.hadoop.http.HttpServer;
|
|
|
|
+import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
|
|
|
|
+import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Initializes Alfredo AuthenticationFilter which provides support for
|
|
* Initializes Alfredo AuthenticationFilter which provides support for
|
|
* Kerberos HTTP SPNEGO authentication.
|
|
* Kerberos HTTP SPNEGO authentication.
|
|
@@ -91,6 +93,20 @@ public class AuthenticationFilterInitializer extends FilterInitializer {
|
|
throw new RuntimeException("Could not read HTTP signature secret file: " + signatureSecretFile);
|
|
throw new RuntimeException("Could not read HTTP signature secret file: " + signatureSecretFile);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Resolve _HOST into bind address
|
|
|
|
+ String bindAddress = conf.get(HttpServer.BIND_ADDRESS);
|
|
|
|
+ String principal = filterConfig
|
|
|
|
+ .get(KerberosAuthenticationHandler.PRINCIPAL);
|
|
|
|
+ if (principal != null) {
|
|
|
|
+ try {
|
|
|
|
+ principal = SecurityUtil.getServerPrincipal(principal, bindAddress);
|
|
|
|
+ } catch (IOException ex) {
|
|
|
|
+ throw new RuntimeException(
|
|
|
|
+ "Could not resolve Kerberos principal name: " + ex.toString(), ex);
|
|
|
|
+ }
|
|
|
|
+ filterConfig.put(KerberosAuthenticationHandler.PRINCIPAL, principal);
|
|
|
|
+ }
|
|
|
|
+
|
|
container.addFilter("authentication",
|
|
container.addFilter("authentication",
|
|
AuthenticationFilter.class.getName(),
|
|
AuthenticationFilter.class.getName(),
|
|
filterConfig);
|
|
filterConfig);
|