ArtifactMap support.
[shibboleth/sp.git] / shibsp / impl / XMLServiceProvider.cpp
index dd00d12..33d540c 100644 (file)
@@ -42,6 +42,7 @@
 #include <log4cpp/Category.hh>\r
 #include <log4cpp/PropertyConfigurator.hh>\r
 #include <saml/SAMLConfig.h>\r
+#include <saml/binding/ArtifactMap.h>\r
 #include <saml/saml1/core/Assertions.h>\r
 #include <saml/saml2/metadata/ChainingMetadataProvider.h>\r
 #include <xmltooling/XMLToolingConfig.h>\r
@@ -216,6 +217,7 @@ namespace {
             delete m_listener;\r
             delete m_tranLog;\r
             XMLToolingConfig::getConfig().setReplayCache(NULL);\r
+            SAMLConfig::getConfig().setArtifactMap(NULL);\r
             for_each(m_storage.begin(), m_storage.end(), cleanup_pair<string,StorageService>());\r
         }\r
 \r
@@ -308,6 +310,7 @@ namespace {
 \r
     static const XMLCh _Application[] =         UNICODE_LITERAL_11(A,p,p,l,i,c,a,t,i,o,n);\r
     static const XMLCh Applications[] =         UNICODE_LITERAL_12(A,p,p,l,i,c,a,t,i,o,n,s);\r
+    static const XMLCh _ArtifactMap[] =         UNICODE_LITERAL_11(A,r,t,i,f,a,c,t,M,a,p);\r
     static const XMLCh _AttributeResolver[] =   UNICODE_LITERAL_17(A,t,t,r,i,b,u,t,e,R,e,s,o,l,v,e,r);\r
     static const XMLCh Credentials[] =          UNICODE_LITERAL_11(C,r,e,d,e,n,t,i,a,l,s);\r
     static const XMLCh CredentialUse[] =        UNICODE_LITERAL_13(C,r,e,d,e,n,t,i,a,l,U,s,e);\r
@@ -320,6 +323,9 @@ namespace {
     static const XMLCh Listener[] =             UNICODE_LITERAL_8(L,i,s,t,e,n,e,r);\r
     static const XMLCh logger[] =               UNICODE_LITERAL_6(l,o,g,g,e,r);\r
     static const XMLCh MemoryListener[] =       UNICODE_LITERAL_14(M,e,m,o,r,y,L,i,s,t,e,n,e,r);\r
+    static const XMLCh _MetadataProvider[] =    UNICODE_LITERAL_16(M,e,t,a,d,a,t,a,P,r,o,v,i,d,e,r);\r
+    static const XMLCh OutOfProcess[] =         UNICODE_LITERAL_12(O,u,t,O,f,P,r,o,c,e,s,s);\r
+    static const XMLCh _path[] =                UNICODE_LITERAL_4(p,a,t,h);\r
     static const XMLCh Policy[] =               UNICODE_LITERAL_6(P,o,l,i,c,y);\r
     static const XMLCh RelyingParty[] =         UNICODE_LITERAL_12(R,e,l,y,i,n,g,P,a,r,t,y);\r
     static const XMLCh _ReplayCache[] =         UNICODE_LITERAL_11(R,e,p,l,a,y,C,a,c,h,e);\r
@@ -329,13 +335,10 @@ namespace {
     static const XMLCh _SessionCache[] =        UNICODE_LITERAL_12(S,e,s,s,i,o,n,C,a,c,h,e);\r
     static const XMLCh SessionInitiator[] =     UNICODE_LITERAL_16(S,e,s,s,i,o,n,I,n,i,t,i,a,t,o,r);\r
     static const XMLCh _StorageService[] =      UNICODE_LITERAL_14(S,t,o,r,a,g,e,S,e,r,v,i,c,e);\r
-    static const XMLCh OutOfProcess[] =         UNICODE_LITERAL_12(O,u,t,O,f,P,r,o,c,e,s,s);\r
     static const XMLCh TCPListener[] =          UNICODE_LITERAL_11(T,C,P,L,i,s,t,e,n,e,r);\r
     static const XMLCh _TrustEngine[] =         UNICODE_LITERAL_11(T,r,u,s,t,E,n,g,i,n,e);\r
-    static const XMLCh UnixListener[] =         UNICODE_LITERAL_12(U,n,i,x,L,i,s,t,e,n,e,r);\r
-    static const XMLCh _MetadataProvider[] =    UNICODE_LITERAL_16(M,e,t,a,d,a,t,a,P,r,o,v,i,d,e,r);\r
-    static const XMLCh _path[] =                UNICODE_LITERAL_4(p,a,t,h);\r
     static const XMLCh _type[] =                UNICODE_LITERAL_4(t,y,p,e);\r
+    static const XMLCh UnixListener[] =         UNICODE_LITERAL_12(U,n,i,x,L,i,s,t,e,n,e,r);\r
 \r
     class SHIBSP_DLLLOCAL PolicyNodeFilter : public DOMNodeFilter\r
     {\r
@@ -859,6 +862,7 @@ short XMLConfigImpl::acceptNode(const DOMNode* node) const
         return FILTER_ACCEPT;\r
     const XMLCh* name=node->getLocalName();\r
     if (XMLString::equals(name,Applications) ||\r
+        XMLString::equals(name,_ArtifactMap) ||\r
         XMLString::equals(name,Credentials) ||\r
         XMLString::equals(name,Extensions::LOCAL_NAME) ||\r
         XMLString::equals(name,Implementation) ||\r
@@ -1054,6 +1058,20 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o
                         replaySS = m_outer->m_storage[inmemID];\r
                     }\r
                     xmlConf.setReplayCache(new ReplayCache(replaySS));\r
+                    \r
+                    // ArtifactMap\r
+                    child=XMLHelper::getFirstChildElement(SHAR,_ArtifactMap);\r
+                    if (child) {\r
+                        auto_ptr_char ssid(child->getAttributeNS(NULL,_StorageService));\r
+                        if (ssid.get() && *ssid.get() && m_outer->m_storage.count(ssid.get())) {\r
+                            log.info("building ArtifactMap on top of StorageService (%s)...", ssid.get());\r
+                            samlConf.setArtifactMap(new ArtifactMap(child, m_outer->m_storage[ssid.get()]));\r
+                        }\r
+                    }\r
+                    if (samlConf.getArtifactMap()==NULL) {\r
+                        log.info("building in-memory ArtifactMap...");\r
+                        samlConf.setArtifactMap(new ArtifactMap(child));\r
+                    }\r
                 }\r
                 else {\r
                     log.info("building in-process SessionCache of type %s...",REMOTED_SESSION_CACHE);\r