2 require_once(
'./Services/WebAccessChecker/class.ilWACException.php');
3 require_once(
'class.ilWACToken.php');
4 require_once(
'./Services/WebAccessChecker/classes/class.ilWebAccessChecker.php');
5 require_once(
'./Services/WebAccessChecker/classes/class.ilWACCookie.php');
34 protected $type = self::TYPE_FILE;
60 $this->cookie = ($ilWACCookieInterface ? $ilWACCookieInterface :
new ilWACCookie());
70 if ($this->
getType() !== self::TYPE_FILE) {
97 $this->
setType(self::TYPE_FOLDER);
99 $name = $plain_token->getHashedId();
101 $this->
getPathObject()->setTimestamp($this->cookie->get($name . self::TS_SUFFIX));
102 $this->
getPathObject()->setTTL($this->cookie->get($name . self::TTL_SUFFIX));
123 $cookie_lifetime = self::getCookieMaxLifetimeInSeconds();
124 $str =
'save folder token for folder: ' . $this->
getPathObject()->getDirName() .
', valid for ' . $cookie_lifetime .
's';
128 $expire =
time() + $cookie_lifetime;
129 $this->cookie->set($id, $this->
getTokenInstance()->getToken(),
time() + 24 * 3600,
'/', null,
false,
false);
130 $this->cookie->set($id . self::TS_SUFFIX,
time(), $expire,
'/',
'',
false,
false);
131 $this->cookie->set($id . self::TTL_SUFFIX, self::getCookieMaxLifetimeInSeconds(), $expire,
'/',
'',
false,
false);
139 if ($this->
getType() !== self::TYPE_FOLDER) {
176 if (!$path_to_file) {
179 $ilWACPath =
new ilWACPath($path_to_file);
180 if (!$ilWACPath->getClient()) {
181 return $path_to_file;
183 $obj =
new self($ilWACPath);
184 $obj->setType(self::TYPE_FILE);
185 $obj->buildAndSetTokenInstance(
time(), self::getTokenMaxLifetimeInSeconds());
187 return $obj->getSignedPath();
196 $obj =
new self(
new ilWACPath($start_file_path), $ilWACCookieInterface);
197 $obj->setType(self::TYPE_FOLDER);
198 $obj->buildAndSetTokenInstance(
time(), self::getCookieMaxLifetimeInSeconds());
199 $obj->saveFolderToken();
261 $current_timestamp =
time();
263 ilWACLog::getInstance()->write(
'Checking Token: ' . $request_token .
', ts: ' . $request_timestamp .
"\n\n\n\n\n\n");
265 $timestamp_valid = ($current_timestamp < ($request_timestamp + $request_ttl));
267 if (!$timestamp_valid) {
274 $simulatedTokenInstance = $this->
buildTokenInstance($request_timestamp, $request_ttl);
275 $token_valid = ($simulatedTokenInstance->getToken() == $request_token);
301 case self::TYPE_FOLDER:
304 case self::TYPE_FILE:
334 return self::$token_max_lifetime_in_seconds;
354 return self::$cookie_max_lifetime_in_seconds;
375 if ($request_ttl > 0) {
379 case self::TYPE_FOLDER:
380 $life_time = self::getCookieMaxLifetimeInSeconds();
382 case self::TYPE_FILE:
383 $life_time = self::getTokenMaxLifetimeInSeconds();
static getCookieMaxLifetimeInSeconds()
setTokenInstance(ilWACToken $token_instance)
revalidatingFolderToken()
static signFolderOfStartFile($start_file_path, ilWACCookieInterface $ilWACCookieInterface=null)
buildTokenInstance($timestamp=null, $ttl=null)
Class ilWACCookieInterface.
setPathObject($path_object)
static $token_max_lifetime_in_seconds
static setCookieMaxLifetimeInSeconds($cookie_max_lifetime_in_seconds)
static signFile($path_to_file)
foreach($mandatory_scripts as $file) $timestamp
__construct(ilWACPath $ilWACPath, ilWACCookieInterface $ilWACCookieInterface=null)
ilWACSignedPath constructor.
buildAndSetTokenInstance($timestamp=null, $ttl=null)
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