Kea 3.3.3
isc::config::CmdResponseCreator Class Reference

Concrete implementation of the HTTP response creator used for processing API commands. More...

#include <cmd_response_creator.h>

Inheritance diagram for isc::config::CmdResponseCreator:

Public Member Functions

 CmdResponseCreator (http::HttpAuthConfigPtr http_auth_config, std::unordered_set< std::string > command_accept_list)
 Constructor.
virtual ~CmdResponseCreator ()=default
 virtual destructor.
virtual http::HttpRequestPtr createNewHttpRequest () const
 Create a new request.
virtual http::HttpResponsePtr createStockHttpResponse (const http::HttpRequestPtr &request, const http::HttpStatusCode &status_code) const
 Creates stock HTTP response.
http::HttpResponseJsonPtr filterCommand (const http::HttpRequestPtr &request, const data::ConstElementPtr &body, const std::unordered_set< std::string > &accept)
 Filter commands.
http::HttpAuthConfigPtr getAuthConfig () const
 Fetches the authentication configuration.
std::unordered_set< std::string > getCommandAcceptList () const
 Fetches the command accept list.
Public Member Functions inherited from isc::http::HttpResponseCreator
virtual ~HttpResponseCreator ()
 Destructor.
virtual HttpResponsePtr createHttpResponse (HttpRequestPtr request) final
 Create HTTP response from HTTP request received.

Static Public Attributes

static bool EMULATE_AGENT_RESPONSE = true
 The emulate agent response flag.

Detailed Description

Concrete implementation of the HTTP response creator used for processing API commands.

See the documentation of the isc::http::HttpResponseCreator for the basic information how HTTP response creators are utilized by the libkea-http library to generate HTTP responses.

This creator expects that received requests are encapsulated in the isc::http::PostHttpRequestJson objects. The generated responses are encapsulated in the HttpResponseJson objects.

This class uses CommandMgr singleton to process commands conveyed in the HTTP body. The JSON responses returned by the manager are placed in the body of the generated HTTP responses.

Definition at line 32 of file cmd_response_creator.h.

Constructor & Destructor Documentation

◆ CmdResponseCreator()

isc::config::CmdResponseCreator::CmdResponseCreator ( http::HttpAuthConfigPtr http_auth_config,
std::unordered_set< std::string > command_accept_list )
inline

Constructor.

Parameters
http_auth_configAuthentication configuration.
command_accept_listCommand accept list.

Definition at line 39 of file cmd_response_creator.h.

◆ ~CmdResponseCreator()

virtual isc::config::CmdResponseCreator::~CmdResponseCreator ( )
virtualdefault

virtual destructor.

Member Function Documentation

◆ createNewHttpRequest()

HttpRequestPtr isc::config::CmdResponseCreator::createNewHttpRequest ( ) const
virtual

Create a new request.

This method creates a bare instance of the isc::http::PostHttpRequestJson.

Returns
Pointer to the new instance of the isc::http::PostHttpRequestJson.

Implements isc::http::HttpResponseCreator.

Definition at line 29 of file cmd_response_creator.cc.

◆ createStockHttpResponse()

HttpResponsePtr isc::config::CmdResponseCreator::createStockHttpResponse ( const http::HttpRequestPtr & request,
const http::HttpStatusCode & status_code ) const
virtual

Creates stock HTTP response.

Parameters
requestPointer to an object representing HTTP request.
status_codeStatus code of the response.
Returns
Pointer to an isc::http::HttpResponseJson object representing stock HTTP response.

Implements isc::http::HttpResponseCreator.

Definition at line 34 of file cmd_response_creator.cc.

◆ filterCommand()

HttpResponseJsonPtr isc::config::CmdResponseCreator::filterCommand ( const http::HttpRequestPtr & request,
const data::ConstElementPtr & body,
const std::unordered_set< std::string > & accept )

Filter commands.

From RBAC code: if the access list is empty or the command cannot be found just return.

Parameters
requestThe HTTP request (for the HTTP version).
bodyThe request body.
acceptThe accept access list.

Definition at line 129 of file cmd_response_creator.cc.

References isc::config::COMMAND_HTTP_LISTENER_COMMAND_REJECTED, isc::config::command_logger, isc::config::CONTROL_COMMAND, isc::config::CONTROL_RESULT, isc::config::CONTROL_TEXT, Element::create(), Element::createMap(), isc::config::DBG_COMMAND, isc::http::FORBIDDEN, LOG_DEBUG, isc::http::HttpVersion::major_, Element::map, isc::http::HttpVersion::minor_, isc::http::HttpResponse::statusCodeToNumber(), isc::http::HttpResponse::statusCodeToString(), and Element::string.

Here is the call graph for this function:

◆ getAuthConfig()

http::HttpAuthConfigPtr isc::config::CmdResponseCreator::getAuthConfig ( ) const
inline

Fetches the authentication configuration.

Returns
the authentication configuration.

Definition at line 86 of file cmd_response_creator.h.

◆ getCommandAcceptList()

std::unordered_set< std::string > isc::config::CmdResponseCreator::getCommandAcceptList ( ) const
inline

Fetches the command accept list.

Returns
the command accept list.

Definition at line 93 of file cmd_response_creator.h.

Member Data Documentation

◆ EMULATE_AGENT_RESPONSE

bool isc::config::CmdResponseCreator::EMULATE_AGENT_RESPONSE = true
static

The emulate agent response flag.

Definition at line 81 of file cmd_response_creator.h.


The documentation for this class was generated from the following files: