55namespace SimpleSAML \XMLSecurity \XML \dsig11 ;
66
77use DOMElement ;
8+ use SimpleSAML \Assert \Assert ;
9+ use SimpleSAML \XML \Exception \SchemaViolationException ;
810use SimpleSAML \XML \ExtendableElementTrait ;
11+ use SimpleSAML \XML \SerializableElementInterface ;
912use SimpleSAML \XML \XsNamespace as NS ;
1013
1114/**
1518 */
1619abstract class AbstractFieldIDType extends AbstractDsig11Element
1720{
18- use ExtendableElementTrait;
21+ // We use our own getter instead of the trait's one, so we prevent their use by marking them private
22+ use ExtendableElementTrait {
23+ getElements as private ;
24+ setElements as private ;
25+ }
1926
2027 /** @var \SimpleSAML\XML\XsNamespace */
2128 public const XS_ANY_ELT_NAMESPACE = NS ::OTHER ;
@@ -24,64 +31,39 @@ abstract class AbstractFieldIDType extends AbstractDsig11Element
2431 /**
2532 * Initialize a FieldIDType element.
2633 *
27- * @param \SimpleSAML\XMLSecurity\XML\dsig11\Prime $prime
28- * @param \SimpleSAML\XMLSecurity\XML\dsig11\TnB $tnb
29- * @param \SimpleSAML\XMLSecurity\XML\dsig11\PnB $pnb
30- * @param \SimpleSAML\XMLSecurity\XML\dsig11\GnB $gnb
31- * @param array<\SimpleSAML\XML\SerializableElementInterface> $children
34+ * @param \SimpleSAML\XML\SerializableElementInterface $fieldId
3235 */
3336 public function __construct (
34- protected Prime $ prime ,
35- protected TnB $ tnb ,
36- protected PnB $ pnb ,
37- protected GnB $ gnb ,
38- array $ children ,
37+ protected Prime |TnB |PnB |GnB |SerializableElementInterface $ fieldId ,
3938 ) {
40- $ this ->setElements ($ children );
39+ if (
40+ !($ fieldId instanceof Prime
41+ || $ fieldId instanceof TnB
42+ || $ fieldId instanceof PnB
43+ || $ fieldId instanceof GnB)
44+ ) {
45+ Assert::true (
46+ (($ fieldId instanceof Chunk) ? $ fieldId ->getNamespaceURI () : $ fieldId ::getNameSpaceURI ())
47+ !== C::NS_XDSIG11 ,
48+ 'A <dsig11:FieldIDType> requires either a Prime, TnB, PnB, GnB or an element in namespace ##other ' ,
49+ SchemaViolationException::class,
50+ );
51+ }
4152 }
4253
4354
4455 /**
45- * Collect the value of the prime -property
56+ * Collect the value of the fieldId -property
4657 *
4758 * @return \SimpleSAML\XMLSecurity\XML\dsig11\Prime
59+ * \SimpleSAML\XMLSecurity\XML\dsig11\TnB
60+ * \SimpleSAML\XMLSecurity\XML\dsig11\PnB
61+ * \SimpleSAML\XMLSecurity\XML\dsig11\GnB
62+ * \SimpleSAML\XML\SerializableElementInterface
4863 */
49- public function getPrime (): Prime
64+ public function getFieldId (): Prime | TnB | PnB | GnB | SerializableElementInterface
5065 {
51- return $ this ->prime ;
52- }
53-
54-
55- /**
56- * Collect the value of the tnb-property
57- *
58- * @return \SimpleSAML\XMLSecurity\XML\dsig11\TnB
59- */
60- public function getTnB (): TnB
61- {
62- return $ this ->tnb ;
63- }
64-
65-
66- /**
67- * Collect the value of the pnb-property
68- *
69- * @return \SimpleSAML\XMLSecurity\XML\dsig11\PnB
70- */
71- public function getPnB (): PnB
72- {
73- return $ this ->pnb ;
74- }
75-
76-
77- /**
78- * Collect the value of the gnb-property
79- *
80- * @return \SimpleSAML\XMLSecurity\XML\dsig11\GnB
81- */
82- public function getGnB (): GnB
83- {
84- return $ this ->gnb ;
66+ return $ this ->fieldId ;
8567 }
8668
8769
@@ -95,14 +77,7 @@ public function toXML(?DOMElement $parent = null): DOMElement
9577 {
9678 $ e = $ this ->instantiateParentElement ($ parent );
9779
98- $ this ->getPrime ()->toXML ($ e );
99- $ this ->getTnB ()->toXML ($ e );
100- $ this ->getPnB ()->toXML ($ e );
101- $ this ->getGnB ()->toXML ($ e );
102-
103- foreach ($ this ->getElements () as $ elt ) {
104- $ elt ->toXML ($ e );
105- }
80+ $ this ->getFieldId ()->toXML ($ e );
10681
10782 return $ e ;
10883 }
0 commit comments