blob: f239c9a01d4ab73209f95a0cadb62ac242e6a54a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
<?php
/**
* Class for SAML 2 logout request messages.
*
* @package simpleSAMLphp
* @version $Id$
*/
class SAML2_LogoutRequest extends SAML2_Request {
/**
* The name identifier of the session that should be terminated.
*
* @var array
*/
private $nameId;
/**
* The session index of the session that should be terminated.
*
* @var string|NULL
*/
private $sessionIndex;
/**
* Constructor for SAML 2 logout request messages.
*
* @param DOMElement|NULL $xml The input message.
*/
public function __construct(DOMElement $xml = NULL) {
parent::__construct('LogoutRequest', $xml);
if ($xml === NULL) {
return;
}
$nameId = SAML2_Utils::xpQuery($xml, './saml:NameID');
if (empty($nameId)) {
throw new Exception('Missing NameID in logout request.');
}
$this->nameId = SAML2_Utils::parseNameId($nameId[0]);
$sessionIndex = SAML2_Utils::xpQuery($xml, './samlp:SessionIndex');
if (!empty($sessionIndex)) {
$this->sessionIndex = $sessionIndex[0]->textContent;
}
}
/**
* Retrieve the name identifier of the session that should be terminated.
*
* @return array The name identifier of the session that should be terminated.
*/
public function getNameId() {
return $this->nameId;
}
/**
* Set the name identifier of the session that should be terminated.
*
* The name identifier must be in the format accepted by SAML2_message::buildNameId().
*
* @see SAML2_message::buildNameId()
* @param array $nameId The name identifier of the session that should be terminated.
*/
public function setNameId($nameId) {
assert('is_array($nameId)');
$this->nameId = $nameId;
}
/**
* 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;
}
/**
* Set the sesion index of the session that should be terminated.
*
* @param string|NULL $sessionIndex The sesion index of the session that should be terminated.
*/
public function setSessionIndex($sessionIndex) {
assert('is_string($sessionIndex)');
$this->sessionIndex = $sessionIndex;
}
/**
* Convert this logout request message to an XML element.
*
* @return DOMElement This logout request.
*/
public function toUnsignedXML() {
$root = parent::toUnsignedXML();
SAML2_Utils::addNameId($root, $this->nameId);
if ($this->sessionIndex !== NULL) {
$sessionIndex = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'SessionIndex');
$sessionIndex->appendChild($this->document->createTextNode($this->sessionIndex));
$root->appendChild($sessionIndex);
}
return $root;
}
}
?>
|