diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php index 9336ac43e74e10e0b6fabfaa50ded8b1d186762b..7f63214a7035cf76889aa8c6faeeb25b9fbebc50 100644 --- a/lib/SimpleSAML/Logger.php +++ b/lib/SimpleSAML/Logger.php @@ -30,10 +30,12 @@ class SimpleSAML_Logger { * Log a message to syslog. */ public function log($priority, $trackid = null, $module, $submodule, $eventtype, $content, $message) { - error_log('This entry is ' . $priority . ' and configuration says minimum ' . $this->loglevel); - error_log('LOG_ERR is ' . LOG_ERR . ' and LOGINFO is ' . LOG_INFO); + /* + error_log('This entry: ' . $message ); + error_log('This entry is ' . $priority . ' and will be loged if <= ' . $this->loglevel); + error_log('LOG_ERR is ' . LOG_ERR . ' and LOGINFO is ' . LOG_INFO . " LOG_DEBUG is " . LOG_DEBUG); + */ if ($priority > $this->loglevel) return; - error_log('Log2'); if ($trackid == null) { $trackid = 'na'; //$session = SimpleSAML_Session::getInstance(true); diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index ef9ccefe313181a8207b22ddd1a0b1f0290809ec..8ad2f0db8369972d2148467d34c12d6072fc0126 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -61,12 +61,16 @@ class SimpleSAML_Session { // Track whether the session object is modified or not. private $dirty = false; + private static $logger = null; + /** * private constructor restricts instantiaton to getInstance() */ private function __construct($authenticated = true) { + if (!isset($this->logger)) $this->logger = new SimpleSAML_Logger(); + $this->authenticated = $authenticated; if ($authenticated) { $this->sessionstarted = time(); @@ -210,6 +214,10 @@ class SimpleSAML_Session { */ public function getAuthnRequest($protocol, $requestid) { + + $this->logger->log(LOG_DEBUG, $this->getTrackID(), 'Library', 'Session', 'DEBUG', $requestid, + 'Get authnrequest from cache ' . $protocol . ' time:' . time() . ' id: '. $requestid ); + $configuration = SimpleSAML_Configuration::getInstance(); if (isset($this->authnrequests[$protocol])) { /* @@ -220,8 +228,12 @@ class SimpleSAML_Session { * If any of the cached requests is elder than the session.requestcache duration, then just * simply delete it :) */ - if ($cache['date'] < $configuration->getValue('session.requestcache', time() - (4*60*60) )) + if ($cache['date'] < time() - $configuration->getValue('session.requestcache', 4*(60*60)) ) { + + $this->logger->log(LOG_DEBUG, $this->getTrackID(), 'Library', 'Session', 'DEBUG', $id, + 'Deleting expired authn request with id ' . $id); unset($this->authnrequests[$protocol][$id]); + } } } /* @@ -245,6 +257,10 @@ class SimpleSAML_Session { * @param $cache The assoc array that will be stored. */ public function setAuthnRequest($protocol, $requestid, array $cache) { + + $this->logger->log(LOG_DEBUG, $this->getTrackID(), 'Library', 'Session', 'DEBUG', $requestid, + 'Set authnrequest ' . $protocol . ' time:' . time() . ' size:' . count($cache) . ' id: '. $requestid ); + $this->dirty = true; $cache['date'] = time(); $this->authnrequests[$protocol][$requestid] = $cache; @@ -360,10 +376,16 @@ class SimpleSAML_Session { /** * Clean the session object. */ - public function clean() { - $this->authnrequests = array(); - $this->logoutrequest = null; - $this->idp = null; + public function clean($cleancache = false) { + + $this->logger->log(LOG_DEBUG, $this->getTrackID(), 'Library', 'Session', 'DEBUG', '-', + 'Cleaning Session. Clean cache: ' . ($cleancache ? 'yes' : 'no') ); + + if ($cleancache) { + $this->authnrequests = array(); + $this->logoutrequest = null; + $this->idp = null; + } $this->authority = null;