#include "saml/binding/SAMLArtifact.h"
#include "saml2/metadata/ChainingMetadataProvider.h"
+#include <memory>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xmltooling/logging.h>
#include <xmltooling/util/XMLHelper.h>
Lockable* ChainingMetadataProvider::lock()
{
- m_log.debug("locked metadata chain (no-op)");
return this; // we're not lockable ourselves...
}
if (ptr) {
m_tlsKey->setData(NULL);
reinterpret_cast<MetadataProvider*>(ptr)->unlock();
- m_log.debug("unlocked embedded metadata provider (%p)", ptr);
- }
- else {
- m_log.debug("unlocked metadata chain (no-op)");
}
}
pair<const EntityDescriptor*,const RoleDescriptor*> ChainingMetadataProvider::getEntityDescriptor(const Criteria& criteria) const
{
- bool bRole = (criteria.role && criteria.protocol); // searching for role also?
-
// Clear any existing lock.
const_cast<ChainingMetadataProvider*>(this)->unlock();
pair<const EntityDescriptor*,const RoleDescriptor*> ret = pair<const EntityDescriptor*,const RoleDescriptor*>(NULL,NULL);
pair<const EntityDescriptor*,const RoleDescriptor*> cur = ret;
for (vector<MetadataProvider*>::const_iterator i=m_providers.begin(); i!=m_providers.end(); ++i) {
- m_log.debug("locking embedded metadata provider (%p)", *i);
(*i)->lock();
- m_log.debug("locked embedded metadata provider (%p)", *i);
cur = (*i)->getEntityDescriptor(criteria);
if (cur.first) {
- if (bRole) {
+ if (criteria.role) {
// We want a role also. Did we find one?
if (cur.second) {
// Are we using a first match policy?
if (m_firstMatch) {
+ // We could have an entity-only match from earlier, so unlock it.
+ if (held)
+ held->unlock();
// Save locked provider.
m_tlsKey->setData(*i);
- m_log.debug("leaving embedded metadata provider locked (%p)", *i);
return cur;
}
else {
// Are we using a first match policy?
if (m_firstMatch) {
+ // I don't think this can happen, but who cares, check anyway.
+ if (held)
+ held->unlock();
+
// Save locked provider.
m_tlsKey->setData(*i);
return cur;
}
else {
// No match, so just unlock this one and move on.
- m_log.debug("unlocking embedded metadata provider (%p)", *i);
(*i)->unlock();
- m_log.debug("unlocked embedded metadata provider (%p)", *i);
}
}