+
+void DiscoverableMetadataProvider::discoEntityAttributes(std::string& s, const EntityAttributes& ea, bool& first) const
+{
+ discoAttributes(s, ea.getAttributes(), first);
+ const vector<saml2::Assertion*>& tokens = ea.getAssertions();
+ for (vector<saml2::Assertion*>::const_iterator t = tokens.begin(); t != tokens.end(); ++t) {
+ const vector<AttributeStatement*> statements = const_cast<const saml2::Assertion*>(*t)->getAttributeStatements();
+ for (vector<AttributeStatement*>::const_iterator st = statements.begin(); st != statements.end(); ++st) {
+ discoAttributes(s, const_cast<const AttributeStatement*>(*st)->getAttributes(), first);
+ }
+ }
+}
+
+void DiscoverableMetadataProvider::discoAttributes(std::string& s, const vector<Attribute*>& attrs, bool& first) const
+{
+ for (indirect_iterator<vector<Attribute*>::const_iterator> a = make_indirect_iterator(attrs.begin());
+ a != make_indirect_iterator(attrs.end()); ++a) {
+
+ if (first) {
+ s += ",\n \"EntityAttributes\": [";
+ first = false;
+ }
+ else {
+ s += ',';
+ }
+
+ auto_ptr_char n(a->getName());
+ s += "\n {\n \"name\": \"";
+ json_safe(s, n.get());
+ s += "\",\n \"values\": [";
+ const vector<XMLObject*>& vals = const_cast<const Attribute&>(*a).getAttributeValues();
+ for (indirect_iterator<vector<XMLObject*>::const_iterator> v = make_indirect_iterator(vals.begin());
+ v != make_indirect_iterator(vals.end()); ++v) {
+ if (v.base() != vals.begin())
+ s += ',';
+ auto_arrayptr<char> val(toUTF8(v->getTextContent()));
+ s += "\n \"";
+ if (val.get())
+ json_safe(s, val.get());
+ s += '\"';
+ }
+ s += "\n ]\n }";
+ }
+}