Skip to content
Snippets Groups Projects
Commit 85e859a0 authored by Olav Morken's avatar Olav Morken
Browse files

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
parent 9bcb56ac
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
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