ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilWebAccessChecker Class Reference

Class ilWebAccessChecker. More...

+ Collaboration diagram for ilWebAccessChecker:

Public Member Functions

 __construct ($path, ilWACCookieInterface $ilWACCookieInterface=null, ilWACHeaderInterface $ilWACHeaderInterface=null)
 ilWebAccessChecker constructor. More...
 
 check ()
 
 initILIAS ()
 
 isChecked ()
 
 setChecked ($checked)
 
 getPathObject ()
 
 setPathObject ($path_object)
 
 getDisposition ()
 
 setDisposition ($disposition)
 
 getOverrideMimetype ()
 
 setOverrideMimetype ($override_mimetype)
 
 isInitialized ()
 
 setInitialized ($initialized)
 
 isSendStatusCode ()
 
 setSendStatusCode ($send_status_code)
 
 isRevalidateFolderTokens ()
 
 setRevalidateFolderTokens ($revalidate_folder_tokens)
 
 getCookie ()
 
 setCookie ($cookie)
 
 getAppliedCheckingMethods ()
 
 setAppliedCheckingMethods ($applied_checking_methods)
 
 getHeader ()
 
 setHeader ($header)
 

Static Public Member Functions

static isDEBUG ()
 
static setDEBUG ($DEBUG)
 
static isUseSeperateLogfile ()
 
static setUseSeperateLogfile ($use_seperate_logfile)
 

Data Fields

const DISPOSITION = 'disposition'
 
const STATUS_CODE = 'status_code'
 
const REVALIDATE = 'revalidate'
 
const CM_FILE_TOKEN = 1
 
const CM_FOLDER_TOKEN = 2
 
const CM_CHECKINGINSTANCE = 3
 
const CM_SECFOLDER = 4
 

Protected Member Functions

 sendHeader ($message)
 
 checkPublicSection ()
 
 checkUser ()
 
 addAppliedCheckingMethod ($method)
 
 isRequestNotFromLoginPage ()
 

Protected Attributes

 $path_object = null
 
 $checked = false
 
 $disposition = ilFileDelivery::DISP_INLINE
 
 $override_mimetype = ''
 
 $send_status_code = false
 
 $initialized = false
 
 $revalidate_folder_tokens = true
 
 $cookie = null
 
 $header = null
 
 $applied_checking_methods = array()
 

Static Protected Attributes

static $DEBUG = false
 
static $use_seperate_logfile = false
 

Detailed Description

Class ilWebAccessChecker.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
1.0.0

Definition at line 17 of file class.ilWebAccessChecker.php.

Constructor & Destructor Documentation

◆ __construct()

ilWebAccessChecker::__construct (   $path,
ilWACCookieInterface  $ilWACCookieInterface = null,
ilWACHeaderInterface  $ilWACHeaderInterface = null 
)

ilWebAccessChecker constructor.

Parameters
$path
\ilWACCookieInterface | null$ilWACCookieInterface

Definition at line 82 of file class.ilWebAccessChecker.php.

82 {
83 $this->setPathObject(new ilWACPath($path));
84 $this->setCookie($ilWACCookieInterface ? $ilWACCookieInterface : new ilWACCookie());
85 $this->setHeader($ilWACHeaderInterface ? $ilWACHeaderInterface : new ilWACHeader());
86 }
$path
Definition: aliased.php:25
Class ilWACCookie.
Class ilWACHeader.
Class ilWACPath.

References $path, setCookie(), setHeader(), and setPathObject().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAppliedCheckingMethod()

ilWebAccessChecker::addAppliedCheckingMethod (   $method)
protected
Parameters
int$method

Definition at line 416 of file class.ilWebAccessChecker.php.

416 {
417 $this->applied_checking_methods[] = $method;
418 }

Referenced by check().

+ Here is the caller graph for this function:

◆ check()

ilWebAccessChecker::check ( )
Returns
bool
Exceptions
ilWACException

Definition at line 93 of file class.ilWebAccessChecker.php.

93 {
94 ilWACLog::getInstance()->write('Checking File: ' . $this->getPathObject()->getPathWithoutQuery());
95 if (!$this->getPathObject()) {
97 }
98
99 // Check if Path has been signed with a token
100 $ilWACSignedPath = new ilWACSignedPath($this->getPathObject(), $this->cookie);
101 if ($ilWACSignedPath->isSignedPath()) {
102 $this->addAppliedCheckingMethod(self::CM_FILE_TOKEN);
103 if ($ilWACSignedPath->isSignedPathValid()) {
104 $this->setChecked(true);
105 ilWACLog::getInstance()->write('checked using token');
106 $this->sendHeader('checked using token');
107
108 return true;
109 }
110 }
111
112 // Check if the whole secured folder has been signed
113 if ($ilWACSignedPath->isFolderSigned()) {
114 $this->addAppliedCheckingMethod(self::CM_FOLDER_TOKEN);
115 if ($ilWACSignedPath->isFolderTokenValid()) {
116 if ($this->isRevalidateFolderTokens()) {
117 $ilWACSignedPath->revalidatingFolderToken();
118 }
119 $this->setChecked(true);
120 ilWACLog::getInstance()->write('checked using secure folder');
121 $this->sendHeader('checked using secure folder');
122
123 return true;
124 }
125 }
126
127 // Fallback, have to initiate ILIAS
128 $this->initILIAS();
129
130 // Maybe the path has been registered, lets check
131 $checkingInstance = ilWACSecurePath::getCheckingInstance($this->getPathObject());
132 if ($checkingInstance instanceof ilWACCheckingClass) {
133 $this->addAppliedCheckingMethod(self::CM_CHECKINGINSTANCE);
134 ilWACLog::getInstance()->write('has checking instance: ' . get_class($checkingInstance));
135 $canBeDelivered = $checkingInstance->canBeDelivered($this->getPathObject());
136 if ($canBeDelivered) {
137 ilWACLog::getInstance()->write('checked using fallback');
138 $this->sendHeader('checked using fallback');
139 if ($ilWACSignedPath->isFolderSigned() && $this->isRevalidateFolderTokens()) {
140 $ilWACSignedPath->revalidatingFolderToken();
141 }
142
143 $this->setChecked(true);
144
145 return true;
146 } else {
147 ilWACLog::getInstance()->write('checking-instance denied access');
148 $this->setChecked(true);
149
150 return false;
151 }
152 }
153
154 // none of the checking mechanisms could have been applied. no access
155 $this->setChecked(true);
156 ilWACLog::getInstance()->write('none of the checking mechanisms could have been applied. access depending on sec folder');
157 if ($this->getPathObject()->isInSecFolder()) {
158 $this->addAppliedCheckingMethod(self::CM_SECFOLDER);
159 ilWACLog::getInstance()->write('file is in sec-folder, no delivery');
160
161 return false;
162 } else {
163 $this->addAppliedCheckingMethod(self::CM_SECFOLDER);
164 ilWACLog::getInstance()->write('file is not in sec-folder, delivery');
165
166 return true;
167 }
168 }
Class ilWACException.
static getInstance()
Class ilWACSignedPath.
Class ilWACCheckingClass.

References addAppliedCheckingMethod(), ilWACException\CODE_NO_PATH, ilWACLog\getInstance(), getPathObject(), initILIAS(), isRevalidateFolderTokens(), sendHeader(), and setChecked().

Referenced by ilWebAccessCheckerDelivery\handleRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkPublicSection()

ilWebAccessChecker::checkPublicSection ( )
protected

Definition at line 211 of file class.ilWebAccessChecker.php.

211 {
212 global $DIC;
213 $not_on_login_page = $this->isRequestNotFromLoginPage();
214 $is_anonymous = ((int)$DIC->user()->getId() === (int)ANONYMOUS_USER_ID);
215 $is_null_user = ($DIC->user()->getId() === 0);
216 $pub_section_activated = (bool)$DIC['ilSetting']->get('pub_section');
217 $isset = isset($DIC['ilSetting']);
218 $instanceof = $DIC['ilSetting'] instanceof ilSetting;
219 if (!$isset || !$instanceof || (!$pub_section_activated && ($is_anonymous || ($is_null_user && $not_on_login_page)))) {
221 }
222 }
ILIAS Setting Class.
global $DIC

References $DIC, ilWACException\ACCESS_DENIED_NO_PUB, and isRequestNotFromLoginPage().

Referenced by initILIAS().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkUser()

ilWebAccessChecker::checkUser ( )
protected

Definition at line 225 of file class.ilWebAccessChecker.php.

225 {
226 global $DIC;
227
228 $is_user = $DIC->user() instanceof ilObjUser;
229 $user_id_is_zero = ((int)$DIC->user()->getId() === 0);
230 $not_on_login_page = $this->isRequestNotFromLoginPage();
231 if (!$is_user || ($user_id_is_zero && $not_on_login_page)) {
233 }
234 }

References $DIC, ilWACException\ACCESS_DENIED_NO_LOGIN, and isRequestNotFromLoginPage().

Referenced by initILIAS().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAppliedCheckingMethods()

ilWebAccessChecker::getAppliedCheckingMethods ( )
Returns
array

Definition at line 400 of file class.ilWebAccessChecker.php.

References $applied_checking_methods.

◆ getCookie()

ilWebAccessChecker::getCookie ( )
Returns
\ilWACCookieInterface

Definition at line 384 of file class.ilWebAccessChecker.php.

References $cookie.

◆ getDisposition()

ilWebAccessChecker::getDisposition ( )
Returns
string

Definition at line 272 of file class.ilWebAccessChecker.php.

References $disposition.

Referenced by ilWebAccessCheckerDelivery\deliver(), ilWebAccessCheckerDelivery\deliverDummyImage(), and ilWebAccessCheckerDelivery\deliverDummyVideo().

+ Here is the caller graph for this function:

◆ getHeader()

ilWebAccessChecker::getHeader ( )
Returns
\ilWACHeaderInterface

Definition at line 424 of file class.ilWebAccessChecker.php.

References $header.

Referenced by sendHeader().

+ Here is the caller graph for this function:

◆ getOverrideMimetype()

ilWebAccessChecker::getOverrideMimetype ( )
Returns
string

Definition at line 288 of file class.ilWebAccessChecker.php.

References $override_mimetype.

◆ getPathObject()

◆ initILIAS()

ilWebAccessChecker::initILIAS ( )
Returns
bool
Exceptions

ilWACException

Definition at line 183 of file class.ilWebAccessChecker.php.

183 {
184 if ($this->isInitialized()) {
185 return true;
186 }
187 $GLOBALS['COOKIE_PATH'] = '/';
188 $this->cookie->set('ilClientId', $this->getPathObject()->getClient(), 0, '/');
190 try {
191 ilWACLog::getInstance()->write('init ILIAS');
193 $this->checkUser();
194 $this->checkPublicSection();
195 } catch (Exception $e) {
196 if ($e instanceof ilWACException
197 && $e->getCode() !== ilWACException::ACCESS_DENIED_NO_LOGIN) {
198 throw $e;
199 }
200 if (($e instanceof Exception && $e->getMessage() == 'Authentication failed.')
201 || $e->getCode() === ilWACException::ACCESS_DENIED_NO_LOGIN) {
202 $this->initAnonymousSession();
203 $this->checkUser();
204 $this->checkPublicSection();
205 }
206 }
207 $this->setInitialized(true);
208 }
static init($a_type)
Init context by type.
const CONTEXT_WAC
static initILIAS()
ilias initialisation
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

References $GLOBALS, ilWACException\ACCESS_DENIED_NO_LOGIN, checkPublicSection(), checkUser(), ilContext\CONTEXT_WAC, ilWACLog\getInstance(), getPathObject(), ilContext\init(), ilInitialisation\initILIAS(), isInitialized(), and setInitialized().

Referenced by check(), and ilWebAccessCheckerDelivery\handleAccessErrors().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isChecked()

ilWebAccessChecker::isChecked ( )
Returns
boolean

Definition at line 240 of file class.ilWebAccessChecker.php.

References $checked.

Referenced by ilWebAccessCheckerDelivery\deliver(), and ilWebAccessCheckerDelivery\deny().

+ Here is the caller graph for this function:

◆ isDEBUG()

static ilWebAccessChecker::isDEBUG ( )
static
Returns
boolean

Definition at line 352 of file class.ilWebAccessChecker.php.

352 {
353 return self::$DEBUG;
354 }

References $DEBUG.

Referenced by ilWACLog\getInstance(), ilWACToken\isDEBUG(), and ilWACTokenTest\testSomeBasics().

+ Here is the caller graph for this function:

◆ isInitialized()

ilWebAccessChecker::isInitialized ( )
Returns
boolean

Definition at line 304 of file class.ilWebAccessChecker.php.

References $initialized.

Referenced by initILIAS().

+ Here is the caller graph for this function:

◆ isRequestNotFromLoginPage()

ilWebAccessChecker::isRequestNotFromLoginPage ( )
protected
Returns
bool

Definition at line 459 of file class.ilWebAccessChecker.php.

459 {
460 $referrer = !is_null($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
461 $not_on_login_page = (strpos($referrer, 'login.php') === false
462 && strpos($referrer, '&baseClass=ilStartUpGUI') === false);
463
464 return $not_on_login_page;
465 }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

References $_SERVER.

Referenced by checkPublicSection(), and checkUser().

+ Here is the caller graph for this function:

◆ isRevalidateFolderTokens()

ilWebAccessChecker::isRevalidateFolderTokens ( )
Returns
boolean

Definition at line 336 of file class.ilWebAccessChecker.php.

References $revalidate_folder_tokens.

Referenced by check().

+ Here is the caller graph for this function:

◆ isSendStatusCode()

ilWebAccessChecker::isSendStatusCode ( )
Returns
boolean

Definition at line 320 of file class.ilWebAccessChecker.php.

References $send_status_code.

Referenced by ilWebAccessCheckerDelivery\handleAccessErrors().

+ Here is the caller graph for this function:

◆ isUseSeperateLogfile()

static ilWebAccessChecker::isUseSeperateLogfile ( )
static
Returns
boolean

Definition at line 368 of file class.ilWebAccessChecker.php.

368 {
370 }

References $use_seperate_logfile.

Referenced by ilWACLog\getInstance().

+ Here is the caller graph for this function:

◆ sendHeader()

ilWebAccessChecker::sendHeader (   $message)
protected
Parameters
$message

Definition at line 174 of file class.ilWebAccessChecker.php.

174 {
175 $this->getHeader()->sendHeader('X-ILIAS-WebAccessChecker: ' . $message);
176 }

References getHeader().

Referenced by check().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAppliedCheckingMethods()

ilWebAccessChecker::setAppliedCheckingMethods (   $applied_checking_methods)
Parameters
array$applied_checking_methods

Definition at line 408 of file class.ilWebAccessChecker.php.

408 {
409 $this->applied_checking_methods = $applied_checking_methods;
410 }

References $applied_checking_methods.

◆ setChecked()

ilWebAccessChecker::setChecked (   $checked)
Parameters
boolean$checked

Definition at line 248 of file class.ilWebAccessChecker.php.

248 {
249 $this->checked = $checked;
250 }

References $checked.

Referenced by check().

+ Here is the caller graph for this function:

◆ setCookie()

ilWebAccessChecker::setCookie (   $cookie)
Parameters
\ilWACCookieInterface$cookie

Definition at line 392 of file class.ilWebAccessChecker.php.

392 {
393 $this->cookie = $cookie;
394 }

References $cookie.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setDEBUG()

static ilWebAccessChecker::setDEBUG (   $DEBUG)
static
Parameters
boolean$DEBUG

Definition at line 360 of file class.ilWebAccessChecker.php.

360 {
361 self::$DEBUG = $DEBUG;
362 }

References $DEBUG.

Referenced by ilWACTokenTest\testCookieGeneration(), ilWACCheckingInstanceTest\testNonCheckingInstanceNoSec(), and ilWACTokenTest\testTokenGeneration().

+ Here is the caller graph for this function:

◆ setDisposition()

ilWebAccessChecker::setDisposition (   $disposition)
Parameters
string$disposition

Definition at line 280 of file class.ilWebAccessChecker.php.

280 {
281 $this->disposition = $disposition;
282 }

References $disposition.

Referenced by ilWebAccessCheckerDelivery\handleRequest().

+ Here is the caller graph for this function:

◆ setHeader()

ilWebAccessChecker::setHeader (   $header)
Parameters
\ilWACHeaderInterface$header

Definition at line 432 of file class.ilWebAccessChecker.php.

432 {
433 $this->header = $header;
434 }

References $header.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setInitialized()

ilWebAccessChecker::setInitialized (   $initialized)
Parameters
boolean$initialized

Definition at line 312 of file class.ilWebAccessChecker.php.

312 {
313 $this->initialized = $initialized;
314 }

References $initialized.

Referenced by initILIAS().

+ Here is the caller graph for this function:

◆ setOverrideMimetype()

ilWebAccessChecker::setOverrideMimetype (   $override_mimetype)
Parameters
string$override_mimetype

Definition at line 296 of file class.ilWebAccessChecker.php.

296 {
297 $this->override_mimetype = $override_mimetype;
298 }

References $override_mimetype.

◆ setPathObject()

ilWebAccessChecker::setPathObject (   $path_object)
Parameters
ilWACPath$path_object

Definition at line 264 of file class.ilWebAccessChecker.php.

264 {
265 $this->path_object = $path_object;
266 }

References $path_object.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setRevalidateFolderTokens()

ilWebAccessChecker::setRevalidateFolderTokens (   $revalidate_folder_tokens)
Parameters
boolean$revalidate_folder_tokens

Definition at line 344 of file class.ilWebAccessChecker.php.

344 {
345 $this->revalidate_folder_tokens = $revalidate_folder_tokens;
346 }

References $revalidate_folder_tokens.

Referenced by ilWebAccessCheckerDelivery\handleRequest().

+ Here is the caller graph for this function:

◆ setSendStatusCode()

ilWebAccessChecker::setSendStatusCode (   $send_status_code)
Parameters
boolean$send_status_code

Definition at line 328 of file class.ilWebAccessChecker.php.

328 {
329 $this->send_status_code = $send_status_code;
330 }

References $send_status_code.

Referenced by ilWebAccessCheckerDelivery\handleRequest().

+ Here is the caller graph for this function:

◆ setUseSeperateLogfile()

static ilWebAccessChecker::setUseSeperateLogfile (   $use_seperate_logfile)
static
Parameters
boolean$use_seperate_logfile

Definition at line 376 of file class.ilWebAccessChecker.php.

376 {
377 self::$use_seperate_logfile = $use_seperate_logfile;
378 }

References $use_seperate_logfile.

Field Documentation

◆ $applied_checking_methods

ilWebAccessChecker::$applied_checking_methods = array()
protected

◆ $checked

ilWebAccessChecker::$checked = false
protected

Definition at line 33 of file class.ilWebAccessChecker.php.

Referenced by isChecked(), and setChecked().

◆ $cookie

ilWebAccessChecker::$cookie = null
protected

Definition at line 65 of file class.ilWebAccessChecker.php.

Referenced by getCookie(), and setCookie().

◆ $DEBUG

ilWebAccessChecker::$DEBUG = false
staticprotected

Definition at line 57 of file class.ilWebAccessChecker.php.

Referenced by isDEBUG(), and setDEBUG().

◆ $disposition

ilWebAccessChecker::$disposition = ilFileDelivery::DISP_INLINE
protected

Definition at line 37 of file class.ilWebAccessChecker.php.

Referenced by getDisposition(), and setDisposition().

◆ $header

ilWebAccessChecker::$header = null
protected

Definition at line 69 of file class.ilWebAccessChecker.php.

Referenced by getHeader(), and setHeader().

◆ $initialized

ilWebAccessChecker::$initialized = false
protected

Definition at line 49 of file class.ilWebAccessChecker.php.

Referenced by isInitialized(), and setInitialized().

◆ $override_mimetype

ilWebAccessChecker::$override_mimetype = ''
protected

Definition at line 41 of file class.ilWebAccessChecker.php.

Referenced by getOverrideMimetype(), and setOverrideMimetype().

◆ $path_object

ilWebAccessChecker::$path_object = null
protected

Definition at line 29 of file class.ilWebAccessChecker.php.

Referenced by getPathObject(), and setPathObject().

◆ $revalidate_folder_tokens

ilWebAccessChecker::$revalidate_folder_tokens = true
protected

◆ $send_status_code

ilWebAccessChecker::$send_status_code = false
protected

Definition at line 45 of file class.ilWebAccessChecker.php.

Referenced by isSendStatusCode(), and setSendStatusCode().

◆ $use_seperate_logfile

ilWebAccessChecker::$use_seperate_logfile = false
staticprotected

Definition at line 61 of file class.ilWebAccessChecker.php.

Referenced by isUseSeperateLogfile(), and setUseSeperateLogfile().

◆ CM_CHECKINGINSTANCE

const ilWebAccessChecker::CM_CHECKINGINSTANCE = 3

Definition at line 24 of file class.ilWebAccessChecker.php.

◆ CM_FILE_TOKEN

const ilWebAccessChecker::CM_FILE_TOKEN = 1

Definition at line 22 of file class.ilWebAccessChecker.php.

◆ CM_FOLDER_TOKEN

const ilWebAccessChecker::CM_FOLDER_TOKEN = 2

Definition at line 23 of file class.ilWebAccessChecker.php.

◆ CM_SECFOLDER

const ilWebAccessChecker::CM_SECFOLDER = 4

Definition at line 25 of file class.ilWebAccessChecker.php.

◆ DISPOSITION

const ilWebAccessChecker::DISPOSITION = 'disposition'

◆ REVALIDATE

const ilWebAccessChecker::REVALIDATE = 'revalidate'

◆ STATUS_CODE

const ilWebAccessChecker::STATUS_CODE = 'status_code'

The documentation for this class was generated from the following file: