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
ConstructorDescriptionCreate a newSecurityContextCallableProcessingInterceptor
that uses theSecurityContext
from theSecurityContextHolder
at the timebeforeConcurrentHandling(NativeWebRequest, Callable)
is invoked.SecurityContextCallableProcessingInterceptor
(SecurityContext securityContext) Creates a newSecurityContextCallableProcessingInterceptor
with the specifiedSecurityContext
. -
Method Summary
Modifier and TypeMethodDescription<T> void
beforeConcurrentHandling
(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task) <T> void
postProcess
(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task, Object concurrentResult) <T> void
preProcess
(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task) void
setSecurityContextHolderStrategy
(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategy
to use.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.context.request.async.CallableProcessingInterceptor
afterCompletion, handleError, handleTimeout
-
Constructor Details
-
SecurityContextCallableProcessingInterceptor
public SecurityContextCallableProcessingInterceptor()Create a newSecurityContextCallableProcessingInterceptor
that uses theSecurityContext
from theSecurityContextHolder
at the timebeforeConcurrentHandling(NativeWebRequest, Callable)
is invoked. -
SecurityContextCallableProcessingInterceptor
Creates a newSecurityContextCallableProcessingInterceptor
with the specifiedSecurityContext
.- Parameters:
securityContext
- theSecurityContext
to set on theSecurityContextHolder
inpreProcess(NativeWebRequest, Callable)
. Cannot be null.- Throws:
IllegalArgumentException
- ifSecurityContext
is null.
-
-
Method Details
-
beforeConcurrentHandling
public <T> void beforeConcurrentHandling(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task) - Specified by:
beforeConcurrentHandling
in interfaceorg.springframework.web.context.request.async.CallableProcessingInterceptor
-
preProcess
public <T> void preProcess(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task) - Specified by:
preProcess
in 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:
postProcess
in interfaceorg.springframework.web.context.request.async.CallableProcessingInterceptor
-
setSecurityContextHolderStrategy
public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategy
to use. The default action is to use theSecurityContextHolderStrategy
stored inSecurityContextHolder
.- Since:
- 5.8
-