[cpp-opensaml] branch master updated: SSPCPP-756 Add LocalDynamicMetadatProvider
Rod Widdowson
rdw at steadingsoftware.com
Fri Dec 1 06:59:46 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=0605fb568490e6ecf96fe16fb28ae9cce4349562
The following commit(s) were added to refs/heads/master by this push:
new 0605fb5 SSPCPP-756 Add LocalDynamicMetadatProvider
0605fb5 is described below
commit 0605fb568490e6ecf96fe16fb28ae9cce4349562
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Dec 1 11:38:23 2017 +0000
SSPCPP-756 Add LocalDynamicMetadatProvider
https://issues.shibboleth.net/jira/browse/SSPCPP-756
Involves some refactoring of AbstractDynamicMetadataProvider,
including moving a method down from the SP
Kill off the old DynamicMetadatProvider which has been an orphan
since the SP version was refactored.
---
Projects/vc15/saml/saml.vcxproj | 5 +-
Projects/vc15/saml/saml.vcxproj.filters | 9 +-
saml/Makefile.am | 3 +-
.../metadata/AbstractDynamicMetadataProvider.h | 16 ++-
saml/saml2/metadata/DynamicMetadataProvider.h | 58 ---------
.../impl/AbstractDynamicMetadataProvider.cpp | 48 ++++++-
.../metadata/impl/ChainingMetadataProvider.cpp | 2 +-
.../metadata/impl/DynamicMetadataProvider.cpp | 138 ---------------------
.../metadata/impl/LocalDynamicMetadataProvider.cpp | 122 ++++++++++++++++++
saml/saml2/metadata/impl/MetadataProvider.cpp | 5 +-
10 files changed, 189 insertions(+), 217 deletions(-)
diff --git a/Projects/vc15/saml/saml.vcxproj b/Projects/vc15/saml/saml.vcxproj
index 117f5cd..a3282ce 100644
--- a/Projects/vc15/saml/saml.vcxproj
+++ b/Projects/vc15/saml/saml.vcxproj
@@ -224,7 +224,7 @@
<ClCompile Include="..\..\..\saml\saml2\metadata\impl\AbstractMetadataProvider.cpp" />
<ClCompile Include="..\..\..\saml\saml2\metadata\impl\BlacklistMetadataFilter.cpp" />
<ClCompile Include="..\..\..\saml\saml2\metadata\impl\ChainingMetadataProvider.cpp" />
- <ClCompile Include="..\..\..\saml\saml2\metadata\impl\DynamicMetadataProvider.cpp" />
+ <ClCompile Include="..\..\..\saml\saml2\metadata\impl\LocalDynamicMetadataProvider.cpp" />
<ClCompile Include="..\..\..\saml\saml2\metadata\impl\EntityRoleMetadataFilter.cpp" />
<ClCompile Include="..\..\..\saml\saml2\metadata\impl\MetadataCredentialContext.cpp" />
<ClCompile Include="..\..\..\saml\saml2\metadata\impl\MetadataCredentialCriteria.cpp" />
@@ -319,7 +319,6 @@
<ClInclude Include="..\..\..\saml\saml2\core\Assertions.h" />
<ClInclude Include="..\..\..\saml\saml2\core\Protocols.h" />
<ClInclude Include="..\..\..\saml\saml2\metadata\AbstractMetadataProvider.h" />
- <ClInclude Include="..\..\..\saml\saml2\metadata\DynamicMetadataProvider.h" />
<ClInclude Include="..\..\..\saml\saml2\metadata\EndpointManager.h" />
<ClInclude Include="..\..\..\saml\saml2\metadata\Metadata.h" />
<ClInclude Include="..\..\..\saml\saml2\metadata\MetadataCredentialContext.h" />
@@ -353,4 +352,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/Projects/vc15/saml/saml.vcxproj.filters b/Projects/vc15/saml/saml.vcxproj.filters
index a4442ef..b2094e9 100644
--- a/Projects/vc15/saml/saml.vcxproj.filters
+++ b/Projects/vc15/saml/saml.vcxproj.filters
@@ -213,9 +213,6 @@
<ClCompile Include="..\..\..\saml\saml2\metadata\impl\ChainingMetadataProvider.cpp">
<Filter>Source Files\saml2\metadata\impl</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\saml\saml2\metadata\impl\DynamicMetadataProvider.cpp">
- <Filter>Source Files\saml2\metadata\impl</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\saml\saml2\metadata\impl\EntityRoleMetadataFilter.cpp">
<Filter>Source Files\saml2\metadata\impl</Filter>
</ClCompile>
@@ -381,6 +378,9 @@
<ClCompile Include="..\..\..\saml\saml2\metadata\impl\AbstractDynamicMetadataProvider.cpp">
<Filter>Source Files\saml2\metadata\impl</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\saml\saml2\metadata\impl\LocalDynamicMetadataProvider.cpp">
+ <Filter>Source Files\saml2\metadata\impl</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\saml\Assertion.h">
@@ -452,9 +452,6 @@
<ClInclude Include="..\..\..\saml\saml2\metadata\AbstractMetadataProvider.h">
<Filter>Header Files\saml2\metadata</Filter>
</ClInclude>
- <ClInclude Include="..\..\..\saml\saml2\metadata\DynamicMetadataProvider.h">
- <Filter>Header Files\saml2\metadata</Filter>
- </ClInclude>
<ClInclude Include="..\..\..\saml\saml2\metadata\EndpointManager.h">
<Filter>Header Files\saml2\metadata</Filter>
</ClInclude>
diff --git a/saml/Makefile.am b/saml/Makefile.am
index 44ecab9..b464eb6 100644
--- a/saml/Makefile.am
+++ b/saml/Makefile.am
@@ -85,7 +85,6 @@ saml2bindinclude_HEADERS = \
saml2mdinclude_HEADERS = \
saml2/metadata/AbstractMetadataProvider.h \
saml2/metadata/DiscoverableMetadataProvider.h \
- saml2/metadata/DynamicMetadataProvider.h \
saml2/metadata/AbstractDynamicMetadataProvider.h \
saml2/metadata/EndpointManager.h \
saml2/metadata/EntityMatcher.h \
@@ -147,8 +146,8 @@ libsaml_la_SOURCES = \
saml2/metadata/impl/BlacklistMetadataFilter.cpp \
saml2/metadata/impl/ChainingMetadataProvider.cpp \
saml2/metadata/impl/DiscoverableMetadataProvider.cpp \
- saml2/metadata/impl/DynamicMetadataProvider.cpp \
saml2/metadata/impl/AbstractDynamicMetadataProvider.cpp \
+ saml2/metadata/impl/LocalDynamicMetadataProvider.cpp \
saml2/metadata/impl/EntityAttributesEntityMatcher.cpp \
saml2/metadata/impl/EntityAttributesMetadataFilter.cpp \
saml2/metadata/impl/EntityRoleMetadataFilter.cpp \
diff --git a/saml/saml2/metadata/AbstractDynamicMetadataProvider.h b/saml/saml2/metadata/AbstractDynamicMetadataProvider.h
index 934685a..3508146 100644
--- a/saml/saml2/metadata/AbstractDynamicMetadataProvider.h
+++ b/saml/saml2/metadata/AbstractDynamicMetadataProvider.h
@@ -24,8 +24,8 @@
* Simple base implementation of a dynamic caching MetadataProvider.
*/
-#ifndef __saml2_dynmetadataprov_h__
-#define __saml2_dynmetadataprov_h__
+#ifndef __saml2_absdynmetadataprov_h__
+#define __saml2_absdynmetadataprov_h__
#include <saml/saml2/metadata/AbstractMetadataProvider.h>
#include <xmltooling/Lockable.h>
@@ -69,7 +69,8 @@ namespace opensaml {
* Resolves a metadata instance using the supplied criteria.
*
* @param criteria lookup criteria
- * @return a valid metadata instance
+ * @return a valid metadata instance (never nullptr)
+ * @throws an exception if resolution failed
*/
virtual EntityDescriptor* resolve(const Criteria& criteria) const = 0;
@@ -82,6 +83,15 @@ namespace opensaml {
*/
virtual time_t cacheEntity(EntityDescriptor* entity, bool locked = false) const;
+ /**
+ * Parse and unmarshal the provided stream, returning the EntityDescriptor if there is one.
+ *
+ * @param stream the stream to parse
+ * @return the entity, or nullptr if there isn't one
+ */
+ EntityDescriptor* entityFromStream(std::istream& stream) const;
+
+
private:
std::string m_id;
std::auto_ptr<xmltooling::RWLock> m_lock;
diff --git a/saml/saml2/metadata/DynamicMetadataProvider.h b/saml/saml2/metadata/DynamicMetadataProvider.h
deleted file mode 100644
index 29baa18..0000000
--- a/saml/saml2/metadata/DynamicMetadataProvider.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the
- * License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * @file saml/saml2/metadata/DynamicMetadataProvider.h
- *
- * Simple implementation of a dynamic caching MetadataProvider.
- */
-
-#ifndef __saml2_absdynmetadataprov_h__
-#define __saml2_absdynmetadataprov_h__
-
-#include <saml/saml2/metadata/AbstractDynamicMetadataProvider.h>
-
-namespace opensaml {
- namespace saml2md {
-
- /**
- * Simple implementation of a dynamic, caching MetadataProvider.
- */
- class SAML_API DynamicMetadataProvider : public AbstractDynamicMetadataProvider
- {
- public:
- /**
- * Constructor.
- *
- * @param e DOM to supply configuration for provider
- */
- DynamicMetadataProvider(const xercesc::DOMElement* e=nullptr);
-
- void init();
-
- protected:
- virtual EntityDescriptor* resolve(const Criteria& criteria) const;
-
- };
-
- };
-};
-
-#endif /* __saml2_dynmetadataprov_h__ */
diff --git a/saml/saml2/metadata/impl/AbstractDynamicMetadataProvider.cpp b/saml/saml2/metadata/impl/AbstractDynamicMetadataProvider.cpp
index 9c4aafa..23b7109 100644
--- a/saml/saml2/metadata/impl/AbstractDynamicMetadataProvider.cpp
+++ b/saml/saml2/metadata/impl/AbstractDynamicMetadataProvider.cpp
@@ -25,19 +25,21 @@
*/
#include "internal.h"
-#include "binding/SAMLArtifact.h"
-#include "saml2/metadata/Metadata.h"
-#include "saml2/metadata/AbstractDynamicMetadataProvider.h"
+#include <binding/SAMLArtifact.h>
+#include <saml2/metadata/Metadata.h>
+#include <saml2/metadata/AbstractDynamicMetadataProvider.h>
+
+#include <xercesc/framework/Wrapper4InputSource.hpp>
#include <xmltooling/logging.h>
#include <xmltooling/XMLToolingConfig.h>
#include <xmltooling/util/NDC.h>
#include <xmltooling/util/Threads.h>
#include <xmltooling/util/XMLHelper.h>
+#include <xmltooling/util/ParserPool.h>
#include <xmltooling/validation/ValidatorSuite.h>
#include <xmltooling/security/SecurityHelper.h>
-
#if defined(XMLTOOLING_LOG4SHIB)
# include <log4shib/NDC.hh>
#elif defined(XMLTOOLING_LOG4CPP)
@@ -393,3 +395,41 @@ time_t AbstractDynamicMetadataProvider::cacheEntity(EntityDescriptor* entity, b
return cacheExp;
}
+
+EntityDescriptor* AbstractDynamicMetadataProvider::entityFromStream(istream &stream) const
+{
+
+ DOMDocument* doc=nullptr;
+ StreamInputSource src(stream, "DynamicMetadataProvider");
+
+ Wrapper4InputSource dsrc(&src, false);
+
+ if (m_validate)
+ doc=XMLToolingConfig::getConfig().getValidatingParser().parse(dsrc);
+ else
+ doc=XMLToolingConfig::getConfig().getParser().parse(dsrc);
+
+ // Wrap the document for now.
+ XercesJanitor<DOMDocument> docjanitor(doc);
+
+ // Check root element.
+ if (!doc->getDocumentElement() || !XMLHelper::isNodeNamed(doc->getDocumentElement(),
+ samlconstants::SAML20MD_NS, EntityDescriptor::LOCAL_NAME)) {
+ throw MetadataException("Root of metadata instance was not an EntityDescriptor");
+ }
+
+ // Unmarshall objects, binding the document.
+ auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true));
+ docjanitor.release();
+
+ // Make sure it's metadata.
+ EntityDescriptor* entity = dynamic_cast<EntityDescriptor*>(xmlObject.get());
+ if (!entity) {
+ throw MetadataException(
+ "Root of metadata instance not recognized: $1", params(1, xmlObject->getElementQName().toString().c_str())
+ );
+ }
+
+ xmlObject.release();
+ return entity;
+}
diff --git a/saml/saml2/metadata/impl/ChainingMetadataProvider.cpp b/saml/saml2/metadata/impl/ChainingMetadataProvider.cpp
index f95cfdd..73bcd96 100644
--- a/saml/saml2/metadata/impl/ChainingMetadataProvider.cpp
+++ b/saml/saml2/metadata/impl/ChainingMetadataProvider.cpp
@@ -177,7 +177,7 @@ void ChainingMetadataProvider::tracker_cleanup(void* ptr)
}
ChainingMetadataProvider::ChainingMetadataProvider(const DOMElement* e)
- : ObservableMetadataProvider(e), m_firstMatch(true), m_trackerLock(Mutex::create()), m_tlsKey(ThreadKey::create(tracker_cleanup)),
+ : MetadataProvider(nullptr), ObservableMetadataProvider(e), m_firstMatch(true), m_trackerLock(Mutex::create()), m_tlsKey(ThreadKey::create(tracker_cleanup)),
m_log(Category::getInstance(SAML_LOGCAT ".Metadata.Chaining"))
{
if (XMLString::equals(e ? e->getAttributeNS(nullptr, precedence) : nullptr, last))
diff --git a/saml/saml2/metadata/impl/DynamicMetadataProvider.cpp b/saml/saml2/metadata/impl/DynamicMetadataProvider.cpp
deleted file mode 100644
index 35bd84c..0000000
--- a/saml/saml2/metadata/impl/DynamicMetadataProvider.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the
- * License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * DynamicMetadataProvider.cpp
- *
- * Simple implementation of a dynamic caching MetadataProvider.
- */
-
-#include "internal.h"
-#include "binding/SAMLArtifact.h"
-#include "saml2/metadata/Metadata.h"
-#include "saml2/metadata/DynamicMetadataProvider.h"
-
-#include <xercesc/framework/Wrapper4InputSource.hpp>
-#include <xercesc/util/XMLUniDefs.hpp>
-#include <xmltooling/logging.h>
-#include <xmltooling/XMLToolingConfig.h>
-#include <xmltooling/util/NDC.h>
-#include <xmltooling/util/ParserPool.h>
-#include <xmltooling/util/Threads.h>
-#include <xmltooling/util/XMLHelper.h>
-#include <xmltooling/validation/ValidatorSuite.h>
-#include <xmltooling/security/SecurityHelper.h>
-
-
-#if defined(XMLTOOLING_LOG4SHIB)
-# include <log4shib/NDC.hh>
-#elif defined(XMLTOOLING_LOG4CPP)
-# include <log4cpp/NDC.hh>
-#endif
-
-using namespace opensaml::saml2md;
-using namespace xmltooling::logging;
-using namespace xmltooling;
-using namespace std;
-
-#include <limits>
-
-# ifndef min
-# define min(a,b) (((a) < (b)) ? (a) : (b))
-# endif
-# ifdef max
-# undef max
-# endif
-
-static const XMLCh id[] = UNICODE_LITERAL_2(i,d);
-static const XMLCh cleanupInterval[] = UNICODE_LITERAL_15(c,l,e,a,n,u,p,I,n,t,e,r,v,a,l);
-static const XMLCh cleanupTimeout[] = UNICODE_LITERAL_14(c,l,e,a,n,u,p,T,i,m,e,o,u,t);
-static const XMLCh maxCacheDuration[] = UNICODE_LITERAL_16(m,a,x,C,a,c,h,e,D,u,r,a,t,i,o,n);
-static const XMLCh minCacheDuration[] = UNICODE_LITERAL_16(m,i,n,C,a,c,h,e,D,u,r,a,t,i,o,n);
-static const XMLCh refreshDelayFactor[] = UNICODE_LITERAL_18(r,e,f,r,e,s,h,D,e,l,a,y,F,a,c,t,o,r);
-static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e);
-
-namespace opensaml {
- namespace saml2md {
- MetadataProvider* SAML_DLLLOCAL DynamicMetadataProviderFactory(const DOMElement* const & e)
- {
- return new DynamicMetadataProvider(e);
- }
- };
-};
-
-DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e)
- : AbstractDynamicMetadataProvider(true, e)
-{
-}
-
-void DynamicMetadataProvider::init()
-{
-}
-
-EntityDescriptor* DynamicMetadataProvider::resolve(const Criteria& criteria) const
-{
- string name;
- if (criteria.entityID_ascii) {
- name = criteria.entityID_ascii;
- }
- else if (criteria.entityID_unicode) {
- auto_ptr_char temp(criteria.entityID_unicode);
- name = temp.get();
- }
- else if (criteria.artifact) {
- throw MetadataException("Unable to resolve metadata dynamically from an artifact.");
- }
-
- try {
- DOMDocument* doc=nullptr;
- auto_ptr_XMLCh widenit(name.c_str());
- URLInputSource src(widenit.get());
- Wrapper4InputSource dsrc(&src,false);
- if (m_validate)
- doc=XMLToolingConfig::getConfig().getValidatingParser().parse(dsrc);
- else
- doc=XMLToolingConfig::getConfig().getParser().parse(dsrc);
-
- // Wrap the document for now.
- XercesJanitor<DOMDocument> docjanitor(doc);
-
- // Unmarshall objects, binding the document.
- auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true));
- docjanitor.release();
-
- // Make sure it's metadata.
- EntityDescriptor* entity = dynamic_cast<EntityDescriptor*>(xmlObject.get());
- if (!entity) {
- throw MetadataException(
- "Root of metadata instance not recognized: $1", params(1,xmlObject->getElementQName().toString().c_str())
- );
- }
- xmlObject.release();
- return entity;
- }
- catch (XMLException& e) {
- auto_ptr_char msg(e.getMessage());
- Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic").error(
- "Xerces error while resolving entityID (%s): %s", name.c_str(), msg.get()
- );
- throw MetadataException(msg.get());
- }
-}
diff --git a/saml/saml2/metadata/impl/LocalDynamicMetadataProvider.cpp b/saml/saml2/metadata/impl/LocalDynamicMetadataProvider.cpp
new file mode 100644
index 0000000..0b007c2
--- /dev/null
+++ b/saml/saml2/metadata/impl/LocalDynamicMetadataProvider.cpp
@@ -0,0 +1,122 @@
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
+ *
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
+ */
+
+/**
+ * LocalDynamicMetadataProvider.cpp
+ *
+ * Implementation of a directory base DynamicMetadataProvider.
+ */
+#include <fstream>
+
+#include <boost/algorithm/string.hpp>
+
+
+#include "internal.h"
+
+#include <xmltooling/logging.h>
+#include <xmltooling/security/SecurityHelper.h>
+
+#include <binding/SAMLArtifact.h>
+#include <saml2/metadata/Metadata.h>
+#include <saml2/metadata/AbstractDynamicMetadataProvider.h>
+
+
+#if defined(XMLTOOLING_LOG4SHIB)
+# include <log4shib/NDC.hh>
+#elif defined(XMLTOOLING_LOG4CPP)
+# include <log4cpp/NDC.hh>
+#endif
+
+using namespace opensaml::saml2md;
+using namespace xmltooling::logging;
+using namespace xmltooling;
+using namespace std;
+
+static const XMLCh id[] = UNICODE_LITERAL_2(i,d);
+static const XMLCh sourceDirectory[] = UNICODE_LITERAL_15(s,o,u,r,c,e,D,i,r,e,c,t,o,r,y);
+
+namespace opensaml {
+ namespace saml2md {
+ class LocalDynamicMetadataProvider : public AbstractDynamicMetadataProvider {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param e DOM to supply configuration for provider
+ */
+ LocalDynamicMetadataProvider(const xercesc::DOMElement* e=nullptr);
+
+ void init() {};
+
+ protected:
+ virtual EntityDescriptor* resolve(const Criteria& criteria) const;
+
+ private:
+ string m_sourceDirectory;
+ Category& m_log;
+ };
+
+ MetadataProvider* SAML_DLLLOCAL LocalDynamicMetadataProviderFactory(const DOMElement* const & e)
+ {
+ return new LocalDynamicMetadataProvider(e);
+ }
+ };
+};
+
+LocalDynamicMetadataProvider::LocalDynamicMetadataProvider(const DOMElement* e)
+ : MetadataProvider(e), AbstractDynamicMetadataProvider(false, e), m_sourceDirectory(XMLHelper::getAttrString(e, nullptr, sourceDirectory)),
+ m_log(Category::getInstance(SAML_LOGCAT ".MetadataProvider.LocalDynamic"))
+{
+ if (m_sourceDirectory.empty())
+ throw MetadataException("LocalDynamicMetadataProvider: sourceDirectory=\"whatever\" must be present");
+
+ if (!boost::algorithm::ends_with(m_sourceDirectory, "/"))
+ m_sourceDirectory += '/';
+}
+
+EntityDescriptor* LocalDynamicMetadataProvider::resolve(const Criteria& criteria) const
+{
+ string name, from;
+ if (criteria.entityID_ascii) {
+ from = criteria.entityID_ascii;
+ name = SecurityHelper::doHash("SHA1", from.c_str(), from.length());
+ }
+ else if (criteria.entityID_unicode) {
+ auto_ptr_char temp(criteria.entityID_unicode);
+ from = criteria.entityID_ascii;
+ SecurityHelper::doHash("SHA1", from.c_str(), from.length());
+ }
+ else if (criteria.artifact) {
+ from = name = criteria.artifact->getSource();
+ }
+ name = m_sourceDirectory + name + ".xml";
+ m_log.debug("transformed named from (%s) to (%s)", from.c_str(), name.c_str());
+
+ ifstream source(name);
+ if (!source) {
+ m_log.debug("file not found");
+ throw IOException("File Not Found");
+ }
+
+ EntityDescriptor* result = entityFromStream(source);
+ if (!result)
+ throw MetadataException("No entity resolved from file");
+ return result;
+}
diff --git a/saml/saml2/metadata/impl/MetadataProvider.cpp b/saml/saml2/metadata/impl/MetadataProvider.cpp
index aae3909..bfd0cfe 100644
--- a/saml/saml2/metadata/impl/MetadataProvider.cpp
+++ b/saml/saml2/metadata/impl/MetadataProvider.cpp
@@ -36,6 +36,7 @@
#include <xmltooling/util/NDC.h>
#include <xmltooling/util/XMLHelper.h>
+#include <errno.h>
using namespace opensaml::saml2md;
using namespace opensaml;
using namespace xmltooling::logging;
@@ -47,7 +48,7 @@ using namespace std;
namespace opensaml {
namespace saml2md {
SAML_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory XMLMetadataProviderFactory;
- SAML_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory DynamicMetadataProviderFactory;
+ SAML_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory LocalDynamicMetadataProviderFactory;
SAML_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory ChainingMetadataProviderFactory;
SAML_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory FolderMetadataProviderFactory;
SAML_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory NullMetadataProviderFactory;
@@ -64,7 +65,7 @@ void SAML_API opensaml::saml2md::registerMetadataProviders()
{
SAMLConfig& conf=SAMLConfig::getConfig();
conf.MetadataProviderManager.registerFactory(XML_METADATA_PROVIDER, XMLMetadataProviderFactory);
- conf.MetadataProviderManager.registerFactory(DYNAMIC_METADATA_PROVIDER, DynamicMetadataProviderFactory);
+ conf.MetadataProviderManager.registerFactory(LOCAL_DYNAMIC_METADATA_PROVIDER, LocalDynamicMetadataProviderFactory);
conf.MetadataProviderManager.registerFactory(CHAINING_METADATA_PROVIDER, ChainingMetadataProviderFactory);
conf.MetadataProviderManager.registerFactory(FOLDER_METADATA_PROVIDER, FolderMetadataProviderFactory);
conf.MetadataProviderManager.registerFactory(NULL_METADATA_PROVIDER, NullMetadataProviderFactory);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list