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) {
105 $path =
$path .
'&' . self::WAC_TIMESTAMP_ID .
'=' 117 $jar = $this->httpService->cookieJar();
118 $cookies = $jar->getAll();
120 $this->
setType(PathType::FOLDER);
123 $name = $plain_token->getHashedId();
127 $token_cookie_value = $this->httpService->request()->getCookieParams()[
$name] ?? $default_token;
129 $default_timestamp = 0;
130 $timestamp_cookie_value = $this->httpService->request()->getCookieParams()[
$name . self::TS_SUFFIX] ?? $default_timestamp;
131 $timestamp_cookie_value = intval($timestamp_cookie_value);
134 $ttl_cookie_value = $this->httpService->request()->getCookieParams()[
$name . self::TTL_SUFFIX] ?? $default_ttl;
135 $ttl_cookie_value = intval($ttl_cookie_value);
138 $this->
getPathObject()->setTimestamp($timestamp_cookie_value);
165 $cookie_lifetime = self::getCookieMaxLifetimeInSeconds();
167 $expire = time() + $cookie_lifetime + 3600;
176 ->withSecure($secure)
178 ->withHttpOnly($http_only);
180 $timestampCookie = $this->cookieFactory->create(
$id . self::TS_SUFFIX, time())
184 ->withSecure($secure)
185 ->withHttpOnly($http_only);
187 $ttlCookie = $this->cookieFactory->create(
$id . self::TTL_SUFFIX, $cookie_lifetime)
191 ->withSecure($secure)
192 ->withHttpOnly($http_only);
194 $response = $this->httpService->cookieJar()->with($tokenCookie)
195 ->with($timestampCookie)
197 ->renderIntoResponseHeader($this->httpService->response());
200 foreach ($this->httpService->cookieJar()->getAll() as $cookie) {
201 setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpires(), $cookie->getPath(), $cookie->getDomain(), $cookie->getSecure(), $cookie->getHttpOnly());
204 $this->httpService->saveResponse(
$response);
213 if ($this->
getType() !== PathType::FOLDER) {
254 if (!$path_to_file) {
257 $ilWACPath =
new ilWACPath($path_to_file);
258 if (!$ilWACPath->getClient()) {
259 return $path_to_file;
262 $obj->setType(PathType::FILE);
263 $obj->buildAndSetTokenInstance(time(), self::getTokenMaxLifetimeInSeconds());
265 return $obj->getSignedPath();
276 $obj->setType(PathType::FOLDER);
277 $obj->buildAndSetTokenInstance(time(), self::getCookieMaxLifetimeInSeconds());
278 $obj->saveFolderToken();
316 assert(is_int(
$type));
349 $current_timestamp = time();
351 $timestamp_valid = ($current_timestamp < ($request_timestamp + $request_ttl));
353 if (!$timestamp_valid) {
359 $simulatedTokenInstance = $this->
buildTokenInstance($request_timestamp, $request_ttl);
360 $token_valid = ($simulatedTokenInstance->getToken() == $request_token);
382 assert(is_int($ttl));
388 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(!array_key_exists('StateId', $_REQUEST)) $id
__construct(ilWACPath $ilWACPath, GlobalHttpState $httpState, CookieFactory $cookieFactory)
ilWACSignedPath constructor.
if($_SERVER['argc']< 4) $client
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()
if(!array_key_exists('domain', $_REQUEST)) $domain
static $cookie_max_lifetime_in_seconds