Пример #1
0
 /**
  * notify encryption module about added/removed users from a file/folder
  *
  * @param string $path relative to data/
  * @throws Exceptions\ModuleDoesNotExistsException
  */
 public function update($path)
 {
     // if a folder was shared, get a list of all (sub-)folders
     if ($this->view->is_dir($path)) {
         $allFiles = $this->util->getAllFiles($path);
     } else {
         $allFiles = array($path);
     }
     $encryptionModule = $this->encryptionManager->getEncryptionModule();
     foreach ($allFiles as $file) {
         $usersSharing = $this->file->getAccessList($file);
         $encryptionModule->update($file, $this->uid, $usersSharing);
     }
 }
Пример #2
0
 /**
  * read encryption module needed to read/write the file located at $path
  *
  * @param string $path
  * @return null|\OCP\Encryption\IEncryptionModule
  * @throws ModuleDoesNotExistsException
  * @throws \Exception
  */
 protected function getEncryptionModule($path)
 {
     $encryptionModule = null;
     $header = $this->getHeader($path);
     $encryptionModuleId = $this->util->getEncryptionModuleId($header);
     if (!empty($encryptionModuleId)) {
         try {
             $encryptionModule = $this->encryptionManager->getEncryptionModule($encryptionModuleId);
         } catch (ModuleDoesNotExistsException $e) {
             $this->logger->critical('Encryption module defined in "' . $path . '" not loaded!');
             throw $e;
         }
     }
     return $encryptionModule;
 }
Пример #3
0
 public function testGetEncryptionModule()
 {
     global $defaultId;
     $defaultId = null;
     $this->config->expects($this->any())->method('getAppValue')->with('core', 'default_encryption_module')->willReturnCallback(function () {
         global $defaultId;
         return $defaultId;
     });
     $this->addNewEncryptionModule($this->manager, 0);
     $defaultId = 'ID0';
     $this->assertCount(1, $this->manager->getEncryptionModules());
     $en0 = $this->manager->getEncryptionModule('ID0');
     $this->assertEquals('ID0', $en0->getId());
     $en0 = self::invokePrivate($this->manager, 'getDefaultEncryptionModule');
     $this->assertEquals('ID0', $en0->getId());
     $this->assertEquals('ID0', $this->manager->getDefaultEncryptionModuleId());
 }
Пример #4
0
 public function testGetDefaultEncryptionModule()
 {
     $config = $this->getMock('\\OCP\\IConfig');
     $config->expects($this->any())->method('getAppValue')->willReturn(true);
     $em = $this->getMock('\\OCP\\Encryption\\IEncryptionModule');
     $em->expects($this->any())->method('getId')->willReturn(0);
     $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
     $m = new Manager($config);
     $m->registerEncryptionModule($em);
     $this->assertSame(1, count($m->getEncryptionModules()));
     $en0 = $m->getEncryptionModule(0);
     $this->assertEquals(0, $en0->getId());
 }