25 require_once(
'./Services/WebAccessChecker/class.ilWACException.php');
26 require_once(
'class.ilWACToken.php');
27 require_once(
'./Services/WebAccessChecker/classes/class.ilWebAccessChecker.php');
28 require_once
'./Services/WebAccessChecker/interfaces/PathType.php';
29 require_once
'./Services/WebAccessChecker/classes/HttpServiceAware.php';
57 protected $type = PathType::FILE;
90 $this->httpService = $httpState;
101 if ($this->
getType() !== PathType::FILE) {
112 $path = $this->
getPathObject()->getPath() .
'&' . self::WAC_TOKEN_ID .
'=' 115 $path = $this->
getPathObject()->getPath() .
'?' . self::WAC_TOKEN_ID .
'=' 119 $path = $path .
'&' . self::WAC_TTL_ID .
'=' . $this->
getTokenInstance()->getTTL();
120 $path = $path .
'&' . self::WAC_TIMESTAMP_ID .
'=' 132 $jar = $this->httpService->cookieJar();
133 $cookies = $jar->getAll();
135 $this->
setType(PathType::FOLDER);
137 $name = $plain_token->getHashedId();
141 $token_cookie_value = $this->httpService->request()->getCookieParams()[
$name] ?? $default_token;
143 $default_timestamp = 0;
144 $timestamp_cookie_value = $this->httpService->request()->getCookieParams()[
$name . self::TS_SUFFIX] ?? $default_timestamp;
145 $timestamp_cookie_value = intval($timestamp_cookie_value);
148 $ttl_cookie_value = $this->httpService->request()->getCookieParams()[
$name . self::TTL_SUFFIX] ?? $default_ttl;
149 $ttl_cookie_value = intval($ttl_cookie_value);
152 $this->
getPathObject()->setTimestamp($timestamp_cookie_value);
180 $cookie_lifetime = $ttl !== 0 ? $ttl : self::getCookieMaxLifetimeInSeconds();
182 $expire = time() + $cookie_lifetime + 3600;
188 $tokenCookie = $this->cookieFactory->create($id, $this->
getTokenInstance()->getToken())
189 ->withExpires($expire)
191 ->withSecure($secure)
192 ->withDomain($domain)
193 ->withHttpOnly($http_only);
195 $timestampCookie = $this->cookieFactory->create($id . self::TS_SUFFIX, time())
196 ->withExpires($expire)
198 ->withDomain($domain)
199 ->withSecure($secure)
200 ->withHttpOnly($http_only);
202 $ttlCookie = $this->cookieFactory->create($id . self::TTL_SUFFIX, $cookie_lifetime)
203 ->withExpires($expire)
205 ->withDomain($domain)
206 ->withSecure($secure)
207 ->withHttpOnly($http_only);
209 $jar = $this->httpService->cookieJar()->with($tokenCookie)
210 ->with($timestampCookie)
214 foreach ($jar->getAll() as $cookie) {
218 $cookie->getExpires(),
220 $cookie->getDomain(),
221 $cookie->getSecure(),
222 $cookie->getHttpOnly()
233 if ($this->
getType() !== PathType::FOLDER) {
278 if (!$path_to_file) {
281 $ilWACPath =
new ilWACPath($path_to_file,
false);
282 if (!$ilWACPath->getClient()) {
283 return $path_to_file;
286 $obj->setType(PathType::FILE);
287 $obj->buildAndSetTokenInstance(time(), self::getTokenMaxLifetimeInSeconds());
289 return $obj->getSignedPath();
300 $obj->setType(PathType::FOLDER);
301 $obj->buildAndSetTokenInstance(time(), self::getCookieMaxLifetimeInSeconds());
302 $obj->saveFolderToken();
340 assert(is_int(
$type));
373 $current_timestamp = time();
375 $timestamp_valid = ($current_timestamp < ($request_timestamp + $request_ttl));
377 if (!$timestamp_valid) {
384 $simulated_token_string = $simulated_token->getToken();
385 $token_valid = ($simulated_token_string == $request_token_string);
407 assert(is_int($ttl));
413 case PathType::FOLDER:
439 assert(is_int($ttl));
450 return self::$token_max_lifetime_in_seconds;
475 return self::$cookie_max_lifetime_in_seconds;
502 if ($request_ttl > 0) {
506 case PathType::FOLDER:
507 $life_time = self::getCookieMaxLifetimeInSeconds();
510 $life_time = self::getTokenMaxLifetimeInSeconds();
Interface GlobalHttpState.
buildTokenInstance($timestamp=0, $ttl=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getCookieMaxLifetimeInSeconds()
setTokenInstance(ilWACToken $token_instance)
revalidatingFolderToken()
if($_SERVER['argc']< 4) $client
__construct(ilWACPath $ilWACPath, GlobalHttpState $httpState, CookieFactory $cookieFactory)
ilWACSignedPath constructor.
trait HttpServiceAware
Trait HttpServiceAware.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static signFolderOfStartFile($start_file_path)
static $token_max_lifetime_in_seconds
static http()
Fetches the global http state from ILIAS.
setPathObject(ilWACPath $path_object)
static setCookieMaxLifetimeInSeconds($cookie_max_lifetime_in_seconds)
buildAndSetTokenInstance($timestamp=0, $ttl=0)
static signFile($path_to_file)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
foreach($mandatory_scripts as $file) $timestamp
trait HttpServiceAware
Trait HttpServiceAware.
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
static getTokenMaxLifetimeInSeconds()
static $cookie_max_lifetime_in_seconds