Browse Source

HADOOP-17621. hadoop-auth to remove jetty-server dependency. (#2865)

Reviewed-by: Akira Ajisaka <aajisaka@apache.org>
(cherry picked from commit dac60b8282013d7776667415a429e7ca35efba66)
Wei-Chiu Chuang 4 years ago
parent
commit
1110b03752

+ 1 - 5
hadoop-common-project/hadoop-auth/pom.xml

@@ -193,11 +193,7 @@
       <artifactId>guava</artifactId>
       <artifactId>guava</artifactId>
       <scope>test</scope>
       <scope>test</scope>
     </dependency>
     </dependency>
-    <dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-server</artifactId>
-    </dependency>
-  </dependencies>
+ </dependencies>
 
 
   <build>
   <build>
     <plugins>
     <plugins>

+ 2 - 6
hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/AuthenticationFilter.java

@@ -19,7 +19,6 @@ import org.apache.hadoop.security.authentication.client.AuthenticatedURL;
 import org.apache.hadoop.security.authentication.client.AuthenticationException;
 import org.apache.hadoop.security.authentication.client.AuthenticationException;
 import org.apache.hadoop.security.authentication.client.KerberosAuthenticator;
 import org.apache.hadoop.security.authentication.client.KerberosAuthenticator;
 import org.apache.hadoop.security.authentication.util.*;
 import org.apache.hadoop.security.authentication.util.*;
-import org.eclipse.jetty.server.Response;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -621,7 +620,7 @@ public class AuthenticationFilter implements Filter {
           errCode = HttpServletResponse.SC_FORBIDDEN;
           errCode = HttpServletResponse.SC_FORBIDDEN;
         }
         }
         // After Jetty 9.4.21, sendError() no longer allows a custom message.
         // After Jetty 9.4.21, sendError() no longer allows a custom message.
-        // use setStatusWithReason() to set a custom message.
+        // use setStatus() to set a custom message.
         String reason;
         String reason;
         if (authenticationEx == null) {
         if (authenticationEx == null) {
           reason = "Authentication required";
           reason = "Authentication required";
@@ -629,10 +628,7 @@ public class AuthenticationFilter implements Filter {
           reason = authenticationEx.getMessage();
           reason = authenticationEx.getMessage();
         }
         }
 
 
-        if (httpResponse instanceof Response) {
-          ((Response)httpResponse).setStatusWithReason(errCode, reason);
-        }
-
+        httpResponse.setStatus(errCode, reason);
         httpResponse.sendError(errCode, reason);
         httpResponse.sendError(errCode, reason);
       }
       }
     }
     }