[cpp-opensaml COMMIT] /branches/REL_2/saml/saml2/metadata/impl/EntityAttributesEntityMatcher.cpp

noreply at shibboleth.net noreply at shibboleth.net
Thu Nov 29 12:04:33 EST 2012


Author: scantor
Date: Thu Nov 29 12:04:33 2012
New Revision: 754

URL: http://svn.shibboleth.net/view/cpp-opensaml?rev=754&view=rev
Log:
Bit of logging to detect missing extension

Modified:
    branches/REL_2/saml/saml2/metadata/impl/EntityAttributesEntityMatcher.cpp

Modified: branches/REL_2/saml/saml2/metadata/impl/EntityAttributesEntityMatcher.cpp
URL: http://svn.shibboleth.net/view/cpp-opensaml/branches/REL_2/saml/saml2/metadata/impl/EntityAttributesEntityMatcher.cpp?rev=754&r1=753&r2=754&view=diff
==============================================================================
--- branches/REL_2/saml/saml2/metadata/impl/EntityAttributesEntityMatcher.cpp (original)
+++ branches/REL_2/saml/saml2/metadata/impl/EntityAttributesEntityMatcher.cpp Thu Nov 29 12:04:33 2012
@@ -63,6 +63,7 @@
 
             bool m_trimTags;
             vector< boost::shared_ptr<Attribute> > m_tags;
+            Category& m_log;
         };
 
         EntityMatcher* SAML_DLLLOCAL EntityAttributesEntityMatcherFactory(const DOMElement* const & e)
@@ -81,7 +82,8 @@
 
 
 EntityAttributesEntityMatcher::EntityAttributesEntityMatcher(const DOMElement* e)
-    : m_trimTags(XMLHelper::getAttrBool(e, false, trimTags))
+    : m_trimTags(XMLHelper::getAttrBool(e, false, trimTags)),
+        m_log(Category::getInstance(SAML_LOGCAT".EntityMatcher.EntityAttributes"))
 {
     // Check for shorthand syntax.
     if (e && e->hasAttributeNS(nullptr, attributeName) && (e->hasAttributeNS(nullptr, attributeValue) || e->hasAttributeNS(nullptr, attributeValueRegex))) {
@@ -115,12 +117,15 @@
 
 bool EntityAttributesEntityMatcher::matches(const EntityDescriptor& entity) const
 {
+    bool extFound = false;
+
     // Check for a tag match in the EntityAttributes extension of the entity and its parent(s).
     const Extensions* exts = entity.getExtensions();
     if (exts) {
         const vector<XMLObject*>& children = exts->getUnknownXMLObjects();
         const XMLObject* xo = find_if(children, ll_dynamic_cast<EntityAttributes*>(_1) != ((EntityAttributes*)nullptr));
         if (xo) {
+            extFound = true;
             // If we find a matching tag, we win. Each tag is treated in OR fashion.
             if (find_if(m_tags.begin(), m_tags.end(),
                 lambda::bind(&EntityAttributesEntityMatcher::_matches, this, dynamic_cast<const EntityAttributes*>(xo),
@@ -137,6 +142,7 @@
             const vector<XMLObject*>& children = exts->getUnknownXMLObjects();
             const XMLObject* xo = find_if(children, ll_dynamic_cast<EntityAttributes*>(_1) != ((EntityAttributes*)nullptr));
             if (xo) {
+                extFound = true;
                 // If we find a matching tag, we win. Each tag is treated in OR fashion.
                 if (find_if(m_tags.begin(), m_tags.end(),
                     lambda::bind(&EntityAttributesEntityMatcher::_matches, this, dynamic_cast<const EntityAttributes*>(xo),
@@ -148,6 +154,11 @@
         group = dynamic_cast<EntitiesDescriptor*>(group->getParent());
     }
 
+    if (!extFound && m_log.isDebugEnabled()) {
+        auto_ptr_char id (entity.getEntityID());
+        m_log.debug("no EntityAttributes extension found for (%s)", id.get());
+    }
+
     return false;
 }
 
@@ -186,7 +197,7 @@
                             }
                             catch (XMLException& ex) {
                                 auto_ptr_char msg(ex.getMessage());
-                                Category::getInstance(SAML_LOGCAT".EntityMatcher.EntityAttributes").error(msg.get());
+                                m_log.error(msg.get());
                             }
                         }
                     }
@@ -205,7 +216,7 @@
                                 }
                                 catch (XMLException& ex) {
                                     auto_ptr_char msg(ex.getMessage());
-                                    Category::getInstance(SAML_LOGCAT".EntityMatcher.EntityAttributes").error(msg.get());
+                                    m_log.error(msg.get());
                                 }
                             }
                             else if (XMLString::equals(tagvalstr, cvalstr)) {



More information about the commits mailing list