예제 #1
0
 /**
  * Change encryption key
  *
  * @param string|null $key
  * @return null|string
  * @throws \Exception
  */
 public function changeEncryptionKey($key = null)
 {
     // prepare new key, encryptor and new configuration segment
     if (!$this->writer->checkIfWritable()) {
         throw new \Exception(__('Deployment configuration file is not writable.'));
     }
     if (null === $key) {
         $key = md5(time());
     }
     $this->encryptor->setNewKey($key);
     $encryptSegment = new ConfigData(ConfigFilePool::APP_ENV);
     $encryptSegment->set(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY, $this->encryptor->exportKeys());
     $configData = [$encryptSegment->getFileKey() => $encryptSegment->getData()];
     // update database and config.php
     $this->beginTransaction();
     try {
         $this->_reEncryptSystemConfigurationValues();
         $this->_reEncryptCreditCardNumbers();
         $this->writer->saveConfig($configData);
         $this->commit();
         return $key;
     } catch (\Exception $e) {
         $this->rollBack();
         throw $e;
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function createConfig(array $options, DeploymentConfig $deploymentConfig)
 {
     $configData = new ConfigData(ConfigFilePool::APP_ENV);
     if (isset($options[self::INPUT_KEY_BACKEND_FRONTNAME])) {
         $configData->set(self::CONFIG_PATH_BACKEND_FRONTNAME, $options[self::INPUT_KEY_BACKEND_FRONTNAME]);
     }
     return [$configData];
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function createConfig(array $options, DeploymentConfig $deploymentConfig)
 {
     $configData = new ConfigData(ConfigFilePool::APP_CONFIG);
     if (isset($options[self::INPUT_KEY_CUSTOM_OPTION])) {
         $configData->set(self::CONFIG_PATH_CUSTOM_OPTION, $options[self::INPUT_KEY_CUSTOM_OPTION]);
     } elseif ($deploymentConfig->get(self::CONFIG_PATH_CUSTOM_OPTION) === null) {
         // set to default value if it is not already set in deployment configuration
         $configData->set(self::CONFIG_PATH_CUSTOM_OPTION, 'default custom value');
     }
     return [$configData];
 }
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function createConfig(array $options, DeploymentConfig $deploymentConfig)
 {
     $configData = new ConfigData(ConfigFilePool::APP_ENV);
     if (!$deploymentConfig->get(self::CONFIG_PATH_BACKEND_FRONTNAME) && !isset($options[self::INPUT_KEY_BACKEND_FRONTNAME])) {
         $options[self::INPUT_KEY_BACKEND_FRONTNAME] = BackendFrontnameGenerator::generate();
     }
     if (isset($options[self::INPUT_KEY_BACKEND_FRONTNAME])) {
         $configData->set(self::CONFIG_PATH_BACKEND_FRONTNAME, $options[self::INPUT_KEY_BACKEND_FRONTNAME]);
     }
     return [$configData];
 }
 /**
  * Creates cache hosts config data
  *
  * @param array $data
  * @return ConfigData
  */
 public function createCacheHostsConfig(array $data)
 {
     $configData = new ConfigData(ConfigFilePool::APP_ENV);
     if (isset($data[ConfigOptionsListConstants::INPUT_KEY_CACHE_HOSTS])) {
         $hostData = explode(',', $data[ConfigOptionsListConstants::INPUT_KEY_CACHE_HOSTS]);
         $hosts = [];
         foreach ($hostData as $data) {
             $dataArray = explode(':', trim($data));
             $host = [];
             $host['host'] = $dataArray[0];
             if (isset($dataArray[1])) {
                 $host['port'] = $dataArray[1];
             }
             $hosts[] = $host;
         }
         $configData->set(ConfigOptionsListConstants::CONFIG_PATH_CACHE_HOSTS, $hosts);
     }
     return $configData;
 }
예제 #6
0
 /**
  * @param string $key
  * @param string $expectedException
  * @dataProvider setWrongKeyDataProvider
  */
 public function testSetWrongKey($key, $expectedException)
 {
     $configData = new ConfigData('testKey');
     $this->setExpectedException('InvalidArgumentException', $expectedException);
     $configData->set($key, 'value');
 }
예제 #7
0
 /**
  * Creates resource config data
  *
  * @return ConfigData
  */
 public function createResourceConfig()
 {
     $configData = new ConfigData(ConfigFilePool::APP_CONFIG);
     if ($this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_RESOURCE_DEFAULT_SETUP) === null) {
         $configData->set(ConfigOptionsList::CONFIG_PATH_RESOURCE_DEFAULT_SETUP, 'default');
     }
     return $configData;
 }
예제 #8
0
 /**
  * Writes installation date to the configuration
  *
  * @return void
  * @SuppressWarnings(PHPMD.UnusedPrivateMethod) Called by install() via callback.
  */
 private function writeInstallationDate()
 {
     $dateData = new ConfigData(ConfigFilePool::APP_ENV);
     $dateData->set(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE, date('r'));
     $configData = [$dateData->getFileKey() => $dateData->getData()];
     $this->deploymentConfigWriter->saveConfig($configData);
 }
예제 #9
0
 /**
  * Creates x-frame-options header config data
  *
  * @return ConfigData
  */
 public function createXFrameConfig()
 {
     $configData = new ConfigData(ConfigFilePool::APP_ENV);
     if ($this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT) === null) {
         $configData->set(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT, 'SAMEORIGIN');
     }
     return $configData;
 }