Switch plugin ctors to shortcut methods, and default the Listener in config.
[shibboleth/sp.git] / shibsp / impl / XMLAccessControl.cpp
index 6eecf78..30f22e5 100644 (file)
@@ -144,19 +144,17 @@ namespace shibsp {
     static const XMLCh _RuleRegex[] =       UNICODE_LITERAL_9(R,u,l,e,R,e,g,e,x);
 }
 
-Rule::Rule(const DOMElement* e)
+Rule::Rule(const DOMElement* e) : m_alias(XMLHelper::getAttrString(e, nullptr, require))
 {
-    auto_ptr_char req(e->getAttributeNS(nullptr,require));
-    if (!req.get() || !*req.get())
+    if (m_alias.empty())
         throw ConfigurationException("Access control rule missing require attribute");
-    m_alias=req.get();
 
     auto_arrayptr<char> vals(toUTF8(e->hasChildNodes() ? e->getFirstChild()->getNodeValue() : nullptr));
     if (!vals.get())
         return;
 
-    const XMLCh* flag = e->getAttributeNS(nullptr,_list);
-    if (flag && (*flag == chLatin_f || *flag == chDigit_0)) {
+    bool listflag = XMLHelper::getAttrBool(e, true, _list);
+    if (!listflag) {
         if (*vals.get())
             m_vals.push_back(vals.get());
         return;
@@ -252,15 +250,14 @@ AccessControl::aclresult_t Rule::authorized(const SPRequest& request, const Sess
     return shib_acl_false;
 }
 
-RuleRegex::RuleRegex(const DOMElement* e) : m_exp(toUTF8(e->hasChildNodes() ? e->getFirstChild()->getNodeValue() : nullptr))
+RuleRegex::RuleRegex(const DOMElement* e)
+    : m_alias(XMLHelper::getAttrString(e, nullptr, require)),
+        m_exp(toUTF8(e->hasChildNodes() ? e->getFirstChild()->getNodeValue() : nullptr))
 {
-    auto_ptr_char req(e->getAttributeNS(nullptr,require));
-    if (!req.get() || !*req.get() || !m_exp.get() || !*m_exp.get())
+    if (m_alias.empty() || !m_exp.get() || !*m_exp.get())
         throw ConfigurationException("Access control rule missing require attribute or element content.");
-    m_alias=req.get();
 
-    const XMLCh* flag = e->getAttributeNS(nullptr,ignoreCase);
-    bool ignore = (flag && (*flag == chLatin_t || *flag == chDigit_1));
+    bool ignore = XMLHelper::getAttrBool(e, false, ignoreCase);
     try {
         m_re = new RegularExpression(e->getFirstChild()->getNodeValue(), (ignore ? ignoreOption : &chNull));
     }