Package org.springframework.security.concurrent

# Class DelegatingSecurityContextExecutor

java.lang.Object
org.springframework.security.concurrent.DelegatingSecurityContextExecutor

All Implemented Interfaces:
  `Executor`

Direct Known Subclasses:
  `DelegatingSecurityContextExecutorService`, `DelegatingSecurityContextTaskExecutor`

public class DelegatingSecurityContextExecutor extends Object implements Executor
An `Executor` which wraps each `Runnable` in a `DelegatingSecurityContextRunnable`.

Since:
  3.2

## Constructor Summary

Constructors
Constructor
Description
`DelegatingSecurityContextExecutor(Executor delegate)`
Creates a new `DelegatingSecurityContextExecutor` that uses the current `SecurityContext` from the `SecurityContextHolder` at the time the task is submitted.
`DelegatingSecurityContextExecutor(Executor delegateExecutor, SecurityContext securityContext)`
Creates a new `DelegatingSecurityContextExecutor` that uses the specified `SecurityContext`.

## Method Summary

Modifier and Type
Method
Description
`final void`
`execute(Runnable task)`
`protected final Executor`
`getDelegateExecutor()`
`void`
`setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy)`
Sets the `SecurityContextHolderStrategy` to use.
`protected final Runnable`
`wrap(Runnable delegate)`
`protected final <T> Callable<T>`
`wrap(Callable<T> delegate)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DelegatingSecurityContextExecutor

public DelegatingSecurityContextExecutor(Executor delegateExecutor, SecurityContext securityContext)
Creates a new `DelegatingSecurityContextExecutor` that uses the specified `SecurityContext`.

Parameters:
  `delegateExecutor` - the `Executor` to delegate to. Cannot be null.
  `securityContext` - the `SecurityContext` to use for each `DelegatingSecurityContextRunnable` or null to default to the current `SecurityContext`

### DelegatingSecurityContextExecutor

public DelegatingSecurityContextExecutor(Executor delegate)
Creates a new `DelegatingSecurityContextExecutor` that uses the current `SecurityContext` from the `SecurityContextHolder` at the time the task is submitted.

Parameters:
  `delegate` - the `Executor` to delegate to. Cannot be null.

## Method Details

### execute

public final void execute(Runnable task)

Specified by:
  `execute` in interface `Executor`

### getDelegateExecutor

protected final Executor getDelegateExecutor()

### setSecurityContextHolderStrategy

public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy)
Sets the `SecurityContextHolderStrategy` to use. The default action is to use the `SecurityContextHolderStrategy` stored in `SecurityContextHolder`.

Since:
  5.8

### wrap

protected final Runnable wrap(Runnable delegate)

### wrap

protected final <T> Callable<T> wrap(Callable<T> delegate)