|
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
|
|
|
toXML as parentToXML; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Convert XML into a X509SerialNumber |
|
27
|
|
|
* |
|
28
|
|
|
* @param \DOMElement $xml The XML element we should load |
|
29
|
|
|
* @return self |
|
30
|
|
|
* |
|
31
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
|
32
|
|
|
* If the qualified name of the supplied element is wrong |
|
33
|
|
|
*/ |
|
34
|
|
|
public static function fromXML(DOMElement $xml): object |
|
35
|
|
|
{ |
|
36
|
|
|
Assert::same($xml->localName, 'X509SerialNumber', InvalidDOMElementException::class); |
|
37
|
|
|
Assert::same($xml->namespaceURI, X509SerialNumber::NS, InvalidDOMElementException::class); |
|
38
|
|
|
Assert::same($xml->getAttributeNS(Constants::NS_XSI, "type"), 'xs:integer'); |
|
39
|
|
|
|
|
40
|
|
|
return new self($xml->textContent); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Convert this X509SerialNumber element to XML. |
|
46
|
|
|
* |
|
47
|
|
|
* @param \DOMElement|null $parent The element we should append this X509SerialNumber element to. |
|
48
|
|
|
* @return \DOMElement |
|
49
|
|
|
*/ |
|
50
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
|
51
|
|
|
{ |
|
52
|
|
|
$e = $this->parentToXML($parent); |
|
53
|
|
|
$e->setAttributeNS(Constants::NS_XSI, 'xsi:type', 'xs:integer'); |
|
54
|
|
|
|
|
55
|
|
|
return $e; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|