X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=blobdiff_plain;f=saml%2Fsaml2%2Fmetadata%2Fimpl%2FMetadataProvider.cpp;h=6c27a18d2b5a0db14a134b32fbd0ef13e5c47456;hp=b0bf17831894c19f5076f93b4bd5ad74a6a489ea;hb=2c99953d441d4a152c9157cd434d1df2e91f85f1;hpb=e55d708c3afe86d26819d5f6c141a67bf6f7ee61 diff --git a/saml/saml2/metadata/impl/MetadataProvider.cpp b/saml/saml2/metadata/impl/MetadataProvider.cpp index b0bf178..6c27a18 100644 --- a/saml/saml2/metadata/impl/MetadataProvider.cpp +++ b/saml/saml2/metadata/impl/MetadataProvider.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Internet2 + * 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. @@ -21,56 +21,100 @@ */ #include "internal.h" +#include "saml2/metadata/MetadataFilter.h" #include "saml2/metadata/MetadataProvider.h" -#include +#include +#include #include +#include using namespace opensaml::saml2md; +using namespace opensaml; +using namespace xmltooling::logging; using namespace xmltooling; -using namespace log4cpp; using namespace std; -static const XMLCh Blacklist[] = UNICODE_LITERAL_23(B,l,a,c,k,l,i,s,t,M,e,t,a,d,a,t,a,F,i,l,t,e,r); -static const XMLCh Exclude[] = UNICODE_LITERAL_7(E,x,c,l,u,d,e); -static const XMLCh Include[] = UNICODE_LITERAL_7(I,n,c,l,u,d,e); -static const XMLCh GenericMetadataFilter[] = UNICODE_LITERAL_14(M,e,t,a,d,a,t,a,F,i,l,t,e,r); -static const XMLCh type[] = UNICODE_LITERAL_4(t,y,p,e); -static const XMLCh Whitelist[] = UNICODE_LITERAL_23(W,h,i,t,e,l,i,s,t,M,e,t,a,d,a,t,a,F,i,l,t,e,r); +namespace opensaml { + namespace saml2md { + 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; + }; +}; + +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(CHAINING_METADATA_PROVIDER, ChainingMetadataProviderFactory); + conf.MetadataProviderManager.registerFactory(NULL_METADATA_PROVIDER, NullMetadataProviderFactory); +} + +void SAML_API opensaml::saml2md::registerMetadataFilters() +{ + SAMLConfig::getConfig().MetadataFilterManager.registerFactory(BLACKLIST_METADATA_FILTER, BlacklistMetadataFilterFactory); + SAMLConfig::getConfig().MetadataFilterManager.registerFactory(WHITELIST_METADATA_FILTER, WhitelistMetadataFilterFactory); + SAMLConfig::getConfig().MetadataFilterManager.registerFactory(SIGNATURE_METADATA_FILTER, SignatureMetadataFilterFactory); +} + +static const XMLCh _MetadataFilter[] = UNICODE_LITERAL_14(M,e,t,a,d,a,t,a,F,i,l,t,e,r); +static const XMLCh Blacklist[] = UNICODE_LITERAL_23(B,l,a,c,k,l,i,s,t,M,e,t,a,d,a,t,a,F,i,l,t,e,r); +static const XMLCh Whitelist[] = UNICODE_LITERAL_23(W,h,i,t,e,l,i,s,t,M,e,t,a,d,a,t,a,F,i,l,t,e,r); +static const XMLCh SigFilter[] = UNICODE_LITERAL_23(S,i,g,n,a,t,u,r,e,M,e,t,a,d,a,t,a,F,i,l,t,e,r); +static const XMLCh Exclude[] = UNICODE_LITERAL_7(E,x,c,l,u,d,e); +static const XMLCh Include[] = UNICODE_LITERAL_7(I,n,c,l,u,d,e); +static const XMLCh type[] = UNICODE_LITERAL_4(t,y,p,e); MetadataProvider::MetadataProvider(const DOMElement* e) { #ifdef _DEBUG NDC ndc("MetadataProvider"); #endif + Category& log = Category::getInstance(SAML_LOGCAT".Metadata"); SAMLConfig& conf=SAMLConfig::getConfig(); - // Locate any default recognized filters. + // Locate any default recognized filters and plugins. try { DOMElement* child = e ? XMLHelper::getFirstChildElement(e) : NULL; while (child) { - if (XMLString::equals(child->getLocalName(),GenericMetadataFilter)) { + if (XMLString::equals(child->getLocalName(),_MetadataFilter)) { auto_ptr_char t(child->getAttributeNS(NULL,type)); - if (t.get()) + if (t.get() && *t.get()) { + log.info("building MetadataFilter of type %s", t.get()); m_filters.push_back(conf.MetadataFilterManager.newPlugin(t.get(),child)); + } + } + else if (XMLString::equals(child->getLocalName(),SigFilter)) { + log.info("building MetadataFilter of type %s", SIGNATURE_METADATA_FILTER); + m_filters.push_back(conf.MetadataFilterManager.newPlugin(SIGNATURE_METADATA_FILTER,child)); } else if (XMLString::equals(child->getLocalName(),Whitelist)) { + log.info("building MetadataFilter of type %s", WHITELIST_METADATA_FILTER); m_filters.push_back(conf.MetadataFilterManager.newPlugin(WHITELIST_METADATA_FILTER,child)); } else if (XMLString::equals(child->getLocalName(),Blacklist)) { + log.info("building MetadataFilter of type %s", BLACKLIST_METADATA_FILTER); m_filters.push_back(conf.MetadataFilterManager.newPlugin(BLACKLIST_METADATA_FILTER,child)); } else if (XMLString::equals(child->getLocalName(),Include)) { + log.info("building MetadataFilter of type %s", WHITELIST_METADATA_FILTER); m_filters.push_back(conf.MetadataFilterManager.newPlugin(WHITELIST_METADATA_FILTER,e)); } else if (XMLString::equals(child->getLocalName(),Exclude)) { + log.info("building MetadataFilter of type %s", BLACKLIST_METADATA_FILTER); m_filters.push_back(conf.MetadataFilterManager.newPlugin(BLACKLIST_METADATA_FILTER,e)); } child = XMLHelper::getNextSiblingElement(child); } } catch (XMLToolingException& ex) { - Category::getInstance(SAML_LOGCAT".Metadata").error("caught exception while installing filters: %s", ex.what()); + log.error("caught exception while installing filters: %s", ex.what()); for_each(m_filters.begin(),m_filters.end(),xmltooling::cleanup()); throw; } @@ -93,24 +137,8 @@ void MetadataProvider::doFilters(XMLObject& xmlObject) const } } -namespace opensaml { - namespace saml2md { - SAML_DLLLOCAL PluginManager::Factory FilesystemMetadataProviderFactory; - SAML_DLLLOCAL PluginManager::Factory BlacklistMetadataFilterFactory; - SAML_DLLLOCAL PluginManager::Factory WhitelistMetadataFilterFactory; - }; -}; - -void SAML_API opensaml::saml2md::registerMetadataProviders() +const EntitiesDescriptor* MetadataProvider::getEntitiesDescriptor(const XMLCh* name, bool strict) const { - SAMLConfig& conf=SAMLConfig::getConfig(); - conf.MetadataProviderManager.registerFactory(FILESYSTEM_METADATA_PROVIDER, FilesystemMetadataProviderFactory); - conf.MetadataProviderManager.registerFactory("edu.internet2.middleware.shibboleth.metadata.provider.XMLMetadata", FilesystemMetadataProviderFactory); - conf.MetadataProviderManager.registerFactory("edu.internet2.middleware.shibboleth.common.provider.XMLMetadata", FilesystemMetadataProviderFactory); -} - -void SAML_API opensaml::saml2md::registerMetadataFilters() -{ - SAMLConfig::getConfig().MetadataFilterManager.registerFactory(BLACKLIST_METADATA_FILTER, BlacklistMetadataFilterFactory); - SAMLConfig::getConfig().MetadataFilterManager.registerFactory(WHITELIST_METADATA_FILTER, WhitelistMetadataFilterFactory); + auto_ptr_char temp(name); + return getEntitiesDescriptor(temp.get(),strict); }