55namespace SimpleSAML \XML ;
66
77use DOMElement ;
8- use SimpleSAML \XML \DOMDocumentFactory ;
9- use SimpleSAML \XML \Exception \MissingAttributeException ;
10- use Serializable ;
11- use SimpleSAML \Assert \Assert ;
8+ use SimpleSAML \XMLSecurity \XML \ds \Signature ;
9+ use SimpleSAML \XMLSecurity \XML \SignableElementInterface ;
10+ use SimpleSAML \XMLSecurity \XML \SignedElementInterface ;
1211
1312/**
1413 * Abstract class to be implemented by all signed classes
@@ -19,12 +18,6 @@ abstract class AbstractSignedXMLElement implements SignedElementInterface
1918{
2019 use SignedElementTrait;
2120
22- /**
23- * Create a document structure for this element
24- *
25- * @param \DOMElement|null $parent The element we should append to.
26- * @return \DOMElement
27- */
2821 /**
2922 * The signed DOM structure.
3023 *
@@ -35,7 +28,87 @@ abstract class AbstractSignedXMLElement implements SignedElementInterface
3528 /**
3629 * The unsigned elelement.
3730 *
38- * @var \SimpleSAML\XML\AbstractXMLElement
31+ * @var \SimpleSAML\XMLSecurity\SignableElementInterface
32+ */
33+ protected SignableElementInterface $ element ;
34+
35+
36+ /**
37+ * Create/parse an alg:SigningMethod element.
38+ *
39+ * @param \DOMElement $xml
40+ * @param \SimpleSAML\XMLSecurity\XML\SignedElementInterface $elt
41+ * @param \SimpleSAML\XMLSecurity\XML\ds\Signature $signature
42+ */
43+ private function __construct (DOMElement $ xml , SignedElementInterface $ elt , Signature $ signature )
44+ {
45+ $ this ->setStructure ($ xml );
46+ $ this ->setElement ($ elt );
47+ $ this ->setSignature ($ signature );
48+ }
49+
50+
51+ /**
52+ * Collect the value of the unsigned element
53+ *
54+ * @return \SimpleSAML\XMLSecurity\XML\SignableElementInterface
55+ */
56+ public function getElement (): SignableElementInterface
57+ {
58+ return $ this ->element ;
59+ }
60+
61+
62+ /**
63+ * Set the value of the elment-property
64+ *
65+ * @param \SimpleSAML\XMLSecurity\XML\SignableElementInterface $elt
66+ */
67+ private function setElement (SignableElementInterface $ elt ): void
68+ {
69+ $ this ->element = $ elt ;
70+ }
71+
72+
73+ /**
74+ * Collect the value of the structure-property
75+ *
76+ * @return \DOMElement
77+ */
78+ public function getStructure (): DOMElement
79+ {
80+ return $ this ->structure ;
81+ }
82+
83+
84+ /**
85+ * Set the value of the structure-property
86+ *
87+ * @param \DOMElement $structure
88+ */
89+ private function setStructure (DOMElement $ structure ): void
90+ {
91+ $ this ->structure = $ structure ;
92+ }
93+
94+
95+ /**
96+ * Create XML from this class
97+ *
98+ * @param \DOMElement|null $parent
99+ * @return \DOMElement
100+ */
101+ public function toXML (DOMElement $ parent = null ): DOMElement
102+ {
103+ return $ this ->structure ;
104+ }
105+
106+
107+ /**
108+ * Create a class from XML
109+ *
110+ * @param \DOMElement $xml
111+ * @return self
39112 */
40- protected AbstractXMLElement $ elt ;
113+ abstract public static function fromXML ( DOMElement $ xml ): object ;
41114}
0 commit comments