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) {
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);
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);
267 return $obj->getSignedPath();
278 $obj->setType(PathType::FOLDER);
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));
480 if ($request_ttl > 0) {
484 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.