summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Åkre Solberg <andreas.solberg@uninett.no>2008-01-28 12:50:31 +0000
committerAndreas Åkre Solberg <andreas.solberg@uninett.no>2008-01-28 12:50:31 +0000
commit6befdb098a16e22a8b6bb69a1c9c49988771577f (patch)
tree26522b80cbf7c5349ae9376b4f8a053798e0da8b
parent20322bb5a858665112ec4f61436171fab38720f5 (diff)
downloadsimplesamlphp-6befdb098a16e22a8b6bb69a1c9c49988771577f.zip
simplesamlphp-6befdb098a16e22a8b6bb69a1c9c49988771577f.tar.gz
simplesamlphp-6befdb098a16e22a8b6bb69a1c9c49988771577f.tar.bz2
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
-rw-r--r--lib/SimpleSAML/Session.php18
-rw-r--r--templates/default/en/status.php2
-rw-r--r--www/example-simple/saml2-example.php5
3 files changed, 15 insertions, 10 deletions
diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php
index 3bf9ff8..02d4426 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 e38885d..0929302 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 30705a3..be04257 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';