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 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.
Constructor and Description |
---|
SecurityContextCallableProcessingInterceptor()
Create a new
SecurityContextCallableProcessingInterceptor that uses the SecurityContext from the
SecurityContextHolder at the time beforeConcurrentHandling(NativeWebRequest, Callable) is invoked. |
SecurityContextCallableProcessingInterceptor(SecurityContext securityContext)
Creates a new
SecurityContextCallableProcessingInterceptor with the specified SecurityContext . |
Modifier and Type | Method and Description |
---|---|
<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) |
public SecurityContextCallableProcessingInterceptor()
SecurityContextCallableProcessingInterceptor
that uses the SecurityContext
from the
SecurityContextHolder
at the time beforeConcurrentHandling(NativeWebRequest, Callable)
is invoked.public SecurityContextCallableProcessingInterceptor(SecurityContext securityContext)
SecurityContextCallableProcessingInterceptor
with the specified SecurityContext
.securityContext
- the SecurityContext
to set on the SecurityContextHolder
in
preProcess(NativeWebRequest, Callable)
. Cannot be null.IllegalArgumentException
- if SecurityContext
is null.public <T> void beforeConcurrentHandling(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task) throws Exception
beforeConcurrentHandling
in interface org.springframework.web.context.request.async.CallableProcessingInterceptor
beforeConcurrentHandling
in class org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
Exception
public <T> void preProcess(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task) throws Exception
preProcess
in interface org.springframework.web.context.request.async.CallableProcessingInterceptor
preProcess
in class org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
Exception
public <T> void postProcess(org.springframework.web.context.request.NativeWebRequest request, Callable<T> task, Object concurrentResult) throws Exception
postProcess
in interface org.springframework.web.context.request.async.CallableProcessingInterceptor
postProcess
in class org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
Exception
Copyright © 2019. All rights reserved.