[cpp-sp COMMIT] /branches/REL_2/shibsp/attribute/resolver/impl/MetadataAttributeExtractor.cpp
noreply at shibboleth.net
noreply at shibboleth.net
Sun Jan 29 00:25:54 GMT 2012
Author: scantor
Date: Sun Jan 29 00:25:54 2012
New Revision: 3564
URL: http://svn.shibboleth.net/view/cpp-sp?rev=3564&view=rev
Log:
Add Logo support to metadata extractor.
Modified:
branches/REL_2/shibsp/attribute/resolver/impl/MetadataAttributeExtractor.cpp
Modified: branches/REL_2/shibsp/attribute/resolver/impl/MetadataAttributeExtractor.cpp
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/shibsp/attribute/resolver/impl/MetadataAttributeExtractor.cpp?rev=3564&r1=3563&r2=3564&view=diff
==============================================================================
--- branches/REL_2/shibsp/attribute/resolver/impl/MetadataAttributeExtractor.cpp (original)
+++ branches/REL_2/shibsp/attribute/resolver/impl/MetadataAttributeExtractor.cpp Sun Jan 29 00:25:54 2012
@@ -97,10 +97,13 @@
m_orgDisplayName,
m_orgURL;
typedef tuple< string,xstring,boost::shared_ptr<AttributeDecoder> > contact_tuple_t;
- vector<contact_tuple_t> m_contacts; // tuple is attributeID, contact type, decoder
+ typedef tuple< string,int,int,boost::shared_ptr<AttributeDecoder> > logo_tuple_t;
+ vector<contact_tuple_t> m_contacts; // tuple is attributeID, contact type, decoder
+ vector<logo_tuple_t> m_logos; // tuple is attributeID, height, width, decoder
template <class T> void doLangSensitive(const GenericRequest*, const vector<T*>&, const string&, vector<shibsp::Attribute*>&) const;
void doContactPerson(const RoleDescriptor*, const contact_tuple_t&, vector<shibsp::Attribute*>&) const;
+ void doLogo(const GenericRequest*, const vector<Logo*>&,const logo_tuple_t&, vector<shibsp::Attribute*>&) const;
};
#if defined (_MSC_VER)
@@ -127,15 +130,26 @@
m_orgDisplayName(XMLHelper::getAttrString(e, nullptr, OrganizationDisplayName::LOCAL_NAME)),
m_orgURL(XMLHelper::getAttrString(e, nullptr, OrganizationURL::LOCAL_NAME))
{
- e = e ? XMLHelper::getFirstChildElement(e, ContactPerson::LOCAL_NAME) : nullptr;
+ e = e ? XMLHelper::getFirstChildElement(e) : nullptr;
while (e) {
- string id(XMLHelper::getAttrString(e, nullptr, _id));
- const XMLCh* type = e->getAttributeNS(nullptr, ContactPerson::CONTACTTYPE_ATTRIB_NAME);
- if (!id.empty() && type && *type) {
- boost::shared_ptr<AttributeDecoder> decoder(SPConfig::getConfig().AttributeDecoderManager.newPlugin(DOMAttributeDecoderType, e));
- m_contacts.push_back(contact_tuple_t(id, type, decoder));
- }
- e = XMLHelper::getNextSiblingElement(e, ContactPerson::LOCAL_NAME);
+ if (XMLHelper::isNodeNamed(e, shibspconstants::SHIB2SPCONFIG_NS, ContactPerson::LOCAL_NAME)) {
+ string id(XMLHelper::getAttrString(e, nullptr, _id));
+ const XMLCh* type = e->getAttributeNS(nullptr, ContactPerson::CONTACTTYPE_ATTRIB_NAME);
+ if (!id.empty() && type && *type) {
+ boost::shared_ptr<AttributeDecoder> decoder(SPConfig::getConfig().AttributeDecoderManager.newPlugin(DOMAttributeDecoderType, e));
+ m_contacts.push_back(contact_tuple_t(id, type, decoder));
+ }
+ }
+ else if (XMLHelper::isNodeNamed(e, shibspconstants::SHIB2SPCONFIG_NS, Logo::LOCAL_NAME)) {
+ string id(XMLHelper::getAttrString(e, nullptr, _id));
+ int h(XMLHelper::getAttrInt(e, 0, Logo::HEIGHT_ATTRIB_NAME));
+ int w(XMLHelper::getAttrInt(e, 0, Logo::WIDTH_ATTRIB_NAME));
+ if (!id.empty()) {
+ boost::shared_ptr<AttributeDecoder> decoder(SPConfig::getConfig().AttributeDecoderManager.newPlugin(DOMAttributeDecoderType, e));
+ m_logos.push_back(logo_tuple_t(id, h, w, decoder));
+ }
+ }
+ e = XMLHelper::getNextSiblingElement(e);
}
}
@@ -161,7 +175,9 @@
attributes.push_back(m_orgURL);
static void (vector<string>::* push_back)(const string&) = &vector<string>::push_back;
static const string& (contact_tuple_t::* tget)() const = &contact_tuple_t::get<0>;
+ static const string& (logo_tuple_t::* tget2)() const = &logo_tuple_t::get<0>;
for_each(m_contacts.begin(), m_contacts.end(), boost::bind(push_back, boost::ref(attributes), boost::bind(tget, _1)));
+ for_each(m_logos.begin(), m_logos.end(), boost::bind(push_back, boost::ref(attributes), boost::bind(tget2, _1)));
}
void MetadataExtractor::extractAttributes(
@@ -224,6 +240,13 @@
doLangSensitive(request, ui->getDescriptions(), m_description, attributes);
doLangSensitive(request, ui->getInformationURLs(), m_informationURL, attributes);
doLangSensitive(request, ui->getPrivacyStatementURLs(), m_privacyURL, attributes);
+ const vector<Logo*>& logos = ui->getLogos();
+ if (!logos.empty()) {
+ for_each(
+ m_logos.begin(), m_logos.end(),
+ boost::bind(&MetadataExtractor::doLogo, this, request, boost::ref(logos), _1, boost::ref(attributes))
[... 86 lines stripped ...]
More information about the commits
mailing list