ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSimpleSAMLphplIdpDiscovery.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 final class ilSimpleSAMLphplIdpDiscovery extends SimpleSAML\XHTML\IdPDisco implements ilSamlIdpDiscovery
26 {
27  private const METADATA_DIRECTORY = 'auth/saml/metadata';
28 
29  public function __construct()
30  {
31  $this->config = SimpleSAML\Configuration::getInstance();
32  $this->metadata = SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler();
33  $this->instance = 'saml';
34  $this->metadataSets = ['saml20-idp-remote'];
35  $this->isPassive = false;
36  }
37 
38  public function getMetadataDirectory(): string
39  {
40  return self::METADATA_DIRECTORY;
41  }
42 
43  public function getList(): array
44  {
45  return $this->getIdPList();
46  }
47 
48  private function getMetadataPath(int $idpId): string
49  {
50  return $this->getMetadataDirectory() . '/' . $idpId . '.xml';
51  }
52 
53  public function storeIdpMetadata(int $idpId, string $metadata): void
54  {
55  global $DIC;
56 
57  $fs = $DIC->filesystem()->storage();
58 
59  $fs->put($this->getMetadataPath($idpId), $metadata);
60  }
61 
62  public function fetchIdpMetadata(int $idpId): string
63  {
64  global $DIC;
65 
66  $fs = $DIC->filesystem()->storage();
67 
68  if (!$fs->has($this->getMetadataPath($idpId))) {
69  return '';
70  }
71 
72  return $fs->read($this->getMetadataPath($idpId));
73  }
74 
75  public function deleteIdpMetadata(int $idpId): void
76  {
77  global $DIC;
78 
79  $fs = $DIC->filesystem()->storage();
80 
81  if ($fs->has($this->getMetadataPath($idpId))) {
82  $fs->delete($this->getMetadataPath($idpId));
83  }
84  }
85 }
global $DIC
Definition: feed.php:28
getList()
This method should return an array of IDPs.
storeIdpMetadata(int $idpId, string $metadata)
Class ilSimpleSAMLphplIdpDiscovery.