|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SAML2\XML\md; |
|
4
|
|
|
|
|
5
|
|
|
use SAML2\Utils; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class representing SAML 2 SPSSODescriptor. |
|
9
|
|
|
* |
|
10
|
|
|
* @package SimpleSAMLphp |
|
11
|
|
|
*/ |
|
12
|
|
|
class SPSSODescriptor extends SSODescriptorType |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* Whether this SP signs authentication requests. |
|
16
|
|
|
* |
|
17
|
|
|
* @var bool|null |
|
18
|
|
|
*/ |
|
19
|
|
|
public $AuthnRequestsSigned = null; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Whether this SP wants the Assertion elements to be signed. |
|
23
|
|
|
* |
|
24
|
|
|
* @var bool|null |
|
25
|
|
|
*/ |
|
26
|
|
|
public $WantAssertionsSigned = null; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* List of AssertionConsumerService endpoints for this SP. |
|
30
|
|
|
* |
|
31
|
|
|
* Array with IndexedEndpointType objects. |
|
32
|
|
|
* |
|
33
|
|
|
* @var \SAML2\XML\md\IndexedEndpointType[] |
|
34
|
|
|
*/ |
|
35
|
|
|
public $AssertionConsumerService = array(); |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* List of AttributeConsumingService descriptors for this SP. |
|
39
|
|
|
* |
|
40
|
|
|
* Array with \SAML2\XML\md\AttributeConsumingService objects. |
|
41
|
|
|
* |
|
42
|
|
|
* @var \SAML2\XML\md\AttributeConsumingService[] |
|
43
|
|
|
*/ |
|
44
|
|
|
public $AttributeConsumingService = array(); |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Initialize a SPSSODescriptor. |
|
48
|
|
|
* |
|
49
|
|
|
* @param \DOMElement|null $xml The XML element we should load. |
|
50
|
|
|
*/ |
|
51
|
|
|
public function __construct(\DOMElement $xml = null) |
|
52
|
|
|
{ |
|
53
|
|
|
parent::__construct('md:SPSSODescriptor', $xml); |
|
54
|
|
|
|
|
55
|
|
|
if ($xml === null) { |
|
56
|
|
|
return; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$this->AuthnRequestsSigned = Utils::parseBoolean($xml, 'AuthnRequestsSigned', null); |
|
60
|
|
|
$this->WantAssertionsSigned = Utils::parseBoolean($xml, 'WantAssertionsSigned', null); |
|
61
|
|
|
|
|
62
|
|
|
foreach (Utils::xpQuery($xml, './saml_metadata:AssertionConsumerService') as $ep) { |
|
63
|
|
|
$this->AssertionConsumerService[] = new IndexedEndpointType($ep); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
foreach (Utils::xpQuery($xml, './saml_metadata:AttributeConsumingService') as $acs) { |
|
67
|
|
|
$this->AttributeConsumingService[] = new AttributeConsumingService($acs); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Add this SPSSODescriptor to an EntityDescriptor. |
|
73
|
|
|
* |
|
74
|
|
|
* @param \DOMElement $parent The EntityDescriptor we should append this SPSSODescriptor to. |
|
75
|
|
|
* @return void |
|
76
|
|
|
*/ |
|
77
|
|
|
public function toXML(\DOMElement $parent) |
|
78
|
|
|
{ |
|
79
|
|
|
assert('is_null($this->AuthnRequestsSigned) || is_bool($this->AuthnRequestsSigned)'); |
|
80
|
|
|
assert('is_null($this->WantAssertionsSigned) || is_bool($this->WantAssertionsSigned)'); |
|
81
|
|
|
assert('is_array($this->AssertionConsumerService)'); |
|
82
|
|
|
assert('is_array($this->AttributeConsumingService)'); |
|
83
|
|
|
|
|
84
|
|
|
$e = parent::toXML($parent); |
|
85
|
|
|
|
|
86
|
|
|
if ($this->AuthnRequestsSigned === true) { |
|
87
|
|
|
$e->setAttribute('AuthnRequestsSigned', 'true'); |
|
88
|
|
|
} elseif ($this->AuthnRequestsSigned === false) { |
|
89
|
|
|
$e->setAttribute('AuthnRequestsSigned', 'false'); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
if ($this->WantAssertionsSigned === true) { |
|
93
|
|
|
$e->setAttribute('WantAssertionsSigned', 'true'); |
|
94
|
|
|
} elseif ($this->WantAssertionsSigned === false) { |
|
95
|
|
|
$e->setAttribute('WantAssertionsSigned', 'false'); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
foreach ($this->AssertionConsumerService as $ep) { |
|
99
|
|
|
$ep->toXML($e, 'md:AssertionConsumerService'); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
foreach ($this->AttributeConsumingService as $acs) { |
|
103
|
|
|
$acs->toXML($e); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|