1212use SimpleSAML \XMLSecurity \Exception \InvalidArgumentException ;
1313use SimpleSAML \XMLSecurity \Exception \NoSignatureFound ;
1414use SimpleSAML \XMLSecurity \Exception \RuntimeException ;
15- use SimpleSAML \XMLSecurity \Key \ AbstractKey ;
15+ use SimpleSAML \XMLSecurity \Key ;
1616use SimpleSAML \XMLSecurity \Utils \Security ;
1717use SimpleSAML \XMLSecurity \Utils \XML ;
1818use SimpleSAML \XMLSecurity \Utils \XPath ;
2121use SimpleSAML \XMLSecurity \XML \ds \X509Certificate ;
2222use SimpleSAML \XMLSecurity \XML \ds \X509Data ;
2323
24+ use function array_pop ;
25+ use function base64_decode ;
26+ use function in_array ;
27+
2428/**
2529 * Helper trait for processing signed elements.
2630 *
@@ -42,7 +46,7 @@ trait SignedElementTrait
4246 *
4347 * @var \SimpleSAML\XMLSecurity\Key\AbstractKey|null
4448 */
45- private ?AbstractKey $ validatingKey = null ;
49+ private ?Key \ AbstractKey $ validatingKey = null ;
4650
4751
4852 /**
@@ -132,14 +136,14 @@ private function validateReference(): SignedElementInterface
132136 $ this ->validateReferenceUri ($ reference , $ xml );
133137
134138 $ xp = XPath::getXPath ($ xml ->ownerDocument );
135- $ sigNode = $ xp -> query ( 'child::ds:Signature ' , $ xml );
139+ $ sigNode = XPath:: xpQuery ( $ xml , 'child::ds:Signature ' , $ xp );
136140 Assert::count (
137141 $ sigNode ,
138142 1 ,
139143 'None or more than one signature found in object. ' ,
140144 RuntimeException::class
141145 );
142- $ xml ->removeChild ($ sigNode-> item ( 0 ) );
146+ $ xml ->removeChild ($ sigNode[ 0 ] );
143147
144148 $ data = XML ::processTransforms ($ reference ->getTransforms (), $ xml );
145149 $ digest = Security::hash ($ reference ->getDigestMethod ()->getAlgorithm (), $ data , false );
@@ -196,7 +200,7 @@ private function verifyInternal(SignatureAlgorithm $verifier): SignedElementInte
196200 *
197201 * @return \SimpleSAML\XMLSecurity\Key\AbstractKey|null The key that successfully validated this signature.
198202 */
199- public function getValidatingKey (): ?AbstractKey
203+ public function getValidatingKey (): ?Key \ AbstractKey
200204 {
201205 return $ this ->validatingKey ;
202206 }
@@ -266,11 +270,11 @@ public function verify(SignatureAlgorithm $verifier = null): SignedElementInterf
266270 }
267271
268272 // build a valid PEM for the certificate
269- $ cert = \ SimpleSAML \ XMLSecurity \ Key \X509Certificate::PEM_HEADER . "\n" .
273+ $ cert = Key \X509Certificate::PEM_HEADER . "\n" .
270274 $ data ->getRawContent () . "\n" .
271- \ SimpleSAML \ XMLSecurity \ Key \X509Certificate::PEM_FOOTER ;
275+ Key \X509Certificate::PEM_FOOTER ;
272276
273- $ key = new \ SimpleSAML \ XMLSecurity \ Key \X509Certificate ($ cert );
277+ $ key = new Key \X509Certificate ($ cert );
274278 $ verifier = $ factory ->getAlgorithm ($ algId , $ key );
275279
276280 try {
0 commit comments