*/
private function generatePrivateKeyAndHash (LocalSearchCriteria $searchInstance) {
// Generate a pseudo-random string
- $randomString = $this->generateRandomString(255);
+ $randomString = $this->getCryptoInstance()->randomString(255);
// Hash and encrypt the string so we become a node id (also documented as "hub id")
$this->setPrivateKey($this->getCryptoInstance()->encryptString($randomString));
self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Re-using found node-id: ' . $this->getNodeId() . '');
} else {
// Generate a pseudo-random string
- $randomString = $this->generateRandomString(255);
+ $randomString = $this->getCryptoInstance()->randomString(255);
// Hash and encrypt the string so we become a node id (also documented as "hub id")
$this->setNodeId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString)));
$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->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR , 1);
+ $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, $this->getRequestInstance()->getRequestElement('mode'));
$searchInstance->setLimit(1);
+ // Remember it for later usage
+ $this->setSearchInstance($searchInstance);
+
// Get a random string
$randomString = $this->generateRamdomString(255);
* "tables". This allows a smooth update for the underlaying
* database table.
*/
- $this->generatePrivateKeyAndHash($searchInstance);
+ $this->generatePrivateKeyAndHash($this->getSearchInstance());
} else {
// Get the node id from result and set it
$this->setPrivateKey(base64_decode($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY)));
* Generate it in a private method (no confusion with 'private
* method access' and 'private key' here! ;-)).
*/
- $this->generatePrivateKeyAndHash($searchInstance);
+ $this->generatePrivateKeyAndHash($this->getSearchInstance());
}
}
assert($requestInstance instanceof Requestable);
// Add node number and type
- $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
- $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $requestInstance->getRequestElement('mode'));
+ $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR , 1);
+ $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, $requestInstance->getRequestElement('mode'));
// Add the node id
$criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID, $this->getNodeId());