ILIAS
release_10 Revision v10.1-43-ga1241a92c2f
◀ ilDoc Overview
class.ilCronStartUp.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
class
ilCronStartUp
22
{
23
private
readonly
ilAuthSession
$authSession
;
24
private
bool
$authenticated
=
false
;
25
26
public
function
__construct
(
27
private
readonly
string
$client
,
28
private
readonly
string
$username,
29
?
ilAuthSession
$authSession = null
30
) {
32
ilContext::init
(
ilContext::CONTEXT_CRON
);
33
34
// TODO @see mantis 20371: To get rid of this, the authentication service has to provide a mechanism to pass the client_id
35
$_GET
[
'client_id'
] =
$this->client
;
36
ilInitialisation::initILIAS
();
37
38
if
(null === $authSession) {
39
global
$DIC
;
40
$authSession = $DIC[
'ilAuthSession'
];
41
}
42
$this->authSession =
$authSession
;
43
}
44
45
49
public
function
authenticate
(): bool
50
{
51
$credentials =
new
ilAuthFrontendCredentials
();
52
$credentials->setUsername($this->username);
53
54
$status =
ilAuthStatus::getInstance
();
55
56
$frontend_factory =
new
ilAuthFrontendFactory
();
57
$frontend_factory->setContext(
ilAuthFrontendFactory::CONTEXT_CLI
);
58
59
$provider_factory =
new
ilAuthProviderCliFactory
();
60
61
$frontend = $frontend_factory->getFrontend(
62
$this->authSession,
63
$status,
64
$credentials,
65
$provider_factory->getProviders($credentials)
66
);
67
68
$frontend->authenticate();
69
70
switch
($status->getStatus()) {
71
case
ilAuthStatus::STATUS_AUTHENTICATED
:
72
$this->authenticated =
true
;
73
ilLoggerFactory::getLogger
(
'auth'
)->debug(
'Authentication successful; Redirecting to starting page.'
);
74
return
true
;
75
76
case
ilAuthStatus::STATUS_AUTHENTICATION_FAILED
:
77
default
:
78
throw
new
ilCronException
($status->getTranslatedReason());
79
}
80
}
81
82
public
function
logout
(): void
83
{
84
if
($this->authenticated) {
85
ilSession::setClosingContext
(
ilSession::SESSION_CLOSE_USER
);
86
$this->authSession->logout();
87
}
88
}
89
}
ilCronException
Definition:
class.ilCronException.php:21
ilAuthProviderCliFactory
Definition:
class.ilAuthProviderCliFactory.php:21
ilCronStartUp\$authenticated
bool $authenticated
Definition:
class.ilCronStartUp.php:24
ilLoggerFactory\getLogger
static getLogger(string $a_component_id)
Get component logger.
Definition:
class.ilLoggerFactory.php:90
ilAuthStatus\STATUS_AUTHENTICATION_FAILED
const STATUS_AUTHENTICATION_FAILED
Definition:
class.ilAuthStatus.php:35
ilContext\CONTEXT_CRON
const CONTEXT_CRON
Definition:
class.ilContext.php:31
ilCronStartUp\__construct
__construct(private readonly string $client, private readonly string $username, ?ilAuthSession $authSession=null)
Definition:
class.ilCronStartUp.php:26
ilAuthSession
ilCronStartUp
ilCronStartUp\$authSession
readonly ilAuthSession $authSession
Definition:
class.ilCronStartUp.php:23
ilAuthFrontendFactory\CONTEXT_CLI
const CONTEXT_CLI
Definition:
class.ilAuthFrontendFactory.php:36
$client
$client
Definition:
dummy_client.php:43
ilInitialisation\initILIAS
static initILIAS()
ilias initialisation
Definition:
class.ilInitialisation.php:1153
ilSession\SESSION_CLOSE_USER
const SESSION_CLOSE_USER
Definition:
class.ilSession.php:33
$DIC
global $DIC
Definition:
shib_login.php:25
ilCronStartUp\logout
logout()
Definition:
class.ilCronStartUp.php:82
$_GET
$_GET['cmd']
Definition:
lti.php:26
ilAuthStatus\STATUS_AUTHENTICATED
const STATUS_AUTHENTICATED
Definition:
class.ilAuthStatus.php:34
ilAuthStatus\getInstance
static getInstance()
Get status instance.
Definition:
class.ilAuthStatus.php:58
ilSession\setClosingContext
static setClosingContext(int $a_context)
set closing context (for statistics)
Definition:
class.ilSession.php:429
ilContext\init
static init(string $a_type)
Init context by type.
Definition:
class.ilContext.php:52
ilAuthFrontendCredentials
Definition:
class.ilAuthFrontendCredentials.php:24
ilAuthFrontendFactory
ilCronStartUp\authenticate
authenticate()
Definition:
class.ilCronStartUp.php:49
components
ILIAS
Cron
classes
class.ilCronStartUp.php
Generated on Wed Sep 10 2025 15:15:24 for ILIAS by
1.8.13 (using
Doxyfile
)