Class DelegatingSecurityContextCallable<V>
- java.lang.Object
- 
- org.springframework.security.concurrent.DelegatingSecurityContextCallable<V>
 
- 
- All Implemented Interfaces:
- java.util.concurrent.Callable<V>
 
 public final class DelegatingSecurityContextCallable<V> extends java.lang.Object implements java.util.concurrent.Callable<V>Wraps a delegate Callablewith logic for setting up aSecurityContextbefore invoking the delegateCallableand then removing theSecurityContextafter the delegate has completed.If there is a SecurityContextthat already exists, it will be restored after thecall()method is invoked.- Since:
- 3.2
 
- 
- 
Constructor SummaryConstructors Constructor Description DelegatingSecurityContextCallable(java.util.concurrent.Callable<V> delegate)Creates a newDelegatingSecurityContextCallablewith theSecurityContextfrom theSecurityContextHolder.DelegatingSecurityContextCallable(java.util.concurrent.Callable<V> delegate, SecurityContext securityContext)Creates a newDelegatingSecurityContextCallablewith a specificSecurityContext.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Vcall()static <V> java.util.concurrent.Callable<V>create(java.util.concurrent.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.java.lang.StringtoString()
 
- 
- 
- 
Constructor Detail- 
DelegatingSecurityContextCallablepublic DelegatingSecurityContextCallable(java.util.concurrent.Callable<V> delegate, SecurityContext securityContext) Creates a newDelegatingSecurityContextCallablewith a specificSecurityContext.- Parameters:
- delegate- the delegate- DelegatingSecurityContextCallableto run with the specified- SecurityContext. Cannot be null.
- securityContext- the- SecurityContextto establish for the delegate- Callable. Cannot be null.
 
 - 
DelegatingSecurityContextCallablepublic DelegatingSecurityContextCallable(java.util.concurrent.Callable<V> delegate) Creates a newDelegatingSecurityContextCallablewith theSecurityContextfrom theSecurityContextHolder.- Parameters:
- delegate- the delegate- Callableto run under the current- SecurityContext. Cannot be null.
 
 
- 
 - 
Method Detail- 
callpublic V call() throws java.lang.Exception - Specified by:
- callin interface- java.util.concurrent.Callable<V>
- Throws:
- java.lang.Exception
 
 - 
setSecurityContextHolderStrategypublic void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use. The default action is to use theSecurityContextHolderStrategystored inSecurityContextHolder.- Since:
- 5.8
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
createpublic static <V> java.util.concurrent.Callable<V> create(java.util.concurrent.Callable<V> delegate, SecurityContext securityContext)Creates aDelegatingSecurityContextCallableand with the givenCallableandSecurityContext, but if the securityContext is null will defaults to the currentSecurityContexton theSecurityContextHolder- Parameters:
- delegate- the delegate- DelegatingSecurityContextCallableto run with the specified- SecurityContext. Cannot be null.
- securityContext- the- SecurityContextto establish for the delegate- Callable. If null, defaults to- SecurityContextHolder.getContext()
- Returns:
 
 
- 
 
-