ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
Module.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Saml;
22 
26 use SimpleSAML\Module as SimpleSamlModule;
28 use ilSession;
29 
30 class Module
31 {
32  public static function run(): void
33  {
34  (new ilSamlAuthFactory())->auth();
35  if (preg_match('@^/saml/sp/saml2-logout.php/@', $_SERVER['PATH_INFO'])) {
36  global $DIC;
38  $DIC['ilAuthSession']->logout();
39  $DIC['ilAppEventHandler']->raise('components/ILIAS/Authentication', 'afterLogout', [
40  'username' => $DIC->user()->getLogin(),
41  ]);
42  }
43  SimpleSamlModule::process()->send();
44  }
45 
46  public static function metadata(): void
47  {
48  $auth = (new ilSamlAuthFactory())->auth();
49  $config = Configuration::getInstance();
50  if ($config->getOptionalBoolean('admin.protectmetadata', false)) {
51  $admin = new Auth();
52  $admin->requireAdmin();
53  }
54 
55  $xml = (new Metadata(new DefaultSimpleSamlFactory()))->buildXML($auth);
56  self::sendXMLString($xml);
57  }
58 
59  private static function sendXMLString(string $xml_string): void
60  {
61  global $DIC;
62  $http = $DIC->http();
63 
64  $response = $http->response()
65  ->withHeader('Content-Type', 'application/xml')
66  ->withBody(Streams::ofString($xml_string));
67 
68  $http->saveResponse($response);
69  $http->sendResponse();
70  $http->close();
71  }
72 }
$response
Definition: xapitoken.php:93
$http
Definition: deliver.php:30
static metadata()
Definition: Module.php:46
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
const int SESSION_CLOSE_USER
global $DIC
Definition: shib_login.php:26
static run()
Definition: Module.php:32
static setClosingContext(int $a_context)
set closing context (for statistics)
Class ilCertificateSettingsCmiXapiFormRepository.
static sendXMLString(string $xml_string)
Definition: Module.php:59