10 require_once(
'./Services/WebAccessChecker/class.ilWACException.php');
11 require_once(
'class.ilWACToken.php');
12 require_once(
'./Services/WebAccessChecker/classes/class.ilWebAccessChecker.php');
13 require_once
'./Services/WebAccessChecker/interfaces/PathType.php';
14 require_once
'./Services/WebAccessChecker/classes/HttpServiceAware.php';
42 protected $type = PathType::FILE;
75 $this->httpService = $httpState;
86 if ($this->
getType() !== PathType::FILE) {
97 $path = $this->
getPathObject()->getPath() .
'&' . self::WAC_TOKEN_ID .
'=' 100 $path = $this->
getPathObject()->getPath() .
'?' . self::WAC_TOKEN_ID .
'=' 104 $path = $path .
'&' . self::WAC_TTL_ID .
'=' . $this->
getTokenInstance()->getTTL();
105 $path = $path .
'&' . self::WAC_TIMESTAMP_ID .
'=' 117 $jar = $this->httpService->cookieJar();
118 $cookies = $jar->getAll();
120 $this->
setType(PathType::FOLDER);
122 $name = $plain_token->getHashedId();
126 $token_cookie_value = $this->httpService->request()->getCookieParams()[
$name] ?? $default_token;
128 $default_timestamp = 0;
129 $timestamp_cookie_value = $this->httpService->request()->getCookieParams()[
$name . self::TS_SUFFIX] ?? $default_timestamp;
130 $timestamp_cookie_value = intval($timestamp_cookie_value);
133 $ttl_cookie_value = $this->httpService->request()->getCookieParams()[
$name . self::TTL_SUFFIX] ?? $default_ttl;
134 $ttl_cookie_value = intval($ttl_cookie_value);
137 $this->
getPathObject()->setTimestamp($timestamp_cookie_value);
165 $cookie_lifetime = $ttl !== 0 ? $ttl : self::getCookieMaxLifetimeInSeconds();
167 $expire = time() + $cookie_lifetime + 3600;
173 $tokenCookie = $this->cookieFactory->create($id, $this->
getTokenInstance()->getToken())
174 ->withExpires($expire)
176 ->withSecure($secure)
177 ->withDomain($domain)
178 ->withHttpOnly($http_only);
180 $timestampCookie = $this->cookieFactory->create($id . self::TS_SUFFIX, time())
181 ->withExpires($expire)
183 ->withDomain($domain)
184 ->withSecure($secure)
185 ->withHttpOnly($http_only);
187 $ttlCookie = $this->cookieFactory->create($id . self::TTL_SUFFIX, $cookie_lifetime)
188 ->withExpires($expire)
190 ->withDomain($domain)
191 ->withSecure($secure)
192 ->withHttpOnly($http_only);
194 $jar = $this->httpService->cookieJar()->with($tokenCookie)
195 ->with($timestampCookie)
199 foreach ($jar->getAll() as $cookie) {
200 setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpires(), $cookie->getPath(),
201 $cookie->getDomain(), $cookie->getSecure(), $cookie->getHttpOnly());
211 if ($this->
getType() !== PathType::FOLDER) {
256 if (!$path_to_file) {
259 $ilWACPath =
new ilWACPath($path_to_file);
260 if (!$ilWACPath->getClient()) {
261 return $path_to_file;
264 $obj->setType(PathType::FILE);
265 $obj->buildAndSetTokenInstance(time(), self::getTokenMaxLifetimeInSeconds());
267 return $obj->getSignedPath();
278 $obj->setType(PathType::FOLDER);
279 $obj->buildAndSetTokenInstance(time(), self::getCookieMaxLifetimeInSeconds());
280 $obj->saveFolderToken();
318 assert(is_int(
$type));
351 $current_timestamp = time();
353 $timestamp_valid = ($current_timestamp < ($request_timestamp + $request_ttl));
355 if (!$timestamp_valid) {
362 $simulated_token_string = $simulated_token->getToken();
363 $token_valid = ($simulated_token_string == $request_token_string);
385 assert(is_int($ttl));
391 case PathType::FOLDER:
417 assert(is_int($ttl));
428 return self::$token_max_lifetime_in_seconds;
453 return self::$cookie_max_lifetime_in_seconds;
480 if ($request_ttl > 0) {
484 case PathType::FOLDER:
485 $life_time = self::getCookieMaxLifetimeInSeconds();
488 $life_time = self::getTokenMaxLifetimeInSeconds();
Interface GlobalHttpState.
buildTokenInstance($timestamp=0, $ttl=0)
static getCookieMaxLifetimeInSeconds()
setTokenInstance(ilWACToken $token_instance)
revalidatingFolderToken()
if($_SERVER['argc']< 4) $client
__construct(ilWACPath $ilWACPath, GlobalHttpState $httpState, CookieFactory $cookieFactory)
ilWACSignedPath constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
trait HttpServiceAware
Trait HttpServiceAware.
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)
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