ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
AbstractChainedValidator.php
Go to the documentation of this file.
1 <?php
2 
3 namespace SAML2\Signature;
4 
8 
9 abstract class AbstractChainedValidator implements ChainedValidator
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_SHA1, 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 }
validateElementWithKeys(SignedElement $element, $pemCandidates)
BC compatible version of the signature check.
$result
$index
Definition: metadata.php:60
validate(XMLSecurityKey $key)
Validate this element against a public key.
Create styles array
The data for the language used.
Describes a logger instance.
$key
Definition: croninfo.php:18