ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilCronStartUp.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
13  private $client = '';
14  private $username = '';
15  private $password = '';
16 
20  public function __construct($a_client_id, $a_login, $a_password)
21  {
22  $this->client = $a_client_id;
23  $this->username = $a_login;
24  $this->password = $a_password;
25  }
26 
30  public function initIlias()
31  {
32  include_once './Services/Context/classes/class.ilContext.php';
34 
35  // define client
36  // @see mantis 20371
37  $_GET['client_id'] = $this->client;
38 
39  include_once './include/inc.header.php';
40  }
41 
42 
43 
50  public function authenticate()
51  {
52  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentials.php';
53  $credentials = new ilAuthFrontendCredentials();
54  $credentials->setUsername($this->username);
55  $credentials->setPassword($this->password);
56 
57  include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
58  $provider_factory = new ilAuthProviderFactory();
59  $providers = $provider_factory->getProviders($credentials);
60 
61  include_once './Services/Authentication/classes/class.ilAuthStatus.php';
62  $status = ilAuthStatus::getInstance();
63 
64  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
65  $frontend_factory = new ilAuthFrontendFactory();
66  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_CLI);
67  $frontend = $frontend_factory->getFrontend(
68  $GLOBALS['DIC']['ilAuthSession'],
69  $status,
70  $credentials,
71  $providers
72  );
73 
74  $frontend->authenticate();
75 
76  switch($status->getStatus())
77  {
79  ilLoggerFactory::getLogger('auth')->debug('Authentication successful; Redirecting to starting page.');
80  return true;
81 
82 
83  default:
85  include_once './Services/Cron/exceptions/class.ilCronException.php';
86  throw new ilCronException($status->getTranslatedReason());
87  }
88  return true;
89  }
90 
94  public function logout()
95  {
97  $GLOBALS['DIC']['ilAuthSession']->logout();
98  }
99 }
Standard cron exception.
$_GET["client_id"]
const STATUS_AUTHENTICATION_FAILED
const CONTEXT_CRON
Factory for auth frontend classes.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
initIlias()
Init ILIAS.
__construct($a_client_id, $a_login, $a_password)
Constructor.
const SESSION_CLOSE_USER
logout()
Closes the current auth session.
static init($a_type)
Init context by type.
static setClosingContext($a_context)
set closing context (for statistics)
static getInstance()
Get status instance.
static getLogger($a_component_id)
Get component logger.
Handles cron (cli) request.
authenticate()
Start authentication.