123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace OC\Encryption;
- use OC\Files\Filesystem;
- use OC\Files\Storage\Wrapper\Encryption;
- use OC\Files\View;
- use OC\Memcache\ArrayCache;
- use OCP\Encryption\IFile;
- use OCP\Encryption\Keys\IStorage as EncryptionKeysStorage;
- use OCP\Files\Mount\IMountPoint;
- use OCP\Files\Storage\IDisableEncryptionStorage;
- use OCP\Files\Storage\IStorage;
- use Psr\Log\LoggerInterface;
- class EncryptionWrapper {
-
- private $arrayCache;
-
- private $manager;
- private LoggerInterface $logger;
-
- public function __construct(ArrayCache $arrayCache,
- Manager $manager,
- LoggerInterface $logger
- ) {
- $this->arrayCache = $arrayCache;
- $this->manager = $manager;
- $this->logger = $logger;
- }
-
- public function wrapStorage(string $mountPoint, IStorage $storage, IMountPoint $mount, bool $force = false) {
- $parameters = [
- 'storage' => $storage,
- 'mountPoint' => $mountPoint,
- 'mount' => $mount
- ];
- if ($force || (!$storage->instanceOfStorage(IDisableEncryptionStorage::class) && $mountPoint !== '/')) {
- $user = \OC::$server->getUserSession()->getUser();
- $mountManager = Filesystem::getMountManager();
- $uid = $user ? $user->getUID() : null;
- $fileHelper = \OC::$server->get(IFile::class);
- $keyStorage = \OC::$server->get(EncryptionKeysStorage::class);
- $util = new Util(
- new View(),
- \OC::$server->getUserManager(),
- \OC::$server->getGroupManager(),
- \OC::$server->getConfig()
- );
- $update = new Update(
- new View(),
- $util,
- Filesystem::getMountManager(),
- $this->manager,
- $fileHelper,
- $this->logger,
- $uid
- );
- return new Encryption(
- $parameters,
- $this->manager,
- $util,
- $this->logger,
- $fileHelper,
- $uid,
- $keyStorage,
- $update,
- $mountManager,
- $this->arrayCache
- );
- } else {
- return $storage;
- }
- }
- }
|