From: Scott Cantor Date: Thu, 22 Jan 2015 22:05:38 +0000 (+0000) Subject: https://issues.shibboleth.net/jira/browse/CPPOST-88 X-Git-Tag: 2.5.4~5 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=commitdiff_plain;h=756c7bfd3d42c1a483e9ac47f4e65bc0e01dbe76 https://issues.shibboleth.net/jira/browse/CPPOST-88 --- diff --git a/saml/saml2/metadata/impl/XMLMetadataProvider.cpp b/saml/saml2/metadata/impl/XMLMetadataProvider.cpp index c26b748..00c4a0c 100644 --- a/saml/saml2/metadata/impl/XMLMetadataProvider.cpp +++ b/saml/saml2/metadata/impl/XMLMetadataProvider.cpp @@ -71,57 +71,13 @@ namespace opensaml { shutdown(); } - void init() { - try { - if (!m_id.empty()) { - string threadid("["); - threadid += m_id + ']'; - logging::NDC::push(threadid); - } - background_load(); - startup(); - } - catch (...) { - startup(); - if (!m_id.empty()) { - logging::NDC::pop(); - } - throw; - } - - if (!m_id.empty()) { - logging::NDC::pop(); - } - } + void init(); const char* getId() const { return m_id.c_str(); } - void outputStatus(ostream& os) const { - os << " 0) { - DateTime ts(m_lastUpdate); - ts.parseDateTime(); - auto_ptr_char timestamp(ts.getFormattedString()); - os << " lastUpdate='" << timestamp.get() << "'"; - } - - if (!m_local && m_reloadInterval > 0) { - os << " reloadInterval='" << m_reloadInterval << "'"; - } - - os << "/>"; - } + void outputStatus(ostream& os) const; const XMLObject* getMetadata() const { return m_object.get(); @@ -152,6 +108,29 @@ namespace opensaml { static const XMLCh dropDOM[] = UNICODE_LITERAL_7(d,r,o,p,D,O,M); static const XMLCh minRefreshDelay[] = UNICODE_LITERAL_15(m,i,n,R,e,f,r,e,s,h,D,e,l,a,y); static const XMLCh refreshDelayFactor[] = UNICODE_LITERAL_18(r,e,f,r,e,s,h,D,e,l,a,y,F,a,c,t,o,r); + + // TODO: need to move this into xmltooling as a utility function + static void xml_encode(ostream& os, const char* start) + { + size_t pos; + while (start && *start) { + pos = strcspn(start, "\"<>&"); + if (pos > 0) { + os.write(start,pos); + start += pos; + } + else { + switch (*start) { + case '"': os << """; break; + case '<': os << "<"; break; + case '>': os << ">"; break; + case '&': os << "&"; break; + default: os << *start; + } + start++; + } + } + } }; }; @@ -186,6 +165,30 @@ XMLMetadataProvider::XMLMetadataProvider(const DOMElement* e) } } +void XMLMetadataProvider::init() +{ + try { + if (!m_id.empty()) { + string threadid("["); + threadid += m_id + ']'; + logging::NDC::push(threadid); + } + background_load(); + startup(); + } + catch (...) { + startup(); + if (!m_id.empty()) { + logging::NDC::pop(); + } + throw; + } + + if (!m_id.empty()) { + logging::NDC::pop(); + } +} + pair XMLMetadataProvider::load(bool backup) { if (!backup) { @@ -366,3 +369,29 @@ void XMLMetadataProvider::index(time_t& validUntil) } indexEntity(dynamic_cast(m_object.get()), validUntil); } + +void XMLMetadataProvider::outputStatus(ostream& os) const +{ + os << " 0) { + DateTime ts(m_lastUpdate); + ts.parseDateTime(); + auto_ptr_char timestamp(ts.getFormattedString()); + os << " lastUpdate='" << timestamp.get() << "'"; + } + + if (!m_local && m_reloadInterval > 0) { + os << " reloadInterval='" << m_reloadInterval << "'"; + } + + os << "/>"; +}