X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=shibsp%2Fimpl%2FXMLServiceProvider.cpp;h=eeb3f38c74f10658654d5e88e0f549118b8a73f8;hb=bdbf27d150b92c16119a413abaad5294c800f4de;hp=0694abf2339488795acc05c7a6e0a77fb2ecc867;hpb=4aed3f0aff79e13df7c30d0400629c5bd2594c55;p=shibboleth%2Fsp.git diff --git a/shibsp/impl/XMLServiceProvider.cpp b/shibsp/impl/XMLServiceProvider.cpp index 0694abf..eeb3f38 100644 --- a/shibsp/impl/XMLServiceProvider.cpp +++ b/shibsp/impl/XMLServiceProvider.cpp @@ -95,11 +95,10 @@ namespace { SAML2Artifact* generateSAML2Artifact(const EntityDescriptor* relyingParty) const { pair index = make_pair(false,0); const PropertySet* props = getRelyingParty(relyingParty); - if (props) - index = getInt("artifactEndpointIndex"); + index = props->getInt("artifactEndpointIndex"); if (!index.first) index = getArtifactEndpointIndex(); - return new SAML2ArtifactType0004(SAMLConfig::getConfig().hashSHA1(getString("entityID").second),index.first ? index.second : 1); + return new SAML2ArtifactType0004(SAMLConfig::getConfig().hashSHA1(props->getString("entityID").second),index.first ? index.second : 1); } MetadataProvider* getMetadataProvider(bool required=true) const { @@ -125,13 +124,13 @@ namespace { return (!m_credResolver && m_base) ? m_base->getCredentialResolver() : m_credResolver; } const PropertySet* getRelyingParty(const EntityDescriptor* provider) const; - const vector& getAudiences() const { - return (m_audiences.empty() && m_base) ? m_base->getAudiences() : m_audiences; + const vector* getAudiences() const { + return (m_audiences.empty() && m_base) ? m_base->getAudiences() : &m_audiences; } #endif string getNotificationURL(const char* resource, bool front, unsigned int index) const; - const set& getRemoteUserAttributeIds() const { + const vector& getRemoteUserAttributeIds() const { return (m_remoteUsers.empty() && m_base) ? m_base->getRemoteUserAttributeIds() : m_remoteUsers; } @@ -172,15 +171,13 @@ namespace { vector m_audiences; // RelyingParty properties - DOMPropertySet* m_partyDefault; #ifdef HAVE_GOOD_STL map m_partyMap; #else map m_partyMap; #endif #endif - set m_remoteUsers; - vector m_frontLogout,m_backLogout; + vector m_remoteUsers,m_frontLogout,m_backLogout; // manage handler objects vector m_handlers; @@ -229,7 +226,7 @@ namespace { map m_appmap; #ifndef SHIBSP_LITE map< string,pair< PropertySet*,vector > > m_policyMap; - map< string, vector< pair< string, pair > > > m_transportOptionMap; + vector< pair< string, pair > > m_transportOptions; #endif // Provides filter to exclude special config elements. @@ -247,7 +244,10 @@ namespace { DOMDocument* m_document; }; - class SHIBSP_DLLLOCAL XMLConfig : public ServiceProvider, public ReloadableXMLFile, public Remoted + class SHIBSP_DLLLOCAL XMLConfig : public ServiceProvider, public ReloadableXMLFile +#ifndef SHIBSP_LITE + ,public Remoted +#endif { public: XMLConfig(const DOMElement* e) : ReloadableXMLFile(e, Category::getInstance(SHIBSP_LOGCAT".Config")), @@ -282,14 +282,15 @@ namespace { pair getXMLString(const char* name, const char* ns=NULL) const {return m_impl->getXMLString(name,ns);} pair getUnsignedInt(const char* name, const char* ns=NULL) const {return m_impl->getUnsignedInt(name,ns);} pair getInt(const char* name, const char* ns=NULL) const {return m_impl->getInt(name,ns);} + void getAll(map& properties) const {return m_impl->getAll(properties);} const PropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:2.0:native:sp:config") const {return m_impl->getPropertySet(name,ns);} const DOMElement* getElement() const {return m_impl->getElement();} + // ServiceProvider +#ifndef SHIBSP_LITE // Remoted void receive(DDF& in, ostream& out); - // ServiceProvider -#ifndef SHIBSP_LITE TransactionLog* getTransactionLog() const { if (m_tranLog) return m_tranLog; @@ -344,14 +345,10 @@ namespace { throw ConfigurationException("Security Policy ($1) not found, check element.", params(1,id)); } - bool setTransportOptions(const char* id, SOAPTransport& transport) const { + bool setTransportOptions(SOAPTransport& transport) const { bool ret = true; - map< string, vector< pair< string, pair > > >::const_iterator p = - m_impl->m_transportOptionMap.find(id); - if (p == m_impl->m_transportOptionMap.end()) - return ret; vector< pair< string, pair > >::const_iterator opt; - for (opt = p->second.begin(); opt != p->second.end(); ++opt) { + for (opt = m_impl->m_transportOptions.begin(); opt != m_impl->m_transportOptions.end(); ++opt) { if (!transport.setProviderOption(opt->first.c_str(), opt->second.first.c_str(), opt->second.second.c_str())) { m_log.error("failed to set SOAPTransport option (%s)", opt->second.first.c_str()); ret = false; @@ -379,8 +376,8 @@ namespace { #pragma warning( pop ) #endif - static const XMLCh _Application[] = UNICODE_LITERAL_11(A,p,p,l,i,c,a,t,i,o,n); - static const XMLCh Applications[] = UNICODE_LITERAL_12(A,p,p,l,i,c,a,t,i,o,n,s); + static const XMLCh ApplicationOverride[] = UNICODE_LITERAL_19(A,p,p,l,i,c,a,t,i,o,n,O,v,e,r,r,i,d,e); + static const XMLCh ApplicationDefaults[] = UNICODE_LITERAL_19(A,p,p,l,i,c,a,t,i,o,n,D,e,f,a,u,l,t,s); static const XMLCh _ArtifactMap[] = UNICODE_LITERAL_11(A,r,t,i,f,a,c,t,M,a,p); static const XMLCh _AttributeExtractor[] = UNICODE_LITERAL_18(A,t,t,r,i,b,u,t,e,E,x,t,r,a,c,t,o,r); static const XMLCh _AttributeFilter[] = UNICODE_LITERAL_15(A,t,t,r,i,b,u,t,e,F,i,l,t,e,r); @@ -391,12 +388,10 @@ namespace { static const XMLCh Binding[] = UNICODE_LITERAL_7(B,i,n,d,i,n,g); static const XMLCh Channel[]= UNICODE_LITERAL_7(C,h,a,n,n,e,l); static const XMLCh _CredentialResolver[] = UNICODE_LITERAL_18(C,r,e,d,e,n,t,i,a,l,R,e,s,o,l,v,e,r); - static const XMLCh DefaultRelyingParty[] = UNICODE_LITERAL_19(D,e,f,a,u,l,t,R,e,l,y,i,n,g,P,a,r,t,y); static const XMLCh _Extensions[] = UNICODE_LITERAL_10(E,x,t,e,n,s,i,o,n,s); static const XMLCh _fatal[] = UNICODE_LITERAL_5(f,a,t,a,l); static const XMLCh _Handler[] = UNICODE_LITERAL_7(H,a,n,d,l,e,r); static const XMLCh _id[] = UNICODE_LITERAL_2(i,d); - static const XMLCh Implementation[] = UNICODE_LITERAL_14(I,m,p,l,e,m,e,n,t,a,t,i,o,n); static const XMLCh InProcess[] = UNICODE_LITERAL_9(I,n,P,r,o,c,e,s,s); static const XMLCh Library[] = UNICODE_LITERAL_7(L,i,b,r,a,r,y); static const XMLCh Listener[] = UNICODE_LITERAL_8(L,i,s,t,e,n,e,r); @@ -404,7 +399,6 @@ namespace { static const XMLCh logger[] = UNICODE_LITERAL_6(l,o,g,g,e,r); static const XMLCh _LogoutInitiator[] = UNICODE_LITERAL_15(L,o,g,o,u,t,I,n,i,t,i,a,t,o,r); static const XMLCh _ManageNameIDService[] = UNICODE_LITERAL_19(M,a,n,a,g,e,N,a,m,e,I,D,S,e,r,v,i,c,e); - static const XMLCh MemoryListener[] = UNICODE_LITERAL_14(M,e,m,o,r,y,L,i,s,t,e,n,e,r); static const XMLCh _MetadataProvider[] = UNICODE_LITERAL_16(M,e,t,a,d,a,t,a,P,r,o,v,i,d,e,r); static const XMLCh Notify[] = UNICODE_LITERAL_6(N,o,t,i,f,y); static const XMLCh _option[] = UNICODE_LITERAL_6(o,p,t,i,o,n); @@ -420,6 +414,7 @@ namespace { static const XMLCh _SessionCache[] = UNICODE_LITERAL_12(S,e,s,s,i,o,n,C,a,c,h,e); static const XMLCh _SessionInitiator[] = UNICODE_LITERAL_16(S,e,s,s,i,o,n,I,n,i,t,i,a,t,o,r); static const XMLCh _SingleLogoutService[] = UNICODE_LITERAL_19(S,i,n,g,l,e,L,o,g,o,u,t,S,e,r,v,i,c,e); + static const XMLCh Site[] = UNICODE_LITERAL_4(S,i,t,e); static const XMLCh _StorageService[] = UNICODE_LITERAL_14(S,t,o,r,a,g,e,S,e,r,v,i,c,e); static const XMLCh TCPListener[] = UNICODE_LITERAL_11(T,C,P,L,i,s,t,e,n,e,r); static const XMLCh TransportOption[] = UNICODE_LITERAL_15(T,r,a,n,s,p,o,r,t,O,p,t,i,o,n); @@ -453,7 +448,7 @@ XMLApplication::XMLApplication( #ifndef SHIBSP_LITE m_metadata(NULL), m_trust(NULL), m_attrExtractor(NULL), m_attrFilter(NULL), m_attrResolver(NULL), - m_credResolver(NULL), m_partyDefault(NULL), + m_credResolver(NULL), #endif m_acsDefault(NULL), m_sessionInitDefault(NULL), m_artifactResolutionDefault(NULL) { @@ -464,7 +459,7 @@ XMLApplication::XMLApplication( try { // First load any property sets. - load(e,log,this); + load(e,NULL,this); if (base) setParent(base); @@ -498,7 +493,7 @@ XMLApplication::XMLApplication( pos = strchr(start,' '); if (pos) *pos=0; - m_remoteUsers.insert(start); + m_remoteUsers.push_back(start); start = pos ? pos+1 : NULL; } free(dup); @@ -558,7 +553,9 @@ XMLApplication::XMLApplication( static const XMLCh _acl[] = UNICODE_LITERAL_9(e,x,p,o,r,t,A,C,L); exportElement->setAttributeNS(NULL,_acl,exportACL.second); } - handler = conf.HandlerManager.newPlugin(samlconstants::SAML20_BINDING_URI, make_pair(exportElement, getId())); + handler = conf.HandlerManager.newPlugin( + samlconstants::SAML20_BINDING_URI, pair(exportElement, getId()) + ); m_handlers.push_back(handler); // Insert into location map. If it contains the handlerURL, we skip past that part. @@ -730,9 +727,6 @@ XMLApplication::XMLApplication( if (nlist->item(i)->getParentNode()->isSameNode(e) && nlist->item(i)->hasChildNodes()) m_audiences.push_back(nlist->item(i)->getFirstChild()->getNodeValue()); - // Always include our own entityID as an audience. - m_audiences.push_back(getXMLString("entityID").second); - if (conf.isEnabled(SPConfig::Metadata)) { child = XMLHelper::getFirstChildElement(e,_MetadataProvider); if (child) { @@ -858,18 +852,13 @@ XMLApplication::XMLApplication( } // Finally, load relying parties. - child = XMLHelper::getFirstChildElement(e,DefaultRelyingParty); - if (child) { - m_partyDefault=new DOMPropertySet(); - m_partyDefault->load(child,log,this); - child = XMLHelper::getFirstChildElement(child,RelyingParty); - while (child) { - auto_ptr rp(new DOMPropertySet()); - rp->load(child,log,this); - rp->setParent(m_partyDefault); - m_partyMap[child->getAttributeNS(NULL,saml2::Attribute::NAME_ATTRIB_NAME)]=rp.release(); - child = XMLHelper::getNextSiblingElement(child,RelyingParty); - } + child = XMLHelper::getFirstChildElement(e,RelyingParty); + while (child) { + auto_ptr rp(new DOMPropertySet()); + rp->load(child,NULL,this); + rp->setParent(this); + m_partyMap[child->getAttributeNS(NULL,saml2::Attribute::NAME_ATTRIB_NAME)]=rp.release(); + child = XMLHelper::getNextSiblingElement(child,RelyingParty); } #endif @@ -906,8 +895,6 @@ void XMLApplication::cleanup() for_each(m_handlers.begin(),m_handlers.end(),xmltooling::cleanup()); m_handlers.clear(); #ifndef SHIBSP_LITE - delete m_partyDefault; - m_partyDefault = NULL; #ifdef HAVE_GOOD_STL for_each(m_partyMap.begin(),m_partyMap.end(),cleanup_pair()); #else @@ -932,16 +919,16 @@ void XMLApplication::cleanup() short XMLApplication::acceptNode(const DOMNode* node) const { const XMLCh* name=node->getLocalName(); - if (XMLString::equals(name,_Application) || + if (XMLString::equals(name,ApplicationOverride) || XMLString::equals(name,_Audience) || XMLString::equals(name,Notify) || + XMLString::equals(name,_Handler) || XMLString::equals(name,_AssertionConsumerService) || XMLString::equals(name,_ArtifactResolutionService) || XMLString::equals(name,_LogoutInitiator) || XMLString::equals(name,_ManageNameIDService) || XMLString::equals(name,_SessionInitiator) || XMLString::equals(name,_SingleLogoutService) || - XMLString::equals(name,DefaultRelyingParty) || XMLString::equals(name,RelyingParty) || XMLString::equals(name,_MetadataProvider) || XMLString::equals(name,_TrustEngine) || @@ -958,10 +945,8 @@ short XMLApplication::acceptNode(const DOMNode* node) const const PropertySet* XMLApplication::getRelyingParty(const EntityDescriptor* provider) const { - if (!m_partyDefault && m_base) - return m_base->getRelyingParty(provider); - else if (!provider) - return m_partyDefault; + if (!provider) + return this; #ifdef HAVE_GOOD_STL map::const_iterator i=m_partyMap.find(provider->getEntityID()); @@ -989,7 +974,7 @@ const PropertySet* XMLApplication::getRelyingParty(const EntityDescriptor* provi } } #endif - return m_partyDefault; + return this; } #endif @@ -1130,18 +1115,18 @@ short XMLConfigImpl::acceptNode(const DOMNode* node) const if (!XMLString::equals(node->getNamespaceURI(),shibspconstants::SHIB2SPCONFIG_NS)) return FILTER_ACCEPT; const XMLCh* name=node->getLocalName(); - if (XMLString::equals(name,Applications) || + if (XMLString::equals(name,ApplicationDefaults) || XMLString::equals(name,_ArtifactMap) || XMLString::equals(name,_Extensions) || - XMLString::equals(name,Implementation) || XMLString::equals(name,Listener) || - XMLString::equals(name,MemoryListener) || - XMLString::equals(name,Policy) || XMLString::equals(name,_RequestMapper) || XMLString::equals(name,_ReplayCache) || + XMLString::equals(name,SecurityPolicies) || XMLString::equals(name,_SessionCache) || + XMLString::equals(name,Site) || XMLString::equals(name,_StorageService) || XMLString::equals(name,TCPListener) || + XMLString::equals(name,TransportOption) || XMLString::equals(name,UnixListener)) return FILTER_REJECT; @@ -1214,7 +1199,7 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o } // First load any property sets. - load(e,log,this); + load(e,NULL,this); const DOMElement* child; string plugtype; @@ -1236,30 +1221,25 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o // Instantiate the ListenerService and SessionCache objects. if (conf.isEnabled(SPConfig::Listener)) { - child=XMLHelper::getFirstChildElement(SHAR,UnixListener); + child=XMLHelper::getFirstChildElement(e,UnixListener); if (child) plugtype=UNIX_LISTENER_SERVICE; else { - child=XMLHelper::getFirstChildElement(SHAR,TCPListener); + child=XMLHelper::getFirstChildElement(e,TCPListener); if (child) plugtype=TCP_LISTENER_SERVICE; else { - child=XMLHelper::getFirstChildElement(SHAR,MemoryListener); - if (child) - plugtype=MEMORY_LISTENER_SERVICE; - else { - child=XMLHelper::getFirstChildElement(SHAR,Listener); - if (child) { - auto_ptr_char type(child->getAttributeNS(NULL,_type)); - if (type.get()) - plugtype=type.get(); - } + child=XMLHelper::getFirstChildElement(e,Listener); + if (child) { + auto_ptr_char type(child->getAttributeNS(NULL,_type)); + if (type.get()) + plugtype=type.get(); } } } if (child) { log.info("building ListenerService of type %s...", plugtype.c_str()); - m_outer->m_listener = conf.ListenerServiceManager.newPlugin(plugtype.c_str(),child); + m_outer->m_listener = conf.ListenerServiceManager.newPlugin(plugtype.c_str(), child); } else { log.fatal("can't build ListenerService, missing conf:Listener element?"); @@ -1267,54 +1247,34 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o } } +#ifndef SHIBSP_LITE if (m_outer->m_listener && conf.isEnabled(SPConfig::OutOfProcess) && !conf.isEnabled(SPConfig::InProcess)) { - m_outer->m_listener->regListener("set::RelayState",m_outer->m_listener); - m_outer->m_listener->regListener("get::RelayState",m_outer->m_listener); + m_outer->m_listener->regListener("set::RelayState", m_outer->m_listener); + m_outer->m_listener->regListener("get::RelayState", m_outer->m_listener); } +#endif if (conf.isEnabled(SPConfig::Caching)) { if (conf.isEnabled(SPConfig::OutOfProcess)) { #ifndef SHIBSP_LITE // First build any StorageServices. - string inmemID; - child=XMLHelper::getFirstChildElement(SHAR,_StorageService); + child=XMLHelper::getFirstChildElement(e,_StorageService); while (child) { auto_ptr_char id(child->getAttributeNS(NULL,_id)); auto_ptr_char type(child->getAttributeNS(NULL,_type)); try { log.info("building StorageService (%s) of type %s...", id.get(), type.get()); m_outer->m_storage[id.get()] = xmlConf.StorageServiceManager.newPlugin(type.get(),child); - if (!strcmp(type.get(),MEMORY_STORAGE_SERVICE)) - inmemID = id.get(); } catch (exception& ex) { log.crit("failed to instantiate StorageService (%s): %s", id.get(), ex.what()); } child=XMLHelper::getNextSiblingElement(child,_StorageService); } - - child=XMLHelper::getFirstChildElement(SHAR,_SessionCache); - if (child) { - auto_ptr_char type(child->getAttributeNS(NULL,_type)); - log.info("building SessionCache of type %s...",type.get()); - m_outer->m_sessionCache=conf.SessionCacheManager.newPlugin(type.get(),child); - } - else { - log.warn("SessionCache unspecified, building SessionCache of type %s...",STORAGESERVICE_SESSION_CACHE); - if (inmemID.empty()) { - inmemID = "memory"; - log.info("no StorageServices configured, providing in-memory version for session cache"); - m_outer->m_storage[inmemID] = xmlConf.StorageServiceManager.newPlugin(MEMORY_STORAGE_SERVICE,NULL); - } - child = e->getOwnerDocument()->createElementNS(NULL,_SessionCache); - auto_ptr_XMLCh ssid(inmemID.c_str()); - const_cast(child)->setAttributeNS(NULL,_StorageService,ssid.get()); - m_outer->m_sessionCache=conf.SessionCacheManager.newPlugin(STORAGESERVICE_SESSION_CACHE,child); - } // Replay cache. StorageService* replaySS=NULL; - child=XMLHelper::getFirstChildElement(SHAR,_ReplayCache); + child=XMLHelper::getFirstChildElement(e,_ReplayCache); if (child) { auto_ptr_char ssid(child->getAttributeNS(NULL,_StorageService)); if (ssid.get() && *ssid.get()) { @@ -1323,22 +1283,16 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o if (replaySS) log.info("building ReplayCache on top of StorageService (%s)...", ssid.get()); else - log.crit("unable to locate StorageService (%s) in configuration", ssid.get()); + log.warn("unable to locate StorageService (%s) for ReplayCache, using dedicated in-memory instance", ssid.get()); } + xmlConf.setReplayCache(new ReplayCache(replaySS)); } - if (!replaySS) { - log.info("building ReplayCache using in-memory StorageService..."); - if (inmemID.empty()) { - inmemID = "memory"; - log.info("no StorageServices configured, providing in-memory version for legacy config"); - m_outer->m_storage[inmemID] = xmlConf.StorageServiceManager.newPlugin(MEMORY_STORAGE_SERVICE,NULL); - } - replaySS = m_outer->m_storage[inmemID]; + else { + log.warn("no ReplayCache built, missing conf:ReplayCache element?"); } - xmlConf.setReplayCache(new ReplayCache(replaySS)); // ArtifactMap - child=XMLHelper::getFirstChildElement(SHAR,_ArtifactMap); + child=XMLHelper::getFirstChildElement(e,_ArtifactMap); if (child) { auto_ptr_char ssid(child->getAttributeNS(NULL,_StorageService)); if (ssid.get() && *ssid.get() && m_outer->m_storage.count(ssid.get())) { @@ -1352,29 +1306,31 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o } #endif } + child=XMLHelper::getFirstChildElement(e,_SessionCache); + if (child) { + auto_ptr_char type(child->getAttributeNS(NULL,_type)); + log.info("building SessionCache of type %s...",type.get()); + m_outer->m_sessionCache=conf.SessionCacheManager.newPlugin(type.get(), child); + } else { - child=XMLHelper::getFirstChildElement(SHIRE,_SessionCache); - if (child) { - auto_ptr_char type(child->getAttributeNS(NULL,_type)); - log.info("building SessionCache of type %s...",type.get()); - m_outer->m_sessionCache=conf.SessionCacheManager.newPlugin(type.get(),child); - } - else { - log.warn("SessionCache unspecified, building SessionCache of type %s...",REMOTED_SESSION_CACHE); - m_outer->m_sessionCache=conf.SessionCacheManager.newPlugin(REMOTED_SESSION_CACHE,child); - } + log.fatal("can't build SessionCache, missing conf:SessionCache element?"); + throw ConfigurationException("Can't build SessionCache, missing conf:SessionCache element?"); } } } // end of first-time-only stuff // Back to the fully dynamic stuff...next up is the RequestMapper. if (conf.isEnabled(SPConfig::RequestMapping)) { - child=XMLHelper::getFirstChildElement(SHIRE,_RequestMapper); + child=XMLHelper::getFirstChildElement(e,_RequestMapper); if (child) { auto_ptr_char type(child->getAttributeNS(NULL,_type)); log.info("building RequestMapper of type %s...",type.get()); m_requestMapper=conf.RequestMapperManager.newPlugin(type.get(),child); } + else { + log.fatal("can't build RequestMapper, missing conf:RequestMapper element?"); + throw ConfigurationException("Can't build RequestMapper, missing conf:RequestMapper element?"); + } } #ifndef SHIBSP_LITE @@ -1388,7 +1344,7 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o pair< PropertySet*,vector >& rules = m_policyMap[id.get()]; rules.first = NULL; auto_ptr settings(new DOMPropertySet()); - settings->load(child, log, &filter); + settings->load(child, NULL, &filter); rules.first = settings.release(); // Process Rule elements. @@ -1404,58 +1360,50 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o rule = XMLHelper::getNextSiblingElement(rule,Rule); } - // Process TransportOption elements. - rule = XMLHelper::getFirstChildElement(child,TransportOption); - while (rule) { - if (rule->hasChildNodes()) { - auto_ptr_char provider(rule->getAttributeNS(NULL,_provider)); - auto_ptr_char option(rule->getAttributeNS(NULL,_option)); - auto_ptr_char value(rule->getFirstChild()->getNodeValue()); - if (provider.get() && *provider.get() && option.get() && *option.get() && value.get() && *value.get()) { - m_transportOptionMap[id.get()].push_back( - make_pair(provider.get(), make_pair(option.get(), value.get())) - ); - } - } - rule = XMLHelper::getNextSiblingElement(rule,TransportOption); - } - child = XMLHelper::getNextSiblingElement(child,Policy); } } + + // Process TransportOption elements. + child = XMLHelper::getLastChildElement(e,TransportOption); + while (child) { + if (child->hasChildNodes()) { + auto_ptr_char provider(child->getAttributeNS(NULL,_provider)); + auto_ptr_char option(child->getAttributeNS(NULL,_option)); + auto_ptr_char value(child->getFirstChild()->getNodeValue()); + if (provider.get() && *provider.get() && option.get() && *option.get() && value.get() && *value.get()) { + m_transportOptions.push_back(make_pair(string(provider.get()), make_pair(string(option.get()), string(value.get())))); + } + } + child = XMLHelper::getPreviousSiblingElement(child,TransportOption); + } #endif // Load the default application. This actually has a fixed ID of "default". ;-) - child=XMLHelper::getLastChildElement(e,Applications); + child=XMLHelper::getLastChildElement(e,ApplicationDefaults); if (!child) { - log.fatal("can't build default Application object, missing conf:Applications element?"); - throw ConfigurationException("can't build default Application object, missing conf:Applications element?"); + log.fatal("can't build default Application object, missing conf:ApplicationDefaults element?"); + throw ConfigurationException("can't build default Application object, missing conf:ApplicationDefaults element?"); } XMLApplication* defapp=new XMLApplication(m_outer,child); m_appmap[defapp->getId()]=defapp; // Load any overrides. - child = XMLHelper::getFirstChildElement(child,_Application); + child = XMLHelper::getFirstChildElement(child,ApplicationOverride); while (child) { auto_ptr iapp(new XMLApplication(m_outer,child,defapp)); if (m_appmap.count(iapp->getId())) - log.crit("found conf:Application element with duplicate id attribute (%s), skipping it", iapp->getId()); + log.crit("found conf:ApplicationOverride element with duplicate id attribute (%s), skipping it", iapp->getId()); else m_appmap[iapp->getId()]=iapp.release(); - child = XMLHelper::getNextSiblingElement(child,_Application); + child = XMLHelper::getNextSiblingElement(child,ApplicationOverride); } } catch (exception&) { cleanup(); throw; } -#ifndef _DEBUG - catch (...) { - cleanup(); - throw; - } -#endif } XMLConfigImpl::~XMLConfigImpl() @@ -1481,9 +1429,9 @@ void XMLConfigImpl::cleanup() m_document = NULL; } +#ifndef SHIBSP_LITE void XMLConfig::receive(DDF& in, ostream& out) { -#ifndef SHIBSP_LITE if (!strcmp(in.name(), "get::RelayState")) { const char* id = in["id"].string(); const char* key = in["key"].string(); @@ -1533,8 +1481,8 @@ void XMLConfig::receive(DDF& in, ostream& out) DDFJanitor jret(ret); out << ret; } -#endif } +#endif pair XMLConfig::load() {