From 85e859a0d99382fcff7477d06959dea3e43e75da Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 9 Aug 2010 08:51:31 +0000 Subject: [PATCH] SAML2/LogoutRequest: Add support for multiple SessionIndex entries in the message. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2493 44740490-163a-0410-bde0-09ae8108e29a --- lib/SAML2/LogoutRequest.php | 51 +++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/lib/SAML2/LogoutRequest.php b/lib/SAML2/LogoutRequest.php index fd441c866..710c58f77 100644 --- a/lib/SAML2/LogoutRequest.php +++ b/lib/SAML2/LogoutRequest.php @@ -18,11 +18,11 @@ class SAML2_LogoutRequest extends SAML2_Request { /** - * The session index of the session that should be terminated. + * The SessionIndexes of the sessions that should be terminated. * - * @var string|NULL + * @var array */ - private $sessionIndex; + private $sessionIndexes; /** @@ -33,6 +33,8 @@ class SAML2_LogoutRequest extends SAML2_Request { public function __construct(DOMElement $xml = NULL) { parent::__construct('LogoutRequest', $xml); + $this->sessionIndexes = array(); + if ($xml === NULL) { return; } @@ -43,9 +45,9 @@ class SAML2_LogoutRequest extends SAML2_Request { } $this->nameId = SAML2_Utils::parseNameId($nameId[0]); - $sessionIndex = SAML2_Utils::xpQuery($xml, './saml_protocol:SessionIndex'); - if (!empty($sessionIndex)) { - $this->sessionIndex = trim($sessionIndex[0]->textContent); + $sessionIndexes = SAML2_Utils::xpQuery($xml, './saml_protocol:SessionIndex'); + foreach ($sessionIndexes as $sessionIndex) { + $this->sessionIndexes[] = trim($sessionIndex->textContent); } } @@ -75,13 +77,38 @@ class SAML2_LogoutRequest extends SAML2_Request { } + /** + * Retrieve the SessionIndexes of the sessions that should be terminated. + * + * @return array The SessionIndexes, or an empty array if all sessions should be terminated. + */ + public function getSessionIndexes() { + return $this->sessionIndexes; + } + + + /** + * Set the SessionIndexes of the sessions that should be terminated. + * + * @param array $sessionIndexes The SessionIndexes, or an empty array if all sessions should be terminated. + */ + public function setSessionIndexes(array $sessionIndexes) { + $this->sessionIndexes = $sessionIndexes; + } + + /** * Retrieve the sesion index of the session that should be terminated. * * @return string|NULL The sesion index of the session that should be terminated. */ public function getSessionIndex() { - return $this->sessionIndex; + + if (empty($this->sessionIndexes)) { + return NULL; + } + + return $this->sessionIndexes[0]; } @@ -93,7 +120,11 @@ class SAML2_LogoutRequest extends SAML2_Request { public function setSessionIndex($sessionIndex) { assert('is_string($sessionIndex) || is_null($sessionIndex)'); - $this->sessionIndex = $sessionIndex; + if (is_null($sessionIndex)) { + $this->sessionIndexes = array(); + } else { + $this->sessionIndexes = array($sessionIndex); + } } @@ -108,8 +139,8 @@ class SAML2_LogoutRequest extends SAML2_Request { SAML2_Utils::addNameId($root, $this->nameId); - if ($this->sessionIndex !== NULL) { - SAML2_Utils::addString($root, SAML2_Const::NS_SAMLP, 'SessionIndex', $this->sessionIndex); + foreach ($this->sessionIndexes as $sessionIndex) { + SAML2_Utils::addString($root, SAML2_Const::NS_SAMLP, 'SessionIndex', $sessionIndex); } return $root; -- GitLab