boost changes and header fixes
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / impl / MetadataProvider.cpp
index 7942e01..b0582f2 100644 (file)
@@ -1,17 +1,21 @@
-/*
- *  Copyright 2001-2010 Internet2
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
  */
 
 /**
@@ -25,6 +29,7 @@
 #include "saml2/metadata/MetadataProvider.h"
 
 #include <algorithm>
+#include <boost/lambda/lambda.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xmltooling/logging.h>
 #include <xmltooling/unicode.h>
@@ -35,6 +40,8 @@ using namespace opensaml::saml2md;
 using namespace opensaml;
 using namespace xmltooling::logging;
 using namespace xmltooling;
+using namespace boost::lambda;
+using namespace boost;
 using namespace std;
 
 namespace opensaml {
@@ -42,6 +49,7 @@ namespace opensaml {
         SAML_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory XMLMetadataProviderFactory;
         SAML_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory DynamicMetadataProviderFactory;
         SAML_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory ChainingMetadataProviderFactory;
+        SAML_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory FolderMetadataProviderFactory;
         SAML_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory NullMetadataProviderFactory;
         SAML_DLLLOCAL PluginManager<MetadataFilter,string,const DOMElement*>::Factory BlacklistMetadataFilterFactory;
         SAML_DLLLOCAL PluginManager<MetadataFilter,string,const DOMElement*>::Factory WhitelistMetadataFilterFactory;
@@ -57,6 +65,7 @@ void SAML_API opensaml::saml2md::registerMetadataProviders()
     conf.MetadataProviderManager.registerFactory(XML_METADATA_PROVIDER, XMLMetadataProviderFactory);
     conf.MetadataProviderManager.registerFactory(DYNAMIC_METADATA_PROVIDER, DynamicMetadataProviderFactory);
     conf.MetadataProviderManager.registerFactory(CHAINING_METADATA_PROVIDER, ChainingMetadataProviderFactory);
+    conf.MetadataProviderManager.registerFactory(FOLDER_METADATA_PROVIDER, FolderMetadataProviderFactory);
     conf.MetadataProviderManager.registerFactory(NULL_METADATA_PROVIDER, NullMetadataProviderFactory);
 }
 
@@ -123,14 +132,17 @@ MetadataProvider::MetadataProvider(const DOMElement* e)
     }
     catch (XMLToolingException& ex) {
         log.error("caught exception while installing filters: %s", ex.what());
-        for_each(m_filters.begin(),m_filters.end(),xmltooling::cleanup<MetadataFilter>());
         throw;
     }
 }
 
 MetadataProvider::~MetadataProvider()
 {
-    for_each(m_filters.begin(), m_filters.end(), xmltooling::cleanup<MetadataFilter>());
+}
+
+const char* MetadataProvider::getId() const
+{
+    return nullptr;
 }
 
 void MetadataProvider::addMetadataFilter(MetadataFilter* newFilter)
@@ -140,11 +152,9 @@ void MetadataProvider::addMetadataFilter(MetadataFilter* newFilter)
 
 MetadataFilter* MetadataProvider::removeMetadataFilter(MetadataFilter* oldFilter)
 {
-    for (vector<MetadataFilter*>::iterator i=m_filters.begin(); i!=m_filters.end(); i++) {
-        if (oldFilter==(*i)) {
-            m_filters.erase(i);
-            return oldFilter;
-        }
+    ptr_vector<MetadataFilter>::iterator i = find_if(m_filters.begin(), m_filters.end(), (&_1 == oldFilter));
+    if (i != m_filters.end()) {
+        return m_filters.release(i).release();
     }
     return nullptr;
 }
@@ -155,12 +165,16 @@ void MetadataProvider::doFilters(XMLObject& xmlObject) const
     NDC ndc("doFilters");
 #endif
     Category& log=Category::getInstance(SAML_LOGCAT".Metadata");
-    for (std::vector<MetadataFilter*>::const_iterator i=m_filters.begin(); i!=m_filters.end(); i++) {
-        log.info("applying metadata filter (%s)", (*i)->getId());
-        (*i)->doFilter(xmlObject);
+    for (ptr_vector<MetadataFilter>::const_iterator i = m_filters.begin(); i != m_filters.end(); i++) {
+        log.info("applying metadata filter (%s)", i->getId());
+        i->doFilter(xmlObject);
     }
 }
 
+void MetadataProvider::outputStatus(ostream& os) const
+{
+}
+
 const EntitiesDescriptor* MetadataProvider::getEntitiesDescriptor(const XMLCh* name, bool strict) const
 {
     auto_ptr_char temp(name);