1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Copyright 2015 SURFnet bv |
7
|
|
|
* |
8
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
9
|
|
|
* you may not use this file except in compliance with the License. |
10
|
|
|
* You may obtain a copy of the License at |
11
|
|
|
* |
12
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
* |
14
|
|
|
* Unless required by applicable law or agreed to in writing, software |
15
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
16
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17
|
|
|
* See the License for the specific language governing permissions and |
18
|
|
|
* limitations under the License. |
19
|
|
|
*/ |
|
|
|
|
20
|
|
|
|
21
|
|
|
namespace Surfnet\StepupSelfService\SamlStepupProviderBundle\Provider; |
22
|
|
|
|
23
|
|
|
use DOMDocument; |
24
|
|
|
use LogicException; |
25
|
|
|
use Surfnet\SamlBundle\Signing\Signable; |
26
|
|
|
use Stringable; |
27
|
|
|
use DOMElement; |
28
|
|
|
use DOMNode; |
29
|
|
|
|
30
|
|
|
class Metadata implements Signable, Stringable |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
/** |
|
|
|
|
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
public $entityId; |
36
|
|
|
|
37
|
|
|
/** |
|
|
|
|
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
public $assertionConsumerUrl; |
41
|
|
|
|
42
|
|
|
/** |
|
|
|
|
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
public $ssoUrl; |
46
|
|
|
|
47
|
|
|
/** |
|
|
|
|
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
public $idpCertificateFile; |
51
|
|
|
|
52
|
|
|
/** |
|
|
|
|
53
|
|
|
* @var DOMDocument |
54
|
|
|
*/ |
55
|
|
|
public $document; |
56
|
|
|
|
57
|
|
|
public function getRootDomElement(): DOMElement |
|
|
|
|
58
|
|
|
{ |
59
|
|
|
if (!$this->document) { |
60
|
|
|
throw new LogicException('Cannot get the rootElement of Metadata before the document has been generated'); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
return $this->document->documentElement; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getAppendBeforeNode(): ?DOMNode |
|
|
|
|
67
|
|
|
{ |
68
|
|
|
if (!$this->document) { |
69
|
|
|
throw new LogicException( |
70
|
|
|
'Cannot get the appendBeforeNode of Metadata before the document has been generated' |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return $this->document->documentElement->childNodes->item(0); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function __toString(): string |
|
|
|
|
78
|
|
|
{ |
79
|
|
|
return (string) $this->document->saveXML(); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|