-
Notifications
You must be signed in to change notification settings - Fork 701
Expand file tree
/
Copy pathResponse.php
More file actions
84 lines (64 loc) · 1.56 KB
/
Response.php
File metadata and controls
84 lines (64 loc) · 1.56 KB
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
<?php
/**
* Class for SAML 2 Response messages.
*
* @package simpleSAMLphp
* @version $Id$
*/
class SAML2_Response extends SAML2_StatusResponse {
/**
* The assertions in this response.
*/
private $assertions;
/**
* Constructor for SAML 2 response messages.
*
* @param DOMElement|NULL $xml The input message.
*/
public function __construct(DOMElement $xml = NULL) {
parent::__construct('Response', $xml);
$this->assertions = array();
if ($xml === NULL) {
return;
}
for ($node = $xml->firstChild; $node !== NULL; $node = $node->nextSibling) {
if ($node->namespaceURI !== SAML2_Const::NS_SAML) {
continue;
}
if ($node->localName === 'Assertion') {
$this->assertions[] = new SAML2_Assertion($node);
} elseif($node->localName === 'EncryptedAssertion') {
$this->assertions[] = new SAML2_EncryptedAssertion($node);
}
}
}
/**
* Retrieve the assertions in this response.
*
* @return array Array of SAML2_Assertion and SAML2_EncryptedAssertion objects.
*/
public function getAssertions() {
return $this->assertions;
}
/**
* Set the assertions that should be included in this response.
*
* @param array The assertions.
*/
public function setAssertions(array $assertions) {
$this->assertions = $assertions;
}
/**
* Convert the response message to an XML element.
*
* @return DOMElement This response.
*/
public function toUnsignedXML() {
$root = parent::toUnsignedXML();
foreach ($this->assertions as $assertion) {
$node = $assertion->toXML($root);
}
return $root;
}
}
?>