Remove Deprecation Markers
Since Spring Security still needs these methods and classes, we should wait on deprecating them if we can. Instead, this commit changes the original classes to have a boolean property that is currently false, but will switch to true in 6.0. At that time, BearerTokenAuthenticationFilter can change to use the handler. Closes gh-11932
This commit is contained in:
+7
-10
@@ -27,6 +27,7 @@ import org.springframework.core.log.LogMessage;
|
||||
import org.springframework.security.authentication.AuthenticationDetailsSource;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.AuthenticationManagerResolver;
|
||||
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
@@ -39,7 +40,6 @@ import org.springframework.security.oauth2.server.resource.web.BearerTokenAuthen
|
||||
import org.springframework.security.oauth2.server.resource.web.BearerTokenResolver;
|
||||
import org.springframework.security.oauth2.server.resource.web.DefaultBearerTokenResolver;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.security.web.authentication.AuthenticationEntryPointFailureHandlerAdapter;
|
||||
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
||||
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
||||
import org.springframework.security.web.context.NullSecurityContextRepository;
|
||||
@@ -73,12 +73,12 @@ public class BearerTokenAuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
private AuthenticationEntryPoint authenticationEntryPoint = new BearerTokenAuthenticationEntryPoint();
|
||||
|
||||
private AuthenticationFailureHandler authenticationFailureHandler = new AuthenticationEntryPointFailureHandlerAdapter(
|
||||
(request, response, authException) -> {
|
||||
// This is a lambda and not a method reference so that the FailureHandler
|
||||
// reflects entrypoint updates
|
||||
this.authenticationEntryPoint.commence(request, response, authException);
|
||||
});
|
||||
private AuthenticationFailureHandler authenticationFailureHandler = (request, response, exception) -> {
|
||||
if (exception instanceof AuthenticationServiceException) {
|
||||
throw exception;
|
||||
}
|
||||
this.authenticationEntryPoint.commence(request, response, exception);
|
||||
};
|
||||
|
||||
private BearerTokenResolver bearerTokenResolver = new DefaultBearerTokenResolver();
|
||||
|
||||
@@ -192,10 +192,7 @@ public class BearerTokenAuthenticationFilter extends OncePerRequestFilter {
|
||||
* Set the {@link AuthenticationEntryPoint} to use. Defaults to
|
||||
* {@link BearerTokenAuthenticationEntryPoint}.
|
||||
* @param authenticationEntryPoint the {@code AuthenticationEntryPoint} to use
|
||||
* @deprecated use
|
||||
* {@link BearerTokenAuthenticationFilter#authenticationFailureHandler} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAuthenticationEntryPoint(final AuthenticationEntryPoint authenticationEntryPoint) {
|
||||
Assert.notNull(authenticationEntryPoint, "authenticationEntryPoint cannot be null");
|
||||
this.authenticationEntryPoint = authenticationEntryPoint;
|
||||
|
||||
Reference in New Issue
Block a user