Convert logging to log4shib via compile time switch.
[shibboleth/cpp-sp.git] / shibsp / attribute / resolver / impl / XMLAttributeExtractor.cpp
index 9b73062..44bf5e4 100644 (file)
@@ -23,7 +23,6 @@
 #include "internal.h"
 #include "Application.h"
 #include "ServiceProvider.h"
-#include "SPRequest.h"
 #include "attribute/AttributeDecoder.h"
 #include "attribute/resolver/AttributeExtractor.h"
 #include "util/SPConstants.h"
@@ -40,7 +39,6 @@ using namespace shibsp;
 using namespace opensaml::saml2md;
 using namespace opensaml;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 using saml1::NameIdentifier;
 using saml2::NameID;
@@ -81,9 +79,8 @@ namespace shibsp {
             const Application& application, const char* assertingParty, const saml2::Attribute& attr, multimap<string,Attribute*>& attributes
             ) const;
 
-        void clearHeaders(SPRequest& request) const {
-            for (vector<string>::const_iterator i = m_attributeIds.begin(); i!=m_attributeIds.end(); ++i)
-                request.clearHeader(i->c_str());
+        void getAttributeIds(vector<string>& attributes) const {
+            attributes.insert(attributes.end(), m_attributeIds.begin(), m_attributeIds.end());
         }
 
     private:
@@ -112,9 +109,9 @@ namespace shibsp {
             const Application& application, const RoleDescriptor* issuer, const XMLObject& xmlObject, multimap<string,Attribute*>& attributes
             ) const;
 
-        void clearHeaders(SPRequest& request) const {
+        void getAttributeIds(std::vector<std::string>& attributes) const {
             if (m_impl)
-                m_impl->clearHeaders(request);
+                m_impl->getAttributeIds(attributes);
         }
 
     protected:
@@ -252,12 +249,9 @@ void XMLExtractorImpl::extractAttributes(
     auto_ptr_char temp(format);
     if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) {
 #endif
-        attributes.insert(
-            make_pair(
-                rule->second.second,
-                rule->second.first->decode(rule->second.second.c_str(), &nameid, assertingParty, application.getString("entityID").second)
-                )
-            );
+        Attribute* a = rule->second.first->decode(rule->second.second.c_str(), &nameid, assertingParty, application.getString("entityID").second);
+        if (a)
+            attributes.insert(make_pair(rule->second.second, a));
     }
 }
 
@@ -280,12 +274,9 @@ void XMLExtractorImpl::extractAttributes(
     auto_ptr_char temp(format);
     if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) {
 #endif
-        attributes.insert(
-            make_pair(
-                rule->second.second,
-                rule->second.first->decode(rule->second.second.c_str(), &nameid, assertingParty, application.getString("entityID").second)
-                )
-            );
+        Attribute* a = rule->second.first->decode(rule->second.second.c_str(), &nameid, assertingParty, application.getString("entityID").second);
+        if (a)
+            attributes.insert(make_pair(rule->second.second, a));
     }
 }
 
@@ -312,12 +303,9 @@ void XMLExtractorImpl::extractAttributes(
     auto_ptr_char temp2(format);
     if ((rule=m_attrMap.find(make_pair(temp1.get(),temp2.get()))) != m_attrMap.end()) {
 #endif
-        attributes.insert(
-            make_pair(
-                rule->second.second,
-                rule->second.first->decode(rule->second.second.c_str(), &attr, assertingParty, application.getString("entityID").second)
-                )
-            );
+        Attribute* a = rule->second.first->decode(rule->second.second.c_str(), &attr, assertingParty, application.getString("entityID").second);
+        if (a)
+            attributes.insert(make_pair(rule->second.second, a));
     }
 }
 
@@ -346,12 +334,9 @@ void XMLExtractorImpl::extractAttributes(
     auto_ptr_char temp2(format);
     if ((rule=m_attrMap.find(make_pair(temp1.get(),temp2.get()))) != m_attrMap.end()) {
 #endif
-        attributes.insert(
-            make_pair(
-                rule->second.second,
-                rule->second.first->decode(rule->second.second.c_str(), &attr, assertingParty, application.getString("entityID").second)
-                )
-            );
+        Attribute* a = rule->second.first->decode(rule->second.second.c_str(), &attr, assertingParty, application.getString("entityID").second);
+        if (a)
+            attributes.insert(make_pair(rule->second.second, a));
     }
 }