/*
- * 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.
#include "attribute/filtering/FilterPolicyContext.h"
#include "attribute/filtering/MatchFunctor.h"
+#include <xmltooling/util/XMLHelper.h>
+
using namespace shibsp;
using namespace std;
+using xmltooling::XMLHelper;
namespace shibsp {
class SHIBSP_DLLLOCAL NumberOfAttributeValuesFunctor : public MatchFunctor
{
unsigned int m_min,m_max;
- xmltooling::auto_ptr_char m_attributeID;
+ string m_attributeID;
size_t count(const FilteringContext& filterContext) const;
public:
NumberOfAttributeValuesFunctor(const DOMElement* e)
- : m_min(0), m_max(INT_MAX), m_attributeID(e ? e->getAttributeNS(NULL,attributeID) : NULL) {
- if (!m_attributeID.get() || !*m_attributeID.get())
+ : m_min(XMLHelper::getAttrInt(e, 0, minimum)),
+ m_max(XMLHelper::getAttrInt(e, INT_MAX, maximum)),
+ m_attributeID(XMLHelper::getAttrString(e, nullptr, attributeID)) {
+ if (m_attributeID.empty())
throw ConfigurationException("No attributeID specified.");
- const XMLCh* num = e->getAttributeNS(NULL, minimum);
- if (num && *num)
- m_min = XMLString::parseInt(num);
- num = e->getAttributeNS(NULL, maximum);
- if (num && *num)
- m_max = XMLString::parseInt(num);
}
bool evaluatePolicyRequirement(const FilteringContext& filterContext) const {
{
size_t count = 0;
pair<multimap<string,Attribute*>::const_iterator,multimap<string,Attribute*>::const_iterator> attrs =
- filterContext.getAttributes().equal_range(m_attributeID.get());
+ filterContext.getAttributes().equal_range(m_attributeID);
for (; attrs.first != attrs.second; ++attrs.first)
count += attrs.first->second->valueCount();
return count;