ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilWebAccessCheckerDelivery Class Reference

Class ilWebAccessCheckerDelivery. More...

+ Collaboration diagram for ilWebAccessCheckerDelivery:

Public Member Functions

 __construct (Services $httpState, CookieFactory $cookieFactory)
 ilWebAccessCheckerDelivery constructor. More...
 

Static Public Member Functions

static run (Services $httpState, CookieFactory $cookieFactory)
 

Protected Member Functions

 handleRequest ()
 
 deny ()
 
 deliverDummyImage ()
 
 deliverDummyVideo ()
 
 handleNotFoundError (ilWACException $e)
 
 handleAccessErrors (ilWACException $e)
 
 deliver ()
 

Private Attributes

ilWebAccessChecker $wac
 
Services $http
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilWebAccessCheckerDelivery::__construct ( Services  $httpState,
CookieFactory  $cookieFactory 
)

ilWebAccessCheckerDelivery constructor.

Definition at line 47 of file class.ilWebAccessCheckerDelivery.php.

References ILIAS\FileDelivery\http().

48  {
49  $this->wac = new ilWebAccessChecker($httpState, $cookieFactory);
50  $this->http = $httpState;
51  }
static http()
Fetches the global http state from ILIAS.
Class ilWebAccessChecker.
+ Here is the call graph for this function:

Member Function Documentation

◆ deliver()

ilWebAccessCheckerDelivery::deliver ( )
protected
Exceptions
ilWACException

Definition at line 165 of file class.ilWebAccessCheckerDelivery.php.

References $data_dir, $ini, $path, $token, ilWACException\ACCESS_WITHOUT_CHECK, CLIENT_DATA_DIR, and ILIAS\FileDelivery\http().

Referenced by handleRequest().

165  : void
166  {
167  if (!$this->wac->isChecked()) {
169  }
170 
171  $path = $this->wac->getPathObject();
172  // This is currently the place where WAC handles things from the ResourceStorageService.
173  if ($path->getModuleType() === 'rs') {
174  // initialize constants
175  if (!defined('CLIENT_DATA_DIR')) {
176  $ini = new ilIniFile("./ilias.ini.php");
177  $ini->read();
178  $data_dir = rtrim($ini->readVariable("clients", "datadir"), '/');
179  $client_data_dir = $data_dir . "/" . $path->getClient();
180  } else {
181  $client_data_dir = CLIENT_DATA_DIR;
182  }
183 
184  $token_factory = new TokenFactory($client_data_dir);
185  $token = $token_factory->check($path->getFileName());
186  $path_to_file = $token->resolveStream(); // FileStream
187  } else {
188  $path_to_file = $path->getCleanURLdecodedPath();
189  }
190 
191  $ilFileDelivery = new Delivery($path_to_file, $this->http);
192  $ilFileDelivery->setCache(true);
193  $ilFileDelivery->setDisposition($this->wac->getDisposition());
194  if ($path->isStreamable()) { // fixed 0016468
195  $ilFileDelivery->stream();
196  } else {
197  $ilFileDelivery->deliver();
198  }
199  }
$path
Definition: ltiservices.php:32
const CLIENT_DATA_DIR
Definition: constants.php:46
static http()
Fetches the global http state from ILIAS.
$token
Definition: xapitoken.php:70
Class Delivery.
Definition: Delivery.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverDummyImage()

ilWebAccessCheckerDelivery::deliverDummyImage ( )
protected

Definition at line 101 of file class.ilWebAccessCheckerDelivery.php.

References ILIAS\FileDelivery\http().

Referenced by handleAccessErrors().

101  : void
102  {
103  $ilFileDelivery = new Delivery('./Services/WebAccessChecker/templates/images/access_denied.png', $this->http);
104  $ilFileDelivery->setDisposition($this->wac->getDisposition());
105  $ilFileDelivery->deliver();
106  }
static http()
Fetches the global http state from ILIAS.
Class Delivery.
Definition: Delivery.php:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverDummyVideo()

ilWebAccessCheckerDelivery::deliverDummyVideo ( )
protected

Definition at line 109 of file class.ilWebAccessCheckerDelivery.php.

References ILIAS\FileDelivery\http().

Referenced by handleAccessErrors().

109  : void
110  {
111  $ilFileDelivery = new Delivery('./Services/WebAccessChecker/templates/images/access_denied.mp4', $this->http);
112  $ilFileDelivery->setDisposition($this->wac->getDisposition());
113  $ilFileDelivery->stream();
114  }
static http()
Fetches the global http state from ILIAS.
Class Delivery.
Definition: Delivery.php:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deny()

ilWebAccessCheckerDelivery::deny ( )
protected
Exceptions
ilWACException

Definition at line 92 of file class.ilWebAccessCheckerDelivery.php.

References ilWACException\ACCESS_DENIED, and ilWACException\ACCESS_WITHOUT_CHECK.

Referenced by handleRequest().

92  : void
93  {
94  if (!$this->wac->isChecked()) {
96  }
98  }
+ Here is the caller graph for this function:

◆ handleAccessErrors()

ilWebAccessCheckerDelivery::handleAccessErrors ( ilWACException  $e)
protected

Definition at line 125 of file class.ilWebAccessCheckerDelivery.php.

References Vendor\Package\$e, $response, deliverDummyImage(), deliverDummyVideo(), and ILIAS\FileDelivery\http().

Referenced by handleRequest().

125  : void
126  {
127  //1.5.2017 Http code needs to be 200 because mod_xsendfile ignores the response with an 401 code. (possible leak of web path via xsendfile header)
128  $response = $this->http
129  ->response()
130  ->withStatus(200);
131 
132  $this->http->saveResponse($response);
133 
134  if ($this->wac->getPathObject()->isVideo()) {
135  $this->deliverDummyVideo();
136  }
137 
138  $this->deliverDummyImage();
139 
140  $this->wac->initILIAS();
141  }
$response
Definition: xapitoken.php:93
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleNotFoundError()

ilWebAccessCheckerDelivery::handleNotFoundError ( ilWACException  $e)
protected

Definition at line 116 of file class.ilWebAccessCheckerDelivery.php.

References $response, and ILIAS\FileDelivery\http().

Referenced by handleRequest().

116  : void
117  {
118  $response = $this->http
119  ->response()
120  ->withStatus(404);
121 
122  $this->http->saveResponse($response);
123  }
$response
Definition: xapitoken.php:93
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleRequest()

ilWebAccessCheckerDelivery::handleRequest ( )
protected

Definition at line 54 of file class.ilWebAccessCheckerDelivery.php.

References Vendor\Package\$e, ilWACException\ACCESS_DENIED, ilWACException\ACCESS_DENIED_NO_LOGIN, ilWACException\ACCESS_DENIED_NO_PUB, deliver(), deny(), ilWebAccessChecker\DISPOSITION, handleAccessErrors(), ilInitialisation\handleErrorReporting(), handleNotFoundError(), ILIAS\FileDelivery\http(), ilWACException\NOT_FOUND, ilWebAccessChecker\REVALIDATE, and ilWebAccessChecker\STATUS_CODE.

54  : void
55  {
56  // Set errorreporting
58  $queries = $this->http->request()->getQueryParams();
59 
60  // Set customizing
61  if (isset($queries[ilWebAccessChecker::DISPOSITION])) {
62  $this->wac->setDisposition($queries[ilWebAccessChecker::DISPOSITION]);
63  }
64  if (isset($queries[ilWebAccessChecker::STATUS_CODE])) {
65  $this->wac->setSendStatusCode($queries[ilWebAccessChecker::STATUS_CODE]);
66  }
67  if (isset($queries[ilWebAccessChecker::REVALIDATE])) {
68  $this->wac->setRevalidateFolderTokens($queries[ilWebAccessChecker::REVALIDATE]);
69  }
70 
71  // Check if File can be delivered
72  try {
73  if ($this->wac->check()) {
74  $this->deliver();
75  } else {
76  $this->deny();
77  }
78  } catch (ilWACException $e) {
79  match ($e->getCode()) {
84  default => $this->handleErrors($e),
85  };
86  }
87  }
static http()
Fetches the global http state from ILIAS.
static handleErrorReporting()
Set error reporting level.
+ Here is the call graph for this function:

◆ run()

static ilWebAccessCheckerDelivery::run ( Services  $httpState,
CookieFactory  $cookieFactory 
)
static

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

37  : void
38  {
39  $obj = new self($httpState, $cookieFactory);
40  $obj->handleRequest();
41  }

Field Documentation

◆ $http

Services ilWebAccessCheckerDelivery::$http
private

Definition at line 34 of file class.ilWebAccessCheckerDelivery.php.

◆ $wac

ilWebAccessChecker ilWebAccessCheckerDelivery::$wac
private

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


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