Class SecurityContextCallableProcessingInterceptor
- java.lang.Object
-
- org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
-
- org.springframework.security.web.context.request.async.SecurityContextCallableProcessingInterceptor
-
- All Implemented Interfaces:
org.springframework.web.context.request.async.CallableProcessingInterceptor
public final class SecurityContextCallableProcessingInterceptor extends org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
Allows for integration with Spring MVC's
Callable
support.A
CallableProcessingInterceptor
that establishes the injectedSecurityContext
on theSecurityContextHolder
whenpreProcess(NativeWebRequest, Callable)
is invoked. It also clear out theSecurityContextHolder
by invokingSecurityContextHolder.clearContext()
in thepostProcess(NativeWebRequest, Callable, Object)
method.- Since:
- 3.2
-
-
Constructor Summary
Constructors Constructor Description SecurityContextCallableProcessingInterceptor()
Create 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> void
beforeConcurrentHandling(org.springframework.web.context.request.NativeWebRequest request, java.util.concurrent.Callable<T> task)
<T> void
postProcess(org.springframework.web.context.request.NativeWebRequest request, java.util.concurrent.Callable<T> task, java.lang.Object concurrentResult)
<T> void
preProcess(org.springframework.web.context.request.NativeWebRequest request, java.util.concurrent.Callable<T> task)
void
setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy)
Sets theSecurityContextHolderStrategy
to use.
-
-
-
Constructor Detail
-
SecurityContextCallableProcessingInterceptor
public SecurityContextCallableProcessingInterceptor()
Create a newSecurityContextCallableProcessingInterceptor
that uses theSecurityContext
from theSecurityContextHolder
at the timebeforeConcurrentHandling(NativeWebRequest, Callable)
is invoked.
-
SecurityContextCallableProcessingInterceptor
public SecurityContextCallableProcessingInterceptor(SecurityContext securityContext)
Creates a newSecurityContextCallableProcessingInterceptor
with the specifiedSecurityContext
.- Parameters:
securityContext
- theSecurityContext
to set on theSecurityContextHolder
inpreProcess(NativeWebRequest, Callable)
. Cannot be null.- Throws:
java.lang.IllegalArgumentException
- ifSecurityContext
is null.
-
-
Method Detail
-
beforeConcurrentHandling
public <T> void beforeConcurrentHandling(org.springframework.web.context.request.NativeWebRequest request, java.util.concurrent.Callable<T> task)
- Specified by:
beforeConcurrentHandling
in interfaceorg.springframework.web.context.request.async.CallableProcessingInterceptor
- Overrides:
beforeConcurrentHandling
in classorg.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
-
preProcess
public <T> void preProcess(org.springframework.web.context.request.NativeWebRequest request, java.util.concurrent.Callable<T> task)
- Specified by:
preProcess
in interfaceorg.springframework.web.context.request.async.CallableProcessingInterceptor
- Overrides:
preProcess
in classorg.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
-
postProcess
public <T> void postProcess(org.springframework.web.context.request.NativeWebRequest request, java.util.concurrent.Callable<T> task, java.lang.Object concurrentResult)
- Specified by:
postProcess
in interfaceorg.springframework.web.context.request.async.CallableProcessingInterceptor
- Overrides:
postProcess
in classorg.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
-
setSecurityContextHolderStrategy
public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy)
Sets theSecurityContextHolderStrategy
to use. The default action is to use theSecurityContextHolderStrategy
stored inSecurityContextHolder
.- Since:
- 5.8
-
-