+void XMLExtractorImpl::generateMetadata(SPSSODescriptor& role) const
+{
+ if (m_requestedAttrs.empty())
+ return;
+ int index = 1;
+ const vector<AttributeConsumingService*>& svcs = const_cast<const SPSSODescriptor*>(&role)->getAttributeConsumingServices();
+ for (vector<AttributeConsumingService*>::const_iterator s =svcs.begin(); s != svcs.end(); ++s) {
+ pair<bool,int> i = (*s)->getIndex();
+ if (i.first && index == i.second)
+ index = i.second + 1;
+ }
+ AttributeConsumingService* svc = AttributeConsumingServiceBuilder::buildAttributeConsumingService();
+ role.getAttributeConsumingServices().push_back(svc);
+ svc->setIndex(index);
+ ServiceName* sn = ServiceNameBuilder::buildServiceName();
+ svc->getServiceNames().push_back(sn);
+ sn->setName(dynamic_cast<EntityDescriptor*>(role.getParent())->getEntityID());
+ static const XMLCh english[] = UNICODE_LITERAL_2(e,n);
+ sn->setLang(english);
+
+ for (vector< pair< pair<xstring,xstring>,bool > >::const_iterator i = m_requestedAttrs.begin(); i != m_requestedAttrs.end(); ++i) {
+ RequestedAttribute* req = RequestedAttributeBuilder::buildRequestedAttribute();
+ svc->getRequestedAttributes().push_back(req);
+ req->setName(i->first.first.c_str());
+ if (i->first.second.empty())
+ req->setNameFormat(saml2::Attribute::URI_REFERENCE);
+ else
+ req->setNameFormat(i->first.second.c_str());
+ if (i->second)
+ req->isRequired(true);
+ }
+}
+