Kea 3.2.0-git
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

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.
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 std::unordered_set< std::string > command_accept_list_
 The server command accept list.
static bool EMULATE_AGENT_RESPONSE = true
 The emulate agent response flag.
static http::HttpAuthConfigPtr http_auth_config_
 The server current authentication configuration.

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.

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 33 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 38 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 133 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:

Member Data Documentation

◆ command_accept_list_

unordered_set< string > isc::config::CmdResponseCreator::command_accept_list_
static

The server command accept list.

Default to the empty list which means to accept everything.

Definition at line 79 of file cmd_response_creator.h.

Referenced by isc::ha::HAService::HAService().

◆ EMULATE_AGENT_RESPONSE

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

The emulate agent response flag.

Definition at line 82 of file cmd_response_creator.h.

◆ http_auth_config_

HttpAuthConfigPtr isc::config::CmdResponseCreator::http_auth_config_
static

The server current authentication configuration.

Default to the empty HttpAuthConfigPtr.

Note
: This is currently not used, except in unit-tests. For the time being, we postponed writing the corresponding code in the HA, so http_auth_config_ is left to its empty default value.

Definition at line 74 of file cmd_response_creator.h.


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