1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\XML\ds; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Constants; |
10
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
11
|
|
|
use SimpleSAML\XML\XMLStringElementTrait; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class representing a ds:X509SerialNumber element. |
15
|
|
|
* |
16
|
|
|
* @package simplesaml/xml-security |
17
|
|
|
*/ |
18
|
|
|
final class X509SerialNumber extends AbstractDsElement |
19
|
|
|
{ |
20
|
|
|
use XMLStringElementTrait; |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Convert XML into a X509SerialNumber |
25
|
|
|
* |
26
|
|
|
* @param \DOMElement $xml The XML element we should load |
27
|
|
|
* @return self |
28
|
|
|
* |
29
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
30
|
|
|
* If the qualified name of the supplied element is wrong |
31
|
|
|
*/ |
32
|
|
|
public static function fromXML(DOMElement $xml): object |
33
|
|
|
{ |
34
|
|
|
Assert::same($xml->localName, 'X509SerialNumber', InvalidDOMElementException::class); |
35
|
|
|
Assert::same($xml->namespaceURI, X509SerialNumber::NS, InvalidDOMElementException::class); |
36
|
|
|
Assert::same($xml->getAttributeNS(Constants::NS_XSI, "type"), 'xs:integer'); |
37
|
|
|
|
38
|
|
|
return new self($xml->textContent); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Convert this X509SerialNumber element to XML. |
44
|
|
|
* |
45
|
|
|
* @param \DOMElement|null $parent The element we should append this X509SerialNumber element to. |
46
|
|
|
* @return \DOMElement |
47
|
|
|
*/ |
48
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
49
|
|
|
{ |
50
|
|
|
$e = $this->instantiateParentElement($parent); |
51
|
|
|
$e->textContent = $this->content; |
52
|
|
|
$e->setAttributeNS(Constants::NS_XSI, 'xsi:type', 'xs:integer'); |
53
|
|
|
|
54
|
|
|
return $e; |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|