Package org.springframework.security.web.access

# Class DelegatingAccessDeniedHandler

java.lang.Object
org.springframework.security.web.access.DelegatingAccessDeniedHandler

All Implemented Interfaces:
  `AccessDeniedHandler`

public final class DelegatingAccessDeniedHandler extends Object implements AccessDeniedHandler
An `AccessDeniedHandler` that delegates to other `AccessDeniedHandler` instances based upon the type of `AccessDeniedException` passed into `handle(HttpServletRequest, HttpServletResponse, AccessDeniedException)`.

Since:
  3.2

## Constructor Summary

Constructors
Constructor
Description
`DelegatingAccessDeniedHandler(LinkedHashMap<Class<? extends org.springframework.security.access.AccessDeniedException>,AccessDeniedHandler> handlers, AccessDeniedHandler defaultHandler)`
Creates a new instance

## Method Summary

Modifier and Type
Method
Description
`void`
`handle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.access.AccessDeniedException accessDeniedException)`
Handles an access denied failure.

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

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

## Constructor Details

### DelegatingAccessDeniedHandler

public DelegatingAccessDeniedHandler(LinkedHashMap<Class<? extends org.springframework.security.access.AccessDeniedException>,AccessDeniedHandler> handlers, AccessDeniedHandler defaultHandler)
Creates a new instance

Parameters:
  `handlers` - a map of the `AccessDeniedException` class to the `AccessDeniedHandler` that should be used. Each is considered in the order they are specified and only the first `AccessDeniedHandler` is ued.
  `defaultHandler` - the default `AccessDeniedHandler` that should be used if none of the handlers matches.

## Method Details

### handle

public void handle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.access.AccessDeniedException accessDeniedException) throws IOException, jakarta.servlet.ServletException
Description copied from interface: `AccessDeniedHandler`
Handles an access denied failure.

Specified by:
  `handle` in interface `AccessDeniedHandler`
Parameters:
  `request` - that resulted in an `AccessDeniedException`
  `response` - so that the user agent can be advised of the failure
  `accessDeniedException` - that caused the invocation
Throws:
  `IOException` - in the event of an IOException
  `jakarta.servlet.ServletException` - in the event of a ServletException