ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ValidatorChain.php
Go to the documentation of this file.
1 <?php
2 
3 namespace SAML2\Signature;
4 
8 
16 {
20  private $logger;
21 
25  private $validators = array();
26 
32  {
33  $this->logger = $logger;
34 
35  // should be done through "adder" injection in the container.
36  foreach ($validators as $validator) {
37  $this->appendValidator($validator);
38  }
39  }
40 
44  public function appendValidator(ChainedValidator $validator)
45  {
46  $this->validators[] = $validator;
47  }
48 
55  public function hasValidSignature(
56  SignedElement $signedElement,
57  CertificateProvider $configuration
58  ) {
59  foreach ($this->validators as $validator) {
60  if ($validator->canValidate($signedElement, $configuration)) {
61  $this->logger->debug(sprintf(
62  'Validating the signed element with validator of type "%s"',
63  get_class($validator)
64  ));
65 
66  return $validator->hasValidSignature($signedElement, $configuration);
67  }
68 
69  $this->logger->debug(sprintf(
70  'Could not validate the signed element with validator of type "%s"',
71  get_class($validator)
72  ));
73  }
74 
75  throw new MissingConfigurationException(sprintf(
76  'No certificates or fingerprints have been configured%s',
77  $configuration->has('entityid') ? ' for "' . $configuration->get('entityid') . '"' : ''
78  ));
79  }
80 }
CertificateProvider interface.
has($key)
Query for whether or not the configuration has a value for the key.
appendValidator(ChainedValidator $validator)
hasValidSignature(SignedElement $signedElement, CertificateProvider $configuration)
Allows for validation of a signature trying different validators till a validator is found that can v...
Create styles array
The data for the language used.
get($key, $default=null)
Query to get the value in the configuration for the given key.
Describes a logger instance.
__construct(LoggerInterface $logger, array $validators)