ILIAS  release_8 Revision v8.24
class.ilCronStartUp.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 private string $client;
24 private string $username;
25 private string $password;
27
28 public function __construct(
29 string $a_client_id,
30 string $a_login,
31 string $a_password,
33 ) {
34 $this->client = $a_client_id;
35 $this->username = $a_login;
36 $this->password = $a_password;
37
39 require_once './Services/Context/classes/class.ilContext.php';
41
42 // @see mantis 20371: To get rid of this, the authentication service has to provide a mechanism to pass the client_id
43 $_GET['client_id'] = $this->client;
45 require_once './include/inc.header.php';
46
47 if (null === $authSession) {
48 global $DIC;
49 $authSession = $DIC['ilAuthSession'];
50 }
51 $this->authSession = $authSession;
52 }
53
54
59 public function authenticate(): bool
60 {
61 $credentials = new ilAuthFrontendCredentials();
62 $credentials->setUsername($this->username);
63 $credentials->setPassword($this->password);
64
65 $provider_factory = new ilAuthProviderFactory();
66 $providers = $provider_factory->getProviders($credentials);
67
68 $status = ilAuthStatus::getInstance();
69
70 $frontend_factory = new ilAuthFrontendFactory();
71 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_CLI);
72
73 $frontend = $frontend_factory->getFrontend(
74 $this->authSession,
75 $status,
76 $credentials,
77 $providers
78 );
79
80 $frontend->authenticate();
81
82 switch ($status->getStatus()) {
84 ilLoggerFactory::getLogger('auth')->debug('Authentication successful; Redirecting to starting page.');
85 return true;
86
87
89 default:
90 throw new ilCronException($status->getTranslatedReason());
91 }
92
93 return true;
94 }
95
96 public function logout(): void
97 {
99 $this->authSession->logout();
100 }
101}
Factory for auth frontend classes.
static getInstance()
Get status instance.
const STATUS_AUTHENTICATION_FAILED
const CONTEXT_CRON
static init(string $a_type)
Init context by type.
authenticate()
Start authentication.
__construct(string $a_client_id, string $a_login, string $a_password, ?ilAuthSession $authSession=null)
ilAuthSession $authSession
static getLogger(string $a_component_id)
Get component logger.
const SESSION_CLOSE_USER
static setClosingContext(int $a_context)
set closing context (for statistics)
global $DIC
Definition: feed.php:28
$_GET['client_id']
Definition: saml1-acs.php:21