Skip to content

Remove Servlet Spec 2.5 Support for SecurityContextHolderAwareRequestFilter #6286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@
import org.springframework.util.CollectionUtils;

/**
* Provides integration with the Servlet 3 APIs in addition to the ones found in
* {@link HttpServlet25RequestFactory}. The additional methods that are integrated with
* can be found below:
* Provides integration with the Servlet 3 APIs. The additional methods that are
* integrated with can be found below:
*
* <ul>
* <li>{@link HttpServletRequest#authenticate(HttpServletResponse)} - Allows the user to
Expand All @@ -71,7 +70,6 @@
* @author Rob Winch
*
* @see SecurityContextHolderAwareRequestFilter
* @see HttpServlet25RequestFactory
* @see Servlet3SecurityContextHolderAwareRequestWrapper
* @see SecurityContextAsyncContext
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
import javax.servlet.http.HttpServletResponse;

/**
* Internal interface for creating a {@link HttpServletRequest}. This allows for creating
* a different implementation for Servlet 2.5 and Servlet 3.0 environments.
* Internal interface for creating a {@link HttpServletRequest}.
*
* @author Rob Winch
* @since 3.2
* @see HttpServlet3RequestFactory
* @see HttpServlet25RequestFactory
*/
interface HttpServletRequestFactory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,14 @@
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.authentication.logout.LogoutHandler;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.web.filter.GenericFilterBean;

/**
* A <code>Filter</code> which populates the <code>ServletRequest</code> with a request
* wrapper which implements the servlet API security methods.
* <p>
* In pre servlet 3 environment the wrapper class used is
* {@link SecurityContextHolderAwareRequestWrapper}. See its javadoc for the methods that
* are implemented.
* </p>
* <p>
* In a servlet 3 environment {@link SecurityContextHolderAwareRequestWrapper} is extended
* to provide the following additional methods:
* {@link SecurityContextHolderAwareRequestWrapper} is extended to provide the following
* additional methods:
* </p>
* <ul>
* <li>{@link HttpServletRequest#authenticate(HttpServletResponse)} - Allows the user to
Expand Down Expand Up @@ -114,8 +108,6 @@ public void setRolePrefix(String rolePrefix) {
* @param authenticationEntryPoint the {@link AuthenticationEntryPoint} to use when
* invoking {@link HttpServletRequest#authenticate(HttpServletResponse)} if the user
* is not authenticated.
*
* @throws IllegalStateException if the Servlet 3 APIs are not found on the classpath
*/
public void setAuthenticationEntryPoint(
AuthenticationEntryPoint authenticationEntryPoint) {
Expand All @@ -136,8 +128,6 @@ public void setAuthenticationEntryPoint(
*
* @param authenticationManager the {@link AuthenticationManager} to use when invoking
* {@link HttpServletRequest#login(String, String)}
*
* @throws IllegalStateException if the Servlet 3 APIs are not found on the classpath
*/
public void setAuthenticationManager(AuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
Expand All @@ -158,8 +148,6 @@ public void setAuthenticationManager(AuthenticationManager authenticationManager
*
* @param logoutHandlers the {@code List&lt;LogoutHandler&gt;}s when invoking
* {@link HttpServletRequest#logout()}.
*
* @throws IllegalStateException if the Servlet 3 APIs are not found on the classpath
*/
public void setLogoutHandlers(List<LogoutHandler> logoutHandlers) {
this.logoutHandlers = logoutHandlers;
Expand All @@ -179,8 +167,7 @@ public void afterPropertiesSet() throws ServletException {

private void updateFactory() {
String rolePrefix = this.rolePrefix;
this.requestFactory = isServlet3() ? createServlet3Factory(rolePrefix)
: new HttpServlet25RequestFactory(this.trustResolver, rolePrefix);
this.requestFactory = createServlet3Factory(rolePrefix);
}

/**
Expand All @@ -205,11 +192,4 @@ private HttpServletRequestFactory createServlet3Factory(String rolePrefix) {
return factory;
}

/**
* Returns true if the Servlet 3 APIs are detected.
* @return
*/
private boolean isServlet3() {
return ClassUtils.hasMethod(ServletRequest.class, "startAsync");
}
}