25 CtrlAgentCfgContext::CtrlAgentCfgContext()
26 : http_host_(
""), http_port_(0),
27 trust_anchor_(
""), cert_file_(
""), key_file_(
""), cert_required_(true) {
31 :
ConfigBase(), ctrl_sockets_(orig.ctrl_sockets_),
32 http_host_(orig.http_host_), http_port_(orig.http_port_),
33 trust_anchor_(orig.trust_anchor_), cert_file_(orig.cert_file_),
34 key_file_(orig.key_file_), cert_required_(orig.cert_required_),
35 hooks_config_(orig.hooks_config_), auth_config_(orig.auth_config_) {
52 s <<
"listening on " << ctx->getHttpHost() <<
", port "
53 << ctx->getHttpPort();
56 if (!ctx->getTrustAnchor().empty()) {
57 s <<
", trust anchor " << ctx->getTrustAnchor()
58 <<
", cert file " << ctx->getCertFile()
59 <<
", key file " << ctx->getKeyFile();
60 if (ctx->getCertRequired()) {
61 s <<
", client certs are required";
63 s <<
", client certs are optional";
66 s <<
", control sockets: ";
69 s << ctx->getControlSocketInfoSummary();
73 if (auth && !auth->empty()) {
74 s <<
", requires basic HTTP authentication";
79 s <<
", " << libs.size() <<
" lib(s):";
80 for (
auto lib = libs.begin(); lib != libs.end(); ++lib) {
81 s << lib->first <<
" ";
112 parser.
parse(ctx, cfg, check_only);
117 excuse =
"undefined configuration parsing error";
133 "Configuration check successful");
136 "Configuration applied successfully.");
142 std::list<std::list<std::string>>
144 static std::list<std::list<std::string>>
const list({
145 {
"authentication",
"clients",
"[]"},
146 {
"hooks-libraries",
"[]",
"parameters",
"*"},
153 auto si = ctrl_sockets_.find(service);
159 const std::string& service) {
160 ctrl_sockets_[service] = control_socket;
165 std::ostringstream s;
166 for (
auto si = ctrl_sockets_.cbegin(); si != ctrl_sockets_.end(); ++si) {
167 if (s.tellp() != 0) {
173 if (s.tellp() == 0) {
186 ca->set(
"http-host", Element::create(http_host_));
188 ca->set(
"http-port", Element::create(static_cast<int64_t>(http_port_)));
190 if (!trust_anchor_.empty()) {
191 ca->set(
"trust-anchor", Element::create(trust_anchor_));
192 ca->set(
"cert-file", Element::create(cert_file_));
193 ca->set(
"key-file", Element::create(key_file_));
194 ca->set(
"cert-required", Element::create(cert_required_));
198 ca->set(
"authentication", auth_config_->toElement());
200 ca->set(
"hooks-libraries", hooks_config_.
toElement());
202 ElementPtr control_sockets = Element::createMap();
203 for (
auto si = ctrl_sockets_.cbegin(); si != ctrl_sockets_.cend(); ++si) {
205 control_sockets->set(si->first, socket);
207 ca->set(
"control-sockets", control_sockets);
210 result->set(
"Control-agent", ca);
static size_t setAllDefaults(const isc::data::ElementPtr &global)
Sets all defaults for Control Agent configuration.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
std::string getControlSocketInfoSummary() const
Returns socket configuration summary in a textual format.
Base class for all configurations.
virtual std::string getConfigSummary(const uint32_t selection) override
Returns configuration summary in the textual format.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
boost::shared_ptr< Element > ElementPtr
std::list< std::list< std::string > > jsonPathsToRedact() const finaloverride
Return a list of all paths that contain passwords or secrets.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
const isc::log::MessageID CTRL_AGENT_CONFIG_CHECK_FAIL
std::vector< HookLibInfo > HookLibsCollection
A storage for information about hook libraries.
isc::log::Logger agent_logger("ctrl-agent")
Control Agent logger.
virtual ~CtrlAgentCfgMgr()
Destructor.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
CtrlAgentCfgContext()
Default constructor.
To be removed. Please use ConfigError instead.
isc::data::ElementPtr toElement() const
Unparse a configuration object.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
boost::shared_ptr< const Element > ConstElementPtr
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
const isc::log::MessageID CTRL_AGENT_CONFIG_FAIL
void setControlSocketInfo(const isc::data::ConstElementPtr &control_socket, const std::string &service)
Sets information about the control socket.
void checkTlsSetup(const isc::data::ConstElementPtr &config)
Check TLS setup consistency i.e.
This file contains several functions and constants that are used for handling commands and responses ...
void parse(const CtrlAgentCfgContextPtr &ctx, const isc::data::ConstElementPtr &config, bool check_only)
Parses the control agent configuration.
isc::data::ConstElementPtr getControlSocketInfo(const std::string &service) const
Returns information about control socket.
The Element class represents a piece of data, used by the command channel and configuration parts...
virtual isc::data::ConstElementPtr parse(isc::data::ConstElementPtr config, bool check_only) override
Parses configuration of the Control Agent.
CtrlAgentCfgMgr()
Constructor.
boost::shared_ptr< CtrlAgentCfgContext > CtrlAgentCfgContextPtr
Pointer to a configuration context.
CtrlAgentCfgContextPtr getCtrlAgentCfgContext()
Convenience method that returns the Control Agent configuration context.
Control Agent Configuration Context.
boost::shared_ptr< HttpAuthConfig > HttpAuthConfigPtr
Type of shared pointers to HTTP authentication configuration.
virtual process::ConfigPtr createNewContext() override
Creates a new, blank CtrlAgentCfgContext context.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.