10require_once(
'./Services/WebAccessChecker/class.ilWACException.php');
11require_once(
'class.ilWACToken.php');
12require_once(
'./Services/WebAccessChecker/classes/class.ilWebAccessChecker.php');
13require_once
'./Services/WebAccessChecker/interfaces/PathType.php';
14require_once
'./Services/WebAccessChecker/classes/HttpServiceAware.php';
42 protected $type = PathType::FILE;
75 $this->httpService = $httpState;
86 if ($this->
getType() !== PathType::FILE) {
105 $path =
$path .
'&' . self::WAC_TIMESTAMP_ID .
'='
117 $jar = $this->httpService->cookieJar();
118 $cookies = $jar->getAll();
120 $this->
setType(PathType::FOLDER);
123 $name = $plain_token->getHashedId();
127 $token_cookie_value = $this->httpService->request()->getCookieParams()[
$name] ?? $default_token;
129 $default_timestamp = 0;
130 $timestamp_cookie_value = $this->httpService->request()->getCookieParams()[
$name .
self::TS_SUFFIX] ?? $default_timestamp;
131 $timestamp_cookie_value = intval($timestamp_cookie_value);
134 $ttl_cookie_value = $this->httpService->request()->getCookieParams()[
$name .
self::TTL_SUFFIX] ?? $default_ttl;
135 $ttl_cookie_value = intval($ttl_cookie_value);
138 $this->
getPathObject()->setTimestamp($timestamp_cookie_value);
167 $expire = time() + $cookie_lifetime + 3600;
176 ->withSecure($secure)
178 ->withHttpOnly($http_only);
180 $timestampCookie = $this->cookieFactory->create(
$id . self::TS_SUFFIX, time())
184 ->withSecure($secure)
185 ->withHttpOnly($http_only);
187 $ttlCookie = $this->cookieFactory->create(
$id . self::TTL_SUFFIX, $cookie_lifetime)
191 ->withSecure($secure)
192 ->withHttpOnly($http_only);
194 $response = $this->httpService->cookieJar()->with($tokenCookie)
195 ->with($timestampCookie)
197 ->renderIntoResponseHeader($this->httpService->response());
200 foreach ($this->httpService->cookieJar()->getAll() as $cookie) {
201 setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpires(), $cookie->getPath(), $cookie->getDomain(), $cookie->getSecure(), $cookie->getHttpOnly());
204 $this->httpService->saveResponse(
$response);
213 if ($this->
getType() !== PathType::FOLDER) {
254 if (!$path_to_file) {
257 $ilWACPath =
new ilWACPath($path_to_file);
258 if (!$ilWACPath->getClient()) {
259 return $path_to_file;
262 $obj->setType(PathType::FILE);
265 return $obj->getSignedPath();
276 $obj->setType(PathType::FOLDER);
278 $obj->saveFolderToken();
316 assert(is_int(
$type));
349 $current_timestamp = time();
351 $timestamp_valid = ($current_timestamp < ($request_timestamp + $request_ttl));
353 if (!$timestamp_valid) {
359 $simulatedTokenInstance = $this->
buildTokenInstance($request_timestamp, $request_ttl);
360 $token_valid = ($simulatedTokenInstance->getToken() == $request_token);
382 assert(is_int($ttl));
388 case PathType::FOLDER:
417 assert(is_int($ttl));
480 if ($request_ttl > 0) {
484 case PathType::FOLDER:
foreach($mandatory_scripts as $file) $timestamp
if(!array_key_exists('domain', $_REQUEST)) $domain
An exception for terminatinating execution or to throw for unit testing.
static signFile($path_to_file)
static $token_max_lifetime_in_seconds
__construct(ilWACPath $ilWACPath, GlobalHttpState $httpState, CookieFactory $cookieFactory)
ilWACSignedPath constructor.
setTokenInstance(ilWACToken $token_instance)
static getCookieMaxLifetimeInSeconds()
static setCookieMaxLifetimeInSeconds($cookie_max_lifetime_in_seconds)
revalidatingFolderToken()
buildAndSetTokenInstance($timestamp=0, $ttl=0)
setPathObject(ilWACPath $path_object)
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
static $cookie_max_lifetime_in_seconds
static signFolderOfStartFile($start_file_path)
buildTokenInstance($timestamp=0, $ttl=0)
static getTokenMaxLifetimeInSeconds()
if($_SERVER['argc']< 4) $client
if(!array_key_exists('StateId', $_REQUEST)) $id
Interface GlobalHttpState.
trait HttpServiceAware
Trait HttpServiceAware.
static http()
Fetches the global http state from ILIAS.
trait HttpServiceAware
Trait HttpServiceAware.