ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AbstractChainedValidator.php
Go to the documentation of this file.
1<?php
2
4
8
10{
14 protected $logger;
15
17 {
18 $this->logger = $logger;
19 }
20
31 protected function validateElementWithKeys(SignedElement $element, $pemCandidates)
32 {
33 $lastException = null;
34 foreach ($pemCandidates as $index => $candidateKey) {
35 $key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, array('type' => 'public'));
36 $key->loadKey($candidateKey->getCertificate());
37
38 try {
39 /*
40 * Make sure that we have a valid signature on either the response or the assertion.
41 */
42 $result = $element->validate($key);
43 if ($result) {
44 $this->logger->debug(sprintf('Validation with key "#%d" succeeded', $index));
45 return true;
46 }
47 $this->logger->debug(sprintf('Validation with key "#%d" failed without exception.', $index));
48 } catch (\Exception $e) {
49 $this->logger->debug(sprintf(
50 'Validation with key "#%d" failed with exception: %s',
51 $index,
52 $e->getMessage()
53 ));
54
55 $lastException = $e;
56 }
57 }
58
59 if ($lastException !== null) {
60 throw $lastException;
61 } else {
62 return false;
63 }
64 }
65}
$result
An exception for terminatinating execution or to throw for unit testing.
validateElementWithKeys(SignedElement $element, $pemCandidates)
BC compatible version of the signature check.
$key
Definition: croninfo.php:18
Describes a logger instance.
Interface \SAML2\Validator\Responsible.
validate(XMLSecurityKey $key)
Validate this element against a public key.
$index
Definition: metadata.php:60