user = $userSession->isLoggedIn() ? $userSession->getUser() : false; } /** * check if recovery key is enabled for user * * @param string $uid * @return bool */ public function isRecoveryEnabledForUser($uid) { return $this->userConfig->getValueBool($uid, 'encryption', 'recoveryEnabled'); } /** * check if the home storage should be encrypted * * @return bool */ public function shouldEncryptHomeStorage() { return $this->appConfig->getValueBool('encryption', 'encryptHomeStorage', true); } /** * set the home storage encryption on/off * * @param bool $encryptHomeStorage */ public function setEncryptHomeStorage(bool $encryptHomeStorage) { $this->appConfig->setValueBool('encryption', 'encryptHomeStorage', $encryptHomeStorage); } /** * check if master key is enabled */ public function isMasterKeyEnabled(): bool { return $this->appConfig->getValueBool('encryption', 'useMasterKey', true); } public function setRecoveryForUser(bool $enabled): bool { try { $this->userConfig->setValueBool($this->user->getUID(), 'encryption', 'recoveryEnabled', $enabled); return true; } catch (PreConditionNotMetException $e) { return false; } } /** * @param string $uid * @return bool */ public function userHasFiles($uid) { return $this->files->file_exists($uid . '/files'); } /** * get owner from give path, path relative to data/ expected * * @param string $path relative to data/ * @return string * @throws \BadMethodCallException */ public function getOwner($path) { $owner = ''; $parts = explode('/', $path, 3); if (count($parts) > 1) { $owner = $parts[1]; if ($this->userManager->userExists($owner) === false) { throw new \BadMethodCallException('Unknown user: ' . 'method expects path to a user folder relative to the data folder'); } } return $owner; } public function getStorage(string $path): ?IStorage { return $this->files->getMount($path)->getStorage(); } }