ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PublicKeyValidator.php
Go to the documentation of this file.
1 <?php
2 
3 namespace SAML2\Signature;
4 
11 
13 {
17  private $configuredKeys;
18 
22  private $keyLoader;
23 
25  {
26  $this->keyLoader = $keyLoader;
27 
28  parent::__construct($logger);
29  }
30 
37  public function canValidate(
38  SignedElement $signedElement,
39  CertificateProvider $configuration
40  ) {
41  $this->configuredKeys = $this->keyLoader->extractPublicKeys($configuration);
42 
43  return !!count($this->configuredKeys);
44  }
45 
52  public function hasValidSignature(
53  SignedElement $signedElement,
54  CertificateProvider $configuration
55  ) {
57  $pemCandidates = $this->configuredKeys->filter(function (Key $key) use ($logger) {
58  if (!$key instanceof X509) {
59  $logger->debug(sprintf('Skipping unknown key type: "%s"', $key['type']));
60  return false;
61  }
62  return true;
63  });
64 
65  if (!count($pemCandidates)) {
66  $this->logger->debug('No configured X509 certificate found to verify the signature with');
67 
68  return false;
69  }
70 
71  return $this->validateElementWithKeys($signedElement, $pemCandidates);
72  }
73 }
validateElementWithKeys(SignedElement $element, $pemCandidates)
BC compatible version of the signature check.
Pure-PHP X.509 Parser.
CertificateProvider interface.
canValidate(SignedElement $signedElement, CertificateProvider $configuration)
Simple DTO wrapper for (X509) keys.
Definition: Key.php:12
__construct(LoggerInterface $logger, KeyLoader $keyLoader)
Describes a logger instance.
$key
Definition: croninfo.php:18
hasValidSignature(SignedElement $signedElement, CertificateProvider $configuration)