2 * Copyright 2009-2010 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * SimpleAggregationAttributeResolver.cpp
20 * AttributeResolver based on SAML queries to third-party AA sources.
24 #include "exceptions.h"
25 #include "Application.h"
26 #include "ServiceProvider.h"
27 #include "SessionCache.h"
28 #include "attribute/NameIDAttribute.h"
29 #include "attribute/SimpleAttribute.h"
30 #include "attribute/filtering/AttributeFilter.h"
31 #include "attribute/filtering/BasicFilteringContext.h"
32 #include "attribute/resolver/AttributeExtractor.h"
33 #include "attribute/resolver/AttributeResolver.h"
34 #include "attribute/resolver/ResolutionContext.h"
35 #include "binding/SOAPClient.h"
36 #include "metadata/MetadataProviderCriteria.h"
37 #include "security/SecurityPolicy.h"
38 #include "security/SecurityPolicyProvider.h"
39 #include "util/SPConstants.h"
41 #include <saml/exceptions.h>
42 #include <saml/SAMLConfig.h>
43 #include <saml/saml2/binding/SAML2SOAPClient.h>
44 #include <saml/saml2/core/Protocols.h>
45 #include <saml/saml2/metadata/Metadata.h>
46 #include <saml/saml2/metadata/MetadataCredentialCriteria.h>
47 #include <saml/saml2/metadata/MetadataProvider.h>
48 #include <xmltooling/XMLToolingConfig.h>
49 #include <xmltooling/security/TrustEngine.h>
50 #include <xmltooling/util/NDC.h>
51 #include <xmltooling/util/URLEncoder.h>
52 #include <xmltooling/util/XMLHelper.h>
53 #include <xercesc/util/XMLUniDefs.hpp>
55 using namespace shibsp;
56 using namespace opensaml::saml2;
57 using namespace opensaml::saml2p;
58 using namespace opensaml::saml2md;
59 using namespace opensaml;
60 using namespace xmltooling;
65 class SHIBSP_DLLLOCAL SimpleAggregationContext : public ResolutionContext
68 SimpleAggregationContext(const Application& application, const Session& session)
73 m_class(XMLString::transcode(session.getAuthnContextClassRef())),
74 m_decl(XMLString::transcode(session.getAuthnContextDeclRef())),
75 m_inputTokens(nullptr),
76 m_inputAttributes(nullptr) {
79 SimpleAggregationContext(
80 const Application& application,
81 const NameID* nameid=nullptr,
82 const XMLCh* entityID=nullptr,
83 const XMLCh* authncontext_class=nullptr,
84 const XMLCh* authncontext_decl=nullptr,
85 const vector<const opensaml::Assertion*>* tokens=nullptr,
86 const vector<shibsp::Attribute*>* attributes=nullptr
87 ) : m_app(application),
90 m_entityid(entityID ? XMLString::transcode(entityID) : nullptr),
91 m_class(const_cast<XMLCh*>(authncontext_class)),
92 m_decl(const_cast<XMLCh*>(authncontext_decl)),
93 m_inputTokens(tokens),
94 m_inputAttributes(attributes) {
97 ~SimpleAggregationContext() {
98 for_each(m_attributes.begin(), m_attributes.end(), xmltooling::cleanup<shibsp::Attribute>());
99 for_each(m_assertions.begin(), m_assertions.end(), xmltooling::cleanup<opensaml::Assertion>());
101 XMLString::release(&m_class);
102 XMLString::release(&m_decl);
104 XMLString::release(&m_entityid);
107 const Application& getApplication() const {
110 const char* getEntityID() const {
111 return m_session ? m_session->getEntityID() : m_entityid;
113 const NameID* getNameID() const {
114 return m_session ? m_session->getNameID() : m_nameid;
116 const XMLCh* getClassRef() const {
119 const XMLCh* getDeclRef() const {
122 const Session* getSession() const {
125 const vector<shibsp::Attribute*>* getInputAttributes() const {
126 return m_inputAttributes;
128 const vector<const opensaml::Assertion*>* getInputTokens() const {
129 return m_inputTokens;
131 vector<shibsp::Attribute*>& getResolvedAttributes() {
134 vector<opensaml::Assertion*>& getResolvedAssertions() {
139 const Application& m_app;
140 const Session* m_session;
141 const NameID* m_nameid;
145 const vector<const opensaml::Assertion*>* m_inputTokens;
146 const vector<shibsp::Attribute*>* m_inputAttributes;
147 vector<shibsp::Attribute*> m_attributes;
148 vector<opensaml::Assertion*> m_assertions;
151 class SHIBSP_DLLLOCAL SimpleAggregationResolver : public AttributeResolver
154 SimpleAggregationResolver(const DOMElement* e);
155 ~SimpleAggregationResolver() {
158 for_each(m_designators.begin(), m_designators.end(), xmltooling::cleanup<saml2::Attribute>());
161 Lockable* lock() {return this;}
164 ResolutionContext* createResolutionContext(
165 const Application& application,
166 const EntityDescriptor* issuer,
167 const XMLCh* protocol,
168 const NameID* nameid=nullptr,
169 const XMLCh* authncontext_class=nullptr,
170 const XMLCh* authncontext_decl=nullptr,
171 const vector<const opensaml::Assertion*>* tokens=nullptr,
172 const vector<shibsp::Attribute*>* attributes=nullptr
174 return new SimpleAggregationContext(
175 application, nameid, (issuer ? issuer->getEntityID() : nullptr), authncontext_class, authncontext_decl, tokens, attributes
179 ResolutionContext* createResolutionContext(const Application& application, const Session& session) const {
180 return new SimpleAggregationContext(application,session);
183 void resolveAttributes(ResolutionContext& ctx) const;
185 void getAttributeIds(vector<string>& attributes) const {
186 // Nothing to do, only the extractor would actually generate them.
190 void doQuery(SimpleAggregationContext& ctx, const char* entityID, const NameID* name) const;
195 vector<string> m_attributeIds;
197 MetadataProvider* m_metadata;
198 TrustEngine* m_trust;
199 vector<saml2::Attribute*> m_designators;
200 vector< pair<string,bool> > m_sources;
201 vector<string> m_exceptionId;
204 AttributeResolver* SHIBSP_DLLLOCAL SimpleAggregationResolverFactory(const DOMElement* const & e)
206 return new SimpleAggregationResolver(e);
209 static const XMLCh attributeId[] = UNICODE_LITERAL_11(a,t,t,r,i,b,u,t,e,I,d);
210 static const XMLCh Entity[] = UNICODE_LITERAL_6(E,n,t,i,t,y);
211 static const XMLCh EntityReference[] = UNICODE_LITERAL_15(E,n,t,i,t,y,R,e,f,e,r,e,n,c,e);
212 static const XMLCh exceptionId[] = UNICODE_LITERAL_11(e,x,c,e,p,t,i,o,n,I,d);
213 static const XMLCh format[] = UNICODE_LITERAL_6(f,o,r,m,a,t);
214 static const XMLCh _MetadataProvider[] = UNICODE_LITERAL_16(M,e,t,a,d,a,t,a,P,r,o,v,i,d,e,r);
215 static const XMLCh policyId[] = UNICODE_LITERAL_8(p,o,l,i,c,y,I,d);
216 static const XMLCh subjectMatch[] = UNICODE_LITERAL_12(s,u,b,j,e,c,t,M,a,t,c,h);
217 static const XMLCh _TrustEngine[] = UNICODE_LITERAL_11(T,r,u,s,t,E,n,g,i,n,e);
218 static const XMLCh _type[] = UNICODE_LITERAL_4(t,y,p,e);
221 SimpleAggregationResolver::SimpleAggregationResolver(const DOMElement* e)
222 : m_log(Category::getInstance(SHIBSP_LOGCAT".AttributeResolver.SimpleAggregation")),
223 m_policyId(XMLHelper::getAttrString(e, nullptr, policyId)),
224 m_subjectMatch(XMLHelper::getAttrBool(e, false, subjectMatch)),
225 m_metadata(nullptr), m_trust(nullptr)
228 xmltooling::NDC ndc("SimpleAggregationResolver");
231 const XMLCh* aid = e ? e->getAttributeNS(nullptr, attributeId) : nullptr;
233 char* dup = XMLString::transcode(aid);
236 while (start && *start) {
237 while (*start && isspace(*start))
241 pos = strchr(start,' ');
244 m_attributeIds.push_back(start);
245 start = pos ? pos+1 : nullptr;
247 XMLString::release(&dup);
249 aid = e->getAttributeNS(nullptr, format);
254 string exid(XMLHelper::getAttrString(e, nullptr, exceptionId));
256 m_exceptionId.push_back(exid);
258 DOMElement* child = XMLHelper::getFirstChildElement(e, _MetadataProvider);
260 string t(XMLHelper::getAttrString(child, nullptr, _type));
262 throw ConfigurationException("MetadataProvider element missing type attribute.");
263 m_log.info("building MetadataProvider of type %s...", t.c_str());
264 auto_ptr<MetadataProvider> mp(SAMLConfig::getConfig().MetadataProviderManager.newPlugin(t.c_str(), child));
266 m_metadata = mp.release();
269 child = XMLHelper::getFirstChildElement(e, _TrustEngine);
272 string t(XMLHelper::getAttrString(child, nullptr, _type));
274 throw ConfigurationException("TrustEngine element missing type attribute.");
275 m_log.info("building TrustEngine of type %s...", t.c_str());
276 m_trust = XMLToolingConfig::getConfig().TrustEngineManager.newPlugin(t.c_str(), child);
284 child = XMLHelper::getFirstChildElement(e);
286 if (child->hasChildNodes() && XMLString::equals(child->getLocalName(), Entity)) {
287 aid = child->getFirstChild()->getNodeValue();
289 auto_ptr_char taid(aid);
290 m_sources.push_back(pair<string,bool>(taid.get(),true));
293 else if (child->hasChildNodes() && XMLString::equals(child->getLocalName(), EntityReference)) {
294 aid = child->getFirstChild()->getNodeValue();
296 auto_ptr_char taid(aid);
297 m_sources.push_back(pair<string,bool>(taid.get(),false));
300 else if (XMLHelper::isNodeNamed(child, samlconstants::SAML20_NS, saml2::Attribute::LOCAL_NAME)) {
302 auto_ptr<XMLObject> obj(saml2::AttributeBuilder::buildOneFromElement(child));
303 saml2::Attribute* down = dynamic_cast<saml2::Attribute*>(obj.get());
305 m_designators.push_back(down);
309 catch (exception& ex) {
310 m_log.error("exception loading attribute designator: %s", ex.what());
313 child = XMLHelper::getNextSiblingElement(child);
317 void SimpleAggregationResolver::doQuery(SimpleAggregationContext& ctx, const char* entityID, const NameID* name) const
320 xmltooling::NDC ndc("doQuery");
322 const Application& application = ctx.getApplication();
323 MetadataProviderCriteria mc(application, entityID, &AttributeAuthorityDescriptor::ELEMENT_QNAME, samlconstants::SAML20P_NS);
324 Locker mlocker(m_metadata);
325 const AttributeAuthorityDescriptor* AA=nullptr;
326 pair<const EntityDescriptor*,const RoleDescriptor*> mdresult =
327 (m_metadata ? m_metadata : application.getMetadataProvider())->getEntityDescriptor(mc);
328 if (!mdresult.first) {
329 m_log.warn("unable to locate metadata for provider (%s)", entityID);
332 else if (!(AA=dynamic_cast<const AttributeAuthorityDescriptor*>(mdresult.second))) {
333 m_log.warn("no SAML 2 AttributeAuthority role found in metadata for (%s)", entityID);
337 const PropertySet* relyingParty = application.getRelyingParty(mdresult.first);
338 pair<bool,bool> signedAssertions = relyingParty->getBool("requireSignedAssertions");
339 pair<bool,const char*> encryption = relyingParty->getString("encryption");
341 // Locate policy key.
342 const char* policyId = m_policyId.empty() ? application.getString("policyId").second : m_policyId.c_str();
344 // Set up policy and SOAP client.
345 auto_ptr<SecurityPolicy> policy(
346 application.getServiceProvider().getSecurityPolicyProvider()->createSecurityPolicy(application, nullptr, policyId)
349 policy->setMetadataProvider(m_metadata);
351 policy->setTrustEngine(m_trust);
352 policy->getAudiences().push_back(relyingParty->getXMLString("entityID").second);
354 MetadataCredentialCriteria mcc(*AA);
355 shibsp::SOAPClient soaper(*policy.get());
357 auto_ptr_XMLCh binding(samlconstants::SAML20_BINDING_SOAP);
358 saml2p::StatusResponseType* srt=nullptr;
359 const vector<AttributeService*>& endpoints=AA->getAttributeServices();
360 for (vector<AttributeService*>::const_iterator ep=endpoints.begin(); !srt && ep!=endpoints.end(); ++ep) {
361 if (!XMLString::equals((*ep)->getBinding(),binding.get()) || !(*ep)->getLocation())
363 auto_ptr_char loc((*ep)->getLocation());
365 auto_ptr<saml2::Subject> subject(saml2::SubjectBuilder::buildSubject());
367 // Encrypt the NameID?
368 if (encryption.first && (!strcmp(encryption.second, "true") || !strcmp(encryption.second, "back"))) {
369 auto_ptr<EncryptedID> encrypted(EncryptedIDBuilder::buildEncryptedID());
372 *(policy->getMetadataProvider()),
375 relyingParty->getXMLString("encryptionAlg").second
377 subject->setEncryptedID(encrypted.release());
380 subject->setNameID(name->cloneNameID());
383 saml2p::AttributeQuery* query = saml2p::AttributeQueryBuilder::buildAttributeQuery();
384 query->setSubject(subject.release());
385 Issuer* iss = IssuerBuilder::buildIssuer();
386 iss->setName(relyingParty->getXMLString("entityID").second);
387 query->setIssuer(iss);
388 for (vector<saml2::Attribute*>::const_iterator ad = m_designators.begin(); ad!=m_designators.end(); ++ad)
389 query->getAttributes().push_back((*ad)->cloneAttribute());
391 SAML2SOAPClient client(soaper, false);
392 client.sendSAML(query, application.getId(), mcc, loc.get());
393 srt = client.receiveSAML();
395 catch (exception& ex) {
396 m_log.error("exception during SAML query to %s: %s", loc.get(), ex.what());
402 m_log.error("unable to obtain a SAML response from attribute authority (%s)", entityID);
403 throw BindingException("Unable to obtain a SAML response from attribute authority.");
406 auto_ptr<saml2p::StatusResponseType> wrapper(srt);
408 saml2p::Response* response = dynamic_cast<saml2p::Response*>(srt);
410 m_log.error("message was not a samlp:Response");
411 throw FatalProfileException("Attribute authority returned an unrecognized message.");
413 else if (!response->getStatus() || !response->getStatus()->getStatusCode() ||
414 !XMLString::equals(response->getStatus()->getStatusCode()->getValue(), saml2p::StatusCode::SUCCESS)) {
415 m_log.error("attribute authority (%s) returned a SAML error", entityID);
416 throw FatalProfileException("Attribute authority returned a SAML error.");
419 saml2::Assertion* newtoken = nullptr;
420 const vector<saml2::Assertion*>& assertions = const_cast<const saml2p::Response*>(response)->getAssertions();
421 if (assertions.empty()) {
422 // Check for encryption.
423 const vector<saml2::EncryptedAssertion*>& encassertions =
424 const_cast<const saml2p::Response*>(response)->getEncryptedAssertions();
425 if (encassertions.empty()) {
426 m_log.warn("response from attribute authority was empty");
429 else if (encassertions.size() > 1) {
430 m_log.warn("simple resolver only supports one assertion in the query response");
433 CredentialResolver* cr=application.getCredentialResolver();
435 m_log.warn("found encrypted assertion, but no CredentialResolver was available");
436 throw FatalProfileException("Assertion was encrypted, but no decryption credentials are available.");
439 // Attempt to decrypt it.
441 Locker credlocker(cr);
442 auto_ptr<XMLObject> tokenwrapper(encassertions.front()->decrypt(*cr, relyingParty->getXMLString("entityID").second, &mcc));
443 newtoken = dynamic_cast<saml2::Assertion*>(tokenwrapper.get());
445 tokenwrapper.release();
446 if (m_log.isDebugEnabled())
447 m_log.debugStream() << "decrypted Assertion: " << *newtoken << logging::eol;
448 // Free the Response now, so we know this is a stand-alone token later.
449 delete wrapper.release();
452 catch (exception& ex) {
453 m_log.error(ex.what());
458 if (assertions.size() > 1)
459 m_log.warn("simple resolver only supports one assertion in the query response");
460 newtoken = assertions.front();
463 if (!newtoken->getSignature() && signedAssertions.first && signedAssertions.second) {
464 m_log.error("assertion unsigned, rejecting it based on signedAssertions policy");
467 throw SecurityPolicyException("Rejected unsigned assertion based on local policy.");
471 // We're going to insist that the assertion issuer is the same as the peer.
472 // Reset the policy's message bits and extract them from the assertion.
474 policy->setMessageID(newtoken->getID());
475 policy->setIssueInstant(newtoken->getIssueInstantEpoch());
476 policy->setIssuer(newtoken->getIssuer());
477 policy->evaluate(*newtoken);
479 // Now we can check the security status of the policy.
480 if (!policy->isAuthenticated())
481 throw SecurityPolicyException("Security of SAML 2.0 query result not established.");
483 if (m_subjectMatch) {
484 // Check for subject match.
485 bool ownedName = false;
486 NameID* respName = newtoken->getSubject() ? newtoken->getSubject()->getNameID() : nullptr;
488 // Check for encryption.
489 EncryptedID* encname = newtoken->getSubject() ? newtoken->getSubject()->getEncryptedID() : nullptr;
491 CredentialResolver* cr=application.getCredentialResolver();
493 m_log.warn("found EncryptedID, but no CredentialResolver was available");
495 Locker credlocker(cr);
496 auto_ptr<XMLObject> decryptedID(encname->decrypt(*cr, relyingParty->getXMLString("entityID").second, &mcc));
497 respName = dynamic_cast<NameID*>(decryptedID.get());
500 decryptedID.release();
501 if (m_log.isDebugEnabled())
502 m_log.debugStream() << "decrypted NameID: " << *respName << logging::eol;
508 auto_ptr<NameID> nameIDwrapper(ownedName ? respName : nullptr);
510 if (!respName || !XMLString::equals(respName->getName(), name->getName()) ||
511 !XMLString::equals(respName->getFormat(), name->getFormat()) ||
512 !XMLString::equals(respName->getNameQualifier(), name->getNameQualifier()) ||
513 !XMLString::equals(respName->getSPNameQualifier(), name->getSPNameQualifier())) {
515 m_log.warnStream() << "ignoring Assertion without strongly matching NameID in Subject: " <<
516 *respName << logging::eol;
518 m_log.warn("ignoring Assertion without NameID in Subject");
525 catch (exception& ex) {
526 m_log.error("assertion failed policy validation: %s", ex.what());
534 wrapper.release(); // detach blows away the Response
536 ctx.getResolvedAssertions().push_back(newtoken);
538 // Finally, extract and filter the result.
540 AttributeExtractor* extractor = application.getAttributeExtractor();
542 Locker extlocker(extractor);
543 extractor->extractAttributes(application, AA, *newtoken, ctx.getResolvedAttributes());
546 AttributeFilter* filter = application.getAttributeFilter();
548 BasicFilteringContext fc(application, ctx.getResolvedAttributes(), AA, ctx.getClassRef(), ctx.getDeclRef());
549 Locker filtlocker(filter);
550 filter->filterAttributes(fc, ctx.getResolvedAttributes());
553 catch (exception& ex) {
554 m_log.error("caught exception extracting/filtering attributes from query result: %s", ex.what());
555 for_each(ctx.getResolvedAttributes().begin(), ctx.getResolvedAttributes().end(), xmltooling::cleanup<shibsp::Attribute>());
556 ctx.getResolvedAttributes().clear();
561 void SimpleAggregationResolver::resolveAttributes(ResolutionContext& ctx) const
564 xmltooling::NDC ndc("resolveAttributes");
567 SimpleAggregationContext& qctx = dynamic_cast<SimpleAggregationContext&>(ctx);
569 // First we manufacture the appropriate NameID to use.
571 for (vector<string>::const_iterator a = m_attributeIds.begin(); !n && a != m_attributeIds.end(); ++a) {
572 const Attribute* attr=nullptr;
573 if (qctx.getSession()) {
574 // Input attributes should be available via multimap.
575 pair<multimap<string,const Attribute*>::const_iterator, multimap<string,const Attribute*>::const_iterator> range =
576 qctx.getSession()->getIndexedAttributes().equal_range(*a);
577 for (; !attr && range.first != range.second; ++range.first) {
578 if (range.first->second->valueCount() > 0)
579 attr = range.first->second;
582 else if (qctx.getInputAttributes()) {
583 // Have to loop over unindexed set.
584 const vector<Attribute*>* matches = qctx.getInputAttributes();
585 for (vector<Attribute*>::const_iterator match = matches->begin(); !attr && match != matches->end(); ++match) {
586 if (*a == (*match)->getId() && (*match)->valueCount() > 0)
592 m_log.debug("using input attribute (%s) as identifier for queries", attr->getId());
593 n = NameIDBuilder::buildNameID();
594 const NameIDAttribute* down = dynamic_cast<const NameIDAttribute*>(attr);
596 // We can create a NameID directly from the source material.
597 const NameIDAttribute::Value& v = down->getValues().front();
598 XMLCh* val = fromUTF8(v.m_Name.c_str());
601 if (!v.m_Format.empty()) {
602 val = fromUTF8(v.m_Format.c_str());
606 if (!v.m_NameQualifier.empty()) {
607 val = fromUTF8(v.m_NameQualifier.c_str());
608 n->setNameQualifier(val);
611 if (!v.m_SPNameQualifier.empty()) {
612 val = fromUTF8(v.m_SPNameQualifier.c_str());
613 n->setSPNameQualifier(val);
616 if (!v.m_SPProvidedID.empty()) {
617 val = fromUTF8(v.m_SPProvidedID.c_str());
618 n->setSPProvidedID(val);
623 // We have to mock up the NameID.
624 XMLCh* val = fromUTF8(attr->getSerializedValues().front().c_str());
627 if (!m_format.empty())
628 n->setFormat(m_format.c_str());
634 if (qctx.getNameID() && m_attributeIds.empty()) {
635 m_log.debug("using authenticated NameID as identifier for queries");
638 m_log.warn("unable to resolve attributes, no suitable query identifier found");
643 auto_ptr<NameID> wrapper(n);
647 // Put initial IdP into history to prevent extra query.
648 if (qctx.getEntityID())
649 history.insert(qctx.getEntityID());
651 // Prepare to track exceptions.
652 SimpleAttribute* exceptAttr = nullptr;
653 if (!m_exceptionId.empty()) {
654 exceptAttr = new SimpleAttribute(m_exceptionId);
656 auto_ptr<Attribute> exceptWrapper(exceptAttr);
658 // We have a master loop over all the possible sources of material.
659 for (vector< pair<string,bool> >::const_iterator source = m_sources.begin(); source != m_sources.end(); ++source) {
660 if (source->second) {
661 // A literal entityID to query.
662 if (history.count(source->first) == 0) {
663 m_log.debug("issuing SAML query to (%s)", source->first.c_str());
665 doQuery(qctx, source->first.c_str(), n ? n : qctx.getNameID());
667 catch (exception& ex) {
669 exceptAttr->getValues().push_back(XMLToolingConfig::getConfig().getURLEncoder()->encode(ex.what()));
671 history.insert(source->first);
674 m_log.debug("skipping previously queried attribute source (%s)", source->first.c_str());
678 m_log.debug("using attribute sources referenced in attribute (%s)", source->first.c_str());
679 if (qctx.getSession()) {
680 // Input attributes should be available via multimap.
681 pair<multimap<string,const Attribute*>::const_iterator, multimap<string,const Attribute*>::const_iterator> range =
682 qctx.getSession()->getIndexedAttributes().equal_range(source->first);
683 for (; range.first != range.second; ++range.first) {
684 const vector<string>& links = range.first->second->getSerializedValues();
685 for (vector<string>::const_iterator link = links.begin(); link != links.end(); ++link) {
686 if (history.count(*link) == 0) {
687 m_log.debug("issuing SAML query to (%s)", link->c_str());
689 doQuery(qctx, link->c_str(), n ? n : qctx.getNameID());
691 catch (exception& ex) {
693 exceptAttr->getValues().push_back(XMLToolingConfig::getConfig().getURLEncoder()->encode(ex.what()));
695 history.insert(*link);
698 m_log.debug("skipping previously queried attribute source (%s)", link->c_str());
703 else if (qctx.getInputAttributes()) {
704 // Have to loop over unindexed set.
705 const vector<Attribute*>* matches = qctx.getInputAttributes();
706 for (vector<Attribute*>::const_iterator match = matches->begin(); match != matches->end(); ++match) {
707 if (source->first == (*match)->getId()) {
708 const vector<string>& links = (*match)->getSerializedValues();
709 for (vector<string>::const_iterator link = links.begin(); link != links.end(); ++link) {
710 if (history.count(*link) == 0) {
711 m_log.debug("issuing SAML query to (%s)", link->c_str());
713 doQuery(qctx, link->c_str(), n ? n : qctx.getNameID());
715 catch (exception& ex) {
717 exceptAttr->getValues().push_back(XMLToolingConfig::getConfig().getURLEncoder()->encode(ex.what()));
719 history.insert(*link);
722 m_log.debug("skipping previously queried attribute source (%s)", link->c_str());
732 qctx.getResolvedAttributes().push_back(exceptWrapper.release());