Package net.shibboleth.shared.spring.error

# Class ExtendedMappingExceptionResolver

java.lang.Object
org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
org.springframework.web.servlet.handler.SimpleMappingExceptionResolver
net.shibboleth.shared.spring.error.ExtendedMappingExceptionResolver

All Implemented Interfaces:
  `Ordered`, `HandlerExceptionResolver`

public class ExtendedMappingExceptionResolver extends SimpleMappingExceptionResolver
Custom Spring exception to view mapper that populates the view model with data obtained via an extension function.

As a default, the view model will include a reference to the active `HttpServletRequest` and the `HTMLEncoder` class.

## Field Summary

Fields
Modifier and Type
Field
Description
`private StringDigester`
`cspDigester`
CSP digester.
`private IdentifierGenerationStrategy`
`cspNonceGenerator`
CSP nonce generator.
`private Object`
`customObject`
Slot for custom view object to inject.
`private static final String`
`MODEL_ATTR_CUSTOM`
Model attribute carrying the custom object.
`private static final String`
`MODEL_ATTR_DIGESTER`
Model attribute carrying the CSP digester.
`private static final String`
`MODEL_ATTR_ENCODER`
Model attribute carrying the `HTMLEncoder` class.
`private static final String`
`MODEL_ATTR_ENVIRONMENT`
Model attribute carrying `EnvironmentCapable.getEnvironment()`.
`private static final String`
`MODEL_ATTR_NONCE`
Model attribute carrying the CSP nonce generator.
`private static final String`
`MODEL_ATTR_REQUEST`
Model attribute carrying `HttpServletRequest`.
`private static final String`
`MODEL_ATTR_RESPONSE`
Model attribute carrying `HttpServletResponse`.
`private static final String`
`MODEL_ATTR_SPRINGCONTEXT`
Model attribute carrying `WebApplicationContext`.
`private final Function<HttpServletRequest,Map<String,Object>>`
`viewModelExtenderFunction`
Function to obtain extensions to view model.

### Fields inherited from class org.springframework.web.servlet.handler.SimpleMappingExceptionResolver

`DEFAULT_EXCEPTION_ATTRIBUTE`

### Fields inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver

`logger`

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

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

## Constructor Summary

Constructors
Constructor
Description
`ExtendedMappingExceptionResolver()`
Constructor.
`ExtendedMappingExceptionResolver(Function<HttpServletRequest,Map<String,Object>> extender)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected ModelAndView`
`doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)`
`protected ModelAndView`
`getModelAndView(String viewName, Exception ex, HttpServletRequest request)`
`void`
`setCSPDigester(StringDigester digester)`
Sets a CSP digester.
`void`
`setCSPNonceGenerator(IdentifierGenerationStrategy generator)`
Sets a CSP nonce generator.
`void`
`setCustomObject(Object custom)`
Sets a custom object to inject into the view.

### Methods inherited from class org.springframework.web.servlet.handler.SimpleMappingExceptionResolver

`addStatusCode, applyStatusCodeIfPossible, determineStatusCode, determineViewName, findMatchingViewName, getDepth, getModelAndView, getStatusCodesAsMap, setDefaultErrorView, setDefaultStatusCode, setExceptionAttribute, setExceptionMappings, setExcludedExceptions, setStatusCodes`

### Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver

`addMappedHandlerClass, buildLogMessage, getMappedHandlerClasses, getOrder, hasHandlerMappings, logException, prepareResponse, preventCaching, resolveException, setMappedHandlerClasses, setMappedHandlerPredicate, setMappedHandlers, setOrder, setPreventResponseCaching, setWarnLogCategory, shouldApplyTo`

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

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

## Field Details

### MODEL_ATTR_REQUEST

@Nonnull private static final String MODEL_ATTR_REQUEST
Model attribute carrying `HttpServletRequest`.

See Also:
  - Constant Field Values

### MODEL_ATTR_RESPONSE

@Nonnull private static final String MODEL_ATTR_RESPONSE
Model attribute carrying `HttpServletResponse`.

See Also:
  - Constant Field Values

### MODEL_ATTR_SPRINGCONTEXT

@Nonnull private static final String MODEL_ATTR_SPRINGCONTEXT
Model attribute carrying `WebApplicationContext`.

See Also:
  - Constant Field Values

### MODEL_ATTR_ENVIRONMENT

@Nonnull private static final String MODEL_ATTR_ENVIRONMENT
Model attribute carrying `EnvironmentCapable.getEnvironment()`.

See Also:
  - Constant Field Values

### MODEL_ATTR_ENCODER

@Nonnull private static final String MODEL_ATTR_ENCODER
Model attribute carrying the `HTMLEncoder` class.

See Also:
  - Constant Field Values

### MODEL_ATTR_DIGESTER

@Nonnull private static final String MODEL_ATTR_DIGESTER
Model attribute carrying the CSP digester.

See Also:
  - Constant Field Values

### MODEL_ATTR_NONCE

@Nonnull private static final String MODEL_ATTR_NONCE
Model attribute carrying the CSP nonce generator.

See Also:
  - Constant Field Values

### MODEL_ATTR_CUSTOM

@Nonnull private static final String MODEL_ATTR_CUSTOM
Model attribute carrying the custom object.

See Also:
  - Constant Field Values

### viewModelExtenderFunction

@Nullable private final Function<HttpServletRequest,Map<String,Object>> viewModelExtenderFunction
Function to obtain extensions to view model.

### cspDigester

@Nullable private StringDigester cspDigester
CSP digester.

### cspNonceGenerator

@Nullable private IdentifierGenerationStrategy cspNonceGenerator
CSP nonce generator.

### customObject

@Nullable private Object customObject
Slot for custom view object to inject.

## Constructor Details

### ExtendedMappingExceptionResolver

public ExtendedMappingExceptionResolver()
Constructor.

### ExtendedMappingExceptionResolver

public ExtendedMappingExceptionResolver(@Nullable Function<HttpServletRequest,Map<String,Object>> extender)
Constructor.

Parameters:
  `extender` - function to obtain extensions to view model

## Method Details

### setCSPDigester

public void setCSPDigester(@Nullable StringDigester digester)
Sets a CSP digester.

Parameters:
  `digester` - CSP digester
Since:
  9.1.0

### setCSPNonceGenerator

public void setCSPNonceGenerator(@Nullable IdentifierGenerationStrategy generator)
Sets a CSP nonce generator.

Parameters:
  `generator` - CSP nonce generator
Since:
  9.1.0

### setCustomObject

public void setCustomObject(@Nullable Object custom)
Sets a custom object to inject into the view.

Parameters:
  `custom` - custom object
Since:
  9.1.0

### doResolveException

protected ModelAndView doResolveException(@Nonnull HttpServletRequest request, @Nonnull HttpServletResponse response, @Nullable Object handler, @Nonnull Exception ex)

Overrides:
  `doResolveException` in class `SimpleMappingExceptionResolver`

### getModelAndView

@Nonnull protected ModelAndView getModelAndView(@Nonnull String viewName, @Nonnull Exception ex, @Nonnull HttpServletRequest request)

Overrides:
  `getModelAndView` in class `SimpleMappingExceptionResolver`