org.springframework.security.web.context.request.async
Class SecurityContextCallableProcessingInterceptor

java.lang.Object
  extended by org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
      extended by 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 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
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.
 
Method Summary
<T> void
beforeConcurrentHandling(NativeWebRequest request, Callable<T> task)
           
<T> void
postProcess(NativeWebRequest request, Callable<T> task, Object concurrentResult)
           
<T> void
preProcess(NativeWebRequest request, Callable<T> task)
           
 
Methods inherited from class org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
afterCompletion, handleTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecurityContextCallableProcessingInterceptor

public SecurityContextCallableProcessingInterceptor()
Create a new SecurityContextCallableProcessingInterceptor that uses the SecurityContext from the SecurityContextHolder at the time beforeConcurrentHandling(NativeWebRequest, Callable) is invoked.


SecurityContextCallableProcessingInterceptor

public SecurityContextCallableProcessingInterceptor(SecurityContext securityContext)
Creates a new SecurityContextCallableProcessingInterceptor with the specified SecurityContext.

Parameters:
securityContext - the SecurityContext to set on the SecurityContextHolder in preProcess(NativeWebRequest, Callable). Cannot be null.
Throws:
IllegalArgumentException - if SecurityContext is null.
Method Detail

beforeConcurrentHandling

public <T> void beforeConcurrentHandling(NativeWebRequest request,
                                         Callable<T> task)
                              throws Exception
Specified by:
beforeConcurrentHandling in interface org.springframework.web.context.request.async.CallableProcessingInterceptor
Overrides:
beforeConcurrentHandling in class org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
Throws:
Exception

preProcess

public <T> void preProcess(NativeWebRequest request,
                           Callable<T> task)
                throws Exception
Specified by:
preProcess in interface org.springframework.web.context.request.async.CallableProcessingInterceptor
Overrides:
preProcess in class org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
Throws:
Exception

postProcess

public <T> void postProcess(NativeWebRequest request,
                            Callable<T> task,
                            Object concurrentResult)
                 throws Exception
Specified by:
postProcess in interface org.springframework.web.context.request.async.CallableProcessingInterceptor
Overrides:
postProcess in class org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
Throws:
Exception