Пример #1
0
 /**
  * Returns a unique ID that identifies this Magento installation.
  * This ID is sent to the Nosto account config iframe and used to link all
  * Nosto accounts used on this installation.
  *
  * @return string the ID.
  */
 public function getInstallationId()
 {
     $installationId = Mage::getStoreConfig(self::XML_PATH_INSTALLATION_ID);
     if (empty($installationId)) {
         // Running bin2hex() will make the ID string length 64 characters.
         $installationId = bin2hex(NostoCryptRandom::getRandomString(32));
         /** @var Mage_Core_Model_Config $config */
         $config = Mage::getModel('core/config');
         $config->saveConfig(self::XML_PATH_INSTALLATION_ID, $installationId, 'default', 0);
         Mage::app()->getCacheInstance()->cleanType('config');
     }
     return $installationId;
 }
Пример #2
0
 /**
  * Encrypts and returns the data.
  *
  * @param NostoAccountInterface $account the account to export the data for.
  * @param NostoExportCollectionInterface $collection the data collection to export.
  * @return string the encrypted data.
  */
 public static function export(NostoAccountInterface $account, NostoExportCollectionInterface $collection)
 {
     $data = '';
     // Use the first 16 chars of the SSO token as secret for encryption.
     $token = $account->getApiToken('sso');
     if (!empty($token)) {
         $tokenValue = $token->getValue();
         $secret = substr($tokenValue, 0, 16);
         if (!empty($secret)) {
             $iv = NostoCryptRandom::getRandomString(16);
             $cipher = new NostoCipher();
             $cipher->setSecret($secret);
             $cipher->setIV($iv);
             $cipherText = $cipher->encrypt($collection->getJson());
             // Prepend the IV to the cipher string so that nosto can parse and use it.
             // There is no security concern with sending the IV as plain text.
             $data = $iv . $cipherText;
         }
     }
     return $data;
 }
Пример #3
0
 /**
  * Returns a unique ID that identifies this Magento installation.
  * This ID is sent to the Nosto account config iframe and used to link all
  * Nosto accounts used on this installation.
  *
  * @return string the ID.
  */
 public function getInstallationId()
 {
     $installationId = Mage::getStoreConfig(self::XML_PATH_INSTALLATION_ID);
     if (empty($installationId)) {
         // Running bin2hex() will make the ID string length 64 characters.
         $installationId = bin2hex(NostoCryptRandom::getRandomString(32));
         /** @var Mage_Core_Model_Config $config */
         $config = Mage::getModel('core/config');
         $config->saveConfig(self::XML_PATH_INSTALLATION_ID, $installationId, 'default', 0);
         /** @var Nosto_Tagging_Helper_Cache $helper */
         $helper = Mage::helper('nosto_tagging/cache');
         $helper->flushConfigCache();
     }
     return $installationId;
 }