|
@@ -97,9 +97,6 @@ import com.sun.jersey.spi.container.servlet.ServletContainer;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import static org.apache.hadoop.fs.CommonConfigurationKeys.DEFAULT_HADOOP_HTTP_STATIC_USER;
|
|
|
-import static org.apache.hadoop.fs.CommonConfigurationKeys.HADOOP_HTTP_STATIC_USER;
|
|
|
-
|
|
|
/**
|
|
|
* Create a Jetty embedded server to answer http requests. The primary goal is
|
|
|
* to serve up status information for the server. There are three contexts:
|
|
@@ -1171,24 +1168,6 @@ public final class HttpServer2 implements FilterContainer {
|
|
|
return sb.toString();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * check whether user is static and unauthenticated, if the
|
|
|
- * answer is TRUE, that means http sever is in non-security
|
|
|
- * environment.
|
|
|
- * @param servletContext the servlet context.
|
|
|
- * @param request the servlet request.
|
|
|
- * @return TRUE/FALSE based on the logic described above.
|
|
|
- */
|
|
|
- public static boolean isStaticUserAndNoneAuthType(
|
|
|
- ServletContext servletContext, HttpServletRequest request) {
|
|
|
- Configuration conf =
|
|
|
- (Configuration) servletContext.getAttribute(CONF_CONTEXT_ATTRIBUTE);
|
|
|
- final String authType = request.getAuthType();
|
|
|
- final String staticUser = conf.get(HADOOP_HTTP_STATIC_USER,
|
|
|
- DEFAULT_HADOOP_HTTP_STATIC_USER);
|
|
|
- return authType == null && staticUser.equals(request.getRemoteUser());
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Checks the user has privileges to access to instrumentation servlets.
|
|
|
* <p/>
|
|
@@ -1286,14 +1265,9 @@ public final class HttpServer2 implements FilterContainer {
|
|
|
|
|
|
@Override
|
|
|
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
|
|
- throws ServletException, IOException {
|
|
|
- // If user is a static user and auth Type is null, that means
|
|
|
- // there is a non-security environment and no need authorization,
|
|
|
- // otherwise, do the authorization.
|
|
|
- final ServletContext servletContext = getServletContext();
|
|
|
- if (!HttpServer2.isStaticUserAndNoneAuthType(servletContext, request) &&
|
|
|
- !HttpServer2.isInstrumentationAccessAllowed(servletContext,
|
|
|
- request, response)) {
|
|
|
+ throws ServletException, IOException {
|
|
|
+ if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
|
|
|
+ request, response)) {
|
|
|
return;
|
|
|
}
|
|
|
response.setContentType("text/plain; charset=UTF-8");
|