code: protected void handleAccessDeniedException(RequestContext context, AccessDeniedException e) throws
              SecurityProviderException, IOException {
          Authentication auth = SecurityUtils.getAuthentication(context.getRequest());
          // If user is anonymous, authentication is required
          if (auth == null) {
              try {
                  // Throw ex just to initialize stack trace
                  throw new AuthenticationRequiredException("Authentication required to access the resource", e);
              } catch (AuthenticationRequiredException ae) {
                  logger.debug("Authentication is required", ae);
  
                  authenticationRequiredHandler.handle(context, ae);
              }
          } else {
              logger.debug("Access denied to user '" + auth.getProfile().getUsername() + "'", e);
  
              accessDeniedHandler.handle(context, e);
          }
      }
docs: Handles the specified {@link AccessDeniedException}, by calling the {@link AccessDeniedHandler}.