+ /**
+ * Generate a private key for en-/decryption
+ *
+ * @return void
+ */
+ public function bootstrapGeneratePrivateKey () {
+ // Get a wrapper instance
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
+
+ // Now get a search criteria instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Search for the node number one which is hard-coded the default
+ $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
+ $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->getRequestInstance()->getRequestElement('mode'));
+ $searchInstance->setLimit(1);
+
+ // Get a result back
+ $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
+
+ // Is it valid?
+ if ($resultInstance->next()) {
+ // Save the result instance in this class
+ $this->setResultInstance($resultInstance);
+
+ // Is the element set?
+ if (is_null($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY))) {
+ /*
+ * Auto-generate the private key for e.g. out-dated database
+ * "tables". This allows a smooth update for the underlaying
+ * database table.
+ */
+ $this->generatePrivateKeyAndHash($searchInstance);
+ } else {
+ // Get the node id from result and set it
+ $this->setPrivateKey(base64_decode($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY)));
+ $this->setPrivateKeyHash($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH));
+
+ // Output message
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Re-using found private key hash: ' . $this->getPrivateKeyHash() . '');
+ }
+ } else {
+ /*
+ * Generate it in a private method (no confusion with 'private
+ * method access' and 'private key' here! ;-)).
+ */
+ $this->generatePrivateKeyAndHash($searchInstance);
+ }
+ }
+