components::security::signed_certificate subordinate_certificate_authority::get_certificate(error_code& ec) const { if (0 == subordinate_certificate_authority_) { HPX_THROWS_IF(ec, invalid_status, "subordinate_certificate_authority::get_certificate", "subordinate_certificate_authority is not initialized yet"); return components::security::signed_certificate::invalid_signed_type; } // Bind the certificate_authority_get_certificate symbol dynamically and invoke it. typedef void (*function_type)( components::security::server::certificate_authority_base* , components::security::signed_certificate*); typedef boost::function<void(function_type)> deleter_type; hpx::util::plugin::dll dll( HPX_MAKE_DLL_STRING(std::string("security"))); std::pair<function_type, deleter_type> function = dll.get<function_type, deleter_type>( "certificate_authority_get_certificate"); components::security::signed_certificate signed_certificate; (*function.first)( subordinate_certificate_authority_, &signed_certificate); return signed_certificate; }
components::security::signed_certificate subordinate_certificate_authority::sign_certificate_signing_request( components::security::signed_certificate_signing_request const & signed_csr) const { HPX_ASSERT(0 != subordinate_certificate_authority_); // Bind the certificate_authority_sign_certificate_signing_request symbol dynamically and invoke it. typedef void (*function_type)( components::security::server::certificate_authority_base* , components::security::signed_certificate_signing_request const & , components::security::signed_certificate*); typedef boost::function<void(function_type)> deleter_type; hpx::util::plugin::dll dll( HPX_MAKE_DLL_STRING(std::string("security"))); std::pair<function_type, deleter_type> function = dll.get<function_type, deleter_type>( "certificate_authority_sign_certificate_signing_request"); components::security::signed_certificate signed_certificate; (*function.first)( subordinate_certificate_authority_ , signed_csr , &signed_certificate); return signed_certificate; }
subordinate_certificate_authority::~subordinate_certificate_authority() { // Bind the delete_subordinate_certificate_authority symbol dynamically and invoke it. typedef void (*function_type)(certificate_authority_type*); typedef boost::function<void(function_type)> deleter_type; hpx::util::plugin::dll dll( HPX_MAKE_DLL_STRING(std::string("security"))); std::pair<function_type, deleter_type> function = dll.get<function_type, deleter_type>( "delete_subordinate_certificate_authority"); (*function.first)(subordinate_certificate_authority_); }
void subordinate_certificate_authority::initialize() { // Bind the new_subordinate_certificate_authority symbol dynamically and invoke it. typedef certificate_authority_type* (*function_type)( components::security::key_pair const&); typedef boost::function<void(function_type)> deleter_type; hpx::util::plugin::dll dll( HPX_MAKE_DLL_STRING(std::string("security"))); std::pair<function_type, deleter_type> function = dll.get<function_type, deleter_type>( "new_subordinate_certificate_authority"); HPX_ASSERT(0 == subordinate_certificate_authority_); subordinate_certificate_authority_ = (*function.first)(key_pair_); }
void subordinate_certificate_authority::set_certificate( components::security::signed_certificate const & signed_certificate) { HPX_ASSERT(0 != subordinate_certificate_authority_); // Bind the subordinate_certificate_authority_set_certificate symbol dynamically and invoke it. typedef void (*function_type)( components::security::server::subordinate_certificate_authority* , components::security::signed_certificate const &); typedef boost::function<void(function_type)> deleter_type; hpx::util::plugin::dll dll( HPX_MAKE_DLL_STRING(std::string("security"))); std::pair<function_type, deleter_type> function = dll.get<function_type, deleter_type>( "subordinate_certificate_authority_set_certificate"); (*function.first)( subordinate_certificate_authority_, signed_certificate); }
bool subordinate_certificate_authority::is_valid() const { HPX_ASSERT(0 != subordinate_certificate_authority_); // Bind the certificate_authority_is_valid symbol dynamically and invoke it. typedef void (*function_type)( components::security::server::certificate_authority_base* , bool*); typedef boost::function<void(function_type)> deleter_type; hpx::util::plugin::dll dll( HPX_MAKE_DLL_STRING(std::string("security"))); std::pair<function_type, deleter_type> function = dll.get<function_type, deleter_type>( "certificate_authority_is_valid"); bool valid; (*function.first)(subordinate_certificate_authority_, &valid); return valid; }
bool test_local_priority_queue_scheduler(hpx::util::section& ini) { // load all components as described in the configuration information if (!ini.has_section("hpx.plugins")) { std::cout << "No plugins found/loaded." << std::endl; return true; // no plugins to load } // each shared library containing plugins may have an ini section // // # mandatory section describing the component module // [hpx.plugins.instance_name] // name = ... # the name of this component module // path = ... # the path where to find this component module // enabled = false # optional (default is assumed to be true) // // # optional section defining additional properties for this module // [hpx.plugins.instance_name.settings] // key = value // hpx::util::section* sec = ini.get_section("hpx.plugins"); if (NULL == sec) { std::cout << "NULL section found" << std::endl; return false; // something bad happened } hpx::util::section::section_map const& s = (*sec).get_sections(); typedef hpx::util::section::section_map::const_iterator iterator; iterator end = s.end(); for (iterator i = s.begin (); i != end; ++i) { // the section name is the instance name of the component hpx::util::section const& sect = i->second; std::string instance (sect.get_name()); std::string component; if (i->second.has_entry("name")) component = sect.get_entry("name"); else component = instance; if (sect.has_entry("enabled")) { std::string tmp = sect.get_entry("enabled"); boost::algorithm::to_lower(tmp); if (tmp == "no" || tmp == "false" || tmp == "0") { std::cout << "plugin factory disabled: " << instance << std::endl; continue; // this plugin has been disabled } } // initialize the factory instance using the preferences from the // ini files hpx::util::section const* glob_ini = NULL; if (ini.has_section("settings")) glob_ini = ini.get_section("settings"); hpx::util::section const* plugin_ini = NULL; std::string plugin_section("hpx.plugins." + instance); if (ini.has_section(plugin_section)) plugin_ini = ini.get_section(plugin_section); boost::filesystem::path lib_path; std::string component_path = sect.get_entry("path"); typedef boost::tokenizer<boost::char_separator<char> > tokenizer; boost::char_separator<char> sep(HPX_INI_PATH_DELIMITER); tokenizer tokens(component_path, sep); boost::system::error_code fsec; for(tokenizer::iterator it = tokens.begin(); it != tokens.end(); ++it) { boost::filesystem::path dir = boost::filesystem::path(*it); lib_path = dir / std::string(HPX_MAKE_DLL_STRING(component)); if(boost::filesystem::exists(lib_path, fsec)) { break; } lib_path.clear(); } if (lib_path.string().empty()) continue; // didn't find this plugin hpx::util::plugin::dll module(lib_path.string(), HPX_MANGLE_STRING(component)); // get the factory typedef hpx::threads::policies::scheduler_plugin_factory_base fbase; hpx::util::plugin::plugin_factory<fbase> pf(module, "scheduler_factory"); try { // create the plugin factory object, if not disabled std::shared_ptr<fbase> factory ( pf.create(instance, glob_ini, plugin_ini, true)); // use factory to create an instance of the plugin std::shared_ptr<hpx::threads::policies::scheduler_base > plugin(factory->create()); // now test for local priority queue scheduler plugin typedef hpx::threads::policies::local_priority_queue_scheduler<> lpq; hpx::threads::policies::scheduler_base* base = plugin.get(); HPX_TEST(dynamic_cast<lpq*>(base) != NULL); } catch(...) { // different type of factory (not "example_factory"), ignore here HPX_TEST(false); } } return true; }