ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 47 of file class.ilWebAccessCheckerDelivery.php.

References ILIAS\FileDelivery\http().

48  {
49  $this->wac = new ilWebAccessChecker($httpState, $cookieFactory);
50  $this->http = $httpState;
51  $this->img_dir = realpath(__DIR__ . '/../templates/images');
52  }
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  $real_path_to_file = realpath(__DIR__ . '/../../../../public/' . $path_to_file);
192 
193  $ilFileDelivery = new Delivery($real_path_to_file, $this->http);
194  $ilFileDelivery->setCache(true);
195  $ilFileDelivery->setDisposition($this->wac->getDisposition());
196  if ($path->isStreamable()) { // fixed 0016468
197  $ilFileDelivery->stream();
198  } else {
199  $ilFileDelivery->deliver();
200  }
201  }
$path
Definition: ltiservices.php:29
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:39
$ini
Definition: raiseError.php:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliverDummyImage()

ilWebAccessCheckerDelivery::deliverDummyImage ( )
protected

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

References ILIAS\FileDelivery\http().

Referenced by handleAccessErrors().

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

◆ deliverDummyVideo()

ilWebAccessCheckerDelivery::deliverDummyVideo ( )
protected

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

References ILIAS\FileDelivery\http().

Referenced by handleAccessErrors().

110  : void
111  {
112  $ilFileDelivery = new Delivery($this->img_dir . '/access_denied.mp4', $this->http);
113  $ilFileDelivery->setDisposition($this->wac->getDisposition());
114  $ilFileDelivery->stream();
115  }
static http()
Fetches the global http state from ILIAS.
Class Delivery.
Definition: Delivery.php:39
+ 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 93 of file class.ilWebAccessCheckerDelivery.php.

References ilWACException\ACCESS_DENIED, and ilWACException\ACCESS_WITHOUT_CHECK.

Referenced by handleRequest().

93  : void
94  {
95  if (!$this->wac->isChecked()) {
97  }
99  }
+ 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 117 of file class.ilWebAccessCheckerDelivery.php.

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

Referenced by handleRequest().

117  : void
118  {
119  $response = $this->http
120  ->response()
121  ->withStatus(404);
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 55 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.

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

◆ $img_dir

string ilWebAccessCheckerDelivery::$img_dir
private

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

◆ $wac

ilWebAccessChecker ilWebAccessCheckerDelivery::$wac
private

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


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