Class SecurityContextCallableProcessingInterceptor
java.lang.Object
org.springframework.security.web.context.request.async.SecurityContextCallableProcessingInterceptor
- All Implemented Interfaces:
org.springframework.web.context.request.async.CallableProcessingInterceptor
public final class SecurityContextCallableProcessingInterceptor
extends Object
implements org.springframework.web.context.request.async.CallableProcessingInterceptor
Allows for integration with Spring MVC's Callable support.
A CallableProcessingInterceptor that establishes the injected
SecurityContext on the SecurityContextHolder when
preProcess(NativeWebRequest, Callable) is invoked. It also clear out the
SecurityContextHolder by invoking SecurityContextHolder.clearContext()
in the postProcess(NativeWebRequest, Callable, Object) method.
- Since:
- 3.2
-
Field Summary
Fields inherited from interface org.springframework.web.context.request.async.CallableProcessingInterceptor
RESPONSE_HANDLED, RESULT_NONE -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newSecurityContextCallableProcessingInterceptorthat uses theSecurityContextfrom theSecurityContextHolderat the timebeforeConcurrentHandling(NativeWebRequest, Callable)is invoked.SecurityContextCallableProcessingInterceptor(SecurityContext securityContext) Creates a newSecurityContextCallableProcessingInterceptorwith the specifiedSecurityContext. -
Method Summary
Modifier and TypeMethodDescription<T> voidbeforeConcurrentHandling(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task) <T> voidpostProcess(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task, Object concurrentResult) <T> voidpreProcess(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task) voidsetSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.context.request.async.CallableProcessingInterceptor
afterCompletion, handleError, handleTimeout
-
Constructor Details
-
SecurityContextCallableProcessingInterceptor
public SecurityContextCallableProcessingInterceptor()Create a newSecurityContextCallableProcessingInterceptorthat uses theSecurityContextfrom theSecurityContextHolderat the timebeforeConcurrentHandling(NativeWebRequest, Callable)is invoked. -
SecurityContextCallableProcessingInterceptor
Creates a newSecurityContextCallableProcessingInterceptorwith the specifiedSecurityContext.- Parameters:
securityContext- theSecurityContextto set on theSecurityContextHolderinpreProcess(NativeWebRequest, Callable). Cannot be null.- Throws:
IllegalArgumentException- ifSecurityContextis null.
-
-
Method Details
-
beforeConcurrentHandling
public <T> void beforeConcurrentHandling(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task) - Specified by:
beforeConcurrentHandlingin interfaceorg.springframework.web.context.request.async.CallableProcessingInterceptor
-
preProcess
public <T> void preProcess(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task) - Specified by:
preProcessin interfaceorg.springframework.web.context.request.async.CallableProcessingInterceptor
-
postProcess
public <T> void postProcess(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task, Object concurrentResult) - Specified by:
postProcessin interfaceorg.springframework.web.context.request.async.CallableProcessingInterceptor
-
setSecurityContextHolderStrategy
public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use. The default action is to use theSecurityContextHolderStrategystored inSecurityContextHolder.- Since:
- 5.8
-