2 * Copyright 2001-2005 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 * shib-ini.h -- config file handling, now XML-based
25 #include <shib/shib-threads.h>
26 #include <log4cpp/Category.hh>
27 #include <log4cpp/PropertyConfigurator.hh>
29 #include <sys/types.h>
34 using namespace shibboleth;
35 using namespace shibtarget;
36 using namespace log4cpp;
38 namespace shibtarget {
40 // Application configuration wrapper
41 class XMLApplication : public virtual IApplication, public XMLPropertySet, public DOMNodeFilter
44 XMLApplication(const IConfig*, const Iterator<ICredentials*>& creds, const DOMElement* e, const XMLApplication* base=NULL);
45 ~XMLApplication() { cleanup(); }
48 pair<bool,bool> getBool(const char* name, const char* ns=NULL) const;
49 pair<bool,const char*> getString(const char* name, const char* ns=NULL) const;
50 pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const;
51 pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const;
52 pair<bool,int> getInt(const char* name, const char* ns=NULL) const;
53 const IPropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
56 const char* getId() const {return getString("id").second;}
57 const char* getHash() const {return m_hash.c_str();}
58 Iterator<SAMLAttributeDesignator*> getAttributeDesignators() const;
59 Iterator<IAAP*> getAAPProviders() const;
60 Iterator<IMetadata*> getMetadataProviders() const;
61 Iterator<ITrust*> getTrustProviders() const;
62 Iterator<const XMLCh*> getAudiences() const;
63 const IPropertySet* getCredentialUse(const IEntityDescriptor* provider) const;
64 const SAMLBrowserProfile* getBrowserProfile() const {return m_profile;}
65 const SAMLBinding* getBinding(const XMLCh* binding) const
66 {return XMLString::compareString(SAMLBinding::SOAP,binding) ? NULL : m_binding;}
67 SAMLBrowserProfile::ArtifactMapper* getArtifactMapper() const {return new STArtifactMapper(this);}
68 const IHandler* getDefaultSessionInitiator() const;
69 const IHandler* getSessionInitiatorById(const char* id) const;
70 const IHandler* getDefaultAssertionConsumerService() const;
71 const IHandler* getAssertionConsumerServiceByIndex(unsigned short index) const;
72 Iterator<const IHandler*> getAssertionConsumerServicesByBinding(const XMLCh* binding) const;
73 Iterator<const IHandler*> getHandlers(const char* path) const;
75 // Provides filter to exclude special config elements.
76 short acceptNode(const DOMNode* node) const;
80 const IConfig* m_ini; // this is ok because its locking scope includes us
81 const XMLApplication* m_base;
83 vector<SAMLAttributeDesignator*> m_designators;
85 vector<IMetadata*> m_metadatas;
86 vector<ITrust*> m_trusts;
87 vector<const XMLCh*> m_audiences;
88 ShibBrowserProfile* m_profile;
89 SAMLBinding* m_binding;
90 ShibHTTPHook* m_bindingHook;
92 // vectors manage object life for handlers and their property sets
93 vector<IHandler*> m_handlers;
94 vector<XMLPropertySet*> m_handlerProps;
96 // maps location (path info) to applicable handlers
97 map<string,vector<const IHandler*> > m_handlerMap;
99 // maps unique indexes to consumer services
100 map<unsigned int,const IHandler*> m_acsIndexMap;
102 // pointer to default consumer service
103 const IHandler* m_acsDefault;
105 // maps binding strings to supporting consumer service(s)
107 typedef map<xstring,vector<const IHandler*> > ACSBindingMap;
109 typedef map<string,vector<const IHandler*> > ACSBindingMap;
111 ACSBindingMap m_acsBindingMap;
113 // maps unique ID strings to session initiators
114 map<string,const IHandler*> m_sessionInitMap;
116 // pointer to default session initiator
117 const IHandler* m_sessionInitDefault;
119 XMLPropertySet* m_credDefault;
121 map<xstring,XMLPropertySet*> m_credMap;
123 map<const XMLCh*,XMLPropertySet*> m_credMap;
127 // Top-level configuration implementation
129 class XMLConfigImpl : public ReloadableXMLFileImpl, public XMLPropertySet, public DOMNodeFilter
132 XMLConfigImpl(const char* pathname, bool first, const XMLConfig* outer)
133 : ReloadableXMLFileImpl(pathname), m_outer(outer), m_requestMapper(NULL) { init(first); }
134 XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* outer)
135 : ReloadableXMLFileImpl(e), m_outer(outer), m_requestMapper(NULL) { init(first); }
138 IRequestMapper* m_requestMapper;
139 map<string,IApplication*> m_appmap;
140 vector<ICredentials*> m_creds;
141 vector<IAttributeFactory*> m_attrFactories;
143 // Provides filter to exclude special config elements.
144 short acceptNode(const DOMNode* node) const;
147 void init(bool first);
148 const XMLConfig* m_outer;
151 class XMLConfig : public IConfig, public ReloadableXMLFile
154 XMLConfig(const DOMElement* e) : ReloadableXMLFile(e), m_listener(NULL), m_sessionCache(NULL), m_replayCache(NULL) {}
156 delete m_sessionCache;
158 delete m_replayCache;
164 void init() { getImplementation(); }
167 pair<bool,bool> getBool(const char* name, const char* ns=NULL) const {return static_cast<XMLConfigImpl*>(m_impl)->getBool(name,ns);}
168 pair<bool,const char*> getString(const char* name, const char* ns=NULL) const {return static_cast<XMLConfigImpl*>(m_impl)->getString(name,ns);}
169 pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const {return static_cast<XMLConfigImpl*>(m_impl)->getXMLString(name,ns);}
170 pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const {return static_cast<XMLConfigImpl*>(m_impl)->getUnsignedInt(name,ns);}
171 pair<bool,int> getInt(const char* name, const char* ns=NULL) const {return static_cast<XMLConfigImpl*>(m_impl)->getInt(name,ns);}
172 const IPropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const {return static_cast<XMLConfigImpl*>(m_impl)->getPropertySet(name,ns);}
173 const DOMElement* getElement() const {return static_cast<XMLConfigImpl*>(m_impl)->getElement();}
176 IListener* getListener() const {return m_listener;}
177 ISessionCache* getSessionCache() const {return m_sessionCache;}
178 IReplayCache* getReplayCache() const {return m_replayCache;}
179 IRequestMapper* getRequestMapper() const {return static_cast<XMLConfigImpl*>(m_impl)->m_requestMapper;}
180 const IApplication* getApplication(const char* applicationId) const {
181 map<string,IApplication*>::const_iterator i=static_cast<XMLConfigImpl*>(m_impl)->m_appmap.find(applicationId);
182 return (i!=static_cast<XMLConfigImpl*>(m_impl)->m_appmap.end()) ? i->second : NULL;
184 Iterator<ICredentials*> getCredentialsProviders() const {return static_cast<XMLConfigImpl*>(m_impl)->m_creds;}
187 virtual ReloadableXMLFileImpl* newImplementation(const char* pathname, bool first=true) const;
188 virtual ReloadableXMLFileImpl* newImplementation(const DOMElement* e, bool first=true) const;
191 friend class XMLConfigImpl;
192 mutable IListener* m_listener;
193 mutable ISessionCache* m_sessionCache;
194 mutable IReplayCache* m_replayCache;
198 IConfig* STConfig::ShibTargetConfigFactory(const DOMElement* e)
200 return new XMLConfig(e);
203 XMLPropertySet::~XMLPropertySet()
205 for (map<string,pair<char*,const XMLCh*> >::iterator i=m_map.begin(); i!=m_map.end(); i++)
206 XMLString::release(&(i->second.first));
207 for_each(m_nested.begin(),m_nested.end(),cleanup<string,IPropertySet>);
210 void XMLPropertySet::load(
213 DOMNodeFilter* filter,
214 const std::map<std::string,std::string>* remapper
218 saml::NDC ndc("load");
222 // Process each attribute as a property.
223 DOMNamedNodeMap* attrs=m_root->getAttributes();
224 for (XMLSize_t i=0; i<attrs->getLength(); i++) {
225 DOMNode* a=attrs->item(i);
226 if (!XMLString::compareString(a->getNamespaceURI(),saml::XML::XMLNS_NS))
228 char* val=XMLString::transcode(a->getNodeValue());
230 auto_ptr_char ns(a->getNamespaceURI());
231 auto_ptr_char name(a->getLocalName());
232 const char* realname=name.get();
234 map<string,string>::const_iterator remap=remapper->find(realname);
235 if (remap!=remapper->end()) {
236 log.warn("remapping property (%s) to (%s)",realname,remap->second.c_str());
237 realname=remap->second.c_str();
241 m_map[string("{") + ns.get() + '}' + realname]=pair<char*,const XMLCh*>(val,a->getNodeValue());
242 log.debug("added property {%s}%s (%s)",ns.get(),realname,val);
245 m_map[realname]=pair<char*,const XMLCh*>(val,a->getNodeValue());
246 log.debug("added property %s (%s)",realname,val);
251 // Process non-excluded elements as nested sets.
252 DOMTreeWalker* walker=
253 static_cast<DOMDocumentTraversal*>(
254 m_root->getOwnerDocument())->createTreeWalker(const_cast<DOMElement*>(m_root),DOMNodeFilter::SHOW_ELEMENT,filter,false
256 e=static_cast<DOMElement*>(walker->firstChild());
258 auto_ptr_char ns(e->getNamespaceURI());
259 auto_ptr_char name(e->getLocalName());
260 const char* realname=name.get();
262 map<string,string>::const_iterator remap=remapper->find(realname);
263 if (remap!=remapper->end()) {
264 log.warn("remapping property set (%s) to (%s)",realname,remap->second.c_str());
265 realname=remap->second.c_str();
270 key=string("{") + ns.get() + '}' + realname;
273 if (m_nested.find(key)!=m_nested.end())
274 log.warn("load() skipping duplicate property set: %s",key.c_str());
276 XMLPropertySet* set=new XMLPropertySet();
277 set->load(e,log,filter,remapper);
279 log.debug("added nested property set: %s",key.c_str());
281 e=static_cast<DOMElement*>(walker->nextSibling());
286 pair<bool,bool> XMLPropertySet::getBool(const char* name, const char* ns) const
288 pair<bool,bool> ret(false,false);
289 map<string,pair<char*,const XMLCh*> >::const_iterator i;
292 i=m_map.find(string("{") + ns + '}' + name);
296 if (i!=m_map.end()) {
298 ret.second=(!strcmp(i->second.first,"true") || !strcmp(i->second.first,"1"));
303 pair<bool,const char*> XMLPropertySet::getString(const char* name, const char* ns) const
305 pair<bool,const char*> ret(false,NULL);
306 map<string,pair<char*,const XMLCh*> >::const_iterator i;
309 i=m_map.find(string("{") + ns + '}' + name);
313 if (i!=m_map.end()) {
315 ret.second=i->second.first;
320 pair<bool,const XMLCh*> XMLPropertySet::getXMLString(const char* name, const char* ns) const
322 pair<bool,const XMLCh*> ret(false,NULL);
323 map<string,pair<char*,const XMLCh*> >::const_iterator i;
326 i=m_map.find(string("{") + ns + '}' + name);
330 if (i!=m_map.end()) {
332 ret.second=i->second.second;
337 pair<bool,unsigned int> XMLPropertySet::getUnsignedInt(const char* name, const char* ns) const
339 pair<bool,unsigned int> ret(false,0);
340 map<string,pair<char*,const XMLCh*> >::const_iterator i;
343 i=m_map.find(string("{") + ns + '}' + name);
347 if (i!=m_map.end()) {
349 ret.second=strtol(i->second.first,NULL,10);
354 pair<bool,int> XMLPropertySet::getInt(const char* name, const char* ns) const
356 pair<bool,int> ret(false,0);
357 map<string,pair<char*,const XMLCh*> >::const_iterator i;
360 i=m_map.find(string("{") + ns + '}' + name);
364 if (i!=m_map.end()) {
366 ret.second=atoi(i->second.first);
371 const IPropertySet* XMLPropertySet::getPropertySet(const char* name, const char* ns) const
373 map<string,IPropertySet*>::const_iterator i;
376 i=m_nested.find(string("{") + ns + '}' + name);
378 i=m_nested.find(name);
380 return (i!=m_nested.end()) ? i->second : NULL;
383 XMLApplication::XMLApplication(
385 const Iterator<ICredentials*>& creds,
387 const XMLApplication* base
388 ) : m_ini(ini), m_base(base), m_profile(NULL), m_binding(NULL), m_bindingHook(NULL),
389 m_credDefault(NULL), m_sessionInitDefault(NULL), m_acsDefault(NULL)
392 saml::NDC ndc("XMLApplication");
394 Category& log=Category::getInstance("shibtarget.XMLApplication");
397 // First load any property sets.
398 map<string,string> root_remap;
399 root_remap["shire"]="session";
400 root_remap["shireURL"]="handlerURL";
401 root_remap["shireSSL"]="handlerSSL";
402 load(e,log,this,&root_remap);
403 const IPropertySet* propcheck=getPropertySet("Errors");
404 if (propcheck && !propcheck->getString("session").first)
405 throw ConfigurationException("<Errors> element requires 'session' (or deprecated 'shire') attribute");
406 propcheck=getPropertySet("Sessions");
407 if (propcheck && !propcheck->getString("handlerURL").first)
408 throw ConfigurationException("<Sessions> element requires 'handlerURL' (or deprecated 'shireURL') attribute");
411 m_hash+=getString("providerId").second;
412 m_hash=SAMLArtifact::toHex(SAMLArtifactType0001::generateSourceId(m_hash.c_str()));
414 ShibTargetConfig& conf=ShibTargetConfig::getConfig();
415 SAMLConfig& shibConf=SAMLConfig::getConfig();
418 bool hardACS=false, hardSessionInit=false;
419 DOMElement* handler=saml::XML::getFirstChildElement(propcheck->getElement());
421 // A handler is split across a property set and the plugin itself, which is based on the Binding property.
422 // We build both objects first and then insert them into various structures for lookup.
424 XMLPropertySet* hprops=new XMLPropertySet();
426 hprops->load(handler,log,this); // filter irrelevant for now, no embedded elements expected
427 const char* bindprop=hprops->getString("Binding").second;
429 throw ConfigurationException("Handler element has no Binding attribute, skipping it...");
430 IPlugIn* hplug=shibConf.getPlugMgr().newPlugin(bindprop,handler);
431 hobj=dynamic_cast<IHandler*>(hplug);
434 throw UnsupportedProfileException(
435 "Plugin for binding ($1) does not implement IHandler interface.",params(1,bindprop)
439 catch (SAMLException& ex) {
440 // If we get here, the handler's not built, so dispose of the property set.
441 log.error("caught exception processing a handler element: %s",ex.what());
448 // Save off the objects after giving the property set to the handler for its use.
449 hobj->setProperties(hprops);
450 m_handlers.push_back(hobj);
451 m_handlerProps.push_back(hprops);
453 // Check for it in the location map.
454 const char* location=hprops->getString("Location").second;
455 if (m_handlerMap.count(location)==0)
456 m_handlerMap[location]=vector<const IHandler*>(1,hobj);
458 m_handlerMap[location].push_back(hobj);
460 // If it's an ACS or SI, handle index/id mappings and defaulting.
461 if (saml::XML::isElementNamed(handler,shibtarget::XML::SAML2META_NS,SHIBT_L(AssertionConsumerService))) {
464 const XMLCh* binding=hprops->getXMLString("Binding").second;
466 const char* binding=hprops->getString("Binding").second;
468 if (m_acsBindingMap.count(binding)==0)
469 m_acsBindingMap[binding]=vector<const IHandler*>(1,hobj);
471 m_acsBindingMap[binding].push_back(hobj);
472 m_acsIndexMap[hprops->getUnsignedInt("index").second]=hobj;
475 pair<bool,bool> defprop=hprops->getBool("isDefault");
477 if (defprop.second) {
482 else if (!m_acsDefault)
486 else if (saml::XML::isElementNamed(handler,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(SessionInitiator))) {
487 pair<bool,const char*> si_id=hprops->getString("id");
488 if (si_id.first && si_id.second)
489 m_sessionInitMap[si_id.second]=hobj;
490 if (!hardSessionInit) {
491 pair<bool,bool> defprop=hprops->getBool("isDefault");
493 if (defprop.second) {
494 hardSessionInit=true;
495 m_sessionInitDefault=hobj;
498 else if (!m_sessionInitDefault)
499 m_sessionInitDefault=hobj;
502 handler=saml::XML::getNextSiblingElement(handler);
505 // If no handlers defined at the root, assume a legacy configuration.
506 if (!m_base && m_handlers.empty()) {
507 // A legacy config installs a SAML POST handler and a Shib session-initiator
508 // at the root handler location. We use the Sessions element itself as the
510 auto_ptr_char b1(Constants::SHIB_SESSIONINIT_PROFILE_URI);
511 IPlugIn* hplug=shibConf.getPlugMgr().newPlugin(b1.get(),propcheck->getElement());
512 IHandler* h1=dynamic_cast<IHandler*>(hplug);
515 throw UnsupportedProfileException(
516 "Plugin for binding ($1) does not implement IHandler interface.",params(1,b1.get())
519 h1->setProperties(propcheck);
520 m_handlers.push_back(h1);
521 m_handlerMap[""]=vector<const IHandler*>(1,h1);
522 m_sessionInitDefault=h1;
524 auto_ptr_char b2(SAMLBrowserProfile::BROWSER_POST);
525 hplug=shibConf.getPlugMgr().newPlugin(b1.get(),propcheck->getElement());
526 IHandler* h2=dynamic_cast<IHandler*>(hplug);
529 throw UnsupportedProfileException(
530 "Plugin for binding ($1) does not implement IHandler interface.",params(1,b2.get())
533 h2->setProperties(propcheck);
534 m_handlers.push_back(h2);
535 m_handlerMap[""].push_back(h2);
539 // Process general configuration elements.
541 DOMNodeList* nlist=e->getElementsByTagNameNS(saml::XML::SAML_NS,L(AttributeDesignator));
542 for (i=0; nlist && i<nlist->getLength(); i++)
543 if (nlist->item(i)->getParentNode()->isSameNode(e))
544 m_designators.push_back(new SAMLAttributeDesignator(static_cast<DOMElement*>(nlist->item(i))));
546 nlist=e->getElementsByTagNameNS(saml::XML::SAML_NS,L(Audience));
547 for (i=0; nlist && i<nlist->getLength(); i++)
548 if (nlist->item(i)->getParentNode()->isSameNode(e))
549 m_audiences.push_back(nlist->item(i)->getFirstChild()->getNodeValue());
551 // Always include our own providerId as an audience.
552 m_audiences.push_back(getXMLString("providerId").second);
554 if (conf.isEnabled(ShibTargetConfig::AAP)) {
555 nlist=e->getElementsByTagNameNS(shibtarget::XML::SHIBTARGET_NS,SHIBT_L(AAPProvider));
556 for (i=0; nlist && i<nlist->getLength(); i++) {
557 if (nlist->item(i)->getParentNode()->isSameNode(e)) {
558 auto_ptr_char type(static_cast<DOMElement*>(nlist->item(i))->getAttributeNS(NULL,SHIBT_L(type)));
559 log.info("building AAP provider of type %s...",type.get());
561 IPlugIn* plugin=shibConf.getPlugMgr().newPlugin(type.get(),static_cast<DOMElement*>(nlist->item(i)));
562 IAAP* aap=dynamic_cast<IAAP*>(plugin);
564 m_aaps.push_back(aap);
567 log.crit("plugin was not an AAP provider");
570 catch (SAMLException& ex) {
571 log.crit("error building AAP provider: %s",ex.what());
577 if (conf.isEnabled(ShibTargetConfig::Metadata)) {
578 nlist=e->getElementsByTagNameNS(shibtarget::XML::SHIBTARGET_NS,SHIBT_L(MetadataProvider));
579 for (i=0; nlist && i<nlist->getLength(); i++) {
580 if (nlist->item(i)->getParentNode()->isSameNode(e)) {
581 auto_ptr_char type(static_cast<DOMElement*>(nlist->item(i))->getAttributeNS(NULL,SHIBT_L(type)));
582 log.info("building metadata provider of type %s...",type.get());
584 IPlugIn* plugin=shibConf.getPlugMgr().newPlugin(type.get(),static_cast<DOMElement*>(nlist->item(i)));
585 IMetadata* md=dynamic_cast<IMetadata*>(plugin);
587 m_metadatas.push_back(md);
590 log.crit("plugin was not a metadata provider");
593 catch (SAMLException& ex) {
594 log.crit("error building metadata provider: %s",ex.what());
598 nlist=e->getElementsByTagNameNS(shibtarget::XML::SHIBTARGET_NS,SHIBT_L(FederationProvider));
599 for (i=0; nlist && i<nlist->getLength(); i++) {
600 if (nlist->item(i)->getParentNode()->isSameNode(e)) {
601 auto_ptr_char type(static_cast<DOMElement*>(nlist->item(i))->getAttributeNS(NULL,SHIBT_L(type)));
602 log.info("building metadata provider of type %s...",type.get());
604 IPlugIn* plugin=shibConf.getPlugMgr().newPlugin(type.get(),static_cast<DOMElement*>(nlist->item(i)));
605 IMetadata* md=dynamic_cast<IMetadata*>(plugin);
607 m_metadatas.push_back(md);
610 log.crit("plugin was not a metadata provider");
613 catch (SAMLException& ex) {
614 log.crit("error building metadata provider: %s",ex.what());
620 if (conf.isEnabled(ShibTargetConfig::Trust)) {
621 nlist=e->getElementsByTagNameNS(shibtarget::XML::SHIBTARGET_NS,SHIBT_L(TrustProvider));
622 for (i=0; nlist && i<nlist->getLength(); i++) {
623 if (nlist->item(i)->getParentNode()->isSameNode(e)) {
624 auto_ptr_char type(static_cast<DOMElement*>(nlist->item(i))->getAttributeNS(NULL,SHIBT_L(type)));
625 log.info("building trust provider of type %s...",type.get());
627 IPlugIn* plugin=shibConf.getPlugMgr().newPlugin(type.get(),static_cast<DOMElement*>(nlist->item(i)));
628 ITrust* trust=dynamic_cast<ITrust*>(plugin);
630 m_trusts.push_back(trust);
633 log.crit("plugin was not a trust provider");
636 catch (SAMLException& ex) {
637 log.crit("error building trust provider: %s",ex.what());
643 // Finally, load credential mappings.
644 const DOMElement* cu=saml::XML::getFirstChildElement(e,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(CredentialUse));
646 m_credDefault=new XMLPropertySet();
647 m_credDefault->load(cu,log,this);
648 cu=saml::XML::getFirstChildElement(cu,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(RelyingParty));
650 XMLPropertySet* rp=new XMLPropertySet();
651 rp->load(cu,log,this);
652 m_credMap[cu->getAttributeNS(NULL,SHIBT_L(Name))]=rp;
653 cu=saml::XML::getNextSiblingElement(cu,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(RelyingParty));
657 if (conf.isEnabled(ShibTargetConfig::Caching)) {
658 // Really finally, build local browser profile and binding objects.
659 m_profile=new ShibBrowserProfile(
660 getMetadataProviders(),
663 m_bindingHook=new ShibHTTPHook(
667 m_binding=SAMLBinding::getInstance(SAMLBinding::SOAP);
668 SAMLSOAPHTTPBinding* bptr=dynamic_cast<SAMLSOAPHTTPBinding*>(m_binding);
670 log.fatal("binding implementation was not SOAP over HTTP");
671 throw UnsupportedExtensionException("binding implementation was not SOAP over HTTP");
673 bptr->addHook(m_bindingHook,m_bindingHook); // the hook is its own global context
676 catch (SAMLException& e) {
677 log.errorStream() << "Error while processing applicaton element: " << e.what() << CategoryStream::ENDLINE;
683 log.error("Unexpected error while processing application element");
690 void XMLApplication::cleanup()
692 delete m_bindingHook;
695 for_each(m_handlers.begin(),m_handlers.end(),shibtarget::cleanup<IHandler>);
697 delete m_credDefault;
699 for_each(m_credMap.begin(),m_credMap.end(),shibtarget::cleanup<xstring,XMLPropertySet>);
701 for_each(m_credMap.begin(),m_credMap.end(),shibtarget::cleanup<const XMLCh*,XMLPropertySet>);
703 for_each(m_designators.begin(),m_designators.end(),shibtarget::cleanup<SAMLAttributeDesignator>);
704 for_each(m_aaps.begin(),m_aaps.end(),shibtarget::cleanup<IAAP>);
705 for_each(m_metadatas.begin(),m_metadatas.end(),shibtarget::cleanup<IMetadata>);
706 for_each(m_trusts.begin(),m_trusts.end(),shibtarget::cleanup<ITrust>);
709 short XMLApplication::acceptNode(const DOMNode* node) const
711 if (saml::XML::isElementNamed(static_cast<const DOMElement*>(node),saml::XML::SAML_NS,L(AttributeDesignator)))
712 return FILTER_REJECT;
713 else if (saml::XML::isElementNamed(static_cast<const DOMElement*>(node),saml::XML::SAML_NS,L(Audience)))
714 return FILTER_REJECT;
715 const XMLCh* name=node->getLocalName();
716 if (!XMLString::compareString(name,SHIBT_L(Application)) ||
717 !XMLString::compareString(name,SHIBT_L(AssertionConsumerService)) ||
718 !XMLString::compareString(name,SHIBT_L(SingleLogoutService)) ||
719 !XMLString::compareString(name,SHIBT_L(DiagnosticService)) ||
720 !XMLString::compareString(name,SHIBT_L(SessionInitiator)) ||
721 !XMLString::compareString(name,SHIBT_L(AAPProvider)) ||
722 !XMLString::compareString(name,SHIBT_L(CredentialUse)) ||
723 !XMLString::compareString(name,SHIBT_L(RelyingParty)) ||
724 !XMLString::compareString(name,SHIBT_L(FederationProvider)) ||
725 !XMLString::compareString(name,SHIBT_L(MetadataProvider)) ||
726 !XMLString::compareString(name,SHIBT_L(TrustProvider)))
727 return FILTER_REJECT;
729 return FILTER_ACCEPT;
732 pair<bool,bool> XMLApplication::getBool(const char* name, const char* ns) const
734 pair<bool,bool> ret=XMLPropertySet::getBool(name,ns);
737 return m_base ? m_base->getBool(name,ns) : ret;
740 pair<bool,const char*> XMLApplication::getString(const char* name, const char* ns) const
742 pair<bool,const char*> ret=XMLPropertySet::getString(name,ns);
745 return m_base ? m_base->getString(name,ns) : ret;
748 pair<bool,const XMLCh*> XMLApplication::getXMLString(const char* name, const char* ns) const
750 pair<bool,const XMLCh*> ret=XMLPropertySet::getXMLString(name,ns);
753 return m_base ? m_base->getXMLString(name,ns) : ret;
756 pair<bool,unsigned int> XMLApplication::getUnsignedInt(const char* name, const char* ns) const
758 pair<bool,unsigned int> ret=XMLPropertySet::getUnsignedInt(name,ns);
761 return m_base ? m_base->getUnsignedInt(name,ns) : ret;
764 pair<bool,int> XMLApplication::getInt(const char* name, const char* ns) const
766 pair<bool,int> ret=XMLPropertySet::getInt(name,ns);
769 return m_base ? m_base->getInt(name,ns) : ret;
772 const IPropertySet* XMLApplication::getPropertySet(const char* name, const char* ns) const
774 const IPropertySet* ret=XMLPropertySet::getPropertySet(name,ns);
777 return m_base->getPropertySet(name,ns);
780 Iterator<SAMLAttributeDesignator*> XMLApplication::getAttributeDesignators() const
782 if (!m_designators.empty() || !m_base)
783 return m_designators;
784 return m_base->getAttributeDesignators();
787 Iterator<IAAP*> XMLApplication::getAAPProviders() const
789 return (m_aaps.empty() && m_base) ? m_base->getAAPProviders() : m_aaps;
792 Iterator<IMetadata*> XMLApplication::getMetadataProviders() const
794 return (m_metadatas.empty() && m_base) ? m_base->getMetadataProviders() : m_metadatas;
797 Iterator<ITrust*> XMLApplication::getTrustProviders() const
799 return (m_trusts.empty() && m_base) ? m_base->getTrustProviders() : m_trusts;
802 Iterator<const XMLCh*> XMLApplication::getAudiences() const
804 return (m_audiences.empty() && m_base) ? m_base->getAudiences() : m_audiences;
807 const IPropertySet* XMLApplication::getCredentialUse(const IEntityDescriptor* provider) const
809 if (!m_credDefault && m_base)
810 return m_base->getCredentialUse(provider);
813 map<xstring,XMLPropertySet*>::const_iterator i=m_credMap.find(provider->getId());
814 if (i!=m_credMap.end())
816 const IEntitiesDescriptor* group=provider->getEntitiesDescriptor();
818 if (group->getName()) {
819 i=m_credMap.find(group->getName());
820 if (i!=m_credMap.end())
823 group=group->getEntitiesDescriptor();
826 map<const XMLCh*,XMLPropertySet*>::const_iterator i=m_credMap.begin();
827 for (; i!=m_credMap.end(); i++) {
828 if (!XMLString::compareString(i->first,provider->getId()))
830 const IEntitiesDescriptor* group=provider->getEntitiesDescriptor();
832 if (!XMLString::compareString(i->first,group->getName()))
834 group=group->getEntitiesDescriptor();
838 return m_credDefault;
841 const IHandler* XMLApplication::getDefaultSessionInitiator() const
843 if (m_sessionInitDefault) return m_sessionInitDefault;
844 return m_base ? m_base->getDefaultSessionInitiator() : NULL;
847 const IHandler* XMLApplication::getSessionInitiatorById(const char* id) const
849 map<string,const IHandler*>::const_iterator i=m_sessionInitMap.find(id);
850 if (i!=m_sessionInitMap.end()) return i->second;
851 return m_base ? m_base->getSessionInitiatorById(id) : NULL;
854 const IHandler* XMLApplication::getDefaultAssertionConsumerService() const
856 if (m_acsDefault) return m_acsDefault;
857 return m_base ? m_base->getDefaultAssertionConsumerService() : NULL;
860 const IHandler* XMLApplication::getAssertionConsumerServiceByIndex(unsigned short index) const
862 map<unsigned int,const IHandler*>::const_iterator i=m_acsIndexMap.find(index);
863 if (i!=m_acsIndexMap.end()) return i->second;
864 return m_base ? m_base->getAssertionConsumerServiceByIndex(index) : NULL;
867 Iterator<const IHandler*> XMLApplication::getAssertionConsumerServicesByBinding(const XMLCh* binding) const
870 ACSBindingMap::const_iterator i=m_acsBindingMap.find(binding);
872 auto_ptr_char temp(binding);
873 ACSBindingMap::const_iterator i=m_acsBindingMap.find(temp.get());
875 if (i!=m_acsBindingMap.end())
877 return m_base ? m_base->getAssertionConsumerServicesByBinding(binding) : EMPTY(const IHandler*);
880 Iterator<const IHandler*> XMLApplication::getHandlers(const char* path) const
883 map<string,vector<const IHandler*> >::const_iterator i=m_handlerMap.find(wrap.substr(0,wrap.find('?')));
884 if (i!=m_handlerMap.end())
886 return m_base ? m_base->getHandlers(path) : EMPTY(const IHandler*);
889 ReloadableXMLFileImpl* XMLConfig::newImplementation(const char* pathname, bool first) const
891 return new XMLConfigImpl(pathname,first,this);
894 ReloadableXMLFileImpl* XMLConfig::newImplementation(const DOMElement* e, bool first) const
896 return new XMLConfigImpl(e,first,this);
899 short XMLConfigImpl::acceptNode(const DOMNode* node) const
901 if (XMLString::compareString(node->getNamespaceURI(),shibtarget::XML::SHIBTARGET_NS))
902 return FILTER_ACCEPT;
903 const XMLCh* name=node->getLocalName();
904 if (!XMLString::compareString(name,SHIBT_L(Applications)) ||
905 !XMLString::compareString(name,SHIBT_L(AttributeFactory)) ||
906 !XMLString::compareString(name,SHIBT_L(CredentialsProvider)) ||
907 !XMLString::compareString(name,SHIBT_L(Extensions)) ||
908 !XMLString::compareString(name,SHIBT_L(Implementation)) ||
909 !XMLString::compareString(name,SHIBT_L(Listener)) ||
910 !XMLString::compareString(name,SHIBT_L(MemorySessionCache)) ||
911 !XMLString::compareString(name,SHIBT_L(MySQLReplayCache)) ||
912 !XMLString::compareString(name,SHIBT_L(MySQLSessionCache)) ||
913 !XMLString::compareString(name,SHIBT_L(RequestMap)) ||
914 !XMLString::compareString(name,SHIBT_L(RequestMapProvider)) ||
915 !XMLString::compareString(name,SHIBT_L(ReplayCache)) ||
916 !XMLString::compareString(name,SHIBT_L(SessionCache)) ||
917 !XMLString::compareString(name,SHIBT_L(TCPListener)) ||
918 !XMLString::compareString(name,SHIBT_L(UnixListener)))
919 return FILTER_REJECT;
921 return FILTER_ACCEPT;
924 void XMLConfigImpl::init(bool first)
927 saml::NDC ndc("init");
929 Category& log=Category::getInstance("shibtarget.Config");
932 if (!saml::XML::isElementNamed(ReloadableXMLFileImpl::m_root,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(ShibbolethTargetConfig)) &&
933 !saml::XML::isElementNamed(ReloadableXMLFileImpl::m_root,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(SPConfig))) {
934 log.error("Construction requires a valid configuration file: (conf:SPConfig as root element)");
935 throw ConfigurationException("Construction requires a valid configuration file: (conf:SPConfig as root element)");
938 SAMLConfig& shibConf=SAMLConfig::getConfig();
939 ShibTargetConfig& conf=ShibTargetConfig::getConfig();
940 const DOMElement* SHAR=saml::XML::getFirstChildElement(ReloadableXMLFileImpl::m_root,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(SHAR));
942 SHAR=saml::XML::getFirstChildElement(ReloadableXMLFileImpl::m_root,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Global));
944 SHAR=saml::XML::getFirstChildElement(ReloadableXMLFileImpl::m_root,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(OutOfProcess));
945 const DOMElement* SHIRE=saml::XML::getFirstChildElement(ReloadableXMLFileImpl::m_root,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(SHIRE));
947 SHIRE=saml::XML::getFirstChildElement(ReloadableXMLFileImpl::m_root,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Local));
949 SHIRE=saml::XML::getFirstChildElement(ReloadableXMLFileImpl::m_root,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(InProcess));
951 // Initialize log4cpp manually in order to redirect log messages as soon as possible.
952 if (conf.isEnabled(ShibTargetConfig::Logging)) {
953 const XMLCh* logger=NULL;
954 if (conf.isEnabled(ShibTargetConfig::OutOfProcess))
955 logger=SHAR->getAttributeNS(NULL,SHIBT_L(logger));
956 else if (conf.isEnabled(ShibTargetConfig::InProcess))
957 logger=SHIRE->getAttributeNS(NULL,SHIBT_L(logger));
958 if (!logger || !*logger)
959 logger=ReloadableXMLFileImpl::m_root->getAttributeNS(NULL,SHIBT_L(logger));
960 if (logger && *logger) {
961 auto_ptr_char logpath(logger);
962 log.debug("loading new logging configuration from (%s), check log destination for status of configuration",logpath.get());
964 PropertyConfigurator::configure(logpath.get());
966 catch (ConfigureFailure& e) {
967 log.error("Error reading logging configuration: %s",e.what());
972 // First load any property sets.
973 map<string,string> root_remap;
974 root_remap["SHAR"]="OutOfProcess";
975 root_remap["SHIRE"]="InProcess";
976 root_remap["Global"]="OutOfProcess";
977 root_remap["Local"]="InProcess";
978 load(ReloadableXMLFileImpl::m_root,log,this,&root_remap);
980 // Much of the processing can only occur on the first instantiation.
982 // Now load any extensions to insure any needed plugins are registered.
984 saml::XML::getFirstChildElement(ReloadableXMLFileImpl::m_root,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Extensions));
986 exts=saml::XML::getFirstChildElement(exts,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Library));
988 auto_ptr_char path(exts->getAttributeNS(NULL,SHIBT_L(path)));
990 SAMLConfig::getConfig().saml_register_extension(path.get(),exts);
991 log.debug("loaded global extension library %s",path.get());
993 catch (SAMLException& e) {
994 const XMLCh* fatal=exts->getAttributeNS(NULL,SHIBT_L(fatal));
995 if (fatal && (*fatal==chLatin_t || *fatal==chDigit_1)) {
996 log.fatal("unable to load mandatory global extension library %s: %s", path.get(), e.what());
1000 log.crit("unable to load optional global extension library %s: %s", path.get(), e.what());
1002 exts=saml::XML::getNextSiblingElement(exts,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Library));
1006 if (conf.isEnabled(ShibTargetConfig::OutOfProcess)) {
1007 exts=saml::XML::getFirstChildElement(SHAR,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Extensions));
1009 exts=saml::XML::getFirstChildElement(exts,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Library));
1011 auto_ptr_char path(exts->getAttributeNS(NULL,SHIBT_L(path)));
1013 SAMLConfig::getConfig().saml_register_extension(path.get(),exts);
1014 log.debug("loaded Global extension library %s",path.get());
1016 catch (SAMLException& e) {
1017 const XMLCh* fatal=exts->getAttributeNS(NULL,SHIBT_L(fatal));
1018 if (fatal && (*fatal==chLatin_t || *fatal==chDigit_1)) {
1019 log.fatal("unable to load mandatory Global extension library %s: %s", path.get(), e.what());
1023 log.crit("unable to load optional Global extension library %s: %s", path.get(), e.what());
1025 exts=saml::XML::getNextSiblingElement(exts,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Library));
1030 if (conf.isEnabled(ShibTargetConfig::InProcess)) {
1031 exts=saml::XML::getFirstChildElement(SHIRE,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Extensions));
1033 exts=saml::XML::getFirstChildElement(exts,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Library));
1035 auto_ptr_char path(exts->getAttributeNS(NULL,SHIBT_L(path)));
1037 SAMLConfig::getConfig().saml_register_extension(path.get(),exts);
1038 log.debug("loaded Local extension library %s",path.get());
1040 catch (SAMLException& e) {
1041 const XMLCh* fatal=exts->getAttributeNS(NULL,SHIBT_L(fatal));
1042 if (fatal && (*fatal==chLatin_t || *fatal==chDigit_1)) {
1043 log.fatal("unable to load mandatory Local extension library %s: %s", path.get(), e.what());
1047 log.crit("unable to load optional Local extension library %s: %s", path.get(), e.what());
1049 exts=saml::XML::getNextSiblingElement(exts,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Library));
1054 // Instantiate the Listener and SessionCache objects.
1055 if (conf.isEnabled(ShibTargetConfig::Listener)) {
1056 IPlugIn* plugin=NULL;
1057 exts=saml::XML::getFirstChildElement(SHAR,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(UnixListener));
1059 log.info("building Listener of type %s...",shibtarget::XML::UnixListenerType);
1060 plugin=shibConf.getPlugMgr().newPlugin(shibtarget::XML::UnixListenerType,exts);
1063 exts=saml::XML::getFirstChildElement(SHAR,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(TCPListener));
1065 log.info("building Listener of type %s...",shibtarget::XML::TCPListenerType);
1066 plugin=shibConf.getPlugMgr().newPlugin(shibtarget::XML::TCPListenerType,exts);
1069 exts=saml::XML::getFirstChildElement(SHAR,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Listener));
1071 auto_ptr_char type(exts->getAttributeNS(NULL,SHIBT_L(type)));
1072 log.info("building Listener of type %s...",type.get());
1073 plugin=shibConf.getPlugMgr().newPlugin(type.get(),exts);
1076 log.fatal("can't build Listener object, missing conf:Listener element?");
1077 throw ConfigurationException("can't build Listener object, missing conf:Listener element?");
1082 IListener* listen=dynamic_cast<IListener*>(plugin);
1084 m_outer->m_listener=listen;
1087 log.fatal("plugin was not a Listener object");
1088 throw UnsupportedExtensionException("plugin was not a Listener object");
1093 if (conf.isEnabled(ShibTargetConfig::Caching)) {
1094 IPlugIn* plugin=NULL;
1095 exts=saml::XML::getFirstChildElement(SHAR,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(MemorySessionCache));
1097 log.info("building Session Cache of type %s...",shibtarget::XML::MemorySessionCacheType);
1098 plugin=shibConf.getPlugMgr().newPlugin(shibtarget::XML::MemorySessionCacheType,exts);
1101 exts=saml::XML::getFirstChildElement(SHAR,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(MySQLSessionCache));
1103 log.info("building Session Cache of type %s...",shibtarget::XML::MySQLSessionCacheType);
1104 plugin=shibConf.getPlugMgr().newPlugin(shibtarget::XML::MySQLSessionCacheType,exts);
1107 exts=saml::XML::getFirstChildElement(SHAR,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(SessionCache));
1109 auto_ptr_char type(exts->getAttributeNS(NULL,SHIBT_L(type)));
1110 log.info("building Session Cache of type %s...",type.get());
1111 plugin=shibConf.getPlugMgr().newPlugin(type.get(),exts);
1114 log.fatal("can't build Session Cache object, missing conf:SessionCache element?");
1115 throw ConfigurationException("can't build Session Cache object, missing conf:SessionCache element?");
1120 ISessionCache* cache=dynamic_cast<ISessionCache*>(plugin);
1122 m_outer->m_sessionCache=cache;
1125 log.fatal("plugin was not a Session Cache object");
1126 throw UnsupportedExtensionException("plugin was not a Session Cache object");
1131 exts=saml::XML::getFirstChildElement(SHAR,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(MySQLReplayCache));
1133 log.info("building Replay Cache of type %s...",shibtarget::XML::MySQLReplayCacheType);
1134 m_outer->m_replayCache=IReplayCache::getInstance(shibtarget::XML::MySQLReplayCacheType,exts);
1137 exts=saml::XML::getFirstChildElement(SHAR,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(ReplayCache));
1139 auto_ptr_char type(exts->getAttributeNS(NULL,SHIBT_L(type)));
1140 log.info("building Replay Cache of type %s...",type.get());
1141 m_outer->m_replayCache=IReplayCache::getInstance(type.get(),exts);
1144 // OpenSAML default provider.
1145 log.info("building default Replay Cache...");
1146 m_outer->m_replayCache=IReplayCache::getInstance();
1152 // Back to the fully dynamic stuff...next up is the Request Mapper.
1153 if (conf.isEnabled(ShibTargetConfig::RequestMapper)) {
1154 const DOMElement* child=saml::XML::getFirstChildElement(SHIRE,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(RequestMapProvider));
1156 auto_ptr_char type(child->getAttributeNS(NULL,SHIBT_L(type)));
1157 log.info("building Request Mapper of type %s...",type.get());
1158 IPlugIn* plugin=shibConf.getPlugMgr().newPlugin(type.get(),child);
1160 IRequestMapper* reqmap=dynamic_cast<IRequestMapper*>(plugin);
1162 m_requestMapper=reqmap;
1165 log.fatal("plugin was not a Request Mapper object");
1166 throw UnsupportedExtensionException("plugin was not a Request Mapper object");
1171 log.fatal("can't build Request Mapper object, missing conf:RequestMapProvider element?");
1172 throw ConfigurationException("can't build Request Mapper object, missing conf:RequestMapProvider element?");
1176 // Now we load any credentials providers.
1178 if (conf.isEnabled(ShibTargetConfig::Credentials)) {
1179 nlist=ReloadableXMLFileImpl::m_root->getElementsByTagNameNS(shibtarget::XML::SHIBTARGET_NS,SHIBT_L(CredentialsProvider));
1180 for (unsigned int i=0; nlist && i<nlist->getLength(); i++) {
1181 auto_ptr_char type(static_cast<DOMElement*>(nlist->item(i))->getAttributeNS(NULL,SHIBT_L(type)));
1182 log.info("building credentials provider of type %s...",type.get());
1184 IPlugIn* plugin=shibConf.getPlugMgr().newPlugin(type.get(),static_cast<DOMElement*>(nlist->item(i)));
1186 ICredentials* creds=dynamic_cast<ICredentials*>(plugin);
1188 m_creds.push_back(creds);
1191 log.crit("plugin was not a credentials provider");
1195 catch (SAMLException& ex) {
1196 log.crit("error building credentials provider: %s",ex.what());
1201 // Now we load any attribute factories
1202 nlist=ReloadableXMLFileImpl::m_root->getElementsByTagNameNS(shibtarget::XML::SHIBTARGET_NS,SHIBT_L(AttributeFactory));
1203 for (unsigned int i=0; nlist && i<nlist->getLength(); i++) {
1204 auto_ptr_char type(static_cast<DOMElement*>(nlist->item(i))->getAttributeNS(NULL,SHIBT_L(type)));
1205 log.info("building Attribute factory of type %s...",type.get());
1207 IPlugIn* plugin=shibConf.getPlugMgr().newPlugin(type.get(),static_cast<DOMElement*>(nlist->item(i)));
1209 IAttributeFactory* fact=dynamic_cast<IAttributeFactory*>(plugin);
1211 m_attrFactories.push_back(fact);
1212 ShibConfig::getConfig().regAttributeMapping(
1213 static_cast<DOMElement*>(nlist->item(i))->getAttributeNS(NULL,L(AttributeName)),
1219 log.crit("plugin was not an Attribute factory");
1223 catch (SAMLException& ex) {
1224 log.crit("error building Attribute factory: %s",ex.what());
1228 // Load the default application. This actually has a fixed ID of "default". ;-)
1229 const DOMElement* app=saml::XML::getFirstChildElement(
1230 ReloadableXMLFileImpl::m_root,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Applications)
1233 log.fatal("can't build default Application object, missing conf:Applications element?");
1234 throw ConfigurationException("can't build default Application object, missing conf:Applications element?");
1236 XMLApplication* defapp=new XMLApplication(m_outer, m_creds, app);
1237 m_appmap[defapp->getId()]=defapp;
1239 // Load any overrides.
1240 nlist=app->getElementsByTagNameNS(shibtarget::XML::SHIBTARGET_NS,SHIBT_L(Application));
1241 for (unsigned int j=0; nlist && j<nlist->getLength(); j++) {
1242 auto_ptr<XMLApplication> iapp(new XMLApplication(m_outer,m_creds,static_cast<DOMElement*>(nlist->item(j)),defapp));
1243 if (m_appmap.find(iapp->getId())!=m_appmap.end())
1244 log.crit("found conf:Application element with duplicate Id attribute, ignoring it");
1246 m_appmap[iapp->getId()]=iapp.release();
1249 catch (SAMLException& e) {
1250 log.errorStream() << "Error while loading SP configuration: " << e.what() << CategoryStream::ENDLINE;
1255 log.error("Unexpected error while loading SP configuration");
1261 XMLConfigImpl::~XMLConfigImpl()
1263 delete m_requestMapper;
1264 for_each(m_appmap.begin(),m_appmap.end(),cleanup<string,IApplication>);
1265 for_each(m_creds.begin(),m_creds.end(),cleanup<ICredentials>);
1266 ShibConfig::getConfig().clearAttributeMappings();
1267 for_each(m_attrFactories.begin(),m_attrFactories.end(),cleanup<IAttributeFactory>);