ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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
 
string $img_dir
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilWebAccessCheckerDelivery constructor.

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

References ILIAS\FileDelivery\http().

49  {
50  $this->wac = new ilWebAccessChecker($httpState, $cookieFactory);
51  $this->http = $httpState;
52  $this->img_dir = realpath(__DIR__ . '/../templates/images');
53  }
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 166 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().

166  : void
167  {
168  if (!$this->wac->isChecked()) {
170  }
171 
172  $path = $this->wac->getPathObject();
173  // This is currently the place where WAC handles things from the ResourceStorageService.
174  if ($path->getModuleType() === 'rs') {
175  // initialize constants
176  if (!defined('CLIENT_DATA_DIR')) {
177  $ini = new ilIniFile("./ilias.ini.php");
178  $ini->read();
179  $data_dir = rtrim($ini->readVariable("clients", "datadir"), '/');
180  $client_data_dir = $data_dir . "/" . $path->getClient();
181  } else {
182  $client_data_dir = CLIENT_DATA_DIR;
183  }
184 
185  $token_factory = new TokenFactory($client_data_dir);
186  $token = $token_factory->check($path->getFileName());
187  $path_to_file = $token->resolveStream(); // FileStream
188  } else {
189  $path_to_file = $path->getCleanURLdecodedPath();
190  }
191 
192  $real_path_to_file = realpath(__DIR__ . '/../../../../public/' . $path_to_file);
193 
194  $ilFileDelivery = new Delivery($real_path_to_file, $this->http);
195  $ilFileDelivery->setCache(true);
196  $ilFileDelivery->setDisposition($this->wac->getDisposition());
197  if ($path->isStreamable()) { // fixed 0016468
198  $ilFileDelivery->stream();
199  } else {
200  $ilFileDelivery->deliver();
201  }
202  }
$path
Definition: ltiservices.php:30
const CLIENT_DATA_DIR
Definition: constants.php:46
static http()
Fetches the global http state from ILIAS.
$token
Definition: xapitoken.php:67
Class Delivery.
Definition: Delivery.php:38
$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 103 of file class.ilWebAccessCheckerDelivery.php.

References ILIAS\FileDelivery\http().

Referenced by handleAccessErrors().

103  : void
104  {
105  $ilFileDelivery = new Delivery($this->img_dir . '/access_denied.png', $this->http);
106  $ilFileDelivery->setDisposition($this->wac->getDisposition());
107  $ilFileDelivery->deliver();
108  }
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 111 of file class.ilWebAccessCheckerDelivery.php.

References ILIAS\FileDelivery\http().

Referenced by handleAccessErrors().

111  : void
112  {
113  $ilFileDelivery = new Delivery($this->img_dir . '/access_denied.mp4', $this->http);
114  $ilFileDelivery->setDisposition($this->wac->getDisposition());
115  $ilFileDelivery->stream();
116  }
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 94 of file class.ilWebAccessCheckerDelivery.php.

References ilWACException\ACCESS_DENIED, and ilWACException\ACCESS_WITHOUT_CHECK.

Referenced by handleRequest().

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

◆ handleAccessErrors()

ilWebAccessCheckerDelivery::handleAccessErrors ( ilWACException  $e)
protected

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

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

Referenced by handleRequest().

126  : void
127  {
128  //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)
129  $response = $this->http
130  ->response()
131  ->withStatus(200);
132 
133  $this->http->saveResponse($response);
134 
135  if ($this->wac->getPathObject()->isVideo()) {
136  $this->deliverDummyVideo();
137  }
138 
139  $this->deliverDummyImage();
140 
141  $this->wac->initILIAS();
142  }
$response
Definition: xapitoken.php:90
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 118 of file class.ilWebAccessCheckerDelivery.php.

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

Referenced by handleRequest().

118  : void
119  {
120  $response = $this->http
121  ->response()
122  ->withStatus(404);
123  $this->http->saveResponse($response);
124  }
$response
Definition: xapitoken.php:90
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 56 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.

56  : void
57  {
58  // Set errorreporting
60  $queries = $this->http->request()->getQueryParams();
61 
62  // Set customizing
63  if (isset($queries[ilWebAccessChecker::DISPOSITION])) {
64  $this->wac->setDisposition($queries[ilWebAccessChecker::DISPOSITION]);
65  }
66  if (isset($queries[ilWebAccessChecker::STATUS_CODE])) {
67  $this->wac->setSendStatusCode($queries[ilWebAccessChecker::STATUS_CODE]);
68  }
69  if (isset($queries[ilWebAccessChecker::REVALIDATE])) {
70  $this->wac->setRevalidateFolderTokens($queries[ilWebAccessChecker::REVALIDATE]);
71  }
72 
73  // Check if File can be delivered
74  try {
75  if ($this->wac->check()) {
76  $this->deliver();
77  } else {
78  $this->deny();
79  }
80  } catch (ilWACException $e) {
81  match ($e->getCode()) {
86  default => $this->handleErrors($e),
87  };
88  }
89  }
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 38 of file class.ilWebAccessCheckerDelivery.php.

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

Field Documentation

◆ $http

Services ilWebAccessCheckerDelivery::$http
private

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

◆ $img_dir

string ilWebAccessCheckerDelivery::$img_dir
private

Definition at line 35 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: