return new htAccessControl();
}
-class ApacheRequestMapper : public virtual IRequestMapper, public virtual IPropertySet
+class ApacheRequestMapper : public virtual IRequestMapper, public virtual PropertySet
{
public:
ApacheRequestMapper(const DOMElement* e);
pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const;
pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const;
pair<bool,int> getInt(const char* name, const char* ns=NULL) const;
- const IPropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
+ const PropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
const DOMElement* getElement() const;
private:
Settings s=m_mapper->getSettings(st);
m_staKey->setData(dynamic_cast<ShibTargetApache*>(st));
m_propsKey->setData((void*)s.first);
- return pair<const IPropertySet*,IAccessControl*>(this,s.second ? s.second : m_htaccess);
+ return pair<const PropertySet*,IAccessControl*>(this,s.second ? s.second : m_htaccess);
}
pair<bool,bool> ApacheRequestMapper::getBool(const char* name, const char* ns) const
{
ShibTargetApache* sta=reinterpret_cast<ShibTargetApache*>(m_staKey->getData());
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
if (sta && !ns) {
// Override Apache-settable boolean properties.
if (name && !strcmp(name,"requireSession") && sta->m_dc->bRequireSession==1)
pair<bool,const char*> ApacheRequestMapper::getString(const char* name, const char* ns) const
{
ShibTargetApache* sta=reinterpret_cast<ShibTargetApache*>(m_staKey->getData());
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
if (sta && !ns) {
// Override Apache-settable string properties.
if (name && !strcmp(name,"authType")) {
pair<bool,const XMLCh*> ApacheRequestMapper::getXMLString(const char* name, const char* ns) const
{
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
return s ? s->getXMLString(name,ns) : pair<bool,const XMLCh*>(false,NULL);
}
pair<bool,unsigned int> ApacheRequestMapper::getUnsignedInt(const char* name, const char* ns) const
{
ShibTargetApache* sta=reinterpret_cast<ShibTargetApache*>(m_staKey->getData());
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
if (sta && !ns) {
// Override Apache-settable int properties.
if (name && !strcmp(name,"redirectToSSL") && sta->m_dc->szRedirectToSSL)
pair<bool,int> ApacheRequestMapper::getInt(const char* name, const char* ns) const
{
ShibTargetApache* sta=reinterpret_cast<ShibTargetApache*>(m_staKey->getData());
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
if (sta && !ns) {
// Override Apache-settable int properties.
if (name && !strcmp(name,"redirectToSSL") && sta->m_dc->szRedirectToSSL)
return s ? s->getInt(name,ns) : pair<bool,int>(false,0);
}
-const IPropertySet* ApacheRequestMapper::getPropertySet(const char* name, const char* ns) const
+const PropertySet* ApacheRequestMapper::getPropertySet(const char* name, const char* ns) const
{
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
return s ? s->getPropertySet(name,ns) : NULL;
}
const DOMElement* ApacheRequestMapper::getElement() const
{
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
return s ? s->getElement() : NULL;
}
IConfig* conf=g_Config->getINI();
Locker locker(conf);
- const IPropertySet* props=conf->getPropertySet("Local");
+ const PropertySet* props=conf->getPropertySet("Local");
if (props) {
pair<bool,const char*> unsetValue=props->getString("unsetHeaderValue");
if (unsetValue.first)
// Access the implementation-specifics for site mappings.
IConfig* conf=g_Config->getINI();
Locker locker(conf);
- const IPropertySet* props=conf->getPropertySet("Local");
+ const PropertySet* props=conf->getPropertySet("Local");
if (props) {
const DOMElement* impl=saml::XML::getFirstChildElement(
props->getElement(),shibtarget::XML::SHIBTARGET_NS,Implementation
}
-class SunRequestMapper : public virtual IRequestMapper, public virtual IPropertySet
+class SunRequestMapper : public virtual IRequestMapper, public virtual PropertySet
{
public:
SunRequestMapper(const DOMElement* e);
pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const;
pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const;
pair<bool,int> getInt(const char* name, const char* ns=NULL) const;
- const IPropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
+ const PropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
const DOMElement* getElement() const;
private:
Settings s=m_mapper->getSettings(st);
m_stKey->setData(dynamic_cast<ShibTargetNSAPI*>(st));
m_propsKey->setData((void*)s.first);
- return pair<const IPropertySet*,IAccessControl*>(this,s.second);
+ return pair<const PropertySet*,IAccessControl*>(this,s.second);
}
pair<bool,bool> SunRequestMapper::getBool(const char* name, const char* ns) const
{
ShibTargetNSAPI* stn=reinterpret_cast<ShibTargetNSAPI*>(m_stKey->getData());
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
if (stn && !ns && name) {
// Override boolean properties.
const char* param=pblock_findval(name,stn->m_pb);
pair<bool,const char*> SunRequestMapper::getString(const char* name, const char* ns) const
{
ShibTargetNSAPI* stn=reinterpret_cast<ShibTargetNSAPI*>(m_stKey->getData());
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
if (stn && !ns && name) {
// Override string properties.
if (!strcmp(name,"authType"))
pair<bool,const XMLCh*> SunRequestMapper::getXMLString(const char* name, const char* ns) const
{
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
return s ? s->getXMLString(name,ns) : pair<bool,const XMLCh*>(false,NULL);
}
pair<bool,unsigned int> SunRequestMapper::getUnsignedInt(const char* name, const char* ns) const
{
ShibTargetNSAPI* stn=reinterpret_cast<ShibTargetNSAPI*>(m_stKey->getData());
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
if (stn && !ns && name) {
// Override int properties.
const char* param=pblock_findval(name,stn->m_pb);
pair<bool,int> SunRequestMapper::getInt(const char* name, const char* ns) const
{
ShibTargetNSAPI* stn=reinterpret_cast<ShibTargetNSAPI*>(m_stKey->getData());
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
if (stn && !ns && name) {
// Override int properties.
const char* param=pblock_findval(name,stn->m_pb);
return s ? s->getInt(name,ns) : pair<bool,int>(false,0);
}
-const IPropertySet* SunRequestMapper::getPropertySet(const char* name, const char* ns) const
+const PropertySet* SunRequestMapper::getPropertySet(const char* name, const char* ns) const
{
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
return s ? s->getPropertySet(name,ns) : NULL;
}
const DOMElement* SunRequestMapper::getElement() const
{
- const IPropertySet* s=reinterpret_cast<const IPropertySet*>(m_propsKey->getData());
+ const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
return s ? s->getElement() : NULL;
}
#include "internal.h"
-using namespace std;
-using namespace log4cpp;
-using namespace saml;
-using namespace shibboleth;
+using namespace shibsp;
using namespace shibtarget;
+using namespace shibboleth;
+using namespace saml;
+using namespace log4cpp;
+using namespace std;
SAMLResponse* STArtifactMapper::resolve(SAMLRequest* request)
{
log.info("lookup succeeded, artifact issued by (%s)", issuer.get());
// Sign it?
- const IPropertySet* credUse=m_app->getCredentialUse(entity);
+ const PropertySet* credUse=m_app->getCredentialUse(entity);
pair<bool,bool> signRequest=credUse ? credUse->getBool("signRequest") : make_pair(false,false);
pair<bool,const char*> signatureAlg=credUse ? credUse->getString("signatureAlg") : pair<bool,const char*>(false,NULL);
if (!signatureAlg.first)
#include <openssl/ssl.h>
#include <openssl/x509_vfy.h>
-using namespace std;
-using namespace log4cpp;
+using namespace shibsp;
using namespace shibtarget;
using namespace shibboleth;
using namespace saml;
+using namespace log4cpp;
+using namespace std;
/*
* Our verifier callback is a front-end for invoking each trust plugin until
try {
log.debug("OpenSAML invoked SSL context callback");
ShibHTTPHook::ShibHTTPHookCallContext* ctx = reinterpret_cast<ShibHTTPHook::ShibHTTPHookCallContext*>(userptr);
- const IPropertySet* credUse=ctx->getCredentialUse();
+ const PropertySet* credUse=ctx->getCredentialUse();
pair<bool,const char*> TLS=credUse ? credUse->getString("TLS") : pair<bool,const char*>(false,NULL);
if (TLS.first) {
Credentials c(ctx->getHook()->getCredentialProviders());
return false;
// Check for HTTP authentication...
- const IPropertySet* credUse=reinterpret_cast<ShibHTTPHookCallContext*>(callCtx)->getCredentialUse();
+ const PropertySet* credUse=reinterpret_cast<ShibHTTPHookCallContext*>(callCtx)->getCredentialUse();
pair<bool,const char*> authType=credUse ? credUse->getString("authType") : pair<bool,const char*>(false,NULL);
if (authType.first) {
#ifdef _DEBUG
#include <algorithm>
#include <log4cpp/Category.hh>
+#include <shibsp/DOMPropertySet.h>
-using namespace std;
-using namespace log4cpp;
-using namespace saml;
-using namespace shibboleth;
+using namespace shibsp;
using namespace shibtarget;
+using namespace shibboleth;
+using namespace saml;
+using namespace log4cpp;
+using namespace std;
namespace shibtarget {
- class Override : public XMLPropertySet, public DOMNodeFilter
+ class Override : public DOMPropertySet, public DOMNodeFilter
{
public:
Override() : m_base(NULL), m_acl(NULL) {}
Override(const DOMElement* e, Category& log, const Override* base=NULL);
~Override();
- // IPropertySet
+ // PropertySet
pair<bool,bool> getBool(const char* name, const char* ns=NULL) const;
pair<bool,const char*> getString(const char* name, const char* ns=NULL) const;
pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const;
pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const;
pair<bool,int> getInt(const char* name, const char* ns=NULL) const;
- const IPropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
+ const PropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
// Provides filter to exclude special config elements.
short acceptNode(const DOMNode* node) const;
pair<bool,bool> Override::getBool(const char* name, const char* ns) const
{
- pair<bool,bool> ret=XMLPropertySet::getBool(name,ns);
+ pair<bool,bool> ret=DOMPropertySet::getBool(name,ns);
if (ret.first)
return ret;
return m_base ? m_base->getBool(name,ns) : ret;
pair<bool,const char*> Override::getString(const char* name, const char* ns) const
{
- pair<bool,const char*> ret=XMLPropertySet::getString(name,ns);
+ pair<bool,const char*> ret=DOMPropertySet::getString(name,ns);
if (ret.first)
return ret;
return m_base ? m_base->getString(name,ns) : ret;
pair<bool,const XMLCh*> Override::getXMLString(const char* name, const char* ns) const
{
- pair<bool,const XMLCh*> ret=XMLPropertySet::getXMLString(name,ns);
+ pair<bool,const XMLCh*> ret=DOMPropertySet::getXMLString(name,ns);
if (ret.first)
return ret;
return m_base ? m_base->getXMLString(name,ns) : ret;
pair<bool,unsigned int> Override::getUnsignedInt(const char* name, const char* ns) const
{
- pair<bool,unsigned int> ret=XMLPropertySet::getUnsignedInt(name,ns);
+ pair<bool,unsigned int> ret=DOMPropertySet::getUnsignedInt(name,ns);
if (ret.first)
return ret;
return m_base ? m_base->getUnsignedInt(name,ns) : ret;
pair<bool,int> Override::getInt(const char* name, const char* ns) const
{
- pair<bool,int> ret=XMLPropertySet::getInt(name,ns);
+ pair<bool,int> ret=DOMPropertySet::getInt(name,ns);
if (ret.first)
return ret;
return m_base ? m_base->getInt(name,ns) : ret;
}
-const IPropertySet* Override::getPropertySet(const char* name, const char* ns) const
+const PropertySet* Override::getPropertySet(const char* name, const char* ns) const
{
- const IPropertySet* ret=XMLPropertySet::getPropertySet(name,ns);
+ const PropertySet* ret=DOMPropertySet::getPropertySet(name,ns);
if (ret || !m_base)
return ret;
return m_base->getPropertySet(name,ns);
if (impl->log->isDebugEnabled()) {
#ifdef _DEBUG
- saml::NDC ndc("getSettings");
+ NDC ndc("getSettings");
#endif
pair<bool,const char*> ret=o->getString("applicationId");
impl->log->debug("mapped %s%s to %s", vhost.str().c_str(), st->getRequestURI() ? st->getRequestURI() : "", ret.second);
#define SHIBTRAN_LOGCAT "Shibboleth-TRANSACTION"
namespace shibtarget {
- // Generic class, which handles the IPropertySet configuration interface.
- // Most of the basic configuration details are exposed via this interface.
- // This implementation extracts the XML tree structure and caches it in a map
- // with the attributes stored in the various possible formats they might be fetched.
- // Elements are treated as nested IPropertySets.
- // The "trick" to this is to pass in an "exclude list" using a DOMNodeFilter. Nested
- // property sets are extracted by running a TreeWalker againt the filter for the
- // immediate children. The filter should skip any excluded elements that will be
- // processed separately.
- class XMLPropertySet : public virtual IPropertySet
- {
- public:
- XMLPropertySet() {}
- ~XMLPropertySet();
-
- std::pair<bool,bool> getBool(const char* name, const char* ns=NULL) const;
- std::pair<bool,const char*> getString(const char* name, const char* ns=NULL) const;
- std::pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const;
- std::pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const;
- std::pair<bool,int> getInt(const char* name, const char* ns=NULL) const;
- const IPropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
- const DOMElement* getElement() const {return m_root;}
-
- void load(
- const DOMElement* e, // root element of property set
- log4cpp::Category& log, // log object for tracing
- DOMNodeFilter* filter, // control what subelements to include
- const std::map<std::string,std::string>* remapper=NULL // on the fly property renaming for legacy support
- );
-
- private:
- const DOMElement* m_root;
- std::map<std::string,std::pair<char*,const XMLCh*> > m_map;
- std::map<std::string,IPropertySet*> m_nested;
- };
-
// ST-aware class that maps SAML artifacts to appropriate binding information
class STArtifactMapper : public virtual saml::SAMLBrowserProfile::ArtifactMapper
{
// Obtain validation rules from application settings.
bool consistentIPAddress=true;
int lifetime=0,timeout=0;
- const IPropertySet* props=app->getPropertySet("Sessions");
+ const PropertySet* props=app->getPropertySet("Sessions");
if (props) {
pair<bool,unsigned int> p=props->getUnsignedInt("lifetime");
if (p.first)
}
// Get protocol signing policy.
- const IPropertySet* credUse=application->getCredentialUse(source);
+ const PropertySet* credUse=application->getCredentialUse(source);
pair<bool,bool> signRequest=credUse ? credUse->getBool("signRequest") : make_pair(false,false);
pair<bool,const char*> signatureAlg=credUse ? credUse->getString("signatureAlg") : pair<bool,const char*>(false,NULL);
if (!signatureAlg.first)
pair<bool,bool> checkAddress=pair<bool,bool>(false,true);
pair<bool,bool> checkReplay=pair<bool,bool>(false,true);
- const IPropertySet* props=app->getPropertySet("Sessions");
+ const PropertySet* props=app->getPropertySet("Sessions");
if (props) {
checkAddress=props->getBool("checkAddress");
if (!checkAddress.first)
const char* providerId=out["provider_id"].string();
if (providerId) {
- const IPropertySet* sessionProps=st->getApplication()->getPropertySet("Sessions");
+ const PropertySet* sessionProps=st->getApplication()->getPropertySet("Sessions");
pair<bool,bool> idpHistory=sessionProps->getBool("idpHistory");
if (!idpHistory.first || idpHistory.second) {
// Set an IdP history cookie locally (essentially just a CDC).
#include "internal.h"
+#include <shibsp/DOMPropertySet.h>
#include <shibsp/SPConfig.h>
#include <log4cpp/Category.hh>
#include <log4cpp/PropertyConfigurator.hh>
namespace shibtarget {
// Application configuration wrapper
- class XMLApplication : public virtual IApplication, public XMLPropertySet, public DOMNodeFilter
+ class XMLApplication : public virtual IApplication, public DOMPropertySet, public DOMNodeFilter
{
public:
XMLApplication(const IConfig*, const Iterator<ICredentials*>& creds, const DOMElement* e, const XMLApplication* base=NULL);
~XMLApplication() { cleanup(); }
- // IPropertySet
+ // PropertySet
pair<bool,bool> getBool(const char* name, const char* ns=NULL) const;
pair<bool,const char*> getString(const char* name, const char* ns=NULL) const;
pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const;
pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const;
pair<bool,int> getInt(const char* name, const char* ns=NULL) const;
- const IPropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
+ const PropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
// IApplication
const char* getId() const {return getString("id").second;}
Iterator<IMetadata*> getMetadataProviders() const;
Iterator<ITrust*> getTrustProviders() const;
Iterator<const XMLCh*> getAudiences() const;
- const IPropertySet* getCredentialUse(const IEntityDescriptor* provider) const;
+ const PropertySet* getCredentialUse(const IEntityDescriptor* provider) const;
const SAMLBrowserProfile* getBrowserProfile() const {return m_profile;}
const SAMLBinding* getBinding(const XMLCh* binding) const
{return XMLString::compareString(SAMLBinding::SOAP,binding) ? NULL : m_binding;}
// vectors manage object life for handlers and their property sets
vector<IHandler*> m_handlers;
- vector<XMLPropertySet*> m_handlerProps;
+ vector<PropertySet*> m_handlerProps;
// maps location (path info) to applicable handlers
map<string,const IHandler*> m_handlerMap;
// pointer to default session initiator
const IHandler* m_sessionInitDefault;
- XMLPropertySet* m_credDefault;
+ DOMPropertySet* m_credDefault;
#ifdef HAVE_GOOD_STL
- map<xstring,XMLPropertySet*> m_credMap;
+ map<xstring,PropertySet*> m_credMap;
#else
- map<const XMLCh*,XMLPropertySet*> m_credMap;
+ map<const XMLCh*,PropertySet*> m_credMap;
#endif
};
// Top-level configuration implementation
class XMLConfig;
- class XMLConfigImpl : public ReloadableXMLFileImpl, public XMLPropertySet, public DOMNodeFilter
+ class XMLConfigImpl : public ReloadableXMLFileImpl, public DOMPropertySet, public DOMNodeFilter
{
public:
XMLConfigImpl(const char* pathname, bool first, const XMLConfig* outer)
void init() { getImplementation(); }
- // IPropertySet
+ // PropertySet
pair<bool,bool> getBool(const char* name, const char* ns=NULL) const {return static_cast<XMLConfigImpl*>(m_impl)->getBool(name,ns);}
pair<bool,const char*> getString(const char* name, const char* ns=NULL) const {return static_cast<XMLConfigImpl*>(m_impl)->getString(name,ns);}
pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const {return static_cast<XMLConfigImpl*>(m_impl)->getXMLString(name,ns);}
pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const {return static_cast<XMLConfigImpl*>(m_impl)->getUnsignedInt(name,ns);}
pair<bool,int> getInt(const char* name, const char* ns=NULL) const {return static_cast<XMLConfigImpl*>(m_impl)->getInt(name,ns);}
- 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);}
+ const PropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const {return static_cast<XMLConfigImpl*>(m_impl)->getPropertySet(name,ns);}
const DOMElement* getElement() const {return static_cast<XMLConfigImpl*>(m_impl)->getElement();}
// IConfig
return new XMLConfig(e);
}
-XMLPropertySet::~XMLPropertySet()
-{
- for (map<string,pair<char*,const XMLCh*> >::iterator i=m_map.begin(); i!=m_map.end(); i++)
- XMLString::release(&(i->second.first));
- for_each(m_nested.begin(),m_nested.end(),xmltooling::cleanup_pair<string,IPropertySet>());
-}
-
-void XMLPropertySet::load(
- const DOMElement* e,
- Category& log,
- DOMNodeFilter* filter,
- const std::map<std::string,std::string>* remapper
- )
-{
-#ifdef _DEBUG
- saml::NDC ndc("load");
-#endif
- m_root=e;
-
- // Process each attribute as a property.
- DOMNamedNodeMap* attrs=m_root->getAttributes();
- for (XMLSize_t i=0; i<attrs->getLength(); i++) {
- DOMNode* a=attrs->item(i);
- if (!XMLString::compareString(a->getNamespaceURI(),saml::XML::XMLNS_NS))
- continue;
- char* val=XMLString::transcode(a->getNodeValue());
- if (val && *val) {
- auto_ptr_char ns(a->getNamespaceURI());
- auto_ptr_char name(a->getLocalName());
- const char* realname=name.get();
- if (remapper) {
- map<string,string>::const_iterator remap=remapper->find(realname);
- if (remap!=remapper->end()) {
- log.warn("remapping property (%s) to (%s)",realname,remap->second.c_str());
- realname=remap->second.c_str();
- }
- }
- if (ns.get()) {
- m_map[string("{") + ns.get() + '}' + realname]=pair<char*,const XMLCh*>(val,a->getNodeValue());
- log.debug("added property {%s}%s (%s)",ns.get(),realname,val);
- }
- else {
- m_map[realname]=pair<char*,const XMLCh*>(val,a->getNodeValue());
- log.debug("added property %s (%s)",realname,val);
- }
- }
- }
-
- // Process non-excluded elements as nested sets.
- DOMTreeWalker* walker=
- static_cast<DOMDocumentTraversal*>(
- m_root->getOwnerDocument())->createTreeWalker(const_cast<DOMElement*>(m_root),DOMNodeFilter::SHOW_ELEMENT,filter,false
- );
- e=static_cast<DOMElement*>(walker->firstChild());
- while (e) {
- auto_ptr_char ns(e->getNamespaceURI());
- auto_ptr_char name(e->getLocalName());
- const char* realname=name.get();
- if (remapper) {
- map<string,string>::const_iterator remap=remapper->find(realname);
- if (remap!=remapper->end()) {
- log.warn("remapping property set (%s) to (%s)",realname,remap->second.c_str());
- realname=remap->second.c_str();
- }
- }
- string key;
- if (ns.get())
- key=string("{") + ns.get() + '}' + realname;
- else
- key=realname;
- if (m_nested.find(key)!=m_nested.end())
- log.warn("load() skipping duplicate property set: %s",key.c_str());
- else {
- XMLPropertySet* set=new XMLPropertySet();
- set->load(e,log,filter,remapper);
- m_nested[key]=set;
- log.debug("added nested property set: %s",key.c_str());
- }
- e=static_cast<DOMElement*>(walker->nextSibling());
- }
- walker->release();
-}
-
-pair<bool,bool> XMLPropertySet::getBool(const char* name, const char* ns) const
-{
- pair<bool,bool> ret(false,false);
- map<string,pair<char*,const XMLCh*> >::const_iterator i;
-
- if (ns)
- i=m_map.find(string("{") + ns + '}' + name);
- else
- i=m_map.find(name);
-
- if (i!=m_map.end()) {
- ret.first=true;
- ret.second=(!strcmp(i->second.first,"true") || !strcmp(i->second.first,"1"));
- }
- return ret;
-}
-
-pair<bool,const char*> XMLPropertySet::getString(const char* name, const char* ns) const
-{
- pair<bool,const char*> ret(false,NULL);
- map<string,pair<char*,const XMLCh*> >::const_iterator i;
-
- if (ns)
- i=m_map.find(string("{") + ns + '}' + name);
- else
- i=m_map.find(name);
-
- if (i!=m_map.end()) {
- ret.first=true;
- ret.second=i->second.first;
- }
- return ret;
-}
-
-pair<bool,const XMLCh*> XMLPropertySet::getXMLString(const char* name, const char* ns) const
-{
- pair<bool,const XMLCh*> ret(false,NULL);
- map<string,pair<char*,const XMLCh*> >::const_iterator i;
-
- if (ns)
- i=m_map.find(string("{") + ns + '}' + name);
- else
- i=m_map.find(name);
-
- if (i!=m_map.end()) {
- ret.first=true;
- ret.second=i->second.second;
- }
- return ret;
-}
-
-pair<bool,unsigned int> XMLPropertySet::getUnsignedInt(const char* name, const char* ns) const
-{
- pair<bool,unsigned int> ret(false,0);
- map<string,pair<char*,const XMLCh*> >::const_iterator i;
-
- if (ns)
- i=m_map.find(string("{") + ns + '}' + name);
- else
- i=m_map.find(name);
-
- if (i!=m_map.end()) {
- ret.first=true;
- ret.second=strtol(i->second.first,NULL,10);
- }
- return ret;
-}
-
-pair<bool,int> XMLPropertySet::getInt(const char* name, const char* ns) const
-{
- pair<bool,int> ret(false,0);
- map<string,pair<char*,const XMLCh*> >::const_iterator i;
-
- if (ns)
- i=m_map.find(string("{") + ns + '}' + name);
- else
- i=m_map.find(name);
-
- if (i!=m_map.end()) {
- ret.first=true;
- ret.second=atoi(i->second.first);
- }
- return ret;
-}
-
-const IPropertySet* XMLPropertySet::getPropertySet(const char* name, const char* ns) const
-{
- map<string,IPropertySet*>::const_iterator i;
-
- if (ns)
- i=m_nested.find(string("{") + ns + '}' + name);
- else
- i=m_nested.find(name);
-
- return (i!=m_nested.end()) ? i->second : NULL;
-}
-
XMLApplication::XMLApplication(
const IConfig* ini,
const Iterator<ICredentials*>& creds,
m_credDefault(NULL), m_sessionInitDefault(NULL), m_acsDefault(NULL)
{
#ifdef _DEBUG
- saml::NDC ndc("XMLApplication");
+ NDC ndc("XMLApplication");
#endif
Category& log=Category::getInstance("shibtarget.XMLApplication");
root_remap["shireURL"]="handlerURL";
root_remap["shireSSL"]="handlerSSL";
load(e,log,this,&root_remap);
- const IPropertySet* propcheck=getPropertySet("Errors");
+ const PropertySet* propcheck=getPropertySet("Errors");
if (propcheck && !propcheck->getString("session").first)
throw ConfigurationException("<Errors> element requires 'session' (or deprecated 'shire') attribute");
propcheck=getPropertySet("Sessions");
// A handler is split across a property set and the plugin itself, which is based on the Binding property.
// We build both objects first and then insert them into various structures for lookup.
IHandler* hobj=NULL;
- XMLPropertySet* hprops=new XMLPropertySet();
+ DOMPropertySet* hprops=new DOMPropertySet();
try {
hprops->load(handler,log,this); // filter irrelevant for now, no embedded elements expected
const char* bindprop=hprops->getString("Binding").second;
// If no handlers defined at the root, assume a legacy configuration.
if (!m_base && m_handlers.empty()) {
// A legacy config installs a SAML POST handler at the root handler location.
- // We use the Sessions element itself as the IPropertySet.
+ // We use the Sessions element itself as the PropertySet.
auto_ptr_char b1(Constants::SHIB_SESSIONINIT_PROFILE_URI);
IPlugIn* hplug=shibConf.getPlugMgr().newPlugin(b1.get(),propcheck->getElement());
// Finally, load credential mappings.
const DOMElement* cu=saml::XML::getFirstChildElement(e,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(CredentialUse));
if (cu) {
- m_credDefault=new XMLPropertySet();
+ m_credDefault=new DOMPropertySet();
m_credDefault->load(cu,log,this);
cu=saml::XML::getFirstChildElement(cu,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(RelyingParty));
while (cu) {
- XMLPropertySet* rp=new XMLPropertySet();
+ DOMPropertySet* rp=new DOMPropertySet();
rp->load(cu,log,this);
m_credMap[cu->getAttributeNS(NULL,SHIBT_L(Name))]=rp;
cu=saml::XML::getNextSiblingElement(cu,shibtarget::XML::SHIBTARGET_NS,SHIBT_L(RelyingParty));
delete m_credDefault;
#ifdef HAVE_GOOD_STL
- for_each(m_credMap.begin(),m_credMap.end(),xmltooling::cleanup_pair<xstring,XMLPropertySet>());
+ for_each(m_credMap.begin(),m_credMap.end(),xmltooling::cleanup_pair<xstring,PropertySet>());
#else
- for_each(m_credMap.begin(),m_credMap.end(),xmltooling::cleanup_pair<const XMLCh*,XMLPropertySet>());
+ for_each(m_credMap.begin(),m_credMap.end(),xmltooling::cleanup_pair<const XMLCh*,PropertySet>());
#endif
for_each(m_designators.begin(),m_designators.end(),xmltooling::cleanup<SAMLAttributeDesignator>());
for_each(m_aaps.begin(),m_aaps.end(),xmltooling::cleanup<IAAP>());
pair<bool,bool> XMLApplication::getBool(const char* name, const char* ns) const
{
- pair<bool,bool> ret=XMLPropertySet::getBool(name,ns);
+ pair<bool,bool> ret=DOMPropertySet::getBool(name,ns);
if (ret.first)
return ret;
return m_base ? m_base->getBool(name,ns) : ret;
pair<bool,const char*> XMLApplication::getString(const char* name, const char* ns) const
{
- pair<bool,const char*> ret=XMLPropertySet::getString(name,ns);
+ pair<bool,const char*> ret=DOMPropertySet::getString(name,ns);
if (ret.first)
return ret;
return m_base ? m_base->getString(name,ns) : ret;
pair<bool,const XMLCh*> XMLApplication::getXMLString(const char* name, const char* ns) const
{
- pair<bool,const XMLCh*> ret=XMLPropertySet::getXMLString(name,ns);
+ pair<bool,const XMLCh*> ret=DOMPropertySet::getXMLString(name,ns);
if (ret.first)
return ret;
return m_base ? m_base->getXMLString(name,ns) : ret;
pair<bool,unsigned int> XMLApplication::getUnsignedInt(const char* name, const char* ns) const
{
- pair<bool,unsigned int> ret=XMLPropertySet::getUnsignedInt(name,ns);
+ pair<bool,unsigned int> ret=DOMPropertySet::getUnsignedInt(name,ns);
if (ret.first)
return ret;
return m_base ? m_base->getUnsignedInt(name,ns) : ret;
pair<bool,int> XMLApplication::getInt(const char* name, const char* ns) const
{
- pair<bool,int> ret=XMLPropertySet::getInt(name,ns);
+ pair<bool,int> ret=DOMPropertySet::getInt(name,ns);
if (ret.first)
return ret;
return m_base ? m_base->getInt(name,ns) : ret;
}
-const IPropertySet* XMLApplication::getPropertySet(const char* name, const char* ns) const
+const PropertySet* XMLApplication::getPropertySet(const char* name, const char* ns) const
{
- const IPropertySet* ret=XMLPropertySet::getPropertySet(name,ns);
+ const PropertySet* ret=DOMPropertySet::getPropertySet(name,ns);
if (ret || !m_base)
return ret;
return m_base->getPropertySet(name,ns);
return (m_audiences.empty() && m_base) ? m_base->getAudiences() : m_audiences;
}
-const IPropertySet* XMLApplication::getCredentialUse(const IEntityDescriptor* provider) const
+const PropertySet* XMLApplication::getCredentialUse(const IEntityDescriptor* provider) const
{
if (!m_credDefault && m_base)
return m_base->getCredentialUse(provider);
#ifdef HAVE_GOOD_STL
- map<xstring,XMLPropertySet*>::const_iterator i=m_credMap.find(provider->getId());
+ map<xstring,PropertySet*>::const_iterator i=m_credMap.find(provider->getId());
if (i!=m_credMap.end())
return i->second;
const IEntitiesDescriptor* group=provider->getEntitiesDescriptor();
group=group->getEntitiesDescriptor();
}
#else
- map<const XMLCh*,XMLPropertySet*>::const_iterator i=m_credMap.begin();
+ map<const XMLCh*,PropertySet*>::const_iterator i=m_credMap.begin();
for (; i!=m_credMap.end(); i++) {
if (!XMLString::compareString(i->first,provider->getId()))
return i->second;
return;
}
- const IPropertySet* credUse=getCredentialUse(role->getEntityDescriptor());
+ const PropertySet* credUse=getCredentialUse(role->getEntityDescriptor());
pair<bool,bool> signedAssertions=credUse ? credUse->getBool("signedAssertions") : make_pair(false,false);
Trust t(trusts);
using namespace log4cpp;
using namespace std;
+using shibsp::PropertySet;
using xmltooling::TemplateEngine;
using xmltooling::XMLToolingException;
using xmltooling::XMLToolingConfig;
class ExtTemplateParameters : public TemplateEngine::TemplateParameters
{
- const IPropertySet* m_props;
+ const PropertySet* m_props;
public:
ExtTemplateParameters() : m_props(NULL) {}
~ExtTemplateParameters() {}
- void setPropertySet(const IPropertySet* props) {
+ void setPropertySet(const PropertySet* props) {
m_props = props;
// Create a timestamp.
if (!strstr(targetURL,handlerURL))
return make_pair(true, returnDecline());
- const IPropertySet* sessionProps=m_priv->m_app->getPropertySet("Sessions");
+ const PropertySet* sessionProps=m_priv->m_app->getPropertySet("Sessions");
if (!sessionProps)
throw ConfigurationException("Unable to map request to application session settings, check configuration.");
catch (MetadataException& e) {
tp.m_map["errorText"] = e.what();
// See if a metadata error page is installed.
- const IPropertySet* props=m_priv->m_app->getPropertySet("Errors");
+ const PropertySet* props=m_priv->m_app->getPropertySet("Errors");
if (props) {
pair<bool,const char*> p=props->getString("metadata");
if (p.first) {
{
static const char* defProps="; path=/";
- const IPropertySet* props=m_priv->m_app ? m_priv->m_app->getPropertySet("Sessions") : NULL;
+ const PropertySet* props=m_priv->m_app ? m_priv->m_app->getPropertySet("Sessions") : NULL;
if (props) {
pair<bool,const char*> p=props->getString("cookieProps");
if (!p.first)
bool ssl_only=false;
const char* handler=NULL;
- const IPropertySet* props=m_priv->m_app->getPropertySet("Sessions");
+ const PropertySet* props=m_priv->m_app->getPropertySet("Sessions");
if (props) {
pair<bool,bool> p=props->getBool("handlerSSL");
if (p.first)
};
TemplateEngine* engine = XMLToolingConfig::getConfig().getTemplateEngine();
- const IPropertySet* props=m_app->getPropertySet("Errors");
+ const PropertySet* props=m_app->getPropertySet("Errors");
if (props) {
pair<bool,const char*> p=props->getString(page);
if (p.first) {
// New headers
#include <saml/base.h>
#include <shibsp/ListenerService.h>
+#include <shibsp/PropertySet.h>
// Old headers
#include <saml/saml.h>
// Abstract APIs for access to configuration information
- /**
- * Interface to a generic set of typed properties or a DOM container of additional
- * data.
- */
- struct SHIBTARGET_EXPORTS IPropertySet
- {
- virtual std::pair<bool,bool> getBool(const char* name, const char* ns=NULL) const=0;
- virtual std::pair<bool,const char*> getString(const char* name, const char* ns=NULL) const=0;
- virtual std::pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const=0;
- virtual std::pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const=0;
- virtual std::pair<bool,int> getInt(const char* name, const char* ns=NULL) const=0;
- virtual const IPropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const=0;
- virtual const DOMElement* getElement() const=0;
- virtual ~IPropertySet() {}
- };
-
// Forward declaration
class SHIBTARGET_EXPORTS ShibTarget;
{
IHandler() : m_props(NULL) {}
virtual ~IHandler() {}
- virtual const IPropertySet* getProperties() const { return m_props; }
- virtual void setProperties(const IPropertySet* properties) { m_props=properties; }
+ virtual const shibsp::PropertySet* getProperties() const { return m_props; }
+ virtual void setProperties(const shibsp::PropertySet* properties) { m_props=properties; }
virtual std::pair<bool,void*> run(ShibTarget* st, bool isHandler=true) const=0;
private:
- const IPropertySet* m_props;
+ const shibsp::PropertySet* m_props;
};
/**
* Application. Implementations should always expose an application named "default"
* as a last resort.
*/
- struct SHIBTARGET_EXPORTS IApplication : public virtual IPropertySet,
+ struct SHIBTARGET_EXPORTS IApplication : public virtual shibsp::PropertySet,
public virtual shibboleth::ShibBrowserProfile::ITokenValidator
{
virtual const char* getId() const=0;
virtual saml::Iterator<shibboleth::IMetadata*> getMetadataProviders() const=0;
virtual saml::Iterator<shibboleth::ITrust*> getTrustProviders() const=0;
virtual saml::Iterator<const XMLCh*> getAudiences() const=0;
- virtual const IPropertySet* getCredentialUse(const shibboleth::IEntityDescriptor* provider) const=0;
+ virtual const shibsp::PropertySet* getCredentialUse(const shibboleth::IEntityDescriptor* provider) const=0;
// caller is borrowing object, must use within scope of config lock
virtual const saml::SAMLBrowserProfile* getBrowserProfile() const=0;
// Client declares a context object and pass as callCtx to send() method.
class ShibHTTPHookCallContext {
public:
- ShibHTTPHookCallContext(const IPropertySet* credUse, const shibboleth::IRoleDescriptor* role)
+ ShibHTTPHookCallContext(const shibsp::PropertySet* credUse, const shibboleth::IRoleDescriptor* role)
: m_credUse(credUse), m_role(role), m_hook(NULL), m_authenticated(false) {}
const ShibHTTPHook* getHook() {return m_hook;}
- const IPropertySet* getCredentialUse() {return m_credUse;}
+ const shibsp::PropertySet* getCredentialUse() {return m_credUse;}
const shibboleth::IRoleDescriptor* getRoleDescriptor() {return m_role;}
bool isAuthenticated() const {return m_authenticated;}
void setAuthenticated() {m_authenticated=true;}
private:
- const IPropertySet* m_credUse;
+ const shibsp::PropertySet* m_credUse;
const shibboleth::IRoleDescriptor* m_role;
ShibHTTPHook* m_hook;
bool m_authenticated;
*/
struct SHIBTARGET_EXPORTS IRequestMapper : public virtual saml::ILockable, public virtual saml::IPlugIn
{
- typedef std::pair<const IPropertySet*,IAccessControl*> Settings;
+ typedef std::pair<const shibsp::PropertySet*,IAccessControl*> Settings;
virtual Settings getSettings(ShibTarget* st) const=0;
virtual ~IRequestMapper() {}
};
- struct SHIBTARGET_EXPORTS IConfig : public virtual saml::ILockable, public virtual IPropertySet, public virtual saml::IPlugIn
+ struct SHIBTARGET_EXPORTS IConfig : public virtual saml::ILockable, public virtual shibsp::PropertySet, public virtual saml::IPlugIn
{
// loads initial configuration
virtual void init()=0;
--- /dev/null
+/*
+ * Copyright 2001-2006 Internet2
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * DOMPropertySet.cpp
+ *
+ * DOM-based property set implementation.
+ */
+
+#include "internal.h"
+#include "DOMPropertySet.h"
+
+#include <algorithm>
+#include <xmltooling/util/NDC.h>
+#include <xmltooling/util/XMLConstants.h>
+
+using namespace shibsp;
+using namespace xmltooling;
+using namespace log4cpp;
+using namespace xercesc;
+using namespace std;
+
+DOMPropertySet::~DOMPropertySet()
+{
+ for (map<string,pair<char*,const XMLCh*> >::iterator i=m_map.begin(); i!=m_map.end(); i++)
+ XMLString::release(&(i->second.first));
+ for_each(m_nested.begin(),m_nested.end(),xmltooling::cleanup_pair<string,DOMPropertySet>());
+}
+
+void DOMPropertySet::load(
+ const DOMElement* e,
+ Category& log,
+ DOMNodeFilter* filter,
+ const std::map<std::string,std::string>* remapper
+ )
+{
+#ifdef _DEBUG
+ NDC ndc("load");
+#endif
+ m_root=e;
+
+ // Process each attribute as a property.
+ DOMNamedNodeMap* attrs=m_root->getAttributes();
+ for (XMLSize_t i=0; i<attrs->getLength(); i++) {
+ DOMNode* a=attrs->item(i);
+ if (!XMLString::compareString(a->getNamespaceURI(),xmlconstants::XMLNS_NS))
+ continue;
+ char* val=XMLString::transcode(a->getNodeValue());
+ if (val && *val) {
+ auto_ptr_char ns(a->getNamespaceURI());
+ auto_ptr_char name(a->getLocalName());
+ const char* realname=name.get();
+ if (remapper) {
+ map<string,string>::const_iterator remap=remapper->find(realname);
+ if (remap!=remapper->end()) {
+ log.warn("remapping property (%s) to (%s)",realname,remap->second.c_str());
+ realname=remap->second.c_str();
+ }
+ }
+ if (ns.get()) {
+ m_map[string("{") + ns.get() + '}' + realname]=pair<char*,const XMLCh*>(val,a->getNodeValue());
+ log.debug("added property {%s}%s (%s)",ns.get(),realname,val);
+ }
+ else {
+ m_map[realname]=pair<char*,const XMLCh*>(val,a->getNodeValue());
+ log.debug("added property %s (%s)",realname,val);
+ }
+ }
+ }
+
+ // Process non-excluded elements as nested sets.
+ DOMTreeWalker* walker=
+ static_cast<DOMDocumentTraversal*>(
+ m_root->getOwnerDocument())->createTreeWalker(const_cast<DOMElement*>(m_root),DOMNodeFilter::SHOW_ELEMENT,filter,false
+ );
+ e=static_cast<DOMElement*>(walker->firstChild());
+ while (e) {
+ auto_ptr_char ns(e->getNamespaceURI());
+ auto_ptr_char name(e->getLocalName());
+ const char* realname=name.get();
+ if (remapper) {
+ map<string,string>::const_iterator remap=remapper->find(realname);
+ if (remap!=remapper->end()) {
+ log.warn("remapping property set (%s) to (%s)",realname,remap->second.c_str());
+ realname=remap->second.c_str();
+ }
+ }
+ string key;
+ if (ns.get())
+ key=string("{") + ns.get() + '}' + realname;
+ else
+ key=realname;
+ if (m_nested.find(key)!=m_nested.end())
+ log.warn("load() skipping duplicate property set: %s",key.c_str());
+ else {
+ DOMPropertySet* set=new DOMPropertySet();
+ set->load(e,log,filter,remapper);
+ m_nested[key]=set;
+ log.debug("added nested property set: %s",key.c_str());
+ }
+ e=static_cast<DOMElement*>(walker->nextSibling());
+ }
+ walker->release();
+}
+
+pair<bool,bool> DOMPropertySet::getBool(const char* name, const char* ns) const
+{
+ pair<bool,bool> ret(false,false);
+ map<string,pair<char*,const XMLCh*> >::const_iterator i;
+
+ if (ns)
+ i=m_map.find(string("{") + ns + '}' + name);
+ else
+ i=m_map.find(name);
+
+ if (i!=m_map.end()) {
+ ret.first=true;
+ ret.second=(!strcmp(i->second.first,"true") || !strcmp(i->second.first,"1"));
+ }
+ return ret;
+}
+
+pair<bool,const char*> DOMPropertySet::getString(const char* name, const char* ns) const
+{
+ pair<bool,const char*> ret(false,NULL);
+ map<string,pair<char*,const XMLCh*> >::const_iterator i;
+
+ if (ns)
+ i=m_map.find(string("{") + ns + '}' + name);
+ else
+ i=m_map.find(name);
+
+ if (i!=m_map.end()) {
+ ret.first=true;
+ ret.second=i->second.first;
+ }
+ return ret;
+}
+
+pair<bool,const XMLCh*> DOMPropertySet::getXMLString(const char* name, const char* ns) const
+{
+ pair<bool,const XMLCh*> ret(false,NULL);
+ map<string,pair<char*,const XMLCh*> >::const_iterator i;
+
+ if (ns)
+ i=m_map.find(string("{") + ns + '}' + name);
+ else
+ i=m_map.find(name);
+
+ if (i!=m_map.end()) {
+ ret.first=true;
+ ret.second=i->second.second;
+ }
+ return ret;
+}
+
+pair<bool,unsigned int> DOMPropertySet::getUnsignedInt(const char* name, const char* ns) const
+{
+ pair<bool,unsigned int> ret(false,0);
+ map<string,pair<char*,const XMLCh*> >::const_iterator i;
+
+ if (ns)
+ i=m_map.find(string("{") + ns + '}' + name);
+ else
+ i=m_map.find(name);
+
+ if (i!=m_map.end()) {
+ ret.first=true;
+ ret.second=strtol(i->second.first,NULL,10);
+ }
+ return ret;
+}
+
+pair<bool,int> DOMPropertySet::getInt(const char* name, const char* ns) const
+{
+ pair<bool,int> ret(false,0);
+ map<string,pair<char*,const XMLCh*> >::const_iterator i;
+
+ if (ns)
+ i=m_map.find(string("{") + ns + '}' + name);
+ else
+ i=m_map.find(name);
+
+ if (i!=m_map.end()) {
+ ret.first=true;
+ ret.second=atoi(i->second.first);
+ }
+ return ret;
+}
+
+const PropertySet* DOMPropertySet::getPropertySet(const char* name, const char* ns) const
+{
+ map<string,DOMPropertySet*>::const_iterator i;
+
+ if (ns)
+ i=m_nested.find(string("{") + ns + '}' + name);
+ else
+ i=m_nested.find(name);
+
+ return (i!=m_nested.end()) ? i->second : NULL;
+}
--- /dev/null
+/*
+ * Copyright 2001-2006 Internet2
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file shibsp/DOMPropertySet.h
+ *
+ * DOM-based property set implementation.
+ */
+
+#ifndef __shibsp_dompropset_h__
+#define __shibsp_dompropset_h__
+
+#include <shibsp/PropertySet.h>
+#include <log4cpp/Category.hh>
+
+namespace shibsp {
+
+ /**
+ * DOM-based property set implementation.
+ */
+ class SHIBSP_API DOMPropertySet : public virtual PropertySet
+ {
+ public:
+ DOMPropertySet() {}
+
+ virtual ~DOMPropertySet();
+
+ std::pair<bool,bool> getBool(const char* name, const char* ns=NULL) const;
+ std::pair<bool,const char*> getString(const char* name, const char* ns=NULL) const;
+ std::pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const;
+ std::pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const;
+ std::pair<bool,int> getInt(const char* name, const char* ns=NULL) const;
+ const PropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
+
+ const xercesc::DOMElement* getElement() const {
+ return m_root;
+ }
+
+ /**
+ * Loads the property set from a DOM element.
+ *
+ * @param e root element of property set
+ * @param log log object for tracing
+ * @param filter optional filter controls what child elements to include as nested PropertySets
+ * @param remapper optional map of property rename rules for legacy property support
+ */
+ void load(
+ const xercesc::DOMElement* e,
+ log4cpp::Category& log,
+ xercesc::DOMNodeFilter* filter,
+ const std::map<std::string,std::string>* remapper=NULL
+ );
+
+ private:
+ const xercesc::DOMElement* m_root;
+ std::map<std::string,std::pair<char*,const XMLCh*> > m_map;
+ std::map<std::string,DOMPropertySet*> m_nested;
+ };
+};
+
+#endif /* __shibsp_dompropset_h__ */
libshibspinclude_HEADERS = \
base.h \
ddf.h \
+ DOMPropertySet.h \
exceptions.h \
ListenerService.h \
paths.h \
+ PropertySet.h \
version.h \
SocketListener.h \
SPConfig.h
libshibsp_la_SOURCES = \
ddf.cpp \
+ DOMPropertySet.cpp \
ListenerService.cpp \
SocketListener.cpp \
TCPListener.cpp \
--- /dev/null
+/*
+ * Copyright 2001-2006 Internet2
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file shibsp/PropertySet.h
+ *
+ * Interface to a generic set of typed properties or a DOM container of additional data.
+ */
+
+#ifndef __shibsp_propset_h__
+#define __shibsp_propset_h__
+
+#include <shibsp/base.h>
+#include <xercesc/dom/DOM.hpp>
+
+namespace shibsp {
+
+ /**
+ * Interface to a generic set of typed properties or a DOM container of additional data.
+ */
+ class SHIBSP_API PropertySet
+ {
+ MAKE_NONCOPYABLE(PropertySet);
+ protected:
+ PropertySet() {}
+ public:
+ virtual ~PropertySet() {}
+
+ /**
+ * Returns a boolean-valued property.
+ *
+ * @param name property name
+ * @param ns property namespace, or NULL
+ * @return a pair consisting of a NULL indicator and the property value iff the indicator is true
+ */
+ virtual std::pair<bool,bool> getBool(const char* name, const char* ns=NULL) const=0;
+
+ /**
+ * Returns a string-valued property.
+ *
+ * @param name property name
+ * @param ns property namespace, or NULL
+ * @return a pair consisting of a NULL indicator and the property value iff the indicator is true
+ */
+ virtual std::pair<bool,const char*> getString(const char* name, const char* ns=NULL) const=0;
+
+ /**
+ * Returns a Unicode string-valued property.
+ *
+ * @param name property name
+ * @param ns property namespace, or NULL
+ * @return a pair consisting of a NULL indicator and the property value iff the indicator is true
+ */
+ virtual std::pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const=0;
+
+ /**
+ * Returns an unsigned integer-valued property.
+ *
+ * @param name property name
+ * @param ns property namespace, or NULL
+ * @return a pair consisting of a NULL indicator and the property value iff the indicator is true
+ */
+ virtual std::pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const=0;
+
+ /**
+ * Returns an integer-valued property.
+ *
+ * @param name property name
+ * @param ns property namespace, or NULL
+ * @return a pair consisting of a NULL indicator and the property value iff the indicator is true
+ */
+ virtual std::pair<bool,int> getInt(const char* name, const char* ns=NULL) const=0;
+
+ /**
+ * Returns a nested property set.
+ *
+ * @param name nested property set name
+ * @param ns nested property set namespace, or NULL
+ * @return the nested property set, or NULL
+ */
+ virtual const PropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const=0;
+
+ /**
+ * Returns a DOM element representing the property container, if any.
+ *
+ * @return a DOM element, or NULL
+ */
+ virtual const xercesc::DOMElement* getElement() const=0;
+ };
+};
+
+#endif /* __shibsp_propset_h__ */
>\r
</File>\r
<File\r
+ RelativePath=".\DOMPropertySet.cpp"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\ListenerService.cpp"\r
>\r
</File>\r
>\r
</File>\r
<File\r
+ RelativePath=".\DOMPropertySet.h"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\exceptions.h"\r
>\r
</File>\r
>\r
</File>\r
<File\r
+ RelativePath=".\PropertySet.h"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\resource.h"\r
>\r
</File>\r