Class DelegatingSecurityContextCallable<V>
java.lang.Object
org.springframework.security.concurrent.DelegatingSecurityContextCallable<V>
- All Implemented Interfaces:
 Callable<V>
 Wraps a delegate Callable with logic for setting up a SecurityContext
 before invoking the delegate Callable and then removing the
 SecurityContext after the delegate has completed.
 
 If there is a SecurityContext that already exists, it will be restored after
 the call() method is invoked.
 
- Since:
 - 3.2
 
- 
Constructor Summary
ConstructorsConstructorDescriptionDelegatingSecurityContextCallable(Callable<V> delegate) Creates a newDelegatingSecurityContextCallablewith theSecurityContextfrom theSecurityContextHolder.DelegatingSecurityContextCallable(Callable<V> delegate, SecurityContext securityContext) Creates a newDelegatingSecurityContextCallablewith a specificSecurityContext. - 
Method Summary
Modifier and TypeMethodDescriptioncall()static <V> Callable<V>create(Callable<V> delegate, SecurityContext securityContext) Creates aDelegatingSecurityContextCallableand with the givenCallableandSecurityContext, but if the securityContext is null will defaults to the currentSecurityContexton theSecurityContextHoldervoidsetSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use.toString() 
- 
Constructor Details
- 
DelegatingSecurityContextCallable
Creates a newDelegatingSecurityContextCallablewith a specificSecurityContext.- Parameters:
 delegate- the delegateDelegatingSecurityContextCallableto run with the specifiedSecurityContext. Cannot be null.securityContext- theSecurityContextto establish for the delegateCallable. Cannot be null.
 - 
DelegatingSecurityContextCallable
Creates a newDelegatingSecurityContextCallablewith theSecurityContextfrom theSecurityContextHolder.- Parameters:
 delegate- the delegateCallableto run under the currentSecurityContext. Cannot be null.
 
 - 
 - 
Method Details
- 
call
 - 
setSecurityContextHolderStrategy
public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use. The default action is to use theSecurityContextHolderStrategystored inSecurityContextHolder.- Since:
 - 5.8
 
 - 
toString
 - 
create
Creates aDelegatingSecurityContextCallableand with the givenCallableandSecurityContext, but if the securityContext is null will defaults to the currentSecurityContexton theSecurityContextHolder- Parameters:
 delegate- the delegateDelegatingSecurityContextCallableto run with the specifiedSecurityContext. Cannot be null.securityContext- theSecurityContextto establish for the delegateCallable. If null, defaults toSecurityContextHolder.getContext()- Returns:
 
 
 -