[cpp-sp] branch master updated: SSPCPP-756 - Dynamic Metadata Provider cleanup

Scott Cantor cantor.2 at osu.edu
Thu May 17 20:44:20 EDT 2018


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=2fdca3281da277646368dcd2e597907ebcc23113

The following commit(s) were added to refs/heads/master by this push:
       new  2fdca32   SSPCPP-756 - Dynamic Metadata Provider cleanup
2fdca32 is described below

commit 2fdca3281da277646368dcd2e597907ebcc23113
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu May 17 20:43:32 2018 -0400

    SSPCPP-756 - Dynamic Metadata Provider cleanup
    
    https://issues.shibboleth.net/jira/browse/SSPCPP-756
    
    Add HTTP caching and status checking.
---
 shibsp/metadata/DynamicMetadataProvider.cpp | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/shibsp/metadata/DynamicMetadataProvider.cpp b/shibsp/metadata/DynamicMetadataProvider.cpp
index f45bb2e..fe1ab1d 100644
--- a/shibsp/metadata/DynamicMetadataProvider.cpp
+++ b/shibsp/metadata/DynamicMetadataProvider.cpp
@@ -50,6 +50,7 @@
 #include <xmltooling/logging.h>
 #include <xmltooling/version.h>
 #include <xmltooling/XMLToolingConfig.h>
+#include <xmltooling/io/HTTPResponse.h>
 #include <xmltooling/security/Credential.h>
 #include <xmltooling/security/CredentialCriteria.h>
 #include <xmltooling/security/CredentialResolver.h>
@@ -301,6 +302,7 @@ EntityDescriptor* DynamicMetadataProvider::resolve(const MetadataProvider::Crite
     }
 
     // Apply properties as directed.
+    transport->setCacheTag(&cacheTag);
     transport->setVerifyHost(m_verifyHost);
     HTTPSOAPTransport *httpTransport = dynamic_cast<HTTPSOAPTransport*>(transport.get());
     if (httpTransport) {
@@ -380,12 +382,22 @@ EntityDescriptor* DynamicMetadataProvider::resolve(const MetadataProvider::Crite
     try {
         // Use a nullptr stream to trigger a body-less "GET" operation.
         transport->send();
+        long status = transport->getStatusCode();
+        if (status == HTTPResponse::XMLTOOLING_HTTP_STATUS_NOTMODIFIED) {
+            m_log.info("metadata resource (%s) was unmodified", name.c_str());
+            return nullptr;
+        }
+        else if (status != HTTPResponse::XMLTOOLING_HTTP_STATUS_OK) {
+            m_log.warn("HTTP status (%ld) resolving metadata resource (%s)", status, name.c_str());
+            throw MetadataException("Unsuccessful HTTP request for metadata resource.");
+        }
+
         istream& msg = transport->receive();
 
         EntityDescriptor* entity = entityFromStream(msg);
 
         if (nullptr != entity && !m_isMDQ && criteria.artifact && !s_artifactWarned) {
-            m_log.warn("Successful resolution of an artifact by a non-MDQ dynamic server is not guaranteed to work");
+            m_log.warn("Successful resolution of an artifact by a non-MDQ dynamic server is not guaranteed to work.");
             s_artifactWarned = true;
         }
 
@@ -393,7 +405,6 @@ EntityDescriptor* DynamicMetadataProvider::resolve(const MetadataProvider::Crite
     }
     catch (const XMLException& e) {
         auto_ptr_char msg(e.getMessage());
-        m_log.error("Xerces error while resolving location (%s): %s", name.c_str(), msg.get());
         throw MetadataException(msg.get());
     }
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list