Move config logic into an "XML" SP plugin, divorce shibd and modules from old libs.
[shibboleth/cpp-sp.git] / shib-target / shib-ini.cpp
index 0e7da7a..edf5908 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2005 Internet2
+ *  Copyright 2001-2007 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -72,7 +72,6 @@ namespace {
         // IApplication
         const char* getId() const {return getString("id").second;}
         const char* getHash() const {return m_hash.c_str();}
-        Iterator<IAAP*> getAAPProviders() const;
         MetadataProvider* getMetadataProvider() const;
         TrustEngine* getTrustEngine() const;
         const vector<const XMLCh*>& getAudiences() const;
@@ -103,7 +102,6 @@ namespace {
         const ServiceProvider* m_sp;   // this is ok because its locking scope includes us
         const XMLApplication* m_base;
         string m_hash;
-        vector<IAAP*> m_aaps;
         MetadataProvider* m_metadata;
         TrustEngine* m_trust;
         vector<const XMLCh*> m_audiences;
@@ -454,25 +452,10 @@ XMLApplication::XMLApplication(
         // Always include our own providerId as an audience.
         m_audiences.push_back(getXMLString("providerId").second);
 
-        if (conf.isEnabled(SPConfig::AAP)) {
+        if (conf.isEnabled(SPConfig::AttributeResolver)) {
             child = XMLHelper::getFirstChildElement(e,AAPProvider);
             while (child) {
-                xmltooling::auto_ptr_char type(child->getAttributeNS(NULL,_type));
-                log.info("building AAP provider of type %s...",type.get());
-                try {
-                    IPlugIn* plugin=shibConf.getPlugMgr().newPlugin(type.get(),child);
-                    IAAP* aap=dynamic_cast<IAAP*>(plugin);
-                    if (aap)
-                        m_aaps.push_back(aap);
-                    else {
-                        delete plugin;
-                        log.crit("plugin was not an AAP provider");
-                    }
-                }
-                catch (exception& ex) {
-                    log.crit("error building AAP provider: %s", ex.what());
-                }
-
+                // TODO: some kind of compatibility
                 child = XMLHelper::getNextSiblingElement(child,AAPProvider);
             }
         }
@@ -597,7 +580,6 @@ void XMLApplication::cleanup()
 #else
     for_each(m_credMap.begin(),m_credMap.end(),xmltooling::cleanup_pair<const XMLCh*,PropertySet>());
 #endif
-    for_each(m_aaps.begin(),m_aaps.end(),xmltooling::cleanup<IAAP>());
 
     delete m_trust;
     delete m_metadata;
@@ -675,11 +657,6 @@ const PropertySet* XMLApplication::getPropertySet(const char* name, const char*
     return m_base->getPropertySet(name,ns);
 }
 
-Iterator<IAAP*> XMLApplication::getAAPProviders() const
-{
-    return (m_aaps.empty() && m_base) ? m_base->getAAPProviders() : m_aaps;
-}
-
 MetadataProvider* XMLApplication::getMetadataProvider() const
 {
     return (!m_metadata && m_base) ? m_base->getMetadataProvider() : m_metadata;
@@ -842,7 +819,8 @@ const Handler* XMLApplication::getHandler(const char* path) const
 
 short XMLConfigImpl::acceptNode(const DOMNode* node) const
 {
-    if (!XMLString::equals(node->getNamespaceURI(),shibspconstants::SHIB1SPCONFIG_NS))
+    if (!XMLString::equals(node->getNamespaceURI(),shibspconstants::SHIB1SPCONFIG_NS) &&
+        !XMLString::equals(node->getNamespaceURI(),shibspconstants::SHIB2SPCONFIG_NS))
         return FILTER_ACCEPT;
     const XMLCh* name=node->getLocalName();
     if (XMLString::equals(name,Applications) ||
@@ -903,7 +881,6 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o
 
     try {
         SPConfig& conf=SPConfig::getConfig();
-        SAMLConfig& shibConf=SAMLConfig::getConfig();
         XMLToolingConfig& xmlConf=XMLToolingConfig::getConfig();
         const DOMElement* SHAR=XMLHelper::getFirstChildElement(e,OutOfProcess);
         if (!SHAR)
@@ -942,6 +919,10 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o
 
         // Much of the processing can only occur on the first instantiation.
         if (first) {
+            // Set clock skew.
+            pair<bool,unsigned int> skew=getUnsignedInt("clockSkew");
+            if (skew.first)
+                xmlConf.clock_skew_secs=skew.second;
 
             // Extensions
             doExtensions(e, "global", log);
@@ -1114,34 +1095,6 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o
             }
         }
 
-        // Now we load any attribute factories
-        child = XMLHelper::getFirstChildElement(e,AttributeFactory);
-        while (child) {
-            xmltooling::auto_ptr_char type(child->getAttributeNS(NULL,_type));
-            log.info("building Attribute factory of type %s...",type.get());
-            try {
-                IPlugIn* plugin=shibConf.getPlugMgr().newPlugin(type.get(),child);
-                if (plugin) {
-                    IAttributeFactory* fact=dynamic_cast<IAttributeFactory*>(plugin);
-                    if (fact) {
-                        m_attrFactories.push_back(fact);
-                        ShibConfig::getConfig().regAttributeMapping(
-                            child->getAttributeNS(NULL,opensaml::saml1::Attribute::ATTRIBUTENAME_ATTRIB_NAME), fact
-                            );
-                    }
-                    else {
-                        delete plugin;
-                        log.crit("plugin was not an Attribute factory");
-                    }
-                }
-            }
-            catch (exception& ex) {
-                log.crit("error building Attribute factory: %s", ex.what());
-            }
-
-            child = XMLHelper::getNextSiblingElement(child,AttributeFactory);
-        }
-
         // Load the default application. This actually has a fixed ID of "default". ;-)
         child=XMLHelper::getFirstChildElement(e,Applications);
         if (!child) {