709bedac0a5b3e073e8776d0b2e715dccf93903f
[shibboleth/sp.git] / shibsp / attribute / resolver / impl / XMLAttributeExtractor.cpp
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * XMLAttributeExtractor.cpp
19  * 
20  * AttributeExtractor based on an XML mapping file.
21  */
22
23 #include "internal.h"
24 #include "Application.h"
25 #include "ServiceProvider.h"
26 #include "attribute/AttributeDecoder.h"
27 #include "attribute/resolver/AttributeExtractor.h"
28 #include "util/SPConstants.h"
29
30 #include <saml/saml1/core/Assertions.h>
31 #include <saml/saml2/core/Assertions.h>
32 #include <saml/saml2/metadata/MetadataCredentialCriteria.h>
33 #include <xmltooling/util/NDC.h>
34 #include <xmltooling/util/ReloadableXMLFile.h>
35 #include <xmltooling/util/XMLHelper.h>
36 #include <xercesc/util/XMLUniDefs.hpp>
37
38 using namespace shibsp;
39 using namespace opensaml::saml2md;
40 using namespace opensaml;
41 using namespace xmltooling;
42 using namespace std;
43 using saml1::NameIdentifier;
44 using saml2::NameID;
45 using saml2::EncryptedAttribute;
46
47 namespace shibsp {
48
49 #if defined (_MSC_VER)
50     #pragma warning( push )
51     #pragma warning( disable : 4250 )
52 #endif
53
54     class XMLExtractorImpl
55     {
56     public:
57         XMLExtractorImpl(const DOMElement* e, Category& log);
58         ~XMLExtractorImpl() {
59             for (attrmap_t::iterator i = m_attrMap.begin(); i!=m_attrMap.end(); ++i)
60                 delete i->second.first;
61             if (m_document)
62                 m_document->release();
63         }
64
65         void setDocument(DOMDocument* doc) {
66             m_document = doc;
67         }
68
69         void extractAttributes(
70             const Application& application, const char* assertingParty, const NameIdentifier& nameid, vector<Attribute*>& attributes
71             ) const;
72         void extractAttributes(
73             const Application& application, const char* assertingParty, const NameID& nameid, vector<Attribute*>& attributes
74             ) const;
75         void extractAttributes(
76             const Application& application, const char* assertingParty, const saml1::Attribute& attr, vector<Attribute*>& attributes
77             ) const;
78         void extractAttributes(
79             const Application& application, const char* assertingParty, const saml2::Attribute& attr, vector<Attribute*>& attributes
80             ) const;
81         void extractAttributes(
82             const Application& application, const char* assertingParty, const Extensions& ext, vector<Attribute*>& attributes
83             ) const;
84
85         void getAttributeIds(vector<string>& attributes) const {
86             attributes.insert(attributes.end(), m_attributeIds.begin(), m_attributeIds.end());
87         }
88
89     private:
90         Category& m_log;
91         DOMDocument* m_document;
92 #ifdef HAVE_GOOD_STL
93         typedef map< pair<xstring,xstring>,pair< AttributeDecoder*,vector<string> > > attrmap_t;
94 #else
95         typedef map< pair<string,string>,pair< AttributeDecoder*,vector<string> > > attrmap_t;
96 #endif
97         attrmap_t m_attrMap;
98         vector<string> m_attributeIds;
99     };
100     
101     class XMLExtractor : public AttributeExtractor, public ReloadableXMLFile
102     {
103     public:
104         XMLExtractor(const DOMElement* e) : ReloadableXMLFile(e, Category::getInstance(SHIBSP_LOGCAT".AttributeExtractor")), m_impl(NULL) {
105             load();
106         }
107         ~XMLExtractor() {
108             delete m_impl;
109         }
110         
111         void extractAttributes(
112             const Application& application, const RoleDescriptor* issuer, const XMLObject& xmlObject, vector<Attribute*>& attributes
113             ) const;
114
115         void getAttributeIds(std::vector<std::string>& attributes) const {
116             if (m_impl)
117                 m_impl->getAttributeIds(attributes);
118         }
119
120     protected:
121         pair<bool,DOMElement*> load();
122
123     private:
124         XMLExtractorImpl* m_impl;
125     };
126
127 #if defined (_MSC_VER)
128     #pragma warning( pop )
129 #endif
130
131     AttributeExtractor* SHIBSP_DLLLOCAL XMLAttributeExtractorFactory(const DOMElement* const & e)
132     {
133         return new XMLExtractor(e);
134     }
135     
136     static const XMLCh _AttributeDecoder[] =    UNICODE_LITERAL_16(A,t,t,r,i,b,u,t,e,D,e,c,o,d,e,r);
137     static const XMLCh Attributes[] =           UNICODE_LITERAL_10(A,t,t,r,i,b,u,t,e,s);
138     static const XMLCh _id[] =                  UNICODE_LITERAL_2(i,d);
139     static const XMLCh _aliases[] =             UNICODE_LITERAL_7(a,l,i,a,s,e,s);
140     static const XMLCh _name[] =                UNICODE_LITERAL_4(n,a,m,e);
141     static const XMLCh nameFormat[] =           UNICODE_LITERAL_10(n,a,m,e,F,o,r,m,a,t);
142 };
143
144 XMLExtractorImpl::XMLExtractorImpl(const DOMElement* e, Category& log) : m_log(log), m_document(NULL)
145 {
146 #ifdef _DEBUG
147     xmltooling::NDC ndc("XMLExtractorImpl");
148 #endif
149     
150     if (!XMLHelper::isNodeNamed(e, shibspconstants::SHIB2ATTRIBUTEMAP_NS, Attributes))
151         throw ConfigurationException("XML AttributeExtractor requires am:Attributes at root of configuration.");
152
153     DOMElement* child = XMLHelper::getFirstChildElement(e, shibspconstants::SHIB2ATTRIBUTEMAP_NS, saml1::Attribute::LOCAL_NAME);
154     while (child) {
155         // Check for missing name or id.
156         const XMLCh* name = child->getAttributeNS(NULL, _name);
157         if (!name || !*name) {
158             m_log.warn("skipping Attribute with no name");
159             child = XMLHelper::getNextSiblingElement(child, shibspconstants::SHIB2ATTRIBUTEMAP_NS, saml1::Attribute::LOCAL_NAME);
160             continue;
161         }
162
163         auto_ptr_char id(child->getAttributeNS(NULL, _id));
164         if (!id.get() || !*id.get()) {
165             m_log.warn("skipping Attribute with no id");
166             child = XMLHelper::getNextSiblingElement(child, shibspconstants::SHIB2ATTRIBUTEMAP_NS, saml1::Attribute::LOCAL_NAME);
167             continue;
168         }
169         else if (!strcmp(id.get(), "REMOTE_USER")) {
170             m_log.warn("skipping Attribute, id of REMOTE_USER is a reserved name");
171             child = XMLHelper::getNextSiblingElement(child, shibspconstants::SHIB2ATTRIBUTEMAP_NS, saml1::Attribute::LOCAL_NAME);
172             continue;
173         }
174
175         AttributeDecoder* decoder=NULL;
176         try {
177             DOMElement* dchild = XMLHelper::getFirstChildElement(child, shibspconstants::SHIB2ATTRIBUTEMAP_NS, _AttributeDecoder);
178             if (dchild) {
179                 auto_ptr<QName> q(XMLHelper::getXSIType(dchild));
180                 if (q.get())
181                     decoder = SPConfig::getConfig().AttributeDecoderManager.newPlugin(*q.get(), dchild);
182             }
183             if (!decoder)
184                 decoder = SPConfig::getConfig().AttributeDecoderManager.newPlugin(StringAttributeDecoderType, NULL);
185         }
186         catch (exception& ex) {
187             m_log.error("skipping Attribute (%s), error building AttributeDecoder: %s", id.get(), ex.what());
188         }
189
190         if (!decoder) {
191             child = XMLHelper::getNextSiblingElement(child, shibspconstants::SHIB2ATTRIBUTEMAP_NS, saml1::Attribute::LOCAL_NAME);
192             continue;
193         }
194
195         // Empty NameFormat implies the usual Shib URI naming defaults.
196         const XMLCh* format = child->getAttributeNS(NULL, nameFormat);
197         if (!format || XMLString::equals(format, shibspconstants::SHIB1_ATTRIBUTE_NAMESPACE_URI) ||
198                 XMLString::equals(format, saml2::Attribute::URI_REFERENCE))
199             format = &chNull;  // ignore default Format/Namespace values
200
201         // Fetch/create the map entry and see if it's a duplicate rule.
202 #ifdef HAVE_GOOD_STL
203         pair< AttributeDecoder*,vector<string> >& decl = m_attrMap[pair<xstring,xstring>(name,format)];
204 #else
205         auto_ptr_char n(name);
206         auto_ptr_char f(format);
207         pair< AttributeDecoder*,vector<string> >& decl = m_attrMap[pair<string,string>(n.get(),f.get())];
208 #endif
209         if (decl.first) {
210             m_log.warn("skipping duplicate Attribute mapping (same name and nameFormat)");
211             delete decoder;
212             child = XMLHelper::getNextSiblingElement(child, shibspconstants::SHIB2ATTRIBUTEMAP_NS, saml1::Attribute::LOCAL_NAME);
213             continue;
214         }
215
216         if (m_log.isInfoEnabled()) {
217 #ifdef HAVE_GOOD_STL
218             auto_ptr_char n(name);
219             auto_ptr_char f(format);
220 #endif
221             m_log.info("creating mapping for Attribute %s%s%s", n.get(), *f.get() ? ", Format/Namespace:" : "", f.get());
222         }
223         
224         decl.first = decoder;
225         decl.second.push_back(id.get());
226         m_attributeIds.push_back(id.get());
227
228         name = child->getAttributeNS(NULL, _aliases);
229         if (name && *name) {
230             auto_ptr_char aliases(name);
231             char* pos;
232             char* start = const_cast<char*>(aliases.get());
233             while (start && *start) {
234                 while (*start && isspace(*start))
235                     start++;
236                 if (!*start)
237                     break;
238                 pos = strchr(start,' ');
239                 if (pos)
240                     *pos=0;
241                 if (strcmp(start, "REMOTE_USER")) {
242                     decl.second.push_back(start);
243                     m_attributeIds.push_back(start);
244                 }
245                 else {
246                     m_log.warn("skipping alias, REMOTE_USER is a reserved name");
247                 }
248                 start = pos ? pos+1 : NULL;
249             }
250         }
251         
252         child = XMLHelper::getNextSiblingElement(child, shibspconstants::SHIB2ATTRIBUTEMAP_NS, saml1::Attribute::LOCAL_NAME);
253     }
254 }
255
256 void XMLExtractorImpl::extractAttributes(
257     const Application& application, const char* assertingParty, const NameIdentifier& nameid, vector<Attribute*>& attributes
258     ) const
259 {
260 #ifdef HAVE_GOOD_STL
261     map< pair<xstring,xstring>,pair< AttributeDecoder*,vector<string> > >::const_iterator rule;
262 #else
263     map< pair<string,string>,pair< AttributeDecoder*,vector<string> > >::const_iterator rule;
264 #endif
265
266     const XMLCh* format = nameid.getFormat();
267     if (!format || !*format)
268         format = NameIdentifier::UNSPECIFIED;
269 #ifdef HAVE_GOOD_STL
270     if ((rule=m_attrMap.find(pair<xstring,xstring>(format,xstring()))) != m_attrMap.end()) {
271 #else
272     auto_ptr_char temp(format);
273     if ((rule=m_attrMap.find(pair<string,string>(temp.get(),string()))) != m_attrMap.end()) {
274 #endif
275         Attribute* a = rule->second.first->decode(rule->second.second, &nameid, assertingParty, application.getString("entityID").second);
276         if (a)
277             attributes.push_back(a);
278     }
279     else if (m_log.isDebugEnabled()) {
280 #ifdef HAVE_GOOD_STL
281         auto_ptr_char temp(format);
282 #endif
283         m_log.debug("skipping unmapped NameIdentifier with format (%s)", temp.get());
284     }
285 }
286
287 void XMLExtractorImpl::extractAttributes(
288     const Application& application, const char* assertingParty, const NameID& nameid, vector<Attribute*>& attributes
289     ) const
290 {
291 #ifdef HAVE_GOOD_STL
292     map< pair<xstring,xstring>,pair< AttributeDecoder*,vector<string> > >::const_iterator rule;
293 #else
294     map< pair<string,string>,pair< AttributeDecoder*,vector<string> > >::const_iterator rule;
295 #endif
296
297     const XMLCh* format = nameid.getFormat();
298     if (!format || !*format)
299         format = NameID::UNSPECIFIED;
300 #ifdef HAVE_GOOD_STL
301     if ((rule=m_attrMap.find(pair<xstring,xstring>(format,xstring()))) != m_attrMap.end()) {
302 #else
303     auto_ptr_char temp(format);
304     if ((rule=m_attrMap.find(pair<string,string>(temp.get(),string()))) != m_attrMap.end()) {
305 #endif
306         Attribute* a = rule->second.first->decode(rule->second.second, &nameid, assertingParty, application.getString("entityID").second);
307         if (a)
308             attributes.push_back(a);
309     }
310     else if (m_log.isDebugEnabled()) {
311 #ifdef HAVE_GOOD_STL
312         auto_ptr_char temp(format);
313 #endif
314         m_log.debug("skipping unmapped NameID with format (%s)", temp.get());
315     }
316 }
317
318 void XMLExtractorImpl::extractAttributes(
319     const Application& application, const char* assertingParty, const saml1::Attribute& attr, vector<Attribute*>& attributes
320     ) const
321 {
322 #ifdef HAVE_GOOD_STL
323     map< pair<xstring,xstring>,pair< AttributeDecoder*,vector<string> > >::const_iterator rule;
324 #else
325     map< pair<string,string>,pair< AttributeDecoder*,vector<string> > >::const_iterator rule;
326 #endif
327
328     const XMLCh* name = attr.getAttributeName();
329     const XMLCh* format = attr.getAttributeNamespace();
330     if (!name || !*name)
331         return;
332     if (!format || XMLString::equals(format, shibspconstants::SHIB1_ATTRIBUTE_NAMESPACE_URI))
333         format = &chNull;
334 #ifdef HAVE_GOOD_STL
335     if ((rule=m_attrMap.find(pair<xstring,xstring>(name,format))) != m_attrMap.end()) {
336 #else
337     auto_ptr_char temp1(name);
338     auto_ptr_char temp2(format);
339     if ((rule=m_attrMap.find(pair<string,string>(temp1.get(),temp2.get()))) != m_attrMap.end()) {
340 #endif
341         Attribute* a = rule->second.first->decode(rule->second.second, &attr, assertingParty, application.getString("entityID").second);
342         if (a)
343             attributes.push_back(a);
344     }
345     else if (m_log.isInfoEnabled()) {
346 #ifdef HAVE_GOOD_STL
347         auto_ptr_char temp1(name);
348         auto_ptr_char temp2(format);
349 #endif
350         m_log.info("skipping unmapped SAML 1.x Attribute with Name: %s%s%s", temp1.get(), *temp2.get() ? ", Namespace:" : "", temp2.get());
351     }
352 }
353
354 void XMLExtractorImpl::extractAttributes(
355     const Application& application, const char* assertingParty, const saml2::Attribute& attr, vector<Attribute*>& attributes
356     ) const
357 {
358 #ifdef HAVE_GOOD_STL
359     map< pair<xstring,xstring>,pair< AttributeDecoder*,vector<string> > >::const_iterator rule;
360 #else
361     map< pair<string,string>,pair< AttributeDecoder*,vector<string> > >::const_iterator rule;
362 #endif
363
364     const XMLCh* name = attr.getName();
365     const XMLCh* format = attr.getNameFormat();
366     if (!name || !*name)
367         return;
368     if (!format || !*format)
369         format = saml2::Attribute::UNSPECIFIED;
370     else if (XMLString::equals(format, saml2::Attribute::URI_REFERENCE))
371         format = &chNull;
372 #ifdef HAVE_GOOD_STL
373     if ((rule=m_attrMap.find(pair<xstring,xstring>(name,format))) != m_attrMap.end()) {
374 #else
375     auto_ptr_char temp1(name);
376     auto_ptr_char temp2(format);
377     if ((rule=m_attrMap.find(pair<string,string>(temp1.get(),temp2.get()))) != m_attrMap.end()) {
378 #endif
379         Attribute* a = rule->second.first->decode(rule->second.second, &attr, assertingParty, application.getString("entityID").second);
380         if (a)
381             attributes.push_back(a);
382     }
383     else if (m_log.isInfoEnabled()) {
384 #ifdef HAVE_GOOD_STL
385         auto_ptr_char temp1(name);
386         auto_ptr_char temp2(format);
387 #endif
388         m_log.info("skipping unmapped SAML 2.0 Attribute with Name: %s%s%s", temp1.get(), *temp2.get() ? ", Format:" : "", temp2.get());
389     }
390 }
391
392 void XMLExtractorImpl::extractAttributes(
393     const Application& application, const char* assertingParty, const Extensions& ext, vector<Attribute*>& attributes
394     ) const
395 {
396     const vector<XMLObject*> exts = ext.getUnknownXMLObjects();
397     for (vector<XMLObject*>::const_iterator i = exts.begin(); i!=exts.end(); ++i) {
398         const saml2::Attribute* attr = dynamic_cast<const saml2::Attribute*>(*i);
399         if (attr)
400             extractAttributes(application, assertingParty, *attr, attributes);
401     }
402 }
403
404 void XMLExtractor::extractAttributes(
405     const Application& application, const RoleDescriptor* issuer, const XMLObject& xmlObject, vector<Attribute*>& attributes
406     ) const
407 {
408     if (!m_impl)
409         return;
410
411     // Check for assertions.
412     if (XMLString::equals(xmlObject.getElementQName().getLocalPart(), saml1::Assertion::LOCAL_NAME)) {
413         const saml2::Assertion* token2 = dynamic_cast<const saml2::Assertion*>(&xmlObject);
414         if (token2) {
415             auto_ptr_char assertingParty(issuer ? dynamic_cast<const EntityDescriptor*>(issuer->getParent())->getEntityID() : NULL);
416             const vector<saml2::AttributeStatement*>& statements = token2->getAttributeStatements();
417             for (vector<saml2::AttributeStatement*>::const_iterator s = statements.begin(); s!=statements.end(); ++s) {
418                 const vector<saml2::Attribute*>& attrs = const_cast<const saml2::AttributeStatement*>(*s)->getAttributes();
419                 for (vector<saml2::Attribute*>::const_iterator a = attrs.begin(); a!=attrs.end(); ++a)
420                     m_impl->extractAttributes(application, assertingParty.get(), *(*a), attributes);
421
422                 const vector<saml2::EncryptedAttribute*>& encattrs = const_cast<const saml2::AttributeStatement*>(*s)->getEncryptedAttributes();
423                 for (vector<saml2::EncryptedAttribute*>::const_iterator ea = encattrs.begin(); ea!=encattrs.end(); ++ea)
424                     extractAttributes(application, issuer, *(*ea), attributes);
425             }
426             return;
427         }
428
429         const saml1::Assertion* token1 = dynamic_cast<const saml1::Assertion*>(&xmlObject);
430         if (token1) {
431             auto_ptr_char assertingParty(issuer ? dynamic_cast<const EntityDescriptor*>(issuer->getParent())->getEntityID() : NULL);
432             const vector<saml1::AttributeStatement*>& statements = token1->getAttributeStatements();
433             for (vector<saml1::AttributeStatement*>::const_iterator s = statements.begin(); s!=statements.end(); ++s) {
434                 const vector<saml1::Attribute*>& attrs = const_cast<const saml1::AttributeStatement*>(*s)->getAttributes();
435                 for (vector<saml1::Attribute*>::const_iterator a = attrs.begin(); a!=attrs.end(); ++a)
436                     m_impl->extractAttributes(application, assertingParty.get(), *(*a), attributes);
437             }
438             return;
439         }
440
441         throw AttributeExtractionException("Unable to extract attributes, unknown object type.");
442     }
443
444     // Check for metadata.
445     if (XMLString::equals(xmlObject.getElementQName().getNamespaceURI(), samlconstants::SAML20MD_NS)) {
446         const EntityDescriptor* entity = dynamic_cast<const EntityDescriptor*>(&xmlObject);
447         if (!entity)
448             throw AttributeExtractionException("Unable to extract attributes, unknown metadata object type.");
449         auto_ptr_char assertingParty(issuer ? dynamic_cast<const EntityDescriptor*>(issuer->getParent())->getEntityID() : NULL);
450         const Extensions* ext = entity->getExtensions();
451         if (ext)
452             m_impl->extractAttributes(application, assertingParty.get(), *ext, attributes);
453         const EntitiesDescriptor* group = dynamic_cast<const EntitiesDescriptor*>(entity->getParent());
454         while (group) {
455             ext = group->getExtensions();
456             if (ext)
457                 m_impl->extractAttributes(application, assertingParty.get(), *ext, attributes);
458             group = dynamic_cast<const EntitiesDescriptor*>(group->getParent());
459         }
460         return;
461     }
462
463     // Check for attributes.
464     if (XMLString::equals(xmlObject.getElementQName().getLocalPart(), saml1::Attribute::LOCAL_NAME)) {
465         auto_ptr_char assertingParty(issuer ? dynamic_cast<const EntityDescriptor*>(issuer->getParent())->getEntityID() : NULL);
466
467         const saml2::Attribute* attr2 = dynamic_cast<const saml2::Attribute*>(&xmlObject);
468         if (attr2)
469             return m_impl->extractAttributes(application, assertingParty.get(), *attr2, attributes);
470
471         const saml1::Attribute* attr1 = dynamic_cast<const saml1::Attribute*>(&xmlObject);
472         if (attr1)
473             return m_impl->extractAttributes(application, assertingParty.get(), *attr1, attributes);
474
475         throw AttributeExtractionException("Unable to extract attributes, unknown object type.");
476     }
477
478     if (XMLString::equals(xmlObject.getElementQName().getLocalPart(), EncryptedAttribute::LOCAL_NAME)) {
479         const EncryptedAttribute* encattr = dynamic_cast<const EncryptedAttribute*>(&xmlObject);
480         if (encattr) {
481             const XMLCh* recipient = application.getXMLString("entityID").second;
482             CredentialResolver* cr = application.getCredentialResolver();
483             if (!cr) {
484                 m_log.warn("found encrypted attribute, but no CredentialResolver was available");
485                 return;
486             }
487
488             try {
489                 Locker credlocker(cr);
490                 if (issuer) {
491                     MetadataCredentialCriteria mcc(*issuer);
492                     auto_ptr<XMLObject> decrypted(encattr->decrypt(*cr, recipient, &mcc));
493                     if (m_log.isDebugEnabled())
494                         m_log.debugStream() << "decrypted Attribute:" << logging::eol << *(decrypted.get()) << logging::eol;
495                     return extractAttributes(application, issuer, *(decrypted.get()), attributes);
496                 }
497                 else {
498                     auto_ptr<XMLObject> decrypted(encattr->decrypt(*cr, recipient));
499                     if (m_log.isDebugEnabled())
500                         m_log.debugStream() << "decrypted Attribute:" << logging::eol << *(decrypted.get()) << logging::eol;
501                     return extractAttributes(application, issuer, *(decrypted.get()), attributes);
502                 }
503             }
504             catch (exception& ex) {
505                 m_log.error("caught exception decrypting Attribute: %s", ex.what());
506                 return;
507             }
508         }
509     }
510
511     // Check for NameIDs.
512     const NameID* name2 = dynamic_cast<const NameID*>(&xmlObject);
513     if (name2) {
514         auto_ptr_char assertingParty(issuer ? dynamic_cast<const EntityDescriptor*>(issuer->getParent())->getEntityID() : NULL);
515         return m_impl->extractAttributes(application, assertingParty.get(), *name2, attributes);
516     }
517
518     const NameIdentifier* name1 = dynamic_cast<const NameIdentifier*>(&xmlObject);
519     if (name1) {
520         auto_ptr_char assertingParty(issuer ? dynamic_cast<const EntityDescriptor*>(issuer->getParent())->getEntityID() : NULL);
521         return m_impl->extractAttributes(application, assertingParty.get(), *name1, attributes);
522     }
523
524     throw AttributeExtractionException("Unable to extract attributes, unknown object type.");
525 }
526
527 pair<bool,DOMElement*> XMLExtractor::load()
528 {
529     // Load from source using base class.
530     pair<bool,DOMElement*> raw = ReloadableXMLFile::load();
531     
532     // If we own it, wrap it.
533     XercesJanitor<DOMDocument> docjanitor(raw.first ? raw.second->getOwnerDocument() : NULL);
534
535     XMLExtractorImpl* impl = new XMLExtractorImpl(raw.second, m_log);
536     
537     // If we held the document, transfer it to the impl. If we didn't, it's a no-op.
538     impl->setDocument(docjanitor.release());
539
540     delete m_impl;
541     m_impl = impl;
542
543     return make_pair(false,(DOMElement*)NULL);
544 }