/** * Encrypts and outputs the data and ends the application flow. * Only send the response if we can encrypt it, i.e. we have an shared encryption secret with nosto. * * @param NostoExportCollectionInterface $collection the data collection to output as encrypted response. */ public function encryptOutput(NostoExportCollectionInterface $collection) { /** @var NostoAccount $account */ $account = Nosto::helper('nosto_tagging/account')->find($this->module->getContext()->language->id); if ($account && $account->isConnectedToNosto()) { $cipher_text = NostoExporter::export($account, $collection); echo $cipher_text; } // It is important to stop the script execution after the export, // in order to avoid any additional data being outputted. die; }
/** * Tests that order history data can be exported. */ public function testOrderHistoryExport() { $collection = new NostoExportOrderCollection(); $collection->append(new NostoOrder()); $cipher_text = NostoExporter::export($this->account, $collection); $this->specify('verify encrypted order export', function () use($collection, $cipher_text) { $cipher = new NostoCipher(); $cipher->setSecret('01098d0fc84ded7c'); $cipher->setIV(substr($cipher_text, 0, 16)); $plain_text = $cipher->decrypt(substr($cipher_text, 16)); $this->assertEquals($collection->getJson(), $plain_text); }); }
/** * Encrypts the export collection and outputs it to the browser. * * @param \NostoExportCollectionInterface $collection the data collection to export. * * @return Raw */ protected function export(\NostoExportCollectionInterface $collection) { /** @var Raw $result */ $result = $this->resultFactory->create(ResultFactory::TYPE_RAW); /** @var Store $store */ $store = $this->_storeManager->getStore(true); $account = $this->_accountHelper->findAccount($store); if ($account !== null) { $cipherText = \NostoExporter::export($account, $collection); $result->setContents($cipherText); } return $result; }
/** * Encrypts the export collection and outputs it to the browser. * * @param NostoExportCollectionInterface $collection the data collection to export. */ protected function export(NostoExportCollectionInterface $collection) { $account = Mage::helper('nosto_tagging/account')->find(); if ($account !== null) { $cipherText = NostoExporter::export($account, $collection); echo $cipherText; } die; }
/** * Encrypts the export collection and outputs it to the browser. * * @param NostoExportCollectionInterface $collection the data collection to export. */ protected function export(NostoExportCollectionInterface $collection) { /** @var Nosto_Tagging_Helper_Account $helper */ $helper = Mage::helper('nosto_tagging/account'); $account = $helper->find(); if ($account !== null) { $cipherText = NostoExporter::export($account, $collection); echo $cipherText; } die; }