浏览代码

Signed-off-by: Russ Whitehead <william.whitehead@lexisnexis.com>

Russ Whitehead 9 年之前
父节点
当前提交
c5d164fece
共有 2 个文件被更改,包括 65 次插入64 次删除
  1. 59 59
      esp/bindings/http/platform/httpbinding.cpp
  2. 6 5
      system/security/shared/secloader.hpp

+ 59 - 59
esp/bindings/http/platform/httpbinding.cpp

@@ -187,7 +187,7 @@ EspHttpBinding::EspHttpBinding(IPropertyTree* tree, const char *bindname, const
             m_authmethod.set(authcfg->queryProp("@method"));
             if (!m_authmethod.isEmpty())
             {
-                PROGLOG("Authenticate method=%s", m_authmethod.str());
+                PROGLOG("Configuring Authenticate method=%s", m_authmethod.str());
                 Owned<IPropertyTree> process_config = getProcessConfig(tree, procname);
 
                 Owned<IPropertyTree> secMgrCfg;
@@ -206,7 +206,7 @@ EspHttpBinding::EspHttpBinding(IPropertyTree* tree, const char *bindname, const
                     if (!secMgrType.isEmpty() && 0==strcmp(secMgrType.str(), m_authmethod.str()))
                     {
                         m_secmgr.setown(SecLoader::loadPluggableSecManager(bindname, authcfg, secMgrCfg));
-                        m_authmap.setown(m_secmgr->createAuthMap(authcfg));//???
+                        m_authmap.setown(m_secmgr->createAuthMap(authcfg));
                     }
                     else
                     {
@@ -215,66 +215,66 @@ EspHttpBinding::EspHttpBinding(IPropertyTree* tree, const char *bindname, const
                 }
                 else
                 {
-            //Legacy Security Manager
-            if(stricmp(m_authmethod.str(), "LdapSecurity") == 0)
-            {
-                StringBuffer lsname;
-                authcfg->getProp("@config", lsname);
-                Owned<IPropertyTree> lscfg = bnd_cfg->getPropTree(StringBuffer(".//ldapSecurity[@name=").appendf("\"%s\"]", lsname.str()).str());
-                if(lscfg == NULL)
-                {
-                    if(process_config.get() != NULL)
-                        lscfg.setown(process_config->getPropTree(StringBuffer("ldapSecurity[@name=").appendf("\"%s\"]", lsname.str()).str()));
-                    if(lscfg == NULL)
+                    //Legacy Security Manager
+                    if(stricmp(m_authmethod.str(), "LdapSecurity") == 0)
                     {
-                        ERRLOG("can't find bnd_cfg for LdapSecurity %s", lsname.str());
-                        throw MakeStringException(-1, "can't find bnd_cfg for LdapSecurity %s", lsname.str());
+                        StringBuffer lsname;
+                        authcfg->getProp("@config", lsname);
+                        Owned<IPropertyTree> lscfg = bnd_cfg->getPropTree(StringBuffer(".//ldapSecurity[@name=").appendf("\"%s\"]", lsname.str()).str());
+                        if(lscfg == NULL)
+                        {
+                            if(process_config.get() != NULL)
+                                lscfg.setown(process_config->getPropTree(StringBuffer("ldapSecurity[@name=").appendf("\"%s\"]", lsname.str()).str()));
+                            if(lscfg == NULL)
+                            {
+                                ERRLOG("can't find bnd_cfg for LdapSecurity %s", lsname.str());
+                                throw MakeStringException(-1, "can't find bnd_cfg for LdapSecurity %s", lsname.str());
+                            }
+                        }
+
+                        m_secmgr.setown(SecLoader::loadSecManager("LdapSecurity", "EspHttpBinding", LINK(lscfg)));
+                        if(m_secmgr.get() == NULL)
+                        {
+                            throw MakeStringException(-1, "error generating SecManager");
+                        }
+
+                        StringBuffer basednbuf;
+                        authcfg->getProp("@resourcesBasedn", basednbuf);
+                        m_secmgr->setExtraParam("resourcesBasedn", basednbuf.str());
+                        basednbuf.clear();
+                        authcfg->getProp("@workunitsBasedn", basednbuf);
+                        m_secmgr->setExtraParam("workunitsBasedn", basednbuf.str());
+
+                        m_authmap.setown(m_secmgr->createAuthMap(authcfg));
+                        m_feature_authmap.setown(m_secmgr->createFeatureMap(authcfg));
+                    }
+                    else if(stricmp(m_authmethod.str(), "Local") == 0)
+                    {
+                        m_secmgr.setown(SecLoader::loadSecManager("Local", "EspHttpBinding", NULL));
+                        m_authmap.setown(m_secmgr->createAuthMap(authcfg));
+                    }
+                    else if(stricmp(m_authmethod.str(), "htpasswd") == 0)
+                    {
+                        Owned<IPropertyTree> cfg;
+                        if(process_config.get() != NULL)
+                            cfg.setown(process_config->getPropTree("htpasswdSecurity"));
+                        if(cfg == NULL)
+                        {
+                            ERRLOG("can't find htpasswdSecurity in configuration");
+                            throw MakeStringException(-1, "can't find htpasswdSecurity in configuration");
+                        }
+
+                        m_secmgr.setown(SecLoader::loadSecManager("htpasswd", "EspHttpBinding", LINK(cfg)));
+                        m_authmap.setown(m_secmgr->createAuthMap(authcfg));
+                    }
+                    IRestartManager* restartManager = dynamic_cast<IRestartManager*>(m_secmgr.get());
+                    if(restartManager!=NULL)
+                    {
+                        IRestartHandler* pHandler = dynamic_cast<IRestartHandler*>(getESPContainer());
+                        if(pHandler!=NULL)
+                            restartManager->setRestartHandler(pHandler);
                     }
                 }
-
-                m_secmgr.setown(SecLoader::loadSecManager("LdapSecurity", "EspHttpBinding", LINK(lscfg)));
-                if(m_secmgr.get() == NULL)
-                {
-                    throw MakeStringException(-1, "error generating SecManager");
-                }
-
-                StringBuffer basednbuf;
-                authcfg->getProp("@resourcesBasedn", basednbuf);
-                m_secmgr->setExtraParam("resourcesBasedn", basednbuf.str());
-                basednbuf.clear();
-                authcfg->getProp("@workunitsBasedn", basednbuf);
-                m_secmgr->setExtraParam("workunitsBasedn", basednbuf.str());
-
-                m_authmap.setown(m_secmgr->createAuthMap(authcfg));
-                m_feature_authmap.setown(m_secmgr->createFeatureMap(authcfg));
-            }
-            else if(stricmp(m_authmethod.str(), "Local") == 0)
-            {
-                m_secmgr.setown(SecLoader::loadSecManager("Local", "EspHttpBinding", NULL));
-                m_authmap.setown(m_secmgr->createAuthMap(authcfg));
-            }
-            else if(stricmp(m_authmethod.str(), "htpasswd") == 0)
-            {
-                Owned<IPropertyTree> cfg;
-                if(process_config.get() != NULL)
-                    cfg.setown(process_config->getPropTree("htpasswdSecurity"));
-                if(cfg == NULL)
-                {
-                    ERRLOG("can't find htpasswdSecurity in configuration");
-                    throw MakeStringException(-1, "can't find htpasswdSecurity in configuration");
-                }
-
-                m_secmgr.setown(SecLoader::loadSecManager("htpasswd", "EspHttpBinding", LINK(cfg)));
-                m_authmap.setown(m_secmgr->createAuthMap(authcfg));
-            }
-            IRestartManager* restartManager = dynamic_cast<IRestartManager*>(m_secmgr.get());
-            if(restartManager!=NULL)
-            {
-                IRestartHandler* pHandler = dynamic_cast<IRestartHandler*>(getESPContainer());
-                if(pHandler!=NULL)
-                    restartManager->setRestartHandler(pHandler);
-            }
-            }
             }
         }
     }

+ 6 - 5
system/security/shared/secloader.hpp

@@ -34,20 +34,20 @@ public:
     /// its instance factory to create and return an ISecManager security manager instance
     /// for the given ESP service
     ///
-    /// @param  svcName         Service name ie 'WsTopology_smc_myesp'
+    /// @param  bindingName     Binding name ie 'WsTopology_smc_myesp'
     /// @param  secMgrCfg       'SecurityManager' IPropertyTree from component config file
     /// @param  authCfg         'Authenticate' IPropertyTree from EspService component binding
     ///
     /// @return an ISecManager Security Manager instance
     ///
-    static ISecManager* loadPluggableSecManager(const char * svcName, IPropertyTree* authCfg, IPropertyTree* secMgrCfg)
+    static ISecManager* loadPluggableSecManager(const char * bindingName, IPropertyTree* authCfg, 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, svcName);
+            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"));
@@ -57,7 +57,7 @@ public:
         //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(), svcName);
+            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;
@@ -66,8 +66,9 @@ public:
             throw MakeStringException(-1, "%s cannot locate procedure %s of '%s'", lsm, instFactory.str(), libName.str());
 
         //Call ISecManager instance factory and return the new instance
-        return xproc(svcName, *secMgrCfg, *authCfg);
+        return xproc(bindingName, *secMgrCfg, *authCfg);
     }
+
     static ISecManager* loadSecManager(const char* model_name, const char* servicename, IPropertyTree* cfg)
     {
         if (!model_name || !*model_name)