https://issues.shibboleth.net/jira/browse/SSPCPP-393
authorscantor <scantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Tue, 11 Oct 2011 17:57:09 +0000 (17:57 +0000)
committerscantor <scantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Tue, 11 Oct 2011 17:57:09 +0000 (17:57 +0000)
git-svn-id: https://svn.shibboleth.net/cpp-sp/branches/REL_2@3528 cb58f699-b61c-0410-a6fe-9272a202ed29

shibsp/impl/StorageServiceSessionCache.cpp

index 9447573..a216a8d 100644 (file)
@@ -144,7 +144,7 @@ namespace shibsp {
 
         unsigned long getCacheTimeout(const Application& app) {
             // Computes offset for adjusting expiration of sessions.
-            // This can either be static, or dynamic based on the per-app session timeout.
+            // This can either be static, or dynamic based on the per-app session timeout or lifetime.
             if (m_cacheTimeout)
                 return m_cacheTimeout;
             pair<bool,unsigned int> timeout = pair<bool,unsigned int>(false, 3600);
@@ -154,7 +154,18 @@ namespace shibsp {
                 if (!timeout.first)
                     timeout.second = 3600;
             }
-            return timeout.second + m_cacheAllowance;
+            // As long as one of the two factors is set, add them together.
+            if (timeout.second > 0 || m_cacheAllowance > 0)
+                return timeout.second + m_cacheAllowance;
+
+            // If timeouts are off, and there's no cache slop set, then use the lifetime.
+            timeout = pair<bool,unsigned int>(false, 28800);
+            if (props) {
+                timeout = props->getUnsignedInt("lifetime");
+                if (!timeout.first || timeout.second == 0)
+                    timeout.second = 28800;
+            }
+            return timeout.second;
         }
 
         Category& m_log;