File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55namespace SimpleSAML \XMLSecurity \XML ;
66
77use DOMElement ;
8+ use SimpleSAML \Assert \Assert ;
9+ use SimpleSAML \XML \Exception \MissingElementException ;
10+ use SimpleSAML \XML \Exception \TooManyElementsException ;
811use SimpleSAML \XMLSecurity \XML \ds \Signature ;
912
1013/**
@@ -39,7 +42,6 @@ abstract class AbstractSignedXMLElement implements SignedElementInterface
3942 */
4043 protected function __construct (DOMElement $ xml , Signature $ signature )
4144 {
42- // $this->element = $elt;
4345 $ this ->setStructure ($ xml );
4446 $ this ->setSignature ($ signature );
4547 }
@@ -96,5 +98,12 @@ public function toXML(DOMElement $parent = null): DOMElement
9698 * @param \DOMElement $xml
9799 * @return self
98100 */
99- abstract public static function fromXML (DOMElement $ xml ): object ;
101+ public static function fromXML (DOMElement $ xml ): object
102+ {
103+ $ signature = Signature::getChildrenOfClass ($ xml );
104+ Assert::minCount ($ signature , 1 , MissingElementException::class);
105+ Assert::maxCount ($ signature , 1 , TooManyElementsException::class);
106+
107+ return new self ($ xml , array_pop ($ signature ));
108+ }
100109}
Original file line number Diff line number Diff line change 44
55namespace SimpleSAML \XMLSecurity \Test \XML ;
66
7- use DOMElement ;
8- use SimpleSAML \Assert \Assert ;
9- use SimpleSAML \XML \Chunk ;
10- use SimpleSAML \XML \Exception \MissingElementException ;
11- use SimpleSAML \XML \Exception \TooManyElementsException ;
12- use SimpleSAML \XML \Utils as XMLUtils ;
13- use SimpleSAML \XMLSecurity \XML \ds \Signature ;
147use SimpleSAML \XMLSecurity \XML \AbstractSignedXMLElement ;
15- use SimpleSAML \XMLSecurity \XML \SignedElementInterface ;
168use SimpleSAML \XMLSecurity \XML \SignedElementTrait ;
179
1810/**
1911 * @package simplesamlphp\saml2
2012 */
2113final class CustomSigned extends AbstractSignedXMLElement
2214{
23- use SignedElementTrait;
24-
25-
26- /**
27- * Create a class from XML
28- *
29- * @param \DOMElement $xml
30- * @return self
31- */
32- public static function fromXML (DOMElement $ xml ): object
33- {
34- $ signature = Signature::getChildrenOfClass ($ xml );
35- Assert::minCount ($ signature , 1 , MissingElementException::class);
36- Assert::maxCount ($ signature , 1 , TooManyElementsException::class);
37-
38- return new self ($ xml , array_pop ($ signature ));
39- }
4015}
You can’t perform that action at this time.
0 commit comments