From: Scott Cantor Date: Mon, 25 Oct 2010 17:12:16 +0000 (+0000) Subject: Support for NameIDFormats. X-Git-Tag: 2.4RC1~6 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-sp.git;a=commitdiff_plain;h=18b98c26f89f35dae84bd7baee3f62c1005509e3 Support for NameIDFormats. --- diff --git a/shibsp/handler/impl/MetadataGenerator.cpp b/shibsp/handler/impl/MetadataGenerator.cpp index 7ae1c9d..7cafe7d 100644 --- a/shibsp/handler/impl/MetadataGenerator.cpp +++ b/shibsp/handler/impl/MetadataGenerator.cpp @@ -89,6 +89,7 @@ namespace shibsp { delete m_org; delete m_entityAttrs; for_each(m_contacts.begin(), m_contacts.end(), xmltooling::cleanup()); + for_each(m_formats.begin(), m_formats.end(), xmltooling::cleanup()); for_each(m_reqAttrs.begin(), m_reqAttrs.end(), xmltooling::cleanup()); for_each(m_attrConsumers.begin(), m_attrConsumers.end(), xmltooling::cleanup()); #endif @@ -114,6 +115,7 @@ namespace shibsp { Organization* m_org; EntityAttributes* m_entityAttrs; vector m_contacts; + vector m_formats; vector m_reqAttrs; vector m_attrConsumers; #endif @@ -184,48 +186,55 @@ MetadataGenerator::MetadataGenerator(const DOMElement* e, const char* appId) m_contacts.push_back(cp); } else { - RequestedAttribute* req = dynamic_cast(child.get()); - if (req) { + NameIDFormat* nif = dynamic_cast(child.get()); + if (nif) { child.release(); - m_reqAttrs.push_back(req); + m_formats.push_back(nif); } else { - AttributeConsumingService* acs = dynamic_cast(child.get()); - if (acs) { + RequestedAttribute* req = dynamic_cast(child.get()); + if (req) { child.release(); - m_attrConsumers.push_back(acs); + m_reqAttrs.push_back(req); } else { - UIInfo* info = dynamic_cast(child.get()); - if (info) { - if (!m_uiinfo) { - child.release(); - m_uiinfo = info; - } - else { - m_log.warn("skipping duplicate UIInfo element"); - } + AttributeConsumingService* acs = dynamic_cast(child.get()); + if (acs) { + child.release(); + m_attrConsumers.push_back(acs); } else { - Organization* org = dynamic_cast(child.get()); - if (org) { - if (!m_org) { + UIInfo* info = dynamic_cast(child.get()); + if (info) { + if (!m_uiinfo) { child.release(); - m_org = org; + m_uiinfo = info; } else { - m_log.warn("skipping duplicate Organization element"); + m_log.warn("skipping duplicate UIInfo element"); } } else { - EntityAttributes* ea = dynamic_cast(child.get()); - if (ea) { - if (!m_entityAttrs) { + Organization* org = dynamic_cast(child.get()); + if (org) { + if (!m_org) { child.release(); - m_entityAttrs = ea; + m_org = org; } else { - m_log.warn("skipping duplicate EntityAttributes element"); + m_log.warn("skipping duplicate Organization element"); + } + } + else { + EntityAttributes* ea = dynamic_cast(child.get()); + if (ea) { + if (!m_entityAttrs) { + child.release(); + m_entityAttrs = ea; + } + else { + m_log.warn("skipping duplicate EntityAttributes element"); + } } } } @@ -363,7 +372,7 @@ pair MetadataGenerator::processMessage( entity->setOrganization(m_org->cloneOrganization()); for (vector::const_iterator cp = m_contacts.begin(); cp != m_contacts.end(); ++cp) - entity->getContactPersons().push_back((*cp)->cloneContactPerson()); + entity->getContactPersons().push_back((*cp)->cloneContactPerson()); if (m_entityAttrs) { if (!entity->getExtensions()) @@ -380,6 +389,9 @@ pair MetadataGenerator::processMessage( role = entity->getSPSSODescriptors().front(); } + for (vector::const_iterator nif = m_formats.begin(); nif != m_formats.end(); ++nif) + role->getNameIDFormats().push_back((*nif)->cloneNameIDFormat()); + if (m_uiinfo) { if (!role->getExtensions()) role->setExtensions(ExtensionsBuilder::buildExtensions());