/** * Modify action. Completes the modification of a key profile */ public function modifyAction() { $crypto = new CryptoModel(array('cryptoID' => $this->_getParam('id'))); $crypto->name = $this->_getParam('name'); $crypto->save(); $this->flash('notice', 'Key profile successfully modified'); $this->_redirector->gotoRoute(array('action' => 'index', 'id' => null)); }
/** * Generates a drop down box listing all crypto profiles * * @param integer current crypto profile (or null if no current profile) * @param string element name * @return string */ public function cryptoSelect($cryptoID, $name = 'cryptoID') { $options[0] = 'none'; $cryptos = CryptoModel::getAllProfiles(); foreach ($cryptos as $crypto) { $profileName = $this->view->h($crypto->name); if (!isset($options[$crypto->cryptoID])) { $options[$crypto->cryptoID] = $profileName; } } return $this->view->formSelect($name, $cryptoID, null, $options); }
public function testEncryptedZipArchiveExportCanBeImported() { $this->auth(); $crypto = CryptoModel::importRijndael256Key('testdupe', 'BqPwhnSskTFzxPUlljXG1zgG8cfgTSaGj8UyRWsKanA='); $instance = new InstanceModel(array('instanceID' => 1)); $zip = new ZipArchiveModel($instance, array('new' => '1')); $zip->addInstanceFullResponsesXMLDocument(); $zip->close(); $encrypted = $crypto->encrypt($zip->getZipFileContents()); $zip->deleteZipFile(); $decrypted = $crypto->decrypt($encrypted); $tempfile = tempnam(PROJECT_PATH . DIRECTORY_SEPARATOR . 'tmp', 'zip'); unlink($tempfile); file_put_contents($tempfile, $decrypted); $zip = new ZipArchiveModel(null, array('filename' => $tempfile)); InstanceModel::importXML($zip, 'test encryption import'); $zip->deleteZipFile(); }
public function PdfDownloadAction() { $session = new Zend_Session_Namespace('login'); $cryptoID = $this->_hasParam('cryptoID') ? $this->_getParam('cryptoID') : null; $pageHeadersAll = $this->_hasParam('pageHeader') ? $this->_getParam('pageHeader') : array(); $pageHeaders = array(); while (list($key, $val) = each($pageHeadersAll)) { if (isset($val[pdf]) && $val[pdf] == 1) { $pageHeaders[] = $key; } } if ($this->_hasParam('download') && isset($session->tempFile)) { if (isset($cryptoID) && $cryptoID != 0) { $this->view->cryptoID = $cryptoID; } $this->view->pdf = file_get_contents($session->tempFile); unlink($session->tempFile); unset($session->tempFile); } else { $instance = new InstanceModel(array('instanceID' => $session->dataInstanceID, 'depth' => 'instance')); $html = $instance->xml2html($pageHeaders); $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $pdf = $dompdf->output(); if (isset($cryptoID) && $cryptoID != 0) { $crypto = new CryptoModel(array('cryptoID' => $cryptoID)); $pdf = $crypto->encrypt($pdf); $this->view->cryptoID = $cryptoID; } $tempFile = tempnam(PROJECT_PATH . DIRECTORY_SEPARATOR . 'tmp', 'exp'); file_put_contents($tempFile, $pdf); $session->tempFile = $tempFile; } $this->view->setRenderLayout(false); }
/** * Imports a Rijndael 256 key * * @param string Name of the encryption profile * @param string Key encoded in base64 * @return CryptoModel */ public static function importRijnDael256Key($name, $key) { if (!isset(self::$cryptoTable)) { self::$cryptoTable = QFrame_Db_Table::getTable('crypto'); } $transactionNumber = self::startSerializableTransaction(); if (self::$cryptoTable->getCryptoID($name) !== NULL) { throw new Exception('Profile name already exists [' . $name . ']'); } if (strlen($key) !== 44) { throw new Exception('Key length must be 44 characters.'); } $row = self::$cryptoTable->createRow(); $row->name = $name; $row->cryptoKey = $key; $row->type = 'RIJNDAEL_256'; $row->save(); self::dbCommit($transactionNumber); return new CryptoModel(array('name' => $name)); }
public function CompletedResponsesXMLSchemaDownloadAction() { $session = new Zend_Session_Namespace('login'); $questionnaire = new QuestionnaireModel(array('questionnaireID' => $session->dataQuestionnaireID, 'depth' => 'questionnaire')); $cryptoID = $this->_hasParam('cryptoID') ? $this->_getParam('cryptoID') : null; if (isset($cryptoID) && $cryptoID != 0) { $crypto = new CryptoModel(array('cryptoID' => $cryptoID)); $this->view->xml = $crypto->encrypt($questionnaire->fetchCompletedResponseSchema()); $this->view->cryptoID = $cryptoID; } else { $this->view->xml = $questionnaire->fetchCompletedResponseSchema(); } $this->view->setRenderLayout(false); }