Adjust default cache timeout based on cache subclass.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Mon, 6 Aug 2007 15:55:58 +0000 (15:55 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Mon, 6 Aug 2007 15:55:58 +0000 (15:55 +0000)
Add a default in-proc cache element to config.

git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2389 cb58f699-b61c-0410-a6fe-9272a202ed29

configs/shibboleth2.xml.in
shibsp/SessionCache.cpp
shibsp/SessionCache.h
shibsp/impl/RemotedSessionCache.cpp
shibsp/impl/StorageServiceSessionCache.cpp

index 78ffb03..884d4c0 100644 (file)
@@ -47,6 +47,8 @@
     
        <!-- The InProcess section pertains to components that run inside the web server. -->
        <InProcess logger="@-PKGSYSCONFDIR-@/native.logger">
+               <SessionCache type="Remoted" cleanupInterval="900" cacheTimeout="900"/>
+       
                <!--
                To customize behavior, map hostnames and path components to applicationId and other settings.
                -->
index 6f05c85..8ff5c00 100644 (file)
@@ -48,14 +48,14 @@ void SHIBSP_API shibsp::registerSessionCaches()
 #endif\r
 }\r
 \r
-SessionCache::SessionCache(const DOMElement* e) : m_cacheTimeout(60*60*8)\r
+SessionCache::SessionCache(const DOMElement* e, unsigned long defaultTimeout) : m_cacheTimeout(defaultTimeout)\r
 {\r
     if (e) {\r
         const XMLCh* tag=e->getAttributeNS(NULL,cacheTimeout);\r
         if (tag && *tag) {\r
             m_cacheTimeout = XMLString::parseInt(tag);\r
             if (!m_cacheTimeout)\r
-                m_cacheTimeout=60*60*8;\r
+                m_cacheTimeout=defaultTimeout;\r
         }\r
     }\r
 }\r
index 91de942..5e22bf1 100644 (file)
@@ -183,11 +183,12 @@ namespace shibsp {
          *  <dd>attribute containing maximum lifetime in seconds for unused sessions to remain in cache</dd>
          * </dl>
          * 
-         * @param e root of DOM tree to configure the cache
+         * @param e                 root of DOM tree to configure the cache
+         * @param defaultTimeout    default cacheTimeout setting to use if none specified in DOM
          */
-        SessionCache(const xercesc::DOMElement* e);
+        SessionCache(const xercesc::DOMElement* e, unsigned long defaultTimeout=3600);
         
-        /** maximum lifetime in seconds for unused sessions to be cached */
+        /** Maximum lifetime in seconds for unused sessions to be cached. */
         unsigned long m_cacheTimeout;
         
     public:
index 48266ff..6f2d8cc 100644 (file)
@@ -261,7 +261,7 @@ void RemotedSession::validate(const Application& application, const char* client
 }\r
 \r
 RemotedCache::RemotedCache(const DOMElement* e)\r
-    : SessionCache(e), m_log(Category::getInstance(SHIBSP_LOGCAT".SessionCache")), m_root(e), m_lock(NULL), shutdown(false)\r
+    : SessionCache(e, 900), m_log(Category::getInstance(SHIBSP_LOGCAT".SessionCache")), m_root(e), m_lock(NULL), shutdown(false)\r
 {\r
     if (!SPConfig::getConfig().getServiceProvider()->getListenerService())\r
         throw ConfigurationException("RemotedCacheService requires a ListenerService, but none available.");\r
index f310a55..ae2135e 100644 (file)
@@ -112,16 +112,16 @@ namespace shibsp {
             return m_attributes;
         }
         const multimap<string,const Attribute*>& getIndexedAttributes() const {
-            if (m_attributeIndex.empty()) {\r
-                if (m_attributes.empty())\r
-                    unmarshallAttributes();\r
-                for (vector<Attribute*>::const_iterator a = m_attributes.begin(); a != m_attributes.end(); ++a) {\r
-                    const vector<string>& aliases = (*a)->getAliases();\r
-                    for (vector<string>::const_iterator alias = aliases.begin(); alias != aliases.end(); ++alias)\r
-                        m_attributeIndex.insert(make_pair(*alias, *a));\r
-                }\r
-            }\r
-            return m_attributeIndex;\r
+            if (m_attributeIndex.empty()) {
+                if (m_attributes.empty())
+                    unmarshallAttributes();
+                for (vector<Attribute*>::const_iterator a = m_attributes.begin(); a != m_attributes.end(); ++a) {
+                    const vector<string>& aliases = (*a)->getAliases();
+                    for (vector<string>::const_iterator alias = aliases.begin(); alias != aliases.end(); ++alias)
+                        m_attributeIndex.insert(make_pair(*alias, *a));
+                }
+            }
+            return m_attributeIndex;
         }
         const vector<const char*>& getAssertionIDs() const {
             if (m_ids.empty()) {
@@ -450,7 +450,7 @@ void StoredSession::addAssertion(Assertion* assertion)
 }
 
 SSCache::SSCache(const DOMElement* e)
-    : SessionCache(e), m_log(Category::getInstance(SHIBSP_LOGCAT".SessionCache")), m_storage(NULL)
+    : SessionCache(e, 3600), m_log(Category::getInstance(SHIBSP_LOGCAT".SessionCache")), m_storage(NULL)
 {
     SPConfig& conf = SPConfig::getConfig();
     const XMLCh* tag = e ? e->getAttributeNS(NULL,_StorageService) : NULL;