From: Scott Cantor Date: Thu, 13 Mar 2008 03:52:27 +0000 (+0000) Subject: Multi-line svn commit, see body. X-Git-Tag: 2.0.0~7 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=commitdiff_plain;h=2c99953d441d4a152c9157cd434d1df2e91f85f1 Multi-line svn commit, see body. Add new builder base class to indicate support for "argument-less" construction. Add "null" metadata provider. --- diff --git a/.cproject b/.cproject index af2ae06..9d80abc 100644 --- a/.cproject +++ b/.cproject @@ -1,7 +1,4 @@ - - - - + @@ -56,7 +53,15 @@ + + + + + + + + @@ -89,19 +94,9 @@ - - - - - - - - - - diff --git a/saml/Makefile.am b/saml/Makefile.am index b8171ff..2ee7847 100644 --- a/saml/Makefile.am +++ b/saml/Makefile.am @@ -142,6 +142,7 @@ libsaml_la_SOURCES = \ saml2/metadata/impl/MetadataImpl.cpp \ saml2/metadata/impl/MetadataProvider.cpp \ saml2/metadata/impl/MetadataSchemaValidators.cpp \ + saml2/metadata/impl/NullMetadataProvider.cpp \ saml2/metadata/impl/SignatureMetadataFilter.cpp \ saml2/metadata/impl/WhitelistMetadataFilter.cpp \ saml2/metadata/impl/XMLMetadataProvider.cpp \ diff --git a/saml/saml.vcproj b/saml/saml.vcproj index efb495c..de99854 100644 --- a/saml/saml.vcproj +++ b/saml/saml.vcproj @@ -364,6 +364,10 @@ > + + diff --git a/saml/saml2/core/Assertions.h b/saml/saml2/core/Assertions.h index 20c4503..91ac1fe 100644 --- a/saml/saml2/core/Assertions.h +++ b/saml/saml2/core/Assertions.h @@ -457,7 +457,7 @@ namespace opensaml { * This is customized to return a SubjectConfirmationData element with an * xsi:type of KeyInfoConfirmationDataType. */ - class SAML_API KeyInfoConfirmationDataTypeBuilder : public xmltooling::XMLObjectBuilder { + class SAML_API KeyInfoConfirmationDataTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder { public: virtual ~KeyInfoConfirmationDataTypeBuilder() {} /** Default builder. */ diff --git a/saml/saml2/metadata/Metadata.h b/saml/saml2/metadata/Metadata.h index 9691329..4ea5a5b 100644 --- a/saml/saml2/metadata/Metadata.h +++ b/saml/saml2/metadata/Metadata.h @@ -619,7 +619,7 @@ namespace opensaml { * This is customized to return a RoleDescriptor element with an * xsi:type of AuthnQueryDescriptorType. */ - class SAML_API AuthnQueryDescriptorTypeBuilder : public xmltooling::XMLObjectBuilder { + class SAML_API AuthnQueryDescriptorTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder { public: virtual ~AuthnQueryDescriptorTypeBuilder() {} /** Default builder. */ @@ -666,7 +666,7 @@ namespace opensaml { * This is customized to return a RoleDescriptor element with an * xsi:type of AttributeQueryDescriptorType. */ - class SAML_API AttributeQueryDescriptorTypeBuilder : public xmltooling::XMLObjectBuilder { + class SAML_API AttributeQueryDescriptorTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder { public: virtual ~AttributeQueryDescriptorTypeBuilder() {} /** Default builder. */ @@ -713,7 +713,7 @@ namespace opensaml { * This is customized to return a RoleDescriptor element with an * xsi:type of AuthzDecisionQueryDescriptorType. */ - class SAML_API AuthzDecisionQueryDescriptorTypeBuilder : public xmltooling::XMLObjectBuilder { + class SAML_API AuthzDecisionQueryDescriptorTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder { public: virtual ~AuthzDecisionQueryDescriptorTypeBuilder() {} /** Default builder. */ diff --git a/saml/saml2/metadata/MetadataProvider.h b/saml/saml2/metadata/MetadataProvider.h index 483d05c..59f826a 100644 --- a/saml/saml2/metadata/MetadataProvider.h +++ b/saml/saml2/metadata/MetadataProvider.h @@ -249,6 +249,9 @@ namespace opensaml { /** MetadataProvider that wraps a sequence of metadata providers. */ #define CHAINING_METADATA_PROVIDER "Chaining" + /** MetadataProvider that returns an empty "dummy" entity descriptor. */ + #define NULL_METADATA_PROVIDER "Null" + DECL_XMLTOOLING_EXCEPTION(MetadataException,SAML_EXCEPTIONAPI(SAML_API),opensaml::saml2md,xmltooling::XMLToolingException,Exceptions related to metadata use); }; }; diff --git a/saml/saml2/metadata/impl/DynamicMetadataProvider.cpp b/saml/saml2/metadata/impl/DynamicMetadataProvider.cpp index 288dd12..835a2ed 100644 --- a/saml/saml2/metadata/impl/DynamicMetadataProvider.cpp +++ b/saml/saml2/metadata/impl/DynamicMetadataProvider.cpp @@ -17,7 +17,7 @@ /** * DynamicMetadataProvider.cpp * - * Base class for caching metadata providers. + * Simple implementation of a dynamic caching MetadataProvider. */ #include "internal.h" diff --git a/saml/saml2/metadata/impl/MetadataProvider.cpp b/saml/saml2/metadata/impl/MetadataProvider.cpp index 969be5a..6c27a18 100644 --- a/saml/saml2/metadata/impl/MetadataProvider.cpp +++ b/saml/saml2/metadata/impl/MetadataProvider.cpp @@ -40,6 +40,7 @@ namespace opensaml { SAML_DLLLOCAL PluginManager::Factory XMLMetadataProviderFactory; SAML_DLLLOCAL PluginManager::Factory DynamicMetadataProviderFactory; SAML_DLLLOCAL PluginManager::Factory ChainingMetadataProviderFactory; + SAML_DLLLOCAL PluginManager::Factory NullMetadataProviderFactory; SAML_DLLLOCAL PluginManager::Factory BlacklistMetadataFilterFactory; SAML_DLLLOCAL PluginManager::Factory WhitelistMetadataFilterFactory; SAML_DLLLOCAL PluginManager::Factory SignatureMetadataFilterFactory; @@ -52,6 +53,7 @@ void SAML_API opensaml::saml2md::registerMetadataProviders() conf.MetadataProviderManager.registerFactory(XML_METADATA_PROVIDER, XMLMetadataProviderFactory); conf.MetadataProviderManager.registerFactory(DYNAMIC_METADATA_PROVIDER, DynamicMetadataProviderFactory); conf.MetadataProviderManager.registerFactory(CHAINING_METADATA_PROVIDER, ChainingMetadataProviderFactory); + conf.MetadataProviderManager.registerFactory(NULL_METADATA_PROVIDER, NullMetadataProviderFactory); } void SAML_API opensaml::saml2md::registerMetadataFilters() diff --git a/saml/saml2/metadata/impl/NullMetadataProvider.cpp b/saml/saml2/metadata/impl/NullMetadataProvider.cpp new file mode 100644 index 0000000..c7c6ca2 --- /dev/null +++ b/saml/saml2/metadata/impl/NullMetadataProvider.cpp @@ -0,0 +1,69 @@ +/* + * Copyright 2001-2007 Internet2 + * + * Licensed 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. + */ + +/** + * NullMetadataProvider.cpp + * + * Dummy provider that returns an empty entity supporting any role. + */ + +#include "internal.h" +#include "saml2/metadata/Metadata.h" +#include "saml2/metadata/DynamicMetadataProvider.h" + +#include + +using namespace opensaml::saml2md; +using namespace xmltooling; +using namespace std; + +namespace opensaml { + namespace saml2md { + class SAML_DLLLOCAL NullMetadataProvider : public DynamicMetadataProvider + { + public: + NullMetadataProvider(const DOMElement* e) : DynamicMetadataProvider(e), m_template(NULL) { + e = XMLHelper::getFirstChildElement(e, samlconstants::SAML20MD_NS, EntityDescriptor::LOCAL_NAME); + if (e) + m_template = dynamic_cast(XMLObjectBuilder::buildOneFromElement(const_cast(e))); + } + + virtual ~NullMetadataProvider() { + delete m_template; + } + + protected: + EntityDescriptor* resolve(const char* entityID) const; + + private: + EntityDescriptor* m_template; + }; + + MetadataProvider* SAML_DLLLOCAL NullMetadataProviderFactory(const DOMElement* const & e) + { + return new NullMetadataProvider(e); + } + }; +}; + +EntityDescriptor* NullMetadataProvider::resolve(const char* entityID) const +{ + // Resolving for us just means fabricating a new dummy element. + EntityDescriptor* entity = m_template ? m_template->cloneEntityDescriptor() : EntityDescriptorBuilder::buildEntityDescriptor(); + auto_ptr_XMLCh temp(entityID); + entity->setEntityID(temp.get()); + return entity; +}