public function forbidden(ServerRequestInterface $request, ResponseInterface $response)
    {
        $contentType = $this->determineContentType($request);
        switch ($contentType) {
            case 'application/json':
                $output = $this->renderJsonErrorMessage();
                break;

            case 'text/html':
                $output = $this->renderHtmlErrorMessage();
                break;

            default:
                throw new Exception('Cannot render unknown content type ' . $contentType);
        }

        return $response
                ->withStatus(403)
                ->withHeader('Content-type', $contentType)
                ->write($output);
    }