1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\XML\dsig11; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Chunk; |
10
|
|
|
use SimpleSAML\XML\Exception\SchemaViolationException; |
11
|
|
|
use SimpleSAML\XML\ExtendableElementTrait; |
12
|
|
|
use SimpleSAML\XML\SerializableElementInterface; |
13
|
|
|
use SimpleSAML\XML\XsNamespace as NS; |
14
|
|
|
use SimpleSAML\XMLSecurity\Constants as C; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Abstract class representing a dsig11:FieldIDType |
18
|
|
|
* |
19
|
|
|
* @package simplesaml/xml-security |
20
|
|
|
*/ |
21
|
|
|
abstract class AbstractFieldIDType extends AbstractDsig11Element |
22
|
|
|
{ |
23
|
|
|
// We use our own getter instead of the trait's one, so we prevent their use by marking them private |
24
|
|
|
use ExtendableElementTrait { |
25
|
|
|
getElements as private; |
26
|
|
|
setElements as private; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** @var \SimpleSAML\XML\XsNamespace */ |
30
|
|
|
public const XS_ANY_ELT_NAMESPACE = NS::OTHER; |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Initialize a FieldIDType element. |
35
|
|
|
* |
36
|
|
|
* @param \SimpleSAML\XML\SerializableElementInterface $fieldId |
37
|
|
|
*/ |
38
|
|
|
public function __construct( |
39
|
|
|
protected Prime|TnB|PnB|GnB|SerializableElementInterface $fieldId, |
40
|
|
|
) { |
41
|
|
|
if ( |
42
|
|
|
!($fieldId instanceof Prime |
43
|
|
|
|| $fieldId instanceof TnB |
44
|
|
|
|| $fieldId instanceof PnB |
45
|
|
|
|| $fieldId instanceof GnB) |
46
|
|
|
) { |
47
|
|
|
Assert::true( |
48
|
|
|
(($fieldId instanceof Chunk) ? $fieldId->getNamespaceURI() : $fieldId::getNameSpaceURI()) |
49
|
|
|
!== C::NS_XDSIG11, |
50
|
|
|
'A <dsig11:FieldIDType> requires either a Prime, TnB, PnB, GnB or an element in namespace ##other', |
51
|
|
|
SchemaViolationException::class, |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Collect the value of the fieldId-property |
59
|
|
|
* |
60
|
|
|
* @return (\SimpleSAML\XMLSecurity\XML\dsig11\Prime| |
|
|
|
|
61
|
|
|
* \SimpleSAML\XMLSecurity\XML\dsig11\TnB| |
62
|
|
|
* \SimpleSAML\XMLSecurity\XML\dsig11\PnB| |
63
|
|
|
* \SimpleSAML\XMLSecurity\XML\dsig11\GnB| |
64
|
|
|
* \SimpleSAML\XML\SerializableElementInterface) |
65
|
|
|
*/ |
66
|
|
|
public function getFieldId(): Prime|TnB|PnB|GnB|SerializableElementInterface |
67
|
|
|
{ |
68
|
|
|
return $this->fieldId; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Convert this FieldIDType element to XML. |
74
|
|
|
* |
75
|
|
|
* @param \DOMElement|null $parent The element we should append this FieldIDType element to. |
76
|
|
|
* @return \DOMElement |
77
|
|
|
*/ |
78
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
79
|
|
|
{ |
80
|
|
|
$e = $this->instantiateParentElement($parent); |
81
|
|
|
|
82
|
|
|
$this->getFieldId()->toXML($e); |
83
|
|
|
|
84
|
|
|
return $e; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|