12#include <boost/algorithm/string.hpp>
37 if (!hook_scripts_path_checker_ || reset) {
38 hook_scripts_path_checker_.reset(
new PathChecker(DEFAULT_HOOK_SCRIPTS_PATH,
"KEA_HOOK_SCRIPTS_PATH"));
39 if (!explicit_path.empty()) {
40 hook_scripts_path_checker_->getPath(
true, explicit_path);
44 return (hook_scripts_path_checker_->getPath());
49 if (!hook_scripts_path_checker_) {
53 return (hook_scripts_path_checker_->validatePath(libpath));
58 if (!hooks_path_checker_ || reset) {
59 hooks_path_checker_.reset(
new PathChecker(DEFAULT_HOOKS_PATH,
"KEA_HOOKS_PATH"));
60 if (!explicit_path.empty()) {
61 hooks_path_checker_->getPath(
true, explicit_path);
65 return (hooks_path_checker_->getPath());
70 if (!hooks_path_checker_) {
74 return (hooks_path_checker_->validatePath(libpath));
89 for (
auto const& library_entry : value->listValue()) {
95 " one or more entries in the hooks-libraries list is not"
96 " a map (" << library_entry->getPosition() <<
")");
101 bool lib_found =
false;
110 for (
auto const& entry_item : library_entry->mapValue()) {
111 if (entry_item.first ==
"library") {
114 " error: value of 'library' element is not a string"
115 " giving the path to a hooks library (" <<
116 entry_item.second->getPosition() <<
")");
122 cfgname = (entry_item.second)->stringValue();
124 }
catch (
const std::exception& ex) {
126 " error: " << ex.what() <<
" ("
127 << entry_item.second->getPosition() <<
")");
136 if (entry_item.first ==
"parameters") {
137 parameters = entry_item.second;
143 << entry_item.first <<
"("
144 << library_entry->getPosition() <<
")");
149 " one or more hooks-libraries elements are missing the"
150 " name of the library" <<
151 " (" << library_entry->getPosition() <<
")");
154 libraries.
add(libname, parameters, cfgname);
To be removed. Please use ConfigError instead.
static std::string validatePath(const std::string libpath)
Validates a script path (script loaded by a hook) against the supported path.
static std::string getHookScriptsPath(bool reset=false, const std::string explicit_path="")
Fetches the supported script path.
Wrapper class that holds hooks libraries configuration.
void clear()
Removes all configured hooks libraries.
void add(const std::string &libname, isc::data::ConstElementPtr parameters, const std::string &cfgname="")
Adds additional hooks libraries.
static std::string validatePath(const std::string libpath)
Validates a library path against the supported path for hooks libraries.
void parse(HooksConfig &libraries, isc::data::ConstElementPtr value)
Parses parameters value.
static std::string getHooksPath(bool reset=false, const std::string explicit_path="")
Fetches the supported Hooks path.
Embodies a supported path against which file paths can be validated.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< PathChecker > PathCheckerPtr
Defines a pointer to a PathChecker.
Defines the logger used by the top-level component of kea-lfc.