New endpoint management and refactored profile methods.
[shibboleth/sp.git] / shib-target / internal.h
index 9b33bc7..18bb1d9 100644 (file)
@@ -71,6 +71,7 @@
 #endif
 
 #include "shib-target.h"
+#include "hresult.h"
 
 #include <log4cpp/Category.hh>
 #include <log4cpp/FixedContextCategory.hh>
@@ -122,12 +123,28 @@ namespace shibtarget {
         RPC();
         ~RPC() {delete m_handle;}
         RPCHandle* operator->() {return m_handle;}
-        void pool() {m_pool.put(m_handle); m_handle=NULL;}
+        void pool() {if (m_handle) m_pool.put(m_handle); m_handle=NULL;}
     
     private:
         RPCHandlePool& m_pool;
         RPCHandle* m_handle;
     };
+    
+    // Helper class for SAML 2.0 Common Domain Cookie operations
+    class CommonDomainCookie
+    {
+    public:
+        CommonDomainCookie(const char* cookie);
+        ~CommonDomainCookie();
+        saml::Iterator<const char*> get() {return m_list;}
+        const char* set(const char* providerId);
+        static const char CDCName[];
+    private:
+        XMLByte* m_decoded;
+        std::string m_encoded;
+        std::vector<const char*> m_list;
+        std::vector<std::string> m_additions;
+    };
 
     // Generic class, which handles the IPropertySet configuration interface.
     // Most of the basic configuration details are exposed via this interface.
@@ -152,29 +169,50 @@ namespace shibtarget {
         const IPropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const;
         const DOMElement* getElement() const {return m_root;}
     
-    protected:
-        void load(const DOMElement* e, log4cpp::Category& log, DOMNodeFilter* filter);
+        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
+    {
+    public:
+        STArtifactMapper(const IApplication* application)
+            : m_app(application), m_localcopy(application->getMetadataProviders()), m_metadata(m_localcopy), m_ctx(NULL) {}
+        virtual ~STArtifactMapper() {delete m_ctx;}
+    
+        saml::SAMLBrowserProfile::ArtifactMapper::ArtifactMapperResponse map(const saml::SAMLArtifact* artifact);
+    
+    private:
+        const IApplication* m_app;
+        saml::Iterator<shibboleth::IMetadata*> m_localcopy;
+        shibboleth::Metadata m_metadata;    // scopes lock around use of role descriptor by hook context
+        shibboleth::ShibHTTPHook::ShibHTTPHookCallContext* m_ctx;
+    };
     
     class STConfig : public ShibTargetConfig
     {
     public:
-        STConfig() : m_tranLog(NULL), m_tranLogLock(NULL) {}
+        STConfig() : m_tranLog(NULL), m_tranLogLock(NULL), m_rpcpool(NULL) {}
         ~STConfig() {}
         
         bool init(const char* schemadir, const char* config);
         void shutdown();
         
-        RPCHandlePool& getRPCHandlePool() {return m_rpcpool;}
+        RPCHandlePool& getRPCHandlePool() {return *m_rpcpool;}
         log4cpp::Category& getTransactionLog() { m_tranLogLock->lock(); return *m_tranLog; }
         void releaseTransactionLog() { m_tranLogLock->unlock();}
     private:
-        RPCHandlePool m_rpcpool;
+        RPCHandlePool* m_rpcpool;
         log4cpp::FixedContextCategory* m_tranLog;
         shibboleth::Mutex* m_tranLogLock;
         static IConfig* ShibTargetConfigFactory(const DOMElement* e);
@@ -184,10 +222,19 @@ namespace shibtarget {
     {
     public:
         static const XMLCh SHIBTARGET_SCHEMA_ID[];
+        static const XMLCh SAML2ASSERT_NS[];
+        static const XMLCh SAML2ASSERT_SCHEMA_ID[];
+        static const XMLCh SAML2META_NS[];
+        static const XMLCh SAML2META_SCHEMA_ID[];
+        static const XMLCh XMLENC_NS[];
+        static const XMLCh XMLENC_SCHEMA_ID[];
     
         static const char htaccessType[];
         static const char MemorySessionCacheType[];
         static const char MySQLSessionCacheType[];
+        static const char MemoryReplayCacheType[];
+        static const char MySQLReplayCacheType[];
+        static const char LegacyRequestMapType[];
         static const char RequestMapType[];
         static const char TCPListenerType[];
         static const char UnixListenerType[];
@@ -200,18 +247,24 @@ namespace shibtarget {
             static const XMLCh applicationId[];
             static const XMLCh Application[];
             static const XMLCh Applications[];
+            static const XMLCh AssertionConsumerService[];
             static const XMLCh CredentialsProvider[];
             static const XMLCh CredentialUse[];
             static const XMLCh Extensions[];
             static const XMLCh fatal[];
             static const XMLCh FederationProvider[];
+            static const XMLCh Global[];
             static const XMLCh Host[];
             static const XMLCh htaccess[];
             static const XMLCh Implementation[];
+            static const XMLCh index[];
+            static const XMLCh isDefault[];
             static const XMLCh Library[];
             static const XMLCh Listener[];
+            static const XMLCh Local[];
             static const XMLCh logger[];
             static const XMLCh MemorySessionCache[];
+            static const XMLCh MySQLReplayCache[];
             static const XMLCh MySQLSessionCache[];
             static const XMLCh name[];
             static const XMLCh Name[];
@@ -220,16 +273,20 @@ namespace shibtarget {
             static const XMLCh Path[];
             static const XMLCh path[];
             static const XMLCh RelyingParty[];
+            static const XMLCh ReplayCache[];
             static const XMLCh RequestMap[];
             static const XMLCh RequestMapProvider[];
             static const XMLCh require[];
             static const XMLCh RevocationProvider[];
             static const XMLCh Rule[];
             static const XMLCh SessionCache[];
+            static const XMLCh SessionInitiator[];
             static const XMLCh SHAR[];
             static const XMLCh ShibbolethTargetConfig[];
             static const XMLCh SHIRE[];
             static const XMLCh Signing[];
+            static const XMLCh SingleLogoutService[];
+            static const XMLCh SPConfig[];
             static const XMLCh TCPListener[];
             static const XMLCh TLS[];
             static const XMLCh TrustProvider[];