Class 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
    • 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​(org.springframework.security.core.context.SecurityContextHolderStrategy securityContextHolderStrategy)
      Sets the SecurityContextHolderStrategy to use.
      • Methods inherited from class org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter

        afterCompletion, handleError, handleTimeout
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • beforeConcurrentHandling

        public <T> void beforeConcurrentHandling​(org.springframework.web.context.request.NativeWebRequest request,
                                                 java.util.concurrent.Callable<T> task)
        Specified by:
        beforeConcurrentHandling in interface org.springframework.web.context.request.async.CallableProcessingInterceptor
        Overrides:
        beforeConcurrentHandling in class org.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 interface org.springframework.web.context.request.async.CallableProcessingInterceptor
        Overrides:
        preProcess in class org.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 interface org.springframework.web.context.request.async.CallableProcessingInterceptor
        Overrides:
        postProcess in class org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter
      • setSecurityContextHolderStrategy

        public void setSecurityContextHolderStrategy​(org.springframework.security.core.context.SecurityContextHolderStrategy securityContextHolderStrategy)
        Sets the SecurityContextHolderStrategy to use. The default action is to use the SecurityContextHolderStrategy stored in SecurityContextHolder.
        Since:
        5.8