ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Module.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Saml;
22
23use SimpleSAML\Utils\Auth;
24use SimpleSAML\Configuration;
26use SimpleSAML\Module as SimpleSamlModule;
28use ilSession;
29
30class 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);
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}
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Definition: Streams.php:32
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
static sendXMLString(string $xml_string)
Definition: Module.php:59
static metadata()
Definition: Module.php:46
static run()
Definition: Module.php:32
static setClosingContext(int $a_context)
set closing context (for statistics)
const int SESSION_CLOSE_USER
$http
Definition: deliver.php:30
Class ilCertificateSettingsCmiXapiFormRepository.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
global $DIC
Definition: shib_login.php:26
$response
Definition: xapitoken.php:93