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

Adding a session->getsize class to measure the size of the session. I also...

Adding a session->getsize class to measure the size of the session. I also removed the reference to the configuration class which saved 12% size of the session size... will be further reduced... hold on.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@202 44740490-163a-0410-bde0-09ae8108e29a
parent 20322bb5
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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>
......
......@@ -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';
......
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