X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=shibsp%2Fimpl%2FXMLServiceProvider.cpp;h=cc412c6c20fb9d64def0e772ff55f73b61865e60;hb=755adf7e70c2a059ca74e6b8e670e455f502bb45;hp=26f36af16f74ec85d0b81529d95b49afcc04acfc;hpb=5afd566cfe415a0c4aa344ee491c1daa12230dba;p=shibboleth%2Fcpp-sp.git diff --git a/shibsp/impl/XMLServiceProvider.cpp b/shibsp/impl/XMLServiceProvider.cpp index 26f36af..cc412c6 100644 --- a/shibsp/impl/XMLServiceProvider.cpp +++ b/shibsp/impl/XMLServiceProvider.cpp @@ -430,6 +430,7 @@ namespace { static const XMLCh OutOfProcess[] = UNICODE_LITERAL_12(O,u,t,O,f,P,r,o,c,e,s,s); static const XMLCh _path[] = UNICODE_LITERAL_4(p,a,t,h); static const XMLCh Policy[] = UNICODE_LITERAL_6(P,o,l,i,c,y); + static const XMLCh PolicyRule[] = UNICODE_LITERAL_10(P,o,l,i,c,y,R,u,l,e); static const XMLCh _provider[] = UNICODE_LITERAL_8(p,r,o,v,i,d,e,r); static const XMLCh RelyingParty[] = UNICODE_LITERAL_12(R,e,l,y,i,n,g,P,a,r,t,y); static const XMLCh _ReplayCache[] = UNICODE_LITERAL_11(R,e,p,l,a,y,C,a,c,h,e); @@ -766,7 +767,7 @@ XMLApplication::XMLApplication( #ifndef SHIBSP_LITE nlist=e->getElementsByTagNameNS(samlconstants::SAML20_NS,Audience::LOCAL_NAME); - if (nlist) { + if (nlist && nlist->getLength()) { log.warn("use of elements outside of a Security Policy Rule is deprecated"); for (XMLSize_t i=0; igetLength(); i++) if (nlist->item(i)->getParentNode()->isSameNode(e) && nlist->item(i)->hasChildNodes()) @@ -1487,8 +1488,8 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o settings->load(child, NULL, &filter); rules.first = settings.release(); - // Process Rule elements. - const DOMElement* rule = XMLHelper::getFirstChildElement(child,Rule); + // Process PolicyRule elements. + const DOMElement* rule = XMLHelper::getFirstChildElement(child,PolicyRule); while (rule) { auto_ptr_char type(rule->getAttributeNS(NULL,_type)); try { @@ -1497,7 +1498,27 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o catch (exception& ex) { log.crit("error instantiating policy rule (%s) in policy (%s): %s", type.get(), id.get(), ex.what()); } - rule = XMLHelper::getNextSiblingElement(rule,Rule); + rule = XMLHelper::getNextSiblingElement(rule,PolicyRule); + } + + if (rules.second.size() == 0) { + // Process Rule elements. + log.warn("detected legacy Policy configuration, please convert to new PolicyRule syntax"); + rule = XMLHelper::getFirstChildElement(child,Rule); + while (rule) { + auto_ptr_char type(rule->getAttributeNS(NULL,_type)); + try { + rules.second.push_back(samlConf.SecurityPolicyRuleManager.newPlugin(type.get(),rule)); + } + catch (exception& ex) { + log.crit("error instantiating policy rule (%s) in policy (%s): %s", type.get(), id.get(), ex.what()); + } + rule = XMLHelper::getNextSiblingElement(rule,Rule); + } + + // Manually add a basic Conditions rule. + log.info("installing a default Conditions rule in policy (%s) for compatibility with legacy configuration", id.get()); + rules.second.push_back(samlConf.SecurityPolicyRuleManager.newPlugin(CONDITIONS_POLICY_RULE, NULL)); } child = XMLHelper::getNextSiblingElement(child,Policy);