Package net.shibboleth.idp.conf.impl

# Class SLF4JMDCServletFilter

java.lang.Object
net.shibboleth.shared.servlet.AbstractConditionalFilter
net.shibboleth.idp.conf.impl.SLF4JMDCServletFilter

All Implemented Interfaces:
  `Filter`, `ChainableFilter`, `Ordered`

public class SLF4JMDCServletFilter extends AbstractConditionalFilter implements ChainableFilter
Servlet filter that sets some interesting MDC attributes as the request comes in and clears the MDC as the response is returned.

## Nested Class Summary

## Nested classes/interfaces inherited from interface net.shibboleth.shared.spring.servlet.ChainableFilter

`ChainableFilter.FilterOrder`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`CLIENT_ADDRESS_MDC_ATTRIBUTE`
MDC attribute name for client address.
`private boolean`
`createSession`
Whether to create a session if it doesn't already exist.
`private Map<String,String>`
`headerMap`
Map of attribute/header pairs to inject.
`static final String`
`JSESSIONID_MDC_ATTRIBUTE`
MDC attribute name for container session ID.
`static final String`
`SERVER_ADDRESS_MDC_ATTRIBUTE`
MDC attribute name for host name of the server to which the current request was sent.
`static final String`
`SERVER_PORT_MDC_ATTRIBUTE`
MDC attribute name for port number to which the current request was sent.

### Fields inherited from interface org.springframework.core.Ordered

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

## Constructor Summary

Constructors
Constructor
Description
`SLF4JMDCServletFilter()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`runFilter(ServletRequest request, ServletResponse response, FilterChain chain)`
`void`
`setCreateSession(boolean flag)`
Sets whether to create a session if one does not exist.
`void`
`setHeaderMap(Map<String,String> map)`
Set a map of MDC attribute names to header names to add to context.

### Methods inherited from class net.shibboleth.shared.servlet.AbstractConditionalFilter

`destroy, doFilter, getActivationCondition, init, setActivationCondition`

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

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

### Methods inherited from interface net.shibboleth.shared.spring.servlet.ChainableFilter

`getOrder`

### Methods inherited from interface jakarta.servlet.Filter

`destroy, doFilter, init`

## Field Details

### SERVER_ADDRESS_MDC_ATTRIBUTE

@Nonnull @NotEmpty public static final String SERVER_ADDRESS_MDC_ATTRIBUTE
MDC attribute name for host name of the server to which the current request was sent.

See Also:
  - Constant Field Values

### SERVER_PORT_MDC_ATTRIBUTE

@Nonnull @NotEmpty public static final String SERVER_PORT_MDC_ATTRIBUTE
MDC attribute name for port number to which the current request was sent.

See Also:
  - Constant Field Values

### CLIENT_ADDRESS_MDC_ATTRIBUTE

@Nonnull @NotEmpty public static final String CLIENT_ADDRESS_MDC_ATTRIBUTE
MDC attribute name for client address.

See Also:
  - Constant Field Values

### JSESSIONID_MDC_ATTRIBUTE

@Nonnull @NotEmpty public static final String JSESSIONID_MDC_ATTRIBUTE
MDC attribute name for container session ID.

See Also:
  - Constant Field Values

### createSession

private boolean createSession
Whether to create a session if it doesn't already exist.

### headerMap

@Nullable private Map<String,String> headerMap
Map of attribute/header pairs to inject.

## Constructor Details

### SLF4JMDCServletFilter

public SLF4JMDCServletFilter()
Constructor.

## Method Details

### setCreateSession

public void setCreateSession(boolean flag)
Sets whether to create a session if one does not exist.

Parameters:
  `flag` - flag to set

### setHeaderMap

public void setHeaderMap(@Nullable Map<String,String> map)
Set a map of MDC attribute names to header names to add to context.

Parameters:
  `map` - header map to set
Since:
  5.1.0

### runFilter

protected void runFilter(@Nonnull ServletRequest request, @Nonnull ServletResponse response, @Nonnull FilterChain chain) throws IOException, ServletException

Specified by:
  `runFilter` in class `AbstractConditionalFilter`
Throws:
  `IOException`
  `ServletException`