ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PublicKeyValidator.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2\Signature;
4
11
13{
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}
An exception for terminatinating execution or to throw for unit testing.
Simple DTO wrapper for (X509) keys.
Definition: Key.php:13
Specific Certificate Key.
Definition: X509.php:9
validateElementWithKeys(SignedElement $element, $pemCandidates)
BC compatible version of the signature check.
canValidate(SignedElement $signedElement, CertificateProvider $configuration)
hasValidSignature(SignedElement $signedElement, CertificateProvider $configuration)
__construct(LoggerInterface $logger, KeyLoader $keyLoader)
$key
Definition: croninfo.php:18
Describes a logger instance.
Pure-PHP X.509 Parser.