11 require_once(
'./Services/WebAccessChecker/class.ilWACException.php');
12 require_once(
'class.ilWACToken.php');
13 require_once(
'./Services/WebAccessChecker/classes/class.ilWebAccessChecker.php');
14 require_once
'./Services/WebAccessChecker/interfaces/PathType.php';
15 require_once
'./Services/WebAccessChecker/classes/HttpServiceAware.php';
43 protected $type = PathType::FILE;
76 $this->httpService = $httpState;
87 if ($this->
getType() !== PathType::FILE) {
106 $path =
$path .
'&' . self::WAC_TIMESTAMP_ID .
'=' 118 $cookieJar = $this->httpService->cookieJar();
120 $this->
setType(PathType::FOLDER);
122 $name = $plain_token->getHashedId();
124 $tokenCookie = $cookieJar->get(
$name);
125 $timestampCookie = $cookieJar->get(
$name . self::TS_SUFFIX);
126 $ttlCookie = $cookieJar->get(
$name . self::TTL_SUFFIX);
129 $tokenCookieValue = is_null($tokenCookie) ? $defaultToken : is_a($tokenCookie->getValue(), Cookie::class) ? $tokenCookie->getValue() : $defaultToken;
131 $defaultTimestamp = 0;
132 $timestampCookieValue = is_null($timestampCookie) ? $defaultTimestamp : is_a($timestampCookie->getValue(), Cookie::class) ? $timestampCookie->getValue() : $defaultTimestamp;
133 $timestampCookieValue = intval($timestampCookieValue);
136 $ttlCookieValue = is_null($ttlCookie) ? $defaultTtl : is_a($ttlCookie->getValue(), Cookie::class) ? $ttlCookie->getValue() : $defaultTtl;
137 $ttlCookieValue = intval($ttlCookieValue);
167 $cookie_lifetime = self::getCookieMaxLifetimeInSeconds();
174 * 3600)->withPath(
'/')->withSecure(
false)->withDomain(null)->withSecure(
false)->withHttpOnly(
false);
176 $timestampCookie = $this->cookieFactory->create(
$id 177 . self::TS_SUFFIX,
time())->withExpires(
$expire)->withPath(
'/')->withDomain(null)->withSecure(
false)->withHttpOnly(
false);
179 $ttlCookie = $this->cookieFactory->create(
$id 180 . self::TTL_SUFFIX, self::getCookieMaxLifetimeInSeconds())->withExpires(
$expire)->withPath(
'/')->withDomain(null)->withSecure(
false)->withHttpOnly(
false);
182 $cookieJar = $this->httpService->cookieJar();
183 $response = $cookieJar->with($tokenCookie)->with($timestampCookie)->with($ttlCookie)->renderIntoResponseHeader($this->httpService->response());
185 $this->httpService->saveResponse(
$response);
194 if ($this->
getType() !== PathType::FOLDER) {
235 if (!$path_to_file) {
238 $ilWACPath =
new ilWACPath($path_to_file);
239 if (!$ilWACPath->getClient()) {
240 return $path_to_file;
243 $obj->setType(PathType::FILE);
244 $obj->buildAndSetTokenInstance(
time(), self::getTokenMaxLifetimeInSeconds());
246 return $obj->getSignedPath();
257 $obj->setType(PathType::FOLDER);
258 $obj->buildAndSetTokenInstance(
time(), self::getCookieMaxLifetimeInSeconds());
259 $obj->saveFolderToken();
297 assert(is_int(
$type));
330 $current_timestamp =
time();
332 $timestamp_valid = ($current_timestamp < ($request_timestamp + $request_ttl));
334 if (!$timestamp_valid) {
340 $simulatedTokenInstance = $this->
buildTokenInstance($request_timestamp, $request_ttl);
341 $token_valid = ($simulatedTokenInstance->getToken() == $request_token);
363 assert(is_int($ttl));
369 case PathType::FOLDER:
398 assert(is_int($ttl));
409 return self::$token_max_lifetime_in_seconds;
434 return self::$cookie_max_lifetime_in_seconds;
461 if ($request_ttl > 0) {
465 case PathType::FOLDER:
466 $life_time = self::getCookieMaxLifetimeInSeconds();
469 $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.
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)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static getTokenMaxLifetimeInSeconds()
static $cookie_max_lifetime_in_seconds