private:
struct SAML_DLLLOCAL Mapping {
- Mapping() : m_expires(0) {}
- auto_ptr<XMLObject> m_xml;
+ Mapping() : m_xml(nullptr), m_expires(0) {}
+ ~Mapping() {
+ delete m_xml;
+ }
+ XMLObject* m_xml;
string m_relying;
time_t m_expires;
};
void ArtifactMappings::storeContent(XMLObject* content, const SAMLArtifact* artifact, const char* relyingParty, int TTL)
{
- Lock wrapper(m_lock.get());
+ Lock wrapper(m_lock);
// Garbage collect any expired artifacts.
time_t now = time(nullptr);
multimap<time_t,string>::iterator stop = m_expMap.upper_bound(now);
for (multimap<time_t,string>::iterator i = m_expMap.begin(); i != stop; m_expMap.erase(i++)) {
+ delete m_artMap[i->second].m_xml;
m_artMap.erase(i->second);
}
// Key is the hexed handle.
string hexed = SAMLArtifact::toHex(artifact->getMessageHandle());
Mapping& m = m_artMap[hexed];
- m.m_xml.reset(content);
+ m.m_xml = content;
if (relyingParty)
m.m_relying = relyingParty;
m.m_expires = now + TTL;
- m_expMap.insert(pair<const time_t,string>(m.m_expires,hexed));
+ m_expMap.insert(pair<const time_t, string>(m.m_expires, hexed));
}
XMLObject* ArtifactMappings::retrieveContent(const SAMLArtifact* artifact, const char* relyingParty)
{
- Category& log=Category::getInstance(SAML_LOGCAT".ArtifactMap");
- Lock wrapper(m_lock.get());
+ Category& log=Category::getInstance(SAML_LOGCAT ".ArtifactMap");
+ Lock wrapper(m_lock);
map<string,Mapping>::iterator i = m_artMap.find(SAMLArtifact::toHex(artifact->getMessageHandle()));
if (i == m_artMap.end())
}
log.debug("resolved artifact for (%s)", relyingParty ? relyingParty : "unknown");
- XMLObject* ret = i->second.m_xml.release();
+ XMLObject* ret = i->second.m_xml;
+ i->second.m_xml = nullptr; // clear member so it doesn't get deleted
removeMapping(i);
return ret;
}
const XMLCh* TTL = e->getAttributeNS(nullptr, artifactTTL);
if (TTL) {
- m_artifactTTL = XMLString::parseInt(TTL);
+ try {
+ m_artifactTTL = XMLString::parseInt(TTL);
+ }
+ catch (XMLException&) {
+ m_artifactTTL = 0;
+ }
if (!m_artifactTTL)
m_artifactTTL = 180;
}
#ifdef _DEBUG
xmltooling::NDC ndc("retrieveContent");
#endif
- Category& log=Category::getInstance(SAML_LOGCAT".ArtifactMap");
+ Category& log=Category::getInstance(SAML_LOGCAT ".ArtifactMap");
if (!m_storage)
return m_mappings->retrieveContent(artifact, relyingParty);