25require_once(
'./Services/WebAccessChecker/class.ilWACException.php');
26require_once(
'class.ilWACToken.php');
27require_once(
'./Services/WebAccessChecker/classes/class.ilWebAccessChecker.php');
28require_once
'./Services/WebAccessChecker/interfaces/PathType.php';
29require_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);
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);
289 return $obj->getSignedPath();
300 $obj->setType(PathType::FOLDER);
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));
502 if ($request_ttl > 0) {
506 case PathType::FOLDER:
foreach($mandatory_scripts as $file) $timestamp
An exception for terminatinating execution or to throw for unit testing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
Interface GlobalHttpState.
trait HttpServiceAware
Trait HttpServiceAware.
static http()
Fetches the global http state from ILIAS.
trait HttpServiceAware
Trait HttpServiceAware.