X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=shibsp%2Fattribute%2Fresolver%2Fimpl%2FChainingAttributeExtractor.cpp;h=c03cfd8f8b41d44a7d661e4cf9adcef05c2b6a28;hb=c51bfd77603cf0ddb0b5e374c35586a8435895d6;hp=c0f5983c5a561a32132080fb030a0f5e653c5598;hpb=0d65bb64fb349e2508287b9d1b31d6f9abfd8971;p=shibboleth%2Fcpp-sp.git diff --git a/shibsp/attribute/resolver/impl/ChainingAttributeExtractor.cpp b/shibsp/attribute/resolver/impl/ChainingAttributeExtractor.cpp index c0f5983..c03cfd8 100644 --- a/shibsp/attribute/resolver/impl/ChainingAttributeExtractor.cpp +++ b/shibsp/attribute/resolver/impl/ChainingAttributeExtractor.cpp @@ -1,17 +1,21 @@ -/* - * Copyright 2001-2010 Internet2 +/** + * 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. * - * 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 + * 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 + * 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. + * 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. */ /** @@ -26,12 +30,14 @@ #include "attribute/Attribute.h" #include "attribute/resolver/AttributeExtractor.h" +#include #include #include using namespace shibsp; using namespace opensaml::saml2md; using namespace xmltooling; +using namespace boost; using namespace std; namespace shibsp { @@ -40,9 +46,7 @@ namespace shibsp { { public: ChainingAttributeExtractor(const DOMElement* e); - virtual ~ChainingAttributeExtractor() { - for_each(m_extractors.begin(), m_extractors.end(), xmltooling::cleanup()); - } + virtual ~ChainingAttributeExtractor() {} Lockable* lock() { return this; @@ -55,22 +59,47 @@ namespace shibsp { const RoleDescriptor* issuer, const XMLObject& xmlObject, vector& attributes - ) const; + ) const { + // Make sure new version gets run. + extractAttributes(application, nullptr, issuer, xmlObject, attributes); + } + + void extractAttributes( + const Application& application, + const GenericRequest* request, + const RoleDescriptor* issuer, + const XMLObject& xmlObject, + vector& attributes + ) const { + for (ptr_vector::iterator i = m_extractors.begin(); i != m_extractors.end(); ++i) { + Locker locker(&(*i)); + i->extractAttributes(application, request, issuer, xmlObject, attributes); + } + } void getAttributeIds(vector& attributes) const { - for (vector::const_iterator i=m_extractors.begin(); i!=m_extractors.end(); ++i) { - Locker locker(*i); - (*i)->getAttributeIds(attributes); + for (ptr_vector::iterator i = m_extractors.begin(); i != m_extractors.end(); ++i) { + Locker locker(&(*i)); + i->getAttributeIds(attributes); + } + } + + void generateMetadata(SPSSODescriptor& role) const { + for (ptr_vector::iterator i = m_extractors.begin(); i != m_extractors.end(); ++i) { + Locker locker(&(*i)); + i->generateMetadata(role); } } private: - vector m_extractors; + mutable ptr_vector m_extractors; }; static const XMLCh _AttributeExtractor[] = UNICODE_LITERAL_18(A,t,t,r,i,b,u,t,e,E,x,t,r,a,c,t,o,r); static const XMLCh _type[] = UNICODE_LITERAL_4(t,y,p,e); + SHIBSP_DLLLOCAL PluginManager::Factory AssertionAttributeExtractorFactory; + SHIBSP_DLLLOCAL PluginManager::Factory MetadataAttributeExtractorFactory; SHIBSP_DLLLOCAL PluginManager::Factory DelegationAttributeExtractorFactory; SHIBSP_DLLLOCAL PluginManager::Factory KeyDescriptorAttributeExtractorFactory; SHIBSP_DLLLOCAL PluginManager::Factory XMLAttributeExtractorFactory; @@ -82,6 +111,8 @@ namespace shibsp { void SHIBSP_API shibsp::registerAttributeExtractors() { + SPConfig::getConfig().AttributeExtractorManager.registerFactory(ASSERTION_ATTRIBUTE_EXTRACTOR, AssertionAttributeExtractorFactory); + SPConfig::getConfig().AttributeExtractorManager.registerFactory(METADATA_ATTRIBUTE_EXTRACTOR, MetadataAttributeExtractorFactory); SPConfig::getConfig().AttributeExtractorManager.registerFactory(DELEGATION_ATTRIBUTE_EXTRACTOR, DelegationAttributeExtractorFactory); SPConfig::getConfig().AttributeExtractorManager.registerFactory(KEYDESCRIPTOR_ATTRIBUTE_EXTRACTOR, KeyDescriptorAttributeExtractorFactory); SPConfig::getConfig().AttributeExtractorManager.registerFactory(XML_ATTRIBUTE_EXTRACTOR, XMLAttributeExtractorFactory); @@ -96,6 +127,32 @@ AttributeExtractor::~AttributeExtractor() { } +void AttributeExtractor::generateMetadata(SPSSODescriptor& role) const +{ +} + +void AttributeExtractor::extractAttributes( + const Application& application, + const GenericRequest* request, + const RoleDescriptor* issuer, + const XMLObject& xmlObject, + vector& attributes + ) const +{ + // Default call into deprecated method. + extractAttributes(application, issuer, xmlObject, attributes); +} + +void AttributeExtractor::extractAttributes( + const Application& application, + const RoleDescriptor* issuer, + const XMLObject& xmlObject, + vector& attributes + ) const +{ + // Empty default for deprecated method. +} + ChainingAttributeExtractor::ChainingAttributeExtractor(const DOMElement* e) { SPConfig& conf = SPConfig::getConfig(); @@ -106,13 +163,15 @@ ChainingAttributeExtractor::ChainingAttributeExtractor(const DOMElement* e) string t(XMLHelper::getAttrString(e, nullptr, _type)); if (!t.empty()) { try { - Category::getInstance(SHIBSP_LOGCAT".AttributeExtractor.Chaining").info( + Category::getInstance(SHIBSP_LOGCAT ".AttributeExtractor.Chaining").info( "building AttributeExtractor of type (%s)...", t.c_str() ); - m_extractors.push_back(conf.AttributeExtractorManager.newPlugin(t.c_str(), e)); + auto_ptr np(conf.AttributeExtractorManager.newPlugin(t.c_str(), e)); + m_extractors.push_back(np.get()); + np.release(); } catch (exception& ex) { - Category::getInstance(SHIBSP_LOGCAT".AttributeExtractor.Chaining").error( + Category::getInstance(SHIBSP_LOGCAT ".AttributeExtractor.Chaining").error( "caught exception processing embedded AttributeExtractor element: %s", ex.what() ); } @@ -120,13 +179,3 @@ ChainingAttributeExtractor::ChainingAttributeExtractor(const DOMElement* e) e = XMLHelper::getNextSiblingElement(e, _AttributeExtractor); } } - -void ChainingAttributeExtractor::extractAttributes( - const Application& application, const RoleDescriptor* issuer, const XMLObject& xmlObject, vector& attributes - ) const -{ - for (vector::const_iterator i=m_extractors.begin(); i!=m_extractors.end(); ++i) { - Locker locker(*i); - (*i)->extractAttributes(application, issuer, xmlObject, attributes); - } -}