Change license header.
[shibboleth/cpp-sp.git] / shibsp / attribute / filtering / impl / AndMatchFunctor.cpp
index 857050d..e2c31a3 100644 (file)
@@ -1,17 +1,21 @@
-/*
- *  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.
- * You may obtain a copy of the License at
+/**
+ * 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.
+ *
+ * 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.
  */
 
 /**
@@ -23,6 +27,7 @@
 #include "internal.h"
 #include "exceptions.h"
 #include "attribute/filtering/FilterPolicyContext.h"
+#include "attribute/filtering/MatchFunctor.h"
 #include "util/SPConstants.h"
 
 #include <xercesc/util/XMLUniDefs.hpp>
@@ -82,15 +87,15 @@ AndMatchFunctor::AndMatchFunctor(const pair<const FilterPolicyContext*,const DOM
     MatchFunctor* func;
     const DOMElement* e = XMLHelper::getFirstChildElement(p.second);
     while (e) {
-        func = NULL;
+        func = nullptr;
         if (XMLHelper::isNodeNamed(e, shibspconstants::SHIB2ATTRIBUTEFILTER_MF_BASIC_NS, Rule)) {
             func = buildFunctor(e, p.first);
         }
         else if (XMLHelper::isNodeNamed(e, shibspconstants::SHIB2ATTRIBUTEFILTER_MF_BASIC_NS, RuleReference)) {
-            auto_ptr_char ref(e->getAttributeNS(NULL, _ref));
-            if (ref.get() && *ref.get()) {
-                multimap<string,MatchFunctor*>::const_iterator rule = p.first->getMatchFunctors().find(ref.get());
-                func = (rule!=p.first->getMatchFunctors().end()) ? rule->second : NULL;
+            string ref = XMLHelper::getAttrString(e, nullptr, _ref);
+            if (!ref.empty()) {
+                multimap<string,MatchFunctor*>::const_iterator rule = p.first->getMatchFunctors().find(ref);
+                func = (rule!=p.first->getMatchFunctors().end()) ? rule->second : nullptr;
             }
         }
 
@@ -104,12 +109,11 @@ AndMatchFunctor::AndMatchFunctor(const pair<const FilterPolicyContext*,const DOM
 MatchFunctor* AndMatchFunctor::buildFunctor(const DOMElement* e, const FilterPolicyContext* functorMap)
 {
     // We'll track and map IDs just for consistency, but don't require them or worry about dups.
-    auto_ptr_char temp(e->getAttributeNS(NULL,_id));
-    const char* id = (temp.get() && *temp.get()) ? temp.get() : "";
-    if (*id && functorMap->getMatchFunctors().count(id))
-        id = "";
+    string id = XMLHelper::getAttrString(e, nullptr, _id);
+    if (!id.empty() && functorMap->getMatchFunctors().count(id))
+        id.clear();
 
-    auto_ptr<QName> type(XMLHelper::getXSIType(e));
+    auto_ptr<xmltooling::QName> type(XMLHelper::getXSIType(e));
     if (!type.get())
         throw ConfigurationException("Child Rule found with no xsi:type.");