File tree Expand file tree Collapse file tree 2 files changed +93
-0
lines changed Expand file tree Collapse file tree 2 files changed +93
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace SimpleSAML \XMLSecurity \Test \XML ;
6+
7+ use SimpleSAML \XML \AbstractXMLElement ;
8+ use SimpleSAML \XML \Chunk ;
9+ use SimpleSAML \XMLSecurity \XML \SignableElementInterface ;
10+ use SimpleSAML \XMLSecurity \XML \SignableElementTrait ;
11+
12+ /**
13+ * @package simplesamlphp\saml2
14+ */
15+ final class CustomSignable extends AbstractXMLElement implements SignableElementInterface
16+ {
17+ use SignableElementTrait;
18+
19+ /** @var \SimpleSAML\XML\Chunk $element */
20+ protected $ element ;
21+
22+ /**
23+ * Constructor
24+ *
25+ * @param \SimpleSAML\XML\Chunk $elt
26+ */
27+ public function __construct (Chunk $ elt ) {
28+ $ this ->setElement ($ elt );
29+ }
30+
31+
32+
33+ /**
34+ * Collect the value of the $element property
35+ *
36+ * @return \SimpleSAML\XML\XML\Chunk
37+ */
38+ public function getElement (): Chunk
39+ {
40+ return $ this ->element ;
41+ }
42+
43+
44+ /**
45+ * Set the value of the elment-property
46+ *
47+ * @param \SimpleSAML\XML\Chunk $elt
48+ */
49+ private function setElement (Chunk $ elt ): void
50+ {
51+ $ this ->element = $ elt ;
52+ }
53+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace SimpleSAML \XMLSecurity \Test \XML ;
6+
7+ use SimpleSAML \XML \Exception \TooManyElementsException ;
8+ use SimpleSAML \XMLSecurity \XML \ds \Signature ;
9+ use SimpleSAML \XMLSecurity \XML \SignedElementInterface ;
10+ use SimpleSAML \XMLSecurity \XML \SignedElementTrait ;
11+
12+ /**
13+ * @package simplesamlphp\saml2
14+ */
15+ final class CustomSigned extends AbstractSignedXMLElement
16+ {
17+ use SignedElementTrait;
18+
19+
20+ /**
21+ * Create a class from XML
22+ *
23+ * @param \DOMElement $xml
24+ * @return self
25+ */
26+ public static function fromXML (DOMElement $ xml ): object
27+ {
28+ $ signature = Signature::getChildrenOfClass ($ xml );
29+ Assert::count ($ signature , 1 , TooManyElementsException::class);
30+
31+ $ element = CustomSignable::getChildrenOfClass ($ xml );
32+ Assert::count ($ element , 1 , TooManyElementsException::class);
33+
34+ return new self (
35+ $ xml ,
36+ array_pop ($ element ),
37+ array_pop ($ signature )
38+ );
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments