77use DOMElement ;
88use Exception ;
99use SimpleSAML \Assert \Assert ;
10- use SimpleSAML \XML \AbstractXMLElement ;
1110use SimpleSAML \XML \Exception \InvalidDOMElementException ;
12- use SimpleSAML \XML \Exception \MissingAttributeException ;
1311use SimpleSAML \XML \Utils as XMLUtils ;
1412use SimpleSAML \XMLSecurity \Utils \Certificate ;
1513use SimpleSAML \XMLSecurity \Utils \Security ;
@@ -29,6 +27,9 @@ final class Signature extends AbstractDsElement
2927 /** @var string[] */
3028 protected array $ certificates = [];
3129
30+ /** @var SignatureValue */
31+ protected SignatureValue $ value ;
32+
3233 /** @var \SimpleSAML\XMLSecurity\XMLSecurityKey|null */
3334 protected ?XMLSecurityKey $ key ;
3435
@@ -47,6 +48,7 @@ final class Signature extends AbstractDsElement
4748 */
4849 public function __construct (
4950 string $ algorithm ,
51+ SignatureValue $ value ,
5052 array $ certificates = [],
5153 ?XMLSecurityKey $ key = null
5254 ) {
@@ -121,6 +123,28 @@ protected function setKey(?XMLSecurityKey $key): void
121123 }
122124
123125
126+ /**
127+ * Get the SignatureValue corresponding to this signature.
128+ *
129+ * @return SignatureValue
130+ */
131+ public function getSignatureValue (): SignatureValue
132+ {
133+ return $ this ->value ;
134+ }
135+
136+
137+ /**
138+ * Set the SignatureValue.
139+ *
140+ * @param SignatureValue $value
141+ */
142+ protected function setSignatureValue (SignatureValue $ value ): void
143+ {
144+ $ this ->value = $ value ;
145+ }
146+
147+
124148 /**
125149 * @return XMLSecurityDSig
126150 */
@@ -165,7 +189,10 @@ public static function fromXML(DOMElement $xml): object
165189 );
166190 }
167191
168- $ signature = new self (self ::getAttribute ($ sigMethod , 'Algorithm ' ), $ certificates );
192+ $ value = SignatureValue::getChildrenOfClass ($ xml );
193+ Assert::count ($ value , 1 , 'ds:Signature needs exactly one ds:SignatureValue ' );
194+
195+ $ signature = new self (self ::getAttribute ($ sigMethod , 'Algorithm ' ), $ value [0 ], $ certificates );
169196
170197 $ signature ->signer ->sigNode = $ xml ;
171198
0 commit comments