Metadata filters, filter auto-registration, and unit tests.
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / impl / FilesystemMetadataProvider.cpp
index dc264d6..113e1a3 100644 (file)
@@ -55,10 +55,13 @@ namespace opensaml {
 
             void init();
 
-            const EntityDescriptor* lookup(const XMLCh* id, bool requireValidMetadata=true) const;
-            const EntityDescriptor* lookup(const char* id, bool requireValidMetadata=true) const;
-            const EntitiesDescriptor* lookupGroup(const XMLCh* name, bool requireValidMetadata=true) const;
-            const EntitiesDescriptor* lookupGroup(const char* name, bool requireValidMetadata=true) const;
+            const EntityDescriptor* getEntityDescriptor(const XMLCh* id, bool requireValidMetadata=true) const;
+            const EntityDescriptor* getEntityDescriptor(const char* id, bool requireValidMetadata=true) const;
+            const EntitiesDescriptor* getEntitiesDescriptor(const XMLCh* name, bool requireValidMetadata=true) const;
+            const EntitiesDescriptor* getEntitiesDescriptor(const char* name, bool requireValidMetadata=true) const;
+            const XMLObject* getMetadata() const {
+                return m_object;
+            }
 
         private:
             XMLObject* load() const;
@@ -98,7 +101,7 @@ static const XMLCh filename[] = UNICODE_LITERAL_8(f,i,l,e,n,a,m,e);
 static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e);
 
 FilesystemMetadataProvider::FilesystemMetadataProvider(const DOMElement* e)
-    : m_root(e), m_filestamp(0), m_validate(false), m_lock(NULL), m_object(NULL)
+    : MetadataProvider(e), m_root(e), m_filestamp(0), m_validate(false), m_lock(NULL), m_object(NULL)
 {
 #ifdef _DEBUG
     NDC ndc("FilesystemMetadataProvider");
@@ -196,10 +199,7 @@ XMLObject* FilesystemMetadataProvider::load() const
         
         auto_ptr<XMLObject> xmlObjectPtr(xmlObject);
         
-        if (m_filter) {
-            log.info("applying metadata filter (%s)", m_filter->getId());
-            m_filter->doFilter(*xmlObject);
-        }
+        doFilters(*xmlObject);
         
         xmlObjectPtr->releaseThisAndChildrenDOM();
         xmlObjectPtr->setDocument(NULL);
@@ -306,7 +306,7 @@ void FilesystemMetadataProvider::index(EntitiesDescriptor* group, time_t validUn
         index(*j,group->getValidUntilEpoch());
 }
 
-const EntitiesDescriptor* FilesystemMetadataProvider::lookupGroup(const char* name, bool strict) const
+const EntitiesDescriptor* FilesystemMetadataProvider::getEntitiesDescriptor(const char* name, bool strict) const
 {
     pair<groupmap_t::const_iterator,groupmap_t::const_iterator> range=m_groups.equal_range(name);
 
@@ -321,13 +321,13 @@ const EntitiesDescriptor* FilesystemMetadataProvider::lookupGroup(const char* na
     return NULL;
 }
 
-const EntitiesDescriptor* FilesystemMetadataProvider::lookupGroup(const XMLCh* name, bool strict) const
+const EntitiesDescriptor* FilesystemMetadataProvider::getEntitiesDescriptor(const XMLCh* name, bool strict) const
 {
     auto_ptr_char temp(name);
-    return lookupGroup(temp.get(),strict);
+    return getEntitiesDescriptor(temp.get(),strict);
 }
 
-const EntityDescriptor* FilesystemMetadataProvider::lookup(const char* name, bool strict) const
+const EntityDescriptor* FilesystemMetadataProvider::getEntityDescriptor(const char* name, bool strict) const
 {
     pair<sitemap_t::const_iterator,sitemap_t::const_iterator> range=m_sites.equal_range(name);
 
@@ -342,8 +342,8 @@ const EntityDescriptor* FilesystemMetadataProvider::lookup(const char* name, boo
     return NULL;
 }
 
-const EntityDescriptor* FilesystemMetadataProvider::lookup(const XMLCh* name, bool strict) const
+const EntityDescriptor* FilesystemMetadataProvider::getEntityDescriptor(const XMLCh* name, bool strict) const
 {
     auto_ptr_char temp(name);
-    return lookup(temp.get(),strict);
+    return getEntityDescriptor(temp.get(),strict);
 }