|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\XML; |
|
6
|
|
|
|
|
7
|
|
|
use DOMElement; |
|
8
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\Signature; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Abstract class to be implemented by all signed classes |
|
12
|
|
|
* |
|
13
|
|
|
* @package simplesamlphp/xml-security |
|
14
|
|
|
*/ |
|
15
|
|
|
abstract class AbstractSignedXMLElement implements SignedElementInterface |
|
16
|
|
|
{ |
|
17
|
|
|
use SignedElementTrait; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* The signed DOM structure. |
|
21
|
|
|
* |
|
22
|
|
|
* @var \DOMElement |
|
23
|
|
|
*/ |
|
24
|
|
|
protected DOMElement $structure; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* The unsigned elelement. |
|
28
|
|
|
* |
|
29
|
|
|
* @var \SimpleSAML\XMLSecurity\XML\SignableElementInterface |
|
30
|
|
|
*/ |
|
31
|
|
|
protected SignableElementInterface $element; |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Create/parse an alg:SigningMethod element. |
|
36
|
|
|
* |
|
37
|
|
|
* @param \DOMElement $xml |
|
38
|
|
|
* @param \SimpleSAML\XMLSecurity\XML\SignableElementInterface $elt |
|
39
|
|
|
* @param \SimpleSAML\XMLSecurity\XML\ds\Signature $signature |
|
40
|
|
|
*/ |
|
41
|
|
|
protected function __construct(DOMElement $xml, SignableElementInterface $elt, Signature $signature) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->element = $elt; |
|
44
|
|
|
$this->setStructure($xml); |
|
45
|
|
|
$this->setSignature($signature); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Output the class as an XML-formatted string |
|
51
|
|
|
* |
|
52
|
|
|
* @return string |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __toString(): string |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->structure->ownerDocument->saveXML(); |
|
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Collect the value of the structure-property |
|
62
|
|
|
* |
|
63
|
|
|
* @return \DOMElement |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getStructure(): DOMElement |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->structure; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Set the value of the structure-property |
|
73
|
|
|
* |
|
74
|
|
|
* @param \DOMElement $structure |
|
75
|
|
|
*/ |
|
76
|
|
|
private function setStructure(DOMElement $structure): void |
|
77
|
|
|
{ |
|
78
|
|
|
$this->structure = $structure; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Create XML from this class |
|
84
|
|
|
* |
|
85
|
|
|
* @param \DOMElement|null $parent |
|
86
|
|
|
* @return \DOMElement |
|
87
|
|
|
*/ |
|
88
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
|
|
|
|
|
|
89
|
|
|
{ |
|
90
|
|
|
return $this->structure; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Create a class from XML |
|
96
|
|
|
* |
|
97
|
|
|
* @param \DOMElement $xml |
|
98
|
|
|
* @return self |
|
99
|
|
|
*/ |
|
100
|
|
|
abstract public static function fromXML(DOMElement $xml): object; |
|
101
|
|
|
} |
|
102
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.