attribute/XMLAttributeDecoder.cpp \
attribute/filtering/impl/AttributeFilter.cpp \
attribute/filtering/impl/ChainingAttributeFilter.cpp \
+ attribute/filtering/impl/DummyAttributeFilter.cpp \
attribute/filtering/impl/XMLAttributeFilter.cpp \
attribute/filtering/impl/BasicFilteringContext.cpp \
attribute/filtering/impl/MatchFunctor.cpp \
/*
- * Copyright 2001-2009 Internet2
+ * Copyright 2001-2010 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/** AttributeFilter based on an XML mapping schema. */
#define XML_ATTRIBUTE_FILTER "XML"
+ /** AttributeFilter based on rejecting/blocking all attributes. */
+ #define DUMMY_ATTRIBUTE_FILTER "Dummy"
+
/** AttributeFilter based on chaining together other filters. */
#define CHAINING_ATTRIBUTE_FILTER "Chaining"
};
/*
- * Copyright 2001-2009 Internet2
+ * Copyright 2001-2010 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
namespace shibsp {
SHIBSP_DLLLOCAL PluginManager<AttributeFilter,string,const DOMElement*>::Factory XMLAttributeFilterFactory;
+ SHIBSP_DLLLOCAL PluginManager<AttributeFilter,string,const DOMElement*>::Factory DummyAttributeFilterFactory;
SHIBSP_DLLLOCAL PluginManager<AttributeFilter,string,const DOMElement*>::Factory ChainingAttributeFilterFactory;
};
{
SPConfig& conf = SPConfig::getConfig();
conf.AttributeFilterManager.registerFactory(XML_ATTRIBUTE_FILTER, XMLAttributeFilterFactory);
+ conf.AttributeFilterManager.registerFactory(DUMMY_ATTRIBUTE_FILTER, DummyAttributeFilterFactory);
conf.AttributeFilterManager.registerFactory(CHAINING_ATTRIBUTE_FILTER, ChainingAttributeFilterFactory);
}
*/
#include "internal.h"
+#include "exceptions.h"
#include "attribute/filtering/AttributeFilter.h"
#include "attribute/filtering/FilteringContext.h"
ChainingAttributeFilter::ChainingAttributeFilter(const DOMElement* e)
{
- SPConfig& conf = SPConfig::getConfig();
-
// Load up the chain of handlers.
- e = XMLHelper::getFirstChildElement(e, _AttributeFilter);
- while (e) {
- string t(XMLHelper::getAttrString(e, nullptr, _type));
- if (!t.empty()) {
- try {
- Category::getInstance(SHIBSP_LOGCAT".AttributeFilter.Chaining").info(
- "building AttributeFilter of type (%s)...", t.c_str()
- );
- m_filters.push_back(conf.AttributeFilterManager.newPlugin(t.c_str(), e));
- }
- catch (exception& ex) {
- Category::getInstance(SHIBSP_LOGCAT".AttributeFilter.Chaining").error(
- "caught exception processing embedded AttributeFilter element: %s", ex.what()
- );
+ try {
+ e = XMLHelper::getFirstChildElement(e, _AttributeFilter);
+ while (e) {
+ string t(XMLHelper::getAttrString(e, nullptr, _type));
+ if (!t.empty()) {
+ Category::getInstance(SHIBSP_LOGCAT".AttributeFilter.Chaining").info("building AttributeFilter of type (%s)...", t.c_str());
+ m_filters.push_back(SPConfig::getConfig().AttributeFilterManager.newPlugin(t.c_str(), e));
}
+ e = XMLHelper::getNextSiblingElement(e, _AttributeFilter);
}
- e = XMLHelper::getNextSiblingElement(e, _AttributeFilter);
}
+ catch (exception&) {
+ for_each(m_filters.begin(), m_filters.end(), xmltooling::cleanup<AttributeFilter>());
+ throw;
+ }
+ if (m_filters.empty())
+ throw ConfigurationException("Chaining AttributeFilter plugin requires at least one child plugin.");
}
--- /dev/null
+/*\r
+ * Copyright 2010 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * DummyAttributeFilter.cpp\r
+ * \r
+ * Pathological AttributeFilter that rejects all attributes.\r
+ */\r
+\r
+#include "internal.h"\r
+#include "attribute/Attribute.h"\r
+#include "attribute/filtering/AttributeFilter.h"\r
+\r
+using namespace shibsp;\r
+using namespace xmltooling;\r
+using namespace std;\r
+\r
+namespace shibsp {\r
+\r
+ class SHIBSP_DLLLOCAL DummyAttributeFilter : public AttributeFilter\r
+ {\r
+ public:\r
+ DummyAttributeFilter(const DOMElement* e) {\r
+ }\r
+ virtual ~DummyAttributeFilter() {\r
+ }\r
+ \r
+ Lockable* lock() {\r
+ return this;\r
+ }\r
+ void unlock() {\r
+ }\r
+ \r
+ void filterAttributes(const FilteringContext& context, vector<Attribute*>& attributes) const {\r
+ Category::getInstance(SHIBSP_LOGCAT".AttributeFilter.Dummy").warn("filtering out all attributes");\r
+ for_each(attributes.begin(), attributes.end(), xmltooling::cleanup<Attribute>());\r
+ attributes.clear();\r
+ }\r
+ };\r
+\r
+ AttributeFilter* SHIBSP_DLLLOCAL DummyAttributeFilterFactory(const DOMElement* const & e)\r
+ {\r
+ return new DummyAttributeFilter(e);\r
+ }\r
+};\r
const char* chainingType,
const XMLCh* localName,
DOMElement* e,
- Category& log
+ Category& log,
+ const char* dummyType=nullptr
);
void doAttributeInfo();
void doHandlers(const ProtocolProvider*, const DOMElement*, Category&);
const char* chainingType,
const XMLCh* localName,
DOMElement* e,
- Category& log
+ Category& log,
+ const char* dummyType
)
{
string t;
}
catch (exception& ex) {
log.crit("error building %s: %s", pluginType, ex.what());
+ if (dummyType) {
+ // Install a dummy version as a safety valve.
+ log.crit("installing safe %s in place of failed version", pluginType);
+ return pluginMgr.newPlugin(dummyType, nullptr);
+ }
}
}
doChainedPlugins(conf.AttributeExtractorManager, "AttributeExtractor", CHAINING_ATTRIBUTE_EXTRACTOR, _AttributeExtractor, e, log);
m_attrFilter =
- doChainedPlugins(conf.AttributeFilterManager, "AttributeFilter", CHAINING_ATTRIBUTE_FILTER, _AttributeFilter, e, log);
+ doChainedPlugins(conf.AttributeFilterManager, "AttributeFilter", CHAINING_ATTRIBUTE_FILTER, _AttributeFilter, e, log, DUMMY_ATTRIBUTE_FILTER);
m_attrResolver =
doChainedPlugins(conf.AttributeResolverManager, "AttributeResolver", CHAINING_ATTRIBUTE_RESOLVER, _AttributeResolver, e, log);
<ClCompile Include="AbstractSPRequest.cpp" />\r
<ClCompile Include="Application.cpp" />\r
<ClCompile Include="attribute\Base64AttributeDecoder.cpp" />\r
+ <ClCompile Include="attribute\filtering\impl\DummyAttributeFilter.cpp" />\r
<ClCompile Include="attribute\filtering\impl\NameIDQualifierStringFunctor.cpp" />\r
<ClCompile Include="binding\impl\XMLProtocolProvider.cpp" />\r
<ClCompile Include="handler\impl\DiscoveryFeed.cpp" />\r
<ClCompile Include="attribute\filtering\impl\NameIDQualifierStringFunctor.cpp">\r
<Filter>Source Files\attribute\filtering\impl</Filter>\r
</ClCompile>\r
+ <ClCompile Include="attribute\filtering\impl\DummyAttributeFilter.cpp">\r
+ <Filter>Source Files\attribute\filtering\impl</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="remoting\impl\SocketListener.h">\r