@@ -34,30 +34,32 @@ final class KeyInfo extends AbstractDsElement
3434 * \SimpleSAML\XMLSecurity\XML\ds\KeyValue|
3535 * \SimpleSAML\XMLSecurity\XML\ds\RetrievalMethod|
3636 * \SimpleSAML\XMLSecurity\XML\ds\X509Data|
37- * \SimpleSAML\XMLSecurity\XML\dsig11\KeyInfoReference|
38- * \SimpleSAML\XMLSecurity\XML\xenc\EncryptedData|
39- * \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey
37+ * \SimpleSAML\XML\SerializableElementInterface
4038 * )[] $info
41- * @param \SimpleSAML\XML\SerializableElementInterface[] $children
4239 * @param string|null $Id
4340 */
4441 public function __construct (
4542 protected array $ info ,
46- array $ children = [],
4743 protected ?string $ Id = null ,
4844 ) {
49- $ combi = array_merge ($ info , $ children );
50-
51- Assert::notEmpty ($ combi , 'ds:KeyInfo cannot be empty ' , InvalidArgumentException::class);
52- Assert::maxCount ($ combi , C::UNBOUNDED_LIMIT );
45+ Assert::notEmpty ($ info , 'ds:KeyInfo cannot be empty ' , InvalidArgumentException::class);
46+ Assert::maxCount ($ info , C::UNBOUNDED_LIMIT );
5347 Assert::allIsInstanceOf (
54- $ combi ,
48+ $ info ,
5549 SerializableElementInterface::class,
5650 InvalidArgumentException::class,
5751 );
5852 Assert::nullOrValidNCName ($ Id );
5953
60- $ this ->setElements ($ children );
54+ foreach ($ info as $ item ) {
55+ if ($ item ->getNamespaceURI () === static ::NS ) {
56+ Assert::isInstanceOfAny (
57+ $ item ,
58+ [KeyName::class, KeyValue::class, RetrievalMethod::class, X509Data::class],
59+ SchemaViolationException::class,
60+ );
61+ }
62+ }
6163 }
6264
6365
@@ -79,7 +81,7 @@ public function getId(): ?string
7981 */
8082 public function getInfo (): array
8183 {
82- return array_merge ( $ this ->info , $ this -> getElements ()) ;
84+ return $ this ->info ;
8385 }
8486
8587
@@ -106,6 +108,7 @@ public static function fromXML(DOMElement $xml): static
106108 //$pgpData = PGPData::getChildrenOfClass($xml);
107109 //$spkiData = SPKIData::getChildrenOfClass($xml);
108110 //$mgmtData = MgmtData::getChildrenOfClass($xml);
111+ $ other = self ::getChildElementsFromXML ($ xml );
109112
110113 $ info = array_merge (
111114 $ keyName ,
@@ -115,10 +118,10 @@ public static function fromXML(DOMElement $xml): static
115118 //$pgpdata,
116119 //$spkidata,
117120 //$mgmtdata,
121+ $ other ,
118122 );
119123
120- $ children = self ::getChildElementsFromXML ($ xml );
121- return new static ($ info , $ children , $ Id );
124+ return new static ($ info , $ Id );
122125 }
123126
124127
0 commit comments