static ISecManager* loadSecManager(const char* model_name, const char* servicename, IPropertyTree* cfg) { if (!model_name || !*model_name) throw MakeStringExceptionDirect(-1, "Security model not specified"); StringBuffer realName; if(stricmp(model_name, "LdapSecurity") == 0) { realName.append(SharedObjectPrefix).append(LDAPSECLIB).append(SharedObjectExtension); HINSTANCE ldapseclib = LoadSharedObject(realName.str(), true, false); if(ldapseclib == NULL) throw MakeStringException(-1, "can't load library %s", realName.str()); newSecManager_t_ xproc = NULL; xproc = (newSecManager_t_)GetSharedProcedure(ldapseclib, "newLdapSecManager"); if (xproc) return xproc(servicename, *cfg); else throw MakeStringException(-1, "procedure newLdapSecManager of %s can't be loaded", realName.str()); } else throw MakeStringException(-1, "Security model %s not supported", model_name); }
/// /// Method: loadPluggableSecManager /// /// Using the given configuration property trees, this method loads the specified /// Security Manager DLL/SO implemented in the specified library file and calls /// its instance factory to create and return an ISecManager security manager instance /// for the given ESP service /// /// @param bindingName Binding name ie 'WsTopology_smc_myesp' /// @param bindingCfg 'Binding' IPropertyTree associated with ESPService /// @param secMgrCfg 'SecurityManager' IPropertyTree from component config file /// /// @return an ISecManager Security Manager instance /// static ISecManager* loadPluggableSecManager(const char * bindingName, IPropertyTree* bindingCfg, IPropertyTree* secMgrCfg) { const char * lsm = "Load Security Manager :"; StringBuffer libName, instFactory; secMgrCfg->getProp("@LibName", libName); if (libName.isEmpty()) throw MakeStringException(-1, "%s library name not specified for %s", lsm, bindingName); //TODO Search for LibName in plugins folder, or in specified location instFactory.set(secMgrCfg->queryProp("@InstanceFactoryName")); if (instFactory.isEmpty()) instFactory.set("createInstance"); //Load the DLL/SO HINSTANCE pluggableSecLib = LoadSharedObject(libName.str(), true, false); if(pluggableSecLib == NULL) throw MakeStringException(-1, "%s can't load library %s for %s", lsm, libName.str(), bindingName); //Retrieve address of exported ISecManager instance factory newPluggableSecManager_t_ xproc = NULL; xproc = (newPluggableSecManager_t_)GetSharedProcedure(pluggableSecLib, instFactory.str()); if (xproc == NULL) throw MakeStringException(-1, "%s cannot locate procedure %s of '%s'", lsm, instFactory.str(), libName.str()); //Call ISecManager instance factory and return the new instance DBGLOG("Calling '%s' in pluggable security manager '%s'", instFactory.str(), libName.str()); return xproc(bindingName, *secMgrCfg, *bindingCfg); }
static ISecManager* loadSecManager(const char* model_name, const char* servicename, IPropertyTree* cfg) { if(model_name && stricmp(model_name, "LdapSecurity") == 0) { HINSTANCE ldapseclib = LoadSharedObject(LDAPSECLIB, true, false); if(ldapseclib == NULL) throw MakeStringException(-1, "can't load library %s", LDAPSECLIB); newSecManager_t_ xproc = NULL; xproc = (newSecManager_t_)GetSharedProcedure(ldapseclib, "newLdapSecManager"); if (xproc) return xproc(servicename, *cfg); else throw MakeStringException(-1, "procedure newLdapSecManager of %s can't be loaded", LDAPSECLIB); } else if(model_name && stricmp(model_name, "Local") == 0) { HINSTANCE ldapseclib = LoadSharedObject(LDAPSECLIB, true, false); if(ldapseclib == NULL) throw MakeStringException(-1, "can't load library %s", LDAPSECLIB); newSecManager_t_ xproc = NULL; xproc = (newSecManager_t_)GetSharedProcedure(ldapseclib, "newLocalSecManager"); if (xproc) return xproc(servicename, *cfg); else throw MakeStringException(-1, "procedure newLocalSecManager of %s can't be loaded", LDAPSECLIB); } else if(model_name && stricmp(model_name, "Default") == 0) { HINSTANCE ldapseclib = LoadSharedObject(LDAPSECLIB, true, false); if(ldapseclib == NULL) throw MakeStringException(-1, "can't load library %s", LDAPSECLIB); newSecManager_t_ xproc = NULL; xproc = (newSecManager_t_)GetSharedProcedure(ldapseclib, "newDefaultSecManager"); if (xproc) return xproc(servicename, *cfg); else throw MakeStringException(-1, "procedure newDefaultSecManager of %s can't be loaded", LDAPSECLIB); } else throw MakeStringException(-1, "Security model %s not supported", model_name?model_name:"UNKNOWN"); }
static void process_pcap( uint8_t *args, const struct pcap_pkthdr *hdr, const uint8_t *p ) { if (direct) xcache_process_packet((uint8_t *)p); else if (xproc((void *)p, hdr->len)) { xexit(); exit(0); } }
static IAuthMap* loadTheDefaultAuthMap(IPropertyTree* cfg) { HINSTANCE seclib = LoadSharedObject(LDAPSECLIB, true, false); // ,false,true may actually be more helpful. if(seclib == NULL) throw MakeStringException(-1, "can't load library %s", LDAPSECLIB); createDefaultAuthMap_t_ xproc = NULL; xproc = (createDefaultAuthMap_t_)GetSharedProcedure(seclib, "newDefaultAuthMap"); if (xproc) return xproc(cfg); else throw MakeStringException(-1, "procedure newDefaultAuthMap of %s can't be loaded", LDAPSECLIB); }
IEspLogAgent* CLoggingManager::loadLoggingAgent(const char* name, const char* dll, const char* service, IPropertyTree* cfg) { StringBuffer plugin; plugin.append(SharedObjectPrefix).append(dll).append(SharedObjectExtension); HINSTANCE loggingAgentLib = LoadSharedObject(plugin.str(), true, false); if(!loggingAgentLib) throw MakeStringException(EspLoggingErrors::LoadLoggingLibraryError, "can't load library %s", plugin.str()); newLoggingAgent_t_ xproc = (newLoggingAgent_t_)GetSharedProcedure(loggingAgentLib, "newLoggingAgent"); if (!xproc) throw MakeStringException(EspLoggingErrors::LoadLoggingLibraryError, "procedure newLoggingAgent of %s can't be loaded", plugin.str()); return (IEspLogAgent*) xproc(); }
IEspLogAgent* CWsLoggingServiceEx::loadLoggingAgent(const char* name, const char* dll) { StringBuffer realName; // add suffix and prefix if needed realName.append(SharedObjectPrefix).append(dll).append(SharedObjectExtension); HINSTANCE loggingAgentLib = LoadSharedObject(realName.str(), true, false); if(!loggingAgentLib) throw MakeStringException(EspLoggingErrors::LoadLoggingLibraryError, "can't load library %s", realName.str()); newLogAgent_t_ xproc = (newLogAgent_t_)GetSharedProcedure(loggingAgentLib, "newLoggingAgent"); if (!xproc) throw MakeStringException(EspLoggingErrors::LoadLoggingLibraryError, "procedure newLoggingAgent of %s can't be loaded", realName.str()); return (IEspLogAgent*) xproc(); }
void CEspConfig::loadService(srv_cfg &xcfg) { esp_service_factory_t xproc = NULL; builtin *pdirect = getBuiltIn(xcfg.plugin.str()); if (pdirect) xproc = pdirect->serv; else { Owned<IEspPlugin> pplg = getPlugin(xcfg.plugin.str()); if (pplg) xproc = (esp_service_factory_t) pplg->getProcAddress("esp_service_factory"); } if (xproc) xcfg.srv.setown(xproc(xcfg.name.str(), xcfg.type.str(), m_envpt.get(), m_process.str())); else throw MakeStringException(-1, "procedure esp_service_factory can't be loaded"); }
ILoggingManager* loadLogggingManager() { StringBuffer realName; realName.append(SharedObjectPrefix).append(LOGGINGMANAGERLIB).append(SharedObjectExtension); HINSTANCE loggingManagerLib = LoadSharedObject(realName.str(), true, false); if(loggingManagerLib == NULL) { printf("can't load library %s\n", realName.str()); return NULL; } newLoggingManager_t_ xproc = NULL; xproc = (newLoggingManager_t_)GetSharedProcedure(loggingManagerLib, "newLoggingManager"); if (!xproc) { printf("procedure newLogggingManager of %s can't be loaded\n", realName.str()); return NULL; } return (ILoggingManager*) xproc(); }
void CEspConfig::loadProtocol(protocol_cfg &xcfg) { esp_protocol_factory_t xproc = NULL; builtin *pdirect = getBuiltIn(xcfg.plugin.str()); if (pdirect) xproc = pdirect->prot; else { Owned<IEspPlugin> pplg = getPlugin(xcfg.plugin.str()); if (pplg) { xproc = (esp_protocol_factory_t) pplg->getProcAddress("esp_protocol_factory"); } } if (xproc) { xcfg.prot.setown(xproc(xcfg.name.str(), xcfg.type.str(), m_envpt.get(), m_process.str())); if (xcfg.prot) xcfg.prot->init(m_envpt.get(), m_process.str(), xcfg.name.str()); } else throw MakeStringException(-1, "procedure esp_protocol_factory can't be loaded"); }
/************************************************************************** * CSecureHttpProtocol Implementation * **************************************************************************/ CSecureHttpProtocol::CSecureHttpProtocol(IPropertyTree* cfg) { m_maxConcurrentThreads = 0; if(cfg != NULL) { m_config.setown(cfg); //ensure keys are specified. Passphrase is optional StringBuffer sb; cfg->getProp("certificate", sb); if(sb.length() == 0) { throw MakeStringException(-1, "certificate file not specified in config file"); } cfg->getProp("privatekey", sb.clear()); if(sb.length() == 0) { throw MakeStringException(-1, "private key file not specified in config file"); } createSecureSocketContextEx2_t xproc = NULL; IEspPlugin *pplg = loadPlugin(SSLIB); if (pplg) xproc = (createSecureSocketContextEx2_t) pplg->getProcAddress("createSecureSocketContextEx2"); else throw MakeStringException(-1, "dll/shared-object %s can't be loaded", SSLIB); if (xproc) m_ssctx.setown(xproc(cfg, ServerSocket)); else throw MakeStringException(-1, "procedure createSecureSocketContextEx2 can't be loaded"); } }
void CEspConfig::loadBinding(binding_cfg &xcfg) { map<string, srv_cfg*>::iterator sit = m_services.find(xcfg.service_name.str()); map<string, protocol_cfg*>::iterator pit = m_protocols.find(xcfg.protocol_name.str()); IEspService *isrv = NULL; IEspProtocol *iprot = NULL; if(sit == m_services.end()) { DBGLOG("Warning: Service %s not found for the binding", xcfg.service_name.str()); } else { isrv = (*sit).second->srv; } if(pit == m_protocols.end()) { throw MakeStringException(-1, "Protocol %s not found for the binding", xcfg.protocol_name.str()); } else { iprot = (*pit).second->prot; if (iprot) { esp_binding_factory_t xproc = NULL; if(isrv != NULL) xcfg.service.setown(LINK(isrv)); xcfg.protocol.setown(LINK(iprot)); builtin *pdirect = getBuiltIn(xcfg.plugin.str()); if (pdirect) { xproc = pdirect->bind; } else { Owned<IEspPlugin> pplg = getPlugin(xcfg.plugin.str()); if (pplg) { xproc = (esp_binding_factory_t) pplg->getProcAddress("esp_binding_factory"); } } if (xproc) { IEspRpcBinding* bind = xproc(xcfg.name.str(), xcfg.type.str(), m_envpt.get(), m_process.str()); if (bind) DBGLOG("Load binding %s (type: %s, process: %s) succeeded", xcfg.name.str(), xcfg.type.str(), m_process.str()); else ERRLOG("Failed to load binding %s (type: %s, process: %s)", xcfg.name.str(), xcfg.type.str(), m_process.str()); xcfg.bind.setown(bind); if (serverstatus) { IPropertyTree *stTree= serverstatus->queryProperties()->addPropTree("ESPservice", createPTree("ESPservice", ipt_caseInsensitive)); if (stTree) { stTree->setProp("@type", xcfg.service->getServiceType()); stTree->setProp("@name", xcfg.service_name.str()); stTree->setPropInt("@port", xcfg.port); } serverstatus->commitProperties(); } } else throw MakeStringException(-1, "procedure esp_binding_factory can't be loaded"); } else { throw MakeStringException(-1, "Protocol %s wasn't loaded correctly for the binding", xcfg.protocol_name.str()); } } }