Пример #1
0
 /**
  * recover users files with the recovery key
  *
  * @param string $recoveryPassword
  * @param string $user
  */
 public function recoverUsersFiles($recoveryPassword, $user)
 {
     $encryptedKey = $this->keyManager->getSystemPrivateKey($this->keyManager->getRecoveryKeyId());
     $privateKey = $this->crypt->decryptPrivateKey($encryptedKey, $recoveryPassword);
     if ($privateKey !== false) {
         $this->recoverAllFiles('/' . $user . '/files/', $privateKey, $user);
     }
 }
Пример #2
0
 /**
  * get the private key which will be used to decrypt all files
  *
  * @param string $user
  * @param string $password
  * @return bool|string
  * @throws \OCA\Encryption\Exceptions\PrivateKeyMissingException
  */
 protected function getPrivateKey($user, $password)
 {
     $recoveryKeyId = $this->keyManager->getRecoveryKeyId();
     if ($user === $recoveryKeyId) {
         $recoveryKey = $this->keyManager->getSystemPrivateKey($recoveryKeyId);
         $privateKey = $this->crypt->decryptPrivateKey($recoveryKey, $password);
     } else {
         $userKey = $this->keyManager->getPrivateKey($user);
         $privateKey = $this->crypt->decryptPrivateKey($userKey, $password, $user);
     }
     return $privateKey;
 }
Пример #3
0
 public function testGetSystemPrivateKey()
 {
     $this->keyStorageMock->expects($this->exactly(1))->method('getSystemUserKey')->with($this->equalTo('keyId.privateKey'))->willReturn('systemPrivateKey');
     $this->assertSame('systemPrivateKey', $this->instance->getSystemPrivateKey('keyId'));
 }