[cpp-opensaml] 02/02: SSPCPP-756 Update NullMetadataProvider

Rod Widdowson rdw at steadingsoftware.com
Thu Nov 30 09:53:10 EST 2017


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

rdw pushed a commit to branch master
in repository cpp-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-opensaml.git;a=commit;h=29163ad5d380afa7f55036189693b5378a3a34f1

commit 29163ad5d380afa7f55036189693b5378a3a34f1
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Nov 30 14:51:17 2017 +0000

    SSPCPP-756 Update NullMetadataProvider
    
    https://issues.shibboleth.net/jira/browse/SSPCPP-756
    
    Null MetadatProvider had rottend slighty.  Derive from
    AbstractDynamicMetadatProvider and fix fallout
---
 saml/saml2/metadata/impl/NullMetadataProvider.cpp | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/saml/saml2/metadata/impl/NullMetadataProvider.cpp b/saml/saml2/metadata/impl/NullMetadataProvider.cpp
index 51e4de2..2a06110 100644
--- a/saml/saml2/metadata/impl/NullMetadataProvider.cpp
+++ b/saml/saml2/metadata/impl/NullMetadataProvider.cpp
@@ -26,7 +26,7 @@
 
 #include "internal.h"
 #include "saml2/metadata/Metadata.h"
-#include "saml2/metadata/DynamicMetadataProvider.h"
+#include "saml2/metadata/AbstractDynamicMetadataProvider.h"
 
 #include <xmltooling/util/XMLHelper.h>
 
@@ -36,10 +36,10 @@ using namespace std;
 
 namespace opensaml {
     namespace saml2md {
-        class SAML_DLLLOCAL NullMetadataProvider : public DynamicMetadataProvider
+        class SAML_DLLLOCAL NullMetadataProvider : public AbstractDynamicMetadataProvider
         {
         public:
-            NullMetadataProvider(const DOMElement* e) : DynamicMetadataProvider(e) {
+            NullMetadataProvider(const DOMElement* e) : AbstractDynamicMetadataProvider(true, e), MetadataProvider(e) {
                 e = XMLHelper::getFirstChildElement(e, samlconstants::SAML20MD_NS, EntityDescriptor::LOCAL_NAME);
                 if (e)
                     m_template.reset(dynamic_cast<EntityDescriptor*>(XMLObjectBuilder::buildOneFromElement(const_cast<DOMElement*>(e))));
@@ -47,8 +47,10 @@ namespace opensaml {
 
             virtual ~NullMetadataProvider() {}
 
+            void init() {}
+
         protected:
-            EntityDescriptor* resolve(const char* entityID) const;
+            EntityDescriptor* resolve(const MetadataProvider::Criteria& criteria) const;
 
         private:
             auto_ptr<EntityDescriptor> m_template;
@@ -61,11 +63,18 @@ namespace opensaml {
     };
 };
 
-EntityDescriptor* NullMetadataProvider::resolve(const char* entityID) const
+EntityDescriptor* NullMetadataProvider::resolve(const MetadataProvider::Criteria& criteria) const
 {
     // Resolving for us just means fabricating a new dummy element.
     EntityDescriptor* entity = m_template.get() ? m_template->cloneEntityDescriptor() : EntityDescriptorBuilder::buildEntityDescriptor();
-    auto_ptr_XMLCh temp(entityID);
-    entity->setEntityID(temp.get());
+
+    if (criteria.entityID_ascii) {
+        auto_ptr_XMLCh temp(criteria.entityID_ascii);
+        entity->setEntityID(temp.get());
+    }
+    else if (criteria.entityID_unicode)
+        entity->setEntityID(criteria.entityID_unicode);
+    else if (criteria.artifact)
+            throw MetadataException("Unable to resolve Null metadata from an artifact.");
     return entity;
 }

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


More information about the commits mailing list