Skip to content
Snippets Groups Projects
Commit 74ae269f authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Added some more debug logging, and fixed a serious bug with the session...

Added some more debug logging, and fixed a serious bug with the session clean() method that caused bridging to not work properly as the cached requestID also was cleaned :)

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@244 44740490-163a-0410-bde0-09ae8108e29a
parent 494b31f3
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment