Example #1
0
 /**
  * decrypt private key and add it to the current session
  * @param array $params with 'uid' and 'password'
  * @return mixed session or false
  */
 public function initEncryption($params)
 {
     $session = new Session($this->view);
     // we tried to initialize the encryption app for this session
     $session->setInitialized(Session::INIT_EXECUTED);
     $encryptedKey = Keymanager::getPrivateKey($this->view, $params['uid']);
     $privateKey = false;
     if ($encryptedKey) {
         $privateKey = Crypt::decryptPrivateKey($encryptedKey, $params['password']);
     }
     if ($privateKey === false) {
         \OCP\Util::writeLog('Encryption library', 'Private key for user "' . $params['uid'] . '" is not valid! Maybe the user password was changed from outside if so please change it back to gain access', \OCP\Util::ERROR);
         return false;
     }
     $session->setPrivateKey($privateKey);
     $session->setInitialized(Session::INIT_SUCCESSFUL);
     return $session;
 }
Example #2
0
 /**
  * set the init status to 'NOT_INITIALIZED' (0) if the app gets enabled
  * @param array $params contains the app ID
  */
 public static function postEnable($params)
 {
     if ($params['app'] === 'files_encryption') {
         $session = new Session(new \OC\Files\View('/'));
         $session->setInitialized(Session::NOT_INITIALIZED);
     }
 }