ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
18  private $authSession;
19 
26  public function __construct(
27  $a_client_id,
28  $a_login,
29  $a_password,
31  ) {
32  $this->client = $a_client_id;
33  $this->username = $a_login;
34  $this->password = $a_password;
35 
36  include_once './Services/Context/classes/class.ilContext.php';
38 
39  // define client
40  // @see mantis 20371
41  $_GET['client_id'] = $this->client;
42 
43  include_once './include/inc.header.php';
44 
45  if (null === $authSession) {
46  global $DIC;
47  $authSession = $DIC['ilAuthSession'];
48  }
49  $this->authSession = $authSession;
50  }
51 
52 
59  public function authenticate()
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 
88  default:
90  throw new ilCronException($status->getTranslatedReason());
91  }
92  return true;
93  }
94 
98  public function logout()
99  {
101  $this->authSession->logout();
102  }
103 }
__construct( $a_client_id, $a_login, $a_password, ilAuthSession $authSession=null)
Standard cron exception.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
const STATUS_AUTHENTICATION_FAILED
const CONTEXT_CRON
Factory for auth frontend classes.
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.