Adjust logging/error-handling, schema fixes, failed message handling.
[shibboleth/sp.git] / shibsp / impl / RemotedSessionCache.cpp
index f23a057..a64222d 100644 (file)
@@ -79,7 +79,7 @@ namespace shibsp {
             m_obj.destroy();\r
             delete m_nameid;\r
             for_each(m_attributes.begin(), m_attributes.end(), cleanup_const_pair<string,Attribute>());\r
-            for_each(m_tokens.begin(), m_tokens.end(), cleanup_pair<string,RootObject>());\r
+            for_each(m_tokens.begin(), m_tokens.end(), cleanup_pair<string,Assertion>());\r
         }\r
         \r
         Lockable* lock() {\r
@@ -130,12 +130,12 @@ namespace shibsp {
             return m_ids;\r
         }\r
         \r
-        const RootObject* getAssertion(const char* id) const;\r
+        const Assertion* getAssertion(const char* id) const;\r
 \r
         void addAttributes(const vector<Attribute*>& attributes) {\r
             throw ConfigurationException("addAttributes method not implemented by this session cache plugin.");\r
         }\r
-        void addAssertion(RootObject* assertion) {\r
+        void addAssertion(Assertion* assertion) {\r
             throw ConfigurationException("addAssertion method not implemented by this session cache plugin.");\r
         }\r
 \r
@@ -151,7 +151,7 @@ namespace shibsp {
         saml2::NameID* m_nameid;\r
         mutable map<string,const Attribute*> m_attributes;\r
         mutable vector<const char*> m_ids;\r
-        mutable map<string,RootObject*> m_tokens;\r
+        mutable map<string,Assertion*> m_tokens;\r
         time_t m_expires,m_lastAccess;\r
         RemotedCache* m_cache;\r
         Mutex* m_lock;\r
@@ -173,7 +173,7 @@ namespace shibsp {
             const char* session_index=NULL,\r
             const char* authncontext_class=NULL,\r
             const char* authncontext_decl=NULL,\r
-            const vector<const RootObject*>* tokens=NULL,\r
+            const vector<const Assertion*>* tokens=NULL,\r
             const vector<Attribute*>* attributes=NULL\r
             );\r
         Session* find(const char* key, const Application& application, const char* client_addr=NULL, time_t timeout=0);\r
@@ -220,9 +220,9 @@ void RemotedSession::unmarshallAttributes() const
     }\r
 }\r
 \r
-const RootObject* RemotedSession::getAssertion(const char* id) const\r
+const Assertion* RemotedSession::getAssertion(const char* id) const\r
 {\r
-    map<string,RootObject*>::const_iterator i = m_tokens.find(id);\r
+    map<string,Assertion*>::const_iterator i = m_tokens.find(id);\r
     if (i!=m_tokens.end())\r
         return i->second;\r
 \r
@@ -243,8 +243,8 @@ const RootObject* RemotedSession::getAssertion(const char* id) const
     auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true));\r
     janitor.release();\r
     \r
-    RootObject* token = dynamic_cast<RootObject*>(xmlObject.get());\r
-    if (!token || !token->isAssertion())\r
+    Assertion* token = dynamic_cast<Assertion*>(xmlObject.get());\r
+    if (!token)\r
         throw FatalProfileException("Cached assertion was of an unknown object type.");\r
 \r
     // Transfer ownership to us.\r
@@ -359,7 +359,7 @@ string RemotedCache::insert(
     const char* session_index,\r
     const char* authncontext_class,\r
     const char* authncontext_decl,\r
-    const vector<const RootObject*>* tokens,\r
+    const vector<const Assertion*>* tokens,\r
     const vector<Attribute*>* attributes\r
     )\r
 {\r
@@ -399,7 +399,7 @@ string RemotedCache::insert(
     if (tokens) {\r
         in.addmember("assertions").list();\r
         in.addmember("tokens").list();\r
-        for (vector<const RootObject*>::const_iterator t = tokens->begin(); t!=tokens->end(); ++t) {\r
+        for (vector<const Assertion*>::const_iterator t = tokens->begin(); t!=tokens->end(); ++t) {\r
             ostringstream tokenstr;\r
             tokenstr << *(*t);\r
             auto_ptr_char tokenid((*t)->getID());\r
@@ -607,17 +607,16 @@ void RemotedCache::cleanup()
     xmltooling::NDC ndc("cleanup");\r
 #endif\r
 \r
-    int rerun_timer = 0;\r
     Mutex* mutex = Mutex::create();\r
   \r
     // Load our configuration details...\r
     static const XMLCh cleanupInterval[] = UNICODE_LITERAL_15(c,l,e,a,n,u,p,I,n,t,e,r,v,a,l);\r
-    const XMLCh* tag=m_root->getAttributeNS(NULL,cleanupInterval);\r
+    const XMLCh* tag=m_root ? m_root->getAttributeNS(NULL,cleanupInterval) : NULL;\r
+    int rerun_timer = 900;\r
     if (tag && *tag)\r
         rerun_timer = XMLString::parseInt(tag);\r
-\r
     if (rerun_timer <= 0)\r
-        rerun_timer = 900;        // rerun every 5 minutes\r
+        rerun_timer = 900;\r
 \r
     mutex->lock();\r
 \r
@@ -704,9 +703,9 @@ void RemotedSession::addAttributes(const vector<Attribute*>& attributes)
     m_attributes.insert(m_attributes.end(), attributes.begin(), attributes.end());\r
 }\r
 \r
-void RemotedSession::addAssertion(RootObject* assertion)\r
+void RemotedSession::addAssertion(Assertion* assertion)\r
 {\r
-    if (!assertion || !assertion->isAssertion())\r
+    if (!assertion)\r
         throw FatalProfileException("Unknown object type passed to session cache for storage.");\r
 \r
     DDF in("addAssertion::"REMOTED_SESSION_CACHE);\r