*/
private $nodeId = '';
+ /**
+ * Session id
+ */
+ private $sessionId = '';
+
/**
* IP/port number of bootstrapping node
*/
return $this->nodeId;
}
+ /**
+ * Setter for session id
+ *
+ * @param $sessionId Our new session id
+ * @return void
+ */
+ private final function setSessionId ($sessionId) {
+ $this->sessionId = (string) $sessionId;
+ }
+
+ /**
+ * Getter for session id
+ *
+ * @return $sessionId Our new session id
+ */
+ private final function getSessionId () {
+ return $this->sessionId;
+ }
+
/**
* Setter for query instance
*
$rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
// Generate a pseudo-random string
- $randomString = $rngInstance->randomString(255) . ':' . $this->getRequestInstance()->getRequestElement('mode');
+ $randomString = $rngInstance->randomString(255) . ':' . $this->getBootIpPort() . ':' . $this->getRequestInstance()->getRequestElement('mode');
// Get a crypto instance
$cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
}
}
+ /**
+ * Generates a session id which will be sent to the other hubs and clients
+ *
+ * @return void
+ */
+ public function bootstrapGenerateSessionId () {
+ // Get an RNG instance
+ $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
+
+ // Generate a pseudo-random string
+ $randomString = $rngInstance->randomString(255) . ':' . $this->getBootIpPort() . ':' . $this->getRequestInstance()->getRequestElement('mode');
+
+ // Get a crypto instance
+ $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
+
+ // Hash and encrypt the string so we become a "node id" aka Hub-Id
+ $this->setSessionId($cryptoInstance->hashString($cryptoInstance->encryptString($randomString)));
+
+ // Get a wrapper instance
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
+
+ // Register the node id with our wrapper
+ $wrapperInstance->registerNodeId($this, $this->getRequestInstance());
+
+ // Output message
+ $this->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . '');
+ }
+
/**
* Getter for boot IP/port combination
*
// Run a test query
$this->getQueryInstance()->doTestQuery();
+
+ // Query queue initialized
+ $this->debugOutput('BOOTSTRAP: Query queue initialized.');
}
/**