43 protected int $type = PathType::FILE;
56 $this->httpService = $httpState;
65 if ($this->
getType() !== PathType::FILE) {
85 return $path .
'&' . self::WAC_TIMESTAMP_ID .
'=' 91 $this->httpService->cookieJar();
93 $this->
setType(PathType::FOLDER);
95 $name = $plain_token->getHashedId();
99 $token_cookie_value = $this->httpService->request()->getCookieParams()[
$name] ?? $default_token;
101 $default_timestamp = 0;
102 $timestamp_cookie_value = $this->httpService->request()->getCookieParams()[
$name . self::TS_SUFFIX] ?? $default_timestamp;
103 $timestamp_cookie_value = (
int) $timestamp_cookie_value;
106 $ttl_cookie_value = $this->httpService->request()->getCookieParams()[
$name . self::TTL_SUFFIX] ?? $default_ttl;
107 $ttl_cookie_value = (
int) $ttl_cookie_value;
110 $this->
getPathObject()->setTimestamp($timestamp_cookie_value);
132 $cookie_lifetime = $ttl !== 0 ? $ttl : self::getCookieMaxLifetimeInSeconds();
134 $expire = time() + $cookie_lifetime + 3600;
141 ->withExpires($expire)
143 ->withSecure($secure)
144 ->withDomain($domain)
145 ->withHttpOnly($http_only);
147 $timestampCookie = $this->cookieFactory->create(
$id . self::TS_SUFFIX, time())
148 ->withExpires($expire)
150 ->withDomain($domain)
151 ->withSecure($secure)
152 ->withHttpOnly($http_only);
154 $ttlCookie = $this->cookieFactory->create(
$id . self::TTL_SUFFIX, $cookie_lifetime)
155 ->withExpires($expire)
157 ->withDomain($domain)
158 ->withSecure($secure)
159 ->withHttpOnly($http_only);
161 $jar = $this->httpService->cookieJar()->with($tokenCookie)
162 ->with($timestampCookie)
166 foreach ($jar->getAll() as $cookie) {
170 $cookie->getExpires(),
172 $cookie->getDomain(),
173 $cookie->getSecure(),
174 $cookie->getHttpOnly()
181 if ($this->
getType() !== PathType::FOLDER) {
215 public static function signFile(
string $path_to_file): string
218 if ($path_to_file ===
'' || $path_to_file ===
'0') {
221 $ilWACPath =
new ilWACPath($path_to_file,
false);
222 if ($ilWACPath->getClient() ===
'' || $ilWACPath->getClient() ===
'0') {
223 return $path_to_file;
226 $obj->setType(PathType::FILE);
227 $obj->buildAndSetTokenInstance(time(), self::getTokenMaxLifetimeInSeconds());
229 return $obj->getSignedPath();
236 $obj->setType(PathType::FOLDER);
237 $obj->buildAndSetTokenInstance(time(), self::getCookieMaxLifetimeInSeconds());
238 $obj->saveFolderToken();
279 $current_timestamp = time();
281 $timestamp_valid = ($current_timestamp < ($request_timestamp + $request_ttl));
283 if (!$timestamp_valid) {
290 $simulated_token_string = $simulated_token->getToken();
291 $token_valid = ($simulated_token_string === $request_token_string);
313 case PathType::FOLDER:
339 return self::$token_max_lifetime_in_seconds;
348 if ($token_max_lifetime_in_seconds > self::MAX_LIFETIME) {
356 return self::$cookie_max_lifetime_in_seconds;
366 if ($cookie_max_lifetime_in_seconds > self::MAX_LIFETIME) {
375 if ($request_ttl > 0) {
379 case PathType::FOLDER:
380 $life_time = self::getCookieMaxLifetimeInSeconds();
383 $life_time = self::getTokenMaxLifetimeInSeconds();
Interface GlobalHttpState.
static getCookieMaxLifetimeInSeconds()
setTokenInstance(ilWACToken $token_instance)
revalidatingFolderToken()
ilWACToken $token_instance
buildAndSetTokenInstance(int $timestamp=0, int $ttl=0)
__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...
static setTokenMaxLifetimeInSeconds(int $token_max_lifetime_in_seconds)
static setCookieMaxLifetimeInSeconds(int $cookie_max_lifetime_in_seconds)
static int $token_max_lifetime_in_seconds
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static signFolderOfStartFile(string $start_file_path)
setPathObject(ilWACPath $path_object)
buildTokenInstance(int $timestamp=0, int $ttl=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
GlobalHttpState $httpService
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
CookieFactory $cookieFactory
foreach($mandatory_scripts as $file) $timestamp
static int $cookie_max_lifetime_in_seconds
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static signFile(string $path_to_file)
static getTokenMaxLifetimeInSeconds()
setChecked(bool $checked)