/**
  * @param $argument
  */
 protected function run($argument)
 {
     // Delete old tokens after 2 days
     if ($this->timeFactory->getTime() - $this->config->getAppValue('core', 'updater.secret.created', $this->timeFactory->getTime()) >= 172800) {
         $this->config->deleteSystemValue('updater.secret');
     }
 }
예제 #2
0
파일: crypt.php 프로젝트: samj1912/repo
 /**
  * @medium
  * Test that data that is written by the crypto stream wrapper with AES 128
  * @note Encrypted data is manually prepared and decrypted here to avoid dependency on success of stream_read
  * @note If this test fails with truncate content, check that enough array slices are being rejoined to form $e, as the crypt.php file may have gotten longer and broken the manual
  * reassembly of its data
  */
 public function testStreamDecryptLongFileContentWithoutHeader()
 {
     // Generate a a random filename
     $filename = 'tmp-' . $this->getUniqueID() . '.test';
     $this->config->setSystemValue('cipher', 'AES-128-CFB');
     // Save long data as encrypted file using stream wrapper
     $cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong . $this->dataLong);
     $this->config->deleteSystemValue('cipher');
     // Test that data was successfully written
     $this->assertTrue(is_int($cryptedFile));
     // Disable encryption proxy to prevent recursive calls
     $proxyStatus = \OC_FileProxy::$enabled;
     \OC_FileProxy::$enabled = false;
     // Get file contents without using any wrapper to get it's actual contents on disk
     $retreivedCryptedFile = $this->view->file_get_contents($this->userId . '/files/' . $filename);
     // Check that the file was encrypted before being written to disk
     $this->assertNotEquals($this->dataLong . $this->dataLong, $retreivedCryptedFile);
     // remove the header to check if we can also decrypt old files without a header,
     //  this files should fall back to AES-128
     $cryptedWithoutHeader = substr($retreivedCryptedFile, \OCA\Files_Encryption\Crypt::BLOCKSIZE);
     $this->view->file_put_contents($this->userId . '/files/' . $filename, $cryptedWithoutHeader);
     // Re-enable proxy - our work is done
     \OC_FileProxy::$enabled = $proxyStatus;
     $decrypted = file_get_contents('crypt:///' . $this->userId . '/files/' . $filename);
     $this->assertEquals($this->dataLong . $this->dataLong, $decrypted);
     // Teardown
     $this->view->unlink($this->userId . '/files/' . $filename);
 }
 /**
  * Sets the email settings
  * @param string $mail_domain
  * @param string $mail_from_address
  * @param string $mail_smtpmode
  * @param string $mail_smtpsecure
  * @param string $mail_smtphost
  * @param string $mail_smtpauthtype
  * @param int $mail_smtpauth
  * @param string $mail_smtpport
  * @return array
  */
 public function setMailSettings($mail_domain, $mail_from_address, $mail_smtpmode, $mail_smtpsecure, $mail_smtphost, $mail_smtpauthtype, $mail_smtpauth, $mail_smtpport)
 {
     $params = get_defined_vars();
     foreach ($params as $key => $value) {
         if (empty($value)) {
             $this->config->deleteSystemValue($key);
         } else {
             $this->config->setSystemValue($key, $value);
         }
     }
     // Delete passwords from config in case no auth is specified
     if ($params['mail_smtpauth'] !== 1) {
         $this->config->deleteSystemValue('mail_smtpname');
         $this->config->deleteSystemValue('mail_smtppassword');
     }
     return array('data' => array('message' => (string) $this->l10n->t('Saved')), 'status' => 'success');
 }