Auto-wrap chained Application plugins, relax order child elements, add some logging.
[shibboleth/sp.git] / shibsp / attribute / filtering / impl / ChainingAttributeFilter.cpp
index 3069ffd..ee4201e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2010 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include "attribute/filtering/AttributeFilter.h"
 #include "attribute/filtering/FilteringContext.h"
 
-#include <log4cpp/Category.hh>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xmltooling/util/XMLHelper.h>
 
 using namespace shibsp;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 namespace shibsp {
@@ -49,7 +47,7 @@ namespace shibsp {
         void unlock() {
         }
         
-        void filterAttributes(const FilteringContext& context, multimap<string,Attribute*>& attributes) const {
+        void filterAttributes(const FilteringContext& context, vector<Attribute*>& attributes) const {
             for (vector<AttributeFilter*>::const_iterator i=m_filters.begin(); i!=m_filters.end(); ++i) {
                 Locker locker(*i);
                 (*i)->filterAttributes(context, attributes);
@@ -74,15 +72,18 @@ ChainingAttributeFilter::ChainingAttributeFilter(const DOMElement* e)
     SPConfig& conf = SPConfig::getConfig();
 
     // Load up the chain of handlers.
-    e = e ? XMLHelper::getFirstChildElement(e, _AttributeFilter) : NULL;
+    e = XMLHelper::getFirstChildElement(e, _AttributeFilter);
     while (e) {
-        auto_ptr_char type(e->getAttributeNS(NULL,_type));
-        if (type.get() && *(type.get())) {
+        string t(XMLHelper::getAttrString(e, nullptr, _type));
+        if (!t.empty()) {
             try {
-                m_filters.push_back(conf.AttributeFilterManager.newPlugin(type.get(),e));
+                Category::getInstance(SHIBSP_LOGCAT".AttributeFilter.Chaining").info(
+                    "building AttributeFilter of type (%s)...", t.c_str()
+                    );
+                m_filters.push_back(conf.AttributeFilterManager.newPlugin(t.c_str(), e));
             }
             catch (exception& ex) {
-                Category::getInstance(SHIBSP_LOGCAT".AttributeFilter").error(
+                Category::getInstance(SHIBSP_LOGCAT".AttributeFilter.Chaining").error(
                     "caught exception processing embedded AttributeFilter element: %s", ex.what()
                     );
             }