|
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\XMLSchema\Exception\InvalidDOMElementException; |
|
10
|
|
|
use SimpleSAML\XMLSchema\Exception\MissingElementException; |
|
11
|
|
|
use SimpleSAML\XMLSchema\Exception\TooManyElementsException; |
|
12
|
|
|
|
|
13
|
|
|
use function array_pop; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class representing a ds:X509IssuerSerial element. |
|
17
|
|
|
* |
|
18
|
|
|
* @package simplesaml/xml-security |
|
19
|
|
|
*/ |
|
20
|
|
|
final class X509IssuerSerial extends AbstractDsElement |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Initialize a X509SubjectName element. |
|
24
|
|
|
* |
|
25
|
|
|
* @param \SimpleSAML\XMLSecurity\XML\ds\X509IssuerName $X509IssuerName |
|
26
|
|
|
* @param \SimpleSAML\XMLSecurity\XML\ds\X509SerialNumber $X509SerialNumber |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct( |
|
29
|
|
|
protected X509IssuerName $X509IssuerName, |
|
30
|
|
|
protected X509SerialNumber $X509SerialNumber, |
|
31
|
|
|
) { |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Collect the value of the X509IssuerName-property |
|
37
|
|
|
* |
|
38
|
|
|
* @return \SimpleSAML\XMLSecurity\XML\ds\X509IssuerName |
|
39
|
|
|
*/ |
|
40
|
|
|
public function getIssuerName(): X509IssuerName |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->X509IssuerName; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Collect the value of the X509SerialNumber-property |
|
48
|
|
|
* |
|
49
|
|
|
* @return \SimpleSAML\XMLSecurity\XML\ds\X509SerialNumber |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getSerialNumber(): X509SerialNumber |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->X509SerialNumber; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Convert XML into a X509IssuerSerial |
|
59
|
|
|
* |
|
60
|
|
|
* @param \DOMElement $xml The XML element we should load |
|
61
|
|
|
* @return static |
|
62
|
|
|
* |
|
63
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
|
64
|
|
|
* If the qualified name of the supplied element is wrong |
|
65
|
|
|
*/ |
|
66
|
|
|
public static function fromXML(DOMElement $xml): static |
|
67
|
|
|
{ |
|
68
|
|
|
Assert::same($xml->localName, 'X509IssuerSerial', InvalidDOMElementException::class); |
|
69
|
|
|
Assert::same($xml->namespaceURI, X509IssuerSerial::NS, InvalidDOMElementException::class); |
|
70
|
|
|
|
|
71
|
|
|
$issuer = X509IssuerName::getChildrenOfClass($xml); |
|
72
|
|
|
$serial = X509SerialNumber::getChildrenOfClass($xml); |
|
73
|
|
|
|
|
74
|
|
|
Assert::minCount($issuer, 1, MissingElementException::class); |
|
75
|
|
|
Assert::maxCount($issuer, 1, TooManyElementsException::class); |
|
76
|
|
|
|
|
77
|
|
|
Assert::minCount($serial, 1, MissingElementException::class); |
|
78
|
|
|
Assert::maxCount($serial, 1, TooManyElementsException::class); |
|
79
|
|
|
|
|
80
|
|
|
return new static( |
|
81
|
|
|
array_pop($issuer), |
|
82
|
|
|
array_pop($serial), |
|
83
|
|
|
); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Convert this X509IssuerSerial element to XML. |
|
89
|
|
|
* |
|
90
|
|
|
* @param \DOMElement|null $parent The element we should append this X509IssuerSerial element to. |
|
91
|
|
|
* @return \DOMElement |
|
92
|
|
|
*/ |
|
93
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
|
94
|
|
|
{ |
|
95
|
|
|
$e = $this->instantiateParentElement($parent); |
|
96
|
|
|
|
|
97
|
|
|
$this->getIssuerName()->toXML($e); |
|
98
|
|
|
$this->getSerialNumber()->toXML($e); |
|
99
|
|
|
|
|
100
|
|
|
return $e; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|