/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 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/Attribute.h"
#include "attribute/filtering/FilteringContext.h"
#include "attribute/filtering/FilterPolicyContext.h"
+#include "attribute/filtering/MatchFunctor.h"
using namespace shibsp;
using namespace std;
*/
class SHIBSP_DLLLOCAL AttributeValueStringFunctor : public MatchFunctor
{
- xmltooling::auto_ptr_char m_value;
xmltooling::auto_ptr_char m_attributeID;
+ char* m_value;
bool hasValue(const FilteringContext& filterContext) const;
bool matches(const Attribute& attribute, size_t index) const;
public:
AttributeValueStringFunctor(const DOMElement* e)
- : m_value(e ? e->getAttributeNS(NULL,value) : NULL), m_attributeID(e ? e->getAttributeNS(NULL,attributeID) : NULL) {
- if (!m_value.get() || !*m_value.get())
+ : m_value(e ? xmltooling::toUTF8(e->getAttributeNS(NULL,value)) : NULL), m_attributeID(e ? e->getAttributeNS(NULL,attributeID) : NULL) {
+ if (!m_value || !*m_value) {
+ delete[] m_value;
throw ConfigurationException("AttributeValueString MatchFunctor requires non-empty value attribute.");
+ }
if (e && e->hasAttributeNS(NULL,ignoreCase)) {
xmltooling::logging::Category::getInstance(SHIBSP_LOGCAT".AttributeFilter").warn(
"ignoreCase property ignored by AttributeValueString MatchFunctor in favor of attribute's caseSensitive property"
}
}
+ virtual ~AttributeValueStringFunctor() {
+ delete[] m_value;
+ }
+
bool evaluatePolicyRequirement(const FilteringContext& filterContext) const {
if (!m_attributeID.get() || !*m_attributeID.get())
throw AttributeFilteringException("No attributeID specified.");
if (!val)
return false;
if (attribute.isCaseSensitive())
- return !strcmp(m_value.get(), val);
+ return !strcmp(m_value, val);
#ifdef HAVE_STRCASECMP
- return !strcasecmp(m_value.get(), val);
+ return !strcasecmp(m_value, val);
#else
- return !stricmp(m_value.get(), val);
+ return !stricmp(m_value, val);
#endif
}