diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index 3bf9ff8c1b0bf97cde0a496a1e7e0d58539a0f5f..02d4426dd65c67c6e71c6952f584f620c38e3a34 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -41,9 +41,6 @@ class SimpleSAML_Session { * about what went wrong. */ private $trackid = 0; - - - private $configuration = null; private $authnrequests = array(); private $shibauthreq = null; @@ -76,7 +73,7 @@ class SimpleSAML_Session { */ private function __construct($protocol, SimpleSAML_XML_AuthnResponse $message = null, $authenticated = true) { - $this->configuration = SimpleSAML_Configuration::getInstance(); + $this->protocol = $protocol; $this->authnresponse = $message; @@ -87,7 +84,8 @@ class SimpleSAML_Session { $this->sessionstarted = time(); } - $this->sessionduration = $this->configuration->getValue('session.duration'); + $configuration = SimpleSAML_Configuration::getInstance(); + $this->sessionduration = $configuration->getValue('session.duration'); $this->trackid = SimpleSAML_Utilities::generateTrackID(); } @@ -206,6 +204,8 @@ class SimpleSAML_Session { * authentication request. */ public function getAuthnRequest($protocol, $requestid) { + + $configuration = SimpleSAML_Configuration::getInstance(); if (isset($this->authnrequests[$protocol])) { /* * Traverse all cached authentication requests in this session for this user using this protocol @@ -215,7 +215,7 @@ class SimpleSAML_Session { * If any of the cached requests is elder than the session.requestcache duration, then just * simply delete it :) */ - if ($cache['date'] < $this->configuration->getValue('session.requestcache', time() - (4*60*60) )) + if ($cache['date'] < $configuration->getValue('session.requestcache', time() - (4*60*60) )) unset($this->authnrequests[$protocol][$id]); } } @@ -355,6 +355,12 @@ class SimpleSAML_Session { public function isModified() { return $this->dirty; } + + + public function getSize() { + $s = serialize($this); + return strlen($s); + } } ?> \ No newline at end of file diff --git a/templates/default/en/status.php b/templates/default/en/status.php index e38885d7a1c62724114e70e845a69da30c043c29..0929302f1b1eb00d45dbd7d814273b9b250fc21e 100644 --- a/templates/default/en/status.php +++ b/templates/default/en/status.php @@ -13,6 +13,8 @@ <p><?php echo $data['valid']; ?>. Your session is valid for <?php echo $data['remaining']; ?> seconds from now.</p> + <p>Session size: <?php echo isset($data['sessionsize']) ? $data['sessionsize'] : 'na'; ?> + <h2>Your attributes</h2> <table> diff --git a/www/example-simple/saml2-example.php b/www/example-simple/saml2-example.php index 30705a345816c4b7e9b17658d35bd794c5680419..be04257fb13d74e36bbbb1864fd137660fde31f1 100644 --- a/www/example-simple/saml2-example.php +++ b/www/example-simple/saml2-example.php @@ -5,10 +5,6 @@ require_once('../_include.php'); require_once('SimpleSAML/Utilities.php'); require_once('SimpleSAML/Session.php'); require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php'); -require_once('SimpleSAML/XML/SAML20/AuthnRequest.php'); -require_once('SimpleSAML/XML/SAML20/AuthnResponse.php'); -require_once('SimpleSAML/Bindings/SAML20/HTTPRedirect.php'); -require_once('SimpleSAML/Bindings/SAML20/HTTPPost.php'); require_once('SimpleSAML/XHTML/Template.php'); @@ -42,6 +38,7 @@ $et = new SimpleSAML_XHTML_Template($config, 'status.php'); $et->data['header'] = 'SAML 2.0 SP Demo Example'; $et->data['remaining'] = $session->remainingTime(); +$et->data['sessionsize'] = $session->getSize(); $et->data['attributes'] = $attributes; $et->data['valid'] = $session->isValid() ? 'Session is valid' : 'Session is invalid';