Skip to content

Commit 733a380

Browse files
dongmyojzheaux
authored andcommitted
Remove Servlet Spec 2.5 Support for SecurityContextHolderAwareRequestFilter
Fixes: gh-6260
1 parent 3bcb1d9 commit 733a380

File tree

4 files changed

+6
-74
lines changed

4 files changed

+6
-74
lines changed

web/src/main/java/org/springframework/security/web/servletapi/HttpServlet25RequestFactory.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

web/src/main/java/org/springframework/security/web/servletapi/HttpServlet3RequestFactory.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@
4848
import org.springframework.util.CollectionUtils;
4949

5050
/**
51-
* Provides integration with the Servlet 3 APIs in addition to the ones found in
52-
* {@link HttpServlet25RequestFactory}. The additional methods that are integrated with
53-
* can be found below:
51+
* Provides integration with the Servlet 3 APIs. The additional methods that are
52+
* integrated with can be found below:
5453
*
5554
* <ul>
5655
* <li>{@link HttpServletRequest#authenticate(HttpServletResponse)} - Allows the user to
@@ -71,7 +70,6 @@
7170
* @author Rob Winch
7271
*
7372
* @see SecurityContextHolderAwareRequestFilter
74-
* @see HttpServlet25RequestFactory
7573
* @see Servlet3SecurityContextHolderAwareRequestWrapper
7674
* @see SecurityContextAsyncContext
7775
*/

web/src/main/java/org/springframework/security/web/servletapi/HttpServletRequestFactory.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919
import javax.servlet.http.HttpServletResponse;
2020

2121
/**
22-
* Internal interface for creating a {@link HttpServletRequest}. This allows for creating
23-
* a different implementation for Servlet 2.5 and Servlet 3.0 environments.
22+
* Internal interface for creating a {@link HttpServletRequest}.
2423
*
2524
* @author Rob Winch
2625
* @since 3.2
2726
* @see HttpServlet3RequestFactory
28-
* @see HttpServlet25RequestFactory
2927
*/
3028
interface HttpServletRequestFactory {
3129

web/src/main/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilter.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,14 @@
3535
import org.springframework.security.web.AuthenticationEntryPoint;
3636
import org.springframework.security.web.authentication.logout.LogoutHandler;
3737
import org.springframework.util.Assert;
38-
import org.springframework.util.ClassUtils;
3938
import org.springframework.web.filter.GenericFilterBean;
4039

4140
/**
4241
* A <code>Filter</code> which populates the <code>ServletRequest</code> with a request
4342
* wrapper which implements the servlet API security methods.
4443
* <p>
45-
* In pre servlet 3 environment the wrapper class used is
46-
* {@link SecurityContextHolderAwareRequestWrapper}. See its javadoc for the methods that
47-
* are implemented.
48-
* </p>
49-
* <p>
50-
* In a servlet 3 environment {@link SecurityContextHolderAwareRequestWrapper} is extended
51-
* to provide the following additional methods:
44+
* {@link SecurityContextHolderAwareRequestWrapper} is extended to provide the following
45+
* additional methods:
5246
* </p>
5347
* <ul>
5448
* <li>{@link HttpServletRequest#authenticate(HttpServletResponse)} - Allows the user to
@@ -114,8 +108,6 @@ public void setRolePrefix(String rolePrefix) {
114108
* @param authenticationEntryPoint the {@link AuthenticationEntryPoint} to use when
115109
* invoking {@link HttpServletRequest#authenticate(HttpServletResponse)} if the user
116110
* is not authenticated.
117-
*
118-
* @throws IllegalStateException if the Servlet 3 APIs are not found on the classpath
119111
*/
120112
public void setAuthenticationEntryPoint(
121113
AuthenticationEntryPoint authenticationEntryPoint) {
@@ -136,8 +128,6 @@ public void setAuthenticationEntryPoint(
136128
*
137129
* @param authenticationManager the {@link AuthenticationManager} to use when invoking
138130
* {@link HttpServletRequest#login(String, String)}
139-
*
140-
* @throws IllegalStateException if the Servlet 3 APIs are not found on the classpath
141131
*/
142132
public void setAuthenticationManager(AuthenticationManager authenticationManager) {
143133
this.authenticationManager = authenticationManager;
@@ -158,8 +148,6 @@ public void setAuthenticationManager(AuthenticationManager authenticationManager
158148
*
159149
* @param logoutHandlers the {@code List&lt;LogoutHandler&gt;}s when invoking
160150
* {@link HttpServletRequest#logout()}.
161-
*
162-
* @throws IllegalStateException if the Servlet 3 APIs are not found on the classpath
163151
*/
164152
public void setLogoutHandlers(List<LogoutHandler> logoutHandlers) {
165153
this.logoutHandlers = logoutHandlers;
@@ -179,8 +167,7 @@ public void afterPropertiesSet() throws ServletException {
179167

180168
private void updateFactory() {
181169
String rolePrefix = this.rolePrefix;
182-
this.requestFactory = isServlet3() ? createServlet3Factory(rolePrefix)
183-
: new HttpServlet25RequestFactory(this.trustResolver, rolePrefix);
170+
this.requestFactory = createServlet3Factory(rolePrefix);
184171
}
185172

186173
/**
@@ -205,11 +192,4 @@ private HttpServletRequestFactory createServlet3Factory(String rolePrefix) {
205192
return factory;
206193
}
207194

208-
/**
209-
* Returns true if the Servlet 3 APIs are detected.
210-
* @return
211-
*/
212-
private boolean isServlet3() {
213-
return ClassUtils.hasMethod(ServletRequest.class, "startAsync");
214-
}
215195
}

0 commit comments

Comments
 (0)