Moved plugin and locking interfaces into libsaml.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Sun, 30 Jan 2005 20:50:48 +0000 (20:50 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Sun, 30 Jan 2005 20:50:48 +0000 (20:50 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@1341 cb58f699-b61c-0410-a6fe-9272a202ed29

shib-mysql-ccache/shib-mysql-ccache.cpp
shib-target/XMLRequestMapper.cpp
shib-target/shib-config.cpp
shib-target/shib-ini.cpp
shib-target/shib-target.h
shib/ShibConfig.cpp
shib/shib.h
test/posttest.cpp
xmlproviders/XMLCredentials.cpp
xmlproviders/XMLProviders.cpp

index 70be103..1a3029b 100644 (file)
@@ -210,7 +210,7 @@ ShibMySQLCCache::ShibMySQLCCache(const DOMElement* e)
   initialized = true;
 
   m_cache = dynamic_cast<ISessionCache*>(
-      ShibConfig::getConfig().m_plugMgr.newPlugin(
+      SAMLConfig::getConfig().m_plugMgr.newPlugin(
         "edu.internet2.middleware.shibboleth.target.provider.MemorySessionCache", e
         )
     );
@@ -619,13 +619,13 @@ IPlugIn* new_mysql_ccache(const DOMElement* e)
 extern "C" int SHIBMYSQL_EXPORTS saml_extension_init(void*)
 {
   // register this ccache type
-  ShibConfig::getConfig().m_plugMgr.regFactory(PLUGINTYPE, &new_mysql_ccache);
+  SAMLConfig::getConfig().m_plugMgr.regFactory(PLUGINTYPE, &new_mysql_ccache);
   return 0;
 }
 
 extern "C" void SHIBMYSQL_EXPORTS saml_extension_term()
 {
-  ShibConfig::getConfig().m_plugMgr.unregFactory(PLUGINTYPE);
+  SAMLConfig::getConfig().m_plugMgr.unregFactory(PLUGINTYPE);
 }
 
 /*************************************************************************
index 3fb940c..6b8e5e0 100644 (file)
@@ -162,14 +162,14 @@ void Override::loadACL(const DOMElement* e, Category& log)
     const DOMElement* acl=saml::XML::getFirstChildElement(e,ShibTargetConfig::SHIBTARGET_NS,SHIBT_L(htaccess));
     if (acl) {
         log.info("building htaccess provider...");
-        plugin=ShibConfig::getConfig().m_plugMgr.newPlugin(shibtarget::XML::htaccessType,acl);
+        plugin=SAMLConfig::getConfig().m_plugMgr.newPlugin(shibtarget::XML::htaccessType,acl);
     }
     else {
         acl=saml::XML::getFirstChildElement(e,ShibTargetConfig::SHIBTARGET_NS,SHIBT_L(AccessControlProvider));
         if (acl) {
             auto_ptr_char type(acl->getAttributeNS(NULL,SHIBT_L(type)));
             log.info("building Access Control provider of type %s...",type.get());
-            plugin=ShibConfig::getConfig().m_plugMgr.newPlugin(type.get(),acl);
+            plugin=SAMLConfig::getConfig().m_plugMgr.newPlugin(type.get(),acl);
         }
     }
     if (plugin) {
index c00923f..3b2aac9 100644 (file)
@@ -162,11 +162,11 @@ bool STConfig::init(const char* schemadir, const char* config)
     try {
         // Register plugin types.
 #ifndef WIN32
-        shibConf.m_plugMgr.regFactory(shibtarget::XML::UnixListenerType,&UnixListenerFactory);
+        samlConf.m_plugMgr.regFactory(shibtarget::XML::UnixListenerType,&UnixListenerFactory);
 #endif
-        shibConf.m_plugMgr.regFactory(shibtarget::XML::TCPListenerType,&TCPListenerFactory);
-        shibConf.m_plugMgr.regFactory(shibtarget::XML::MemorySessionCacheType,&MemoryCacheFactory);
-        shibConf.m_plugMgr.regFactory(shibtarget::XML::RequestMapType,&XMLRequestMapFactory);
+        samlConf.m_plugMgr.regFactory(shibtarget::XML::TCPListenerType,&TCPListenerFactory);
+        samlConf.m_plugMgr.regFactory(shibtarget::XML::MemorySessionCacheType,&MemoryCacheFactory);
+        samlConf.m_plugMgr.regFactory(shibtarget::XML::RequestMapType,&XMLRequestMapFactory);
         //shibConf.m_plugMgr.regFactory(shibtarget::XML::htaccessType,&htaccessFactory);
         saml::XML::registerSchema(ShibTargetConfig::SHIBTARGET_NS,shibtarget::XML::SHIBTARGET_SCHEMA_ID);
         
index 0bae7cf..f5a9a05 100644 (file)
@@ -357,7 +357,7 @@ XMLApplication::XMLApplication(const DOMElement* e, const XMLApplication* base)
         load(e,log,this);
 
         ShibTargetConfig& conf=ShibTargetConfig::getConfig();
-        ShibConfig& shibConf=ShibConfig::getConfig();
+        SAMLConfig& shibConf=SAMLConfig::getConfig();
         int i;
         DOMNodeList* nlist=e->getElementsByTagNameNS(saml::XML::SAML_NS,L(AttributeDesignator));
         for (i=0; nlist && i<nlist->getLength(); i++) {
@@ -652,7 +652,7 @@ void XMLConfigImpl::init(bool first)
             throw MalformedException("Construction requires a valid configuration file: (conf:ShibbolethTargetConfig as root element)");
         }
 
-        ShibConfig& shibConf=ShibConfig::getConfig();
+        SAMLConfig& shibConf=SAMLConfig::getConfig();
         ShibTargetConfig& conf=ShibTargetConfig::getConfig();
         const DOMElement* SHAR=saml::XML::getFirstChildElement(ReloadableXMLFileImpl::m_root,ShibTargetConfig::SHIBTARGET_NS,SHIBT_L(SHAR));
         const DOMElement* SHIRE=saml::XML::getFirstChildElement(ReloadableXMLFileImpl::m_root,ShibTargetConfig::SHIBTARGET_NS,SHIBT_L(SHIRE));
index 0e1fed6..57e3a39 100644 (file)
@@ -149,7 +149,7 @@ namespace shibtarget {
         virtual ~IPropertySet() {}
     };
 
-    struct SHIBTARGET_EXPORTS IListener : public virtual shibboleth::IPlugIn
+    struct SHIBTARGET_EXPORTS IListener : public virtual saml::IPlugIn
     {
 #ifdef WIN32
         typedef SOCKET ShibSocket;
@@ -165,7 +165,7 @@ namespace shibtarget {
         virtual ~IListener() {}
     };
 
-    struct SHIBTARGET_EXPORTS IAccessControl : public virtual shibboleth::ILockable, public virtual shibboleth::IPlugIn
+    struct SHIBTARGET_EXPORTS IAccessControl : public virtual saml::ILockable, public virtual saml::IPlugIn
     {
         virtual bool authorized(
             const saml::SAMLAuthenticationStatement& authn, const saml::Iterator<saml::SAMLAssertion*>& attrs
@@ -173,7 +173,7 @@ namespace shibtarget {
         virtual ~IAccessControl() {}
     };
 
-    struct SHIBTARGET_EXPORTS IRequestMapper : public virtual shibboleth::ILockable, public virtual shibboleth::IPlugIn
+    struct SHIBTARGET_EXPORTS IRequestMapper : public virtual saml::ILockable, public virtual saml::IPlugIn
     {
         typedef std::pair<const IPropertySet*,IAccessControl*> Settings;
         virtual Settings getSettingsFromURL(const char* url) const=0;
@@ -197,7 +197,7 @@ namespace shibtarget {
         virtual ~IApplication() {}
     };
 
-        struct SHIBTARGET_EXPORTS ISessionCacheEntry : public virtual shibboleth::ILockable
+        struct SHIBTARGET_EXPORTS ISessionCacheEntry : public virtual saml::ILockable
     {
         virtual bool isValid(time_t lifetime, time_t timeout) const=0;
         virtual const char* getClientAddress() const=0;
@@ -208,7 +208,7 @@ namespace shibtarget {
         virtual ~ISessionCacheEntry() {}
     };
 
-    struct SHIBTARGET_EXPORTS ISessionCache : public virtual shibboleth::IPlugIn
+    struct SHIBTARGET_EXPORTS ISessionCache : public virtual saml::IPlugIn
     {
         virtual void thread_init()=0;
         virtual void thread_end()=0;
@@ -226,7 +226,7 @@ namespace shibtarget {
         virtual ~ISessionCache() {}
     };
 
-    struct SHIBTARGET_EXPORTS IConfig : public virtual shibboleth::ILockable, public virtual IPropertySet, public virtual shibboleth::IPlugIn
+    struct SHIBTARGET_EXPORTS IConfig : public virtual saml::ILockable, public virtual IPropertySet, public virtual saml::IPlugIn
     {
         virtual const IListener* getListener() const=0;
         virtual ISessionCache* getSessionCache() const=0;
index 4372d77..18107f9 100644 (file)
@@ -121,26 +121,6 @@ void ShibConfig::term()
     g_openssl_locks.clear();
 }
 
-void PlugManager::regFactory(const char* type, Factory* factory)
-{
-    if (type && factory)
-        m_map[type]=factory;
-}
-
-IPlugIn* PlugManager::newPlugin(const char* type, const DOMElement* source)
-{
-    FactoryMap::const_iterator i=m_map.find(type);
-    if (i==m_map.end())
-        throw saml::UnsupportedExtensionException(std::string("unable to build plugin of type '") + type + "'");
-    return i->second(source);
-}
-
-void PlugManager::unregFactory(const char* type)
-{
-    if (type)
-        m_map.erase(type);
-}
-
 ShibConfig& ShibConfig::getConfig()
 {
     return g_config;
index 53d0740..2652007 100644 (file)
@@ -92,38 +92,6 @@ namespace shibboleth
     DECLARE_SHIB_EXCEPTION(CredentialException,SAMLException);
     DECLARE_SHIB_EXCEPTION(InvalidHandleException,RetryableProfileException);
 
-    // Manages pluggable implementations of interfaces
-    // Would prefer this to be a template, but the Windows STL isn't DLL-safe.
-
-    struct SHIB_EXPORTS IPlugIn
-    {
-        virtual ~IPlugIn() {}
-    };
-
-    class SHIB_EXPORTS PlugManager
-    {
-    public:
-        PlugManager() {}
-        ~PlugManager() {}
-
-        typedef IPlugIn* Factory(const DOMElement* source);
-        void regFactory(const char* type, Factory* factory);
-        void unregFactory(const char* type);
-        IPlugIn* newPlugin(const char* type, const DOMElement* source);
-
-    private:
-        typedef std::map<std::string, Factory*> FactoryMap;
-        FactoryMap m_map;
-    };
-
-    // Various interfaces inherit from this to support locking
-    struct SHIB_EXPORTS ILockable
-    {
-        virtual void lock()=0;
-        virtual void unlock()=0;
-        virtual ~ILockable() {}
-    };    
-
     // Metadata abstract interfaces, based on SAML 2.0
     
     struct SHIB_EXPORTS IContactPerson
@@ -311,13 +279,13 @@ namespace shibboleth
         virtual ~IScopedRoleDescriptor() {}
     };
        
-    struct SHIB_EXPORTS IMetadata : public virtual ILockable, public virtual IPlugIn
+    struct SHIB_EXPORTS IMetadata : public virtual saml::ILockable, public virtual saml::IPlugIn
     {
         virtual const IEntityDescriptor* lookup(const XMLCh* id) const=0;
         virtual ~IMetadata() {}
     };
 
-    struct SHIB_EXPORTS IRevocation : public virtual ILockable, public virtual IPlugIn
+    struct SHIB_EXPORTS IRevocation : public virtual saml::ILockable, public virtual saml::IPlugIn
     {
         virtual saml::Iterator<void*> getRevocationLists(const IEntityDescriptor* provider, const IRoleDescriptor* role=NULL) const=0;
         virtual ~IRevocation() {}
@@ -326,7 +294,7 @@ namespace shibboleth
     // Trust interface hides *all* details of signature and SSL validation.
     // Pluggable providers can fully override the Shibboleth trust model here.
     
-    struct SHIB_EXPORTS ITrust : public virtual IPlugIn
+    struct SHIB_EXPORTS ITrust : public virtual saml::IPlugIn
     {
         virtual bool validate(
             const saml::Iterator<IRevocation*>& revocations,
@@ -339,7 +307,7 @@ namespace shibboleth
 
     // Credentials interface abstracts access to "owned" keys and certificates.
     
-    struct SHIB_EXPORTS ICredResolver : public virtual IPlugIn
+    struct SHIB_EXPORTS ICredResolver : public virtual saml::IPlugIn
     {
         virtual void attach(void* ctx) const=0;
         virtual XSECCryptoKey* getKey() const=0;
@@ -349,7 +317,7 @@ namespace shibboleth
         virtual ~ICredResolver() {}
     };
 
-    struct SHIB_EXPORTS ICredentials : public virtual ILockable, public virtual IPlugIn
+    struct SHIB_EXPORTS ICredentials : public virtual saml::ILockable, public virtual saml::IPlugIn
     {
         virtual const ICredResolver* lookup(const char* id) const=0;
         virtual ~ICredentials() {}
@@ -369,7 +337,7 @@ namespace shibboleth
         virtual ~IAttributeRule() {}
     };
     
-    struct SHIB_EXPORTS IAAP : public virtual ILockable, public virtual IPlugIn
+    struct SHIB_EXPORTS IAAP : public virtual saml::ILockable, public virtual saml::IPlugIn
     {
         virtual bool anyAttribute() const=0;
         virtual const IAttributeRule* lookup(const XMLCh* attrName, const XMLCh* attrNamespace=NULL) const=0;
@@ -411,18 +379,6 @@ namespace shibboleth
 
     // Glue classes between abstract metadata and concrete providers
     
-    class SHIB_EXPORTS Locker
-    {
-    public:
-        Locker(ILockable* lockee) : m_lockee(lockee) {m_lockee->lock();}
-        ~Locker() {if (m_lockee) m_lockee->unlock();}
-        
-    private:
-        Locker(const Locker&);
-        void operator=(const Locker&);
-        ILockable* m_lockee;
-    };
-    
     class SHIB_EXPORTS Metadata
     {
     public:
@@ -595,9 +551,6 @@ namespace shibboleth
 
         // enables runtime and clients to access configuration
         static ShibConfig& getConfig();
-
-        // allows pluggable implementations of metadata and configuration data
-        PlugManager m_plugMgr;
     };
 
     /* Helper classes for implementing reloadable XML-based config files
@@ -618,7 +571,7 @@ namespace shibboleth
         const DOMElement* m_root;
     };
 
-    class SHIB_EXPORTS ReloadableXMLFile : protected virtual ILockable
+    class SHIB_EXPORTS ReloadableXMLFile : protected virtual saml::ILockable
     {
     public:
         ReloadableXMLFile(const DOMElement* e);
index dcce3c4..69dd921 100644 (file)
@@ -94,7 +94,7 @@ int main(int argc,char* argv[])
         dummy->setAttributeNS(NULL,url,src.get());
 
         IMetadata* metadatas[1];
-        metadatas[0]=dynamic_cast<IMetadata*>(conf2.m_plugMgr.newPlugin("edu.internet2.middleware.shibboleth.provider.XMLMetadata",dummy));
+        metadatas[0]=dynamic_cast<IMetadata*>(conf1.m_plugMgr.newPlugin("edu.internet2.middleware.shibboleth.provider.XMLMetadata",dummy));
         dummydoc->release();
         ArrayIterator<IMetadata*> sites(metadatas,1);
         
index af3c358..723349f 100644 (file)
@@ -144,7 +144,7 @@ void XMLCredentialsImpl::init()
             
             if (!cr_type.empty()) {
                 try {
-                    IPlugIn* plugin=ShibConfig::getConfig().m_plugMgr.newPlugin(cr_type.c_str(),child);
+                    IPlugIn* plugin=SAMLConfig::getConfig().m_plugMgr.newPlugin(cr_type.c_str(),child);
                     ICredResolver* cr=dynamic_cast<ICredResolver*>(plugin);
                     if (cr)
                         m_resolverMap[id.get()]=cr;
index 6e615ba..4b233c3 100644 (file)
@@ -143,7 +143,7 @@ extern "C" int XML_EXPORTS saml_extension_init(void*)
     saml::XML::registerSchema(::XML::XMLENC_NS,::XML::XMLENC_SCHEMA_ID);
 
     // Register metadata factories
-    ShibConfig& conf=ShibConfig::getConfig();
+    SAMLConfig& conf=SAMLConfig::getConfig();
     conf.m_plugMgr.regFactory("edu.internet2.middleware.shibboleth.common.provider.XMLMetadata",&XMLMetadataFactory);
     conf.m_plugMgr.regFactory("edu.internet2.middleware.shibboleth.common.provider.XMLRevocation",&XMLRevocationFactory);
     conf.m_plugMgr.regFactory("edu.internet2.middleware.shibboleth.common.provider.XMLTrust",&XMLTrustFactory);
@@ -159,7 +159,7 @@ extern "C" int XML_EXPORTS saml_extension_init(void*)
 extern "C" void XML_EXPORTS saml_extension_term()
 {
     // Unregister metadata factories
-    ShibConfig& conf=ShibConfig::getConfig();
+    SAMLConfig& conf=SAMLConfig::getConfig();
     conf.m_plugMgr.unregFactory("edu.internet2.middleware.shibboleth.common.provider.XMLMetadata");
     conf.m_plugMgr.unregFactory("edu.internet2.middleware.shibboleth.common.provider.XMLRevocation");
     conf.m_plugMgr.unregFactory("edu.internet2.middleware.shibboleth.common.provider.XMLTrust");