]> git.mxchange.org Git - hub.git/commitdiff
Hub project continued: (I have now a little more time)
authorRoland Häder <roland@mxchange.org>
Sat, 7 Jul 2012 23:40:20 +0000 (23:40 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 7 Jul 2012 23:40:20 +0000 (23:40 +0000)
- Added generting of a private key and its hash. This private key will be used
  instead of the node id for encryption and decryption.
- Fixed updating node information table (a search instance is needed for
  "UPDATE")
- TODOs.txt updated

12 files changed:
application/hub/config.php
application/hub/interfaces/nodes/class_NodeHelper.php
application/hub/interfaces/wrapper/class_NodeInformationWrapper.php
application/hub/main/class_BaseHubSystem.php
application/hub/main/commands/console/class_HubConsoleMainCommand.php
application/hub/main/database/wrapper/node/class_NodeInformationDatabaseWrapper.php
application/hub/main/filter/bootstrap/node/class_NodeBootstrapGenerateNodeIdFilter.php
application/hub/main/filter/bootstrap/node/class_NodeBootstrapGeneratePrivateKeyFilter.php [new file with mode: 0644]
application/hub/main/filter/bootstrap/node/class_NodeBootstrapGenerateSessionIdFilter.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/package/class_NetworkPackage.php
docs/TODOs.txt

index ccd347cecac7355cac36ee0b777717c5d8705222..ce94011bb2a0f33984cf90d00d3ea407986cba12 100644 (file)
@@ -165,12 +165,15 @@ $cfg->setConfigEntry('node_activation_self_announcement_task_filter', 'NodeActiv
 // CFG: NODE-WELCOME-TEASER-FILTER
 $cfg->setConfigEntry('node_welcome_teaser_filter', 'NodeWelcomeTeaserFilter');
 
-// CFG: NODE-BOOTSTRAP-GENERATE-HUBID-FILTER
+// CFG: NODE-BOOTSTRAP-GENERATE-NODEID-FILTER
 $cfg->setConfigEntry('node_bootstrap_generate_nodeid_filter', 'NodeBootstrapGenerateNodeIdFilter');
 
 // CFG: NODE-BOOTSTRAP-GENERATE-SESSIONID-FILTER
 $cfg->setConfigEntry('node_bootstrap_generate_sessionid_filter', 'NodeBootstrapGenerateSessionIdFilter');
 
+// CFG: NODE-BOOTSTRAP-GENERATE-PRIVATE-KEY-FILTER
+$cfg->setConfigEntry('node_bootstrap_generate_private_key_filter', 'NodeBootstrapGeneratePrivateKeyFilter');
+
 // CFG: NODE-BOOTSTRAP-RESTORE-NODELIST-FILTER
 $cfg->setConfigEntry('node_bootstrap_restore_nodelist_filter', 'NodeBootstrapRestoreNodeListFilter');
 
@@ -601,6 +604,12 @@ $cfg->setConfigEntry('node_id', '');
 // CFG: SESSION-ID
 $cfg->setConfigEntry('session_id', '');
 
+// CFG: PRIVATE-KEY
+$cfg->setConfigEntry('private_key', '');
+
+// CFG: PRIVATE-KEY-HASH
+$cfg->setConfigEntry('private_key_hash', '');
+
 // CFG: INTERNAL-IP
 $cfg->setConfigEntry('internal_ip', ConsoleTools::acquireSelfIPAddress());
 
index d995d202ba375fd2b5a83c8db6daa3d38cd1f0e2..80addaf8144a865b3af0ef82970ee9e410cfd527 100644 (file)
@@ -82,6 +82,13 @@ interface NodeHelper extends FrameworkInterface {
         */
        function bootstrapGenerateSessionId ();
 
+       /**
+        * Generates a private key for en-/decryption
+        *
+        * @return      void
+        */
+       function bootstrapGeneratePrivateKey ();
+
        /**
         * Initializes the listener pool (class)
         *
index df6fa70606464eabec3ed8b6fa4ee5c972c8c21b..ad56069e4b99cdc0235c59c4a2fa2edf1bd7c767 100644 (file)
@@ -36,11 +36,23 @@ interface NodeInformationWrapper extends FrameworkInterface {
         * 'Registers' a new session id along with data provided in the node instance.
         * This may sound confusing but avoids double code very nicely...
         *
-        * @param       $nodeInstance           A node instance
+        * @param       $nodeInstance           An instance of a BaseHubNode class
+        * @param       $requestInstance        An instance of a Requestable class
+        * @param       $searchInstance         An instance of a LocalSearchCriteria class
+        * @return      void
+        */
+       function registerSessionId (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance);
+
+       /**
+        * 'Registers' a private key  along with data provided in the node instance.
+        * This may sound confusing but avoids double code very nicely...
+        *
+        * @param       $nodeInstance           An instance of a BaseHubNode class
         * @param       $requestInstance        An instance of a Requestable class
+        * @param       $searchInstance         An instance of a LocalSearchCriteria class
         * @return      void
         */
-       function registerSessionId (BaseHubNode $nodeInstance, Requestable $requestInstance);
+       function registerPrivateKey (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance);
 }
 
 // [EOF]
index 6a7ff2f1d85f1fb250311d7c9c449bf3488f1fd5..11155907a23fc76f31ba38eca5598fd5edf01eee 100644 (file)
@@ -214,7 +214,7 @@ class BaseHubSystem extends BaseFrameworkSystem {
        /**
         * Setter for listener pool instance
         *
-        * @param       $listenerPoolInstance   Our new listener pool instance
+        * @param       $listenerPoolInstance   The new listener pool instance
         * @return      void
         */
        protected final function setListenerPoolInstance (PoolableListener $listenerPoolInstance) {
@@ -290,7 +290,7 @@ class BaseHubSystem extends BaseFrameworkSystem {
        /**
         * Setter for node id
         *
-        * @param       $nodeId         Our new node id
+        * @param       $nodeId         The new node id
         * @return      void
         */
        protected final function setNodeId ($nodeId) {
@@ -308,10 +308,52 @@ class BaseHubSystem extends BaseFrameworkSystem {
                return $this->getConfigInstance()->getConfigEntry('node_id');
        }
 
+       /**
+        * Setter for private key
+        *
+        * @param       $privateKey             The new private key
+        * @return      void
+        */
+       protected final function setPrivateKey ($privateKey) {
+               // Set it config now
+               $this->getConfigInstance()->setConfigEntry('private_key', (string) $privateKey);
+       }
+
+       /**
+        * Getter for private key
+        *
+        * @return      $privateKey             Current private key
+        */
+       public final function getPrivateKey () {
+               // Get it from config
+               return $this->getConfigInstance()->getConfigEntry('private_key');
+       }
+
+       /**
+        * Setter for private key hash
+        *
+        * @param       $privateKeyHash         The new private key hash
+        * @return      void
+        */
+       protected final function setPrivateKeyHash ($privateKeyHash) {
+               // Set it config now
+               $this->getConfigInstance()->setConfigEntry('private_key_hash', (string) $privateKeyHash);
+       }
+
+       /**
+        * Getter for private key hash
+        *
+        * @return      $privateKeyHash         Current private key hash
+        */
+       public final function getPrivateKeyHash () {
+               // Get it from config
+               return $this->getConfigInstance()->getConfigEntry('private_key_hash');
+       }
+
        /**
         * Setter for session id
         *
-        * @param       $sessionId              Our new session id
+        * @param       $sessionId              The new session id
         * @return      void
         */
        protected final function setSessionId ($sessionId) {
index b3d9ef71fd8ffe5b1aef317dc419de0ab2823d68..ebbd0f3aefa42a32120210a1bed6cab21f1bd516 100644 (file)
@@ -122,12 +122,13 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable {
                // Add bootstrap filters
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_nodeid_filter'));
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_sessionid_filter'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_private_key_filter'));
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_restore_nodelist_filter'));
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_init_queues_filter'));
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_extra_bootstrapping_filter'));
                $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_listener_pool_filter'));
 
-               // Add hub activation filters
+               // Add node activation filters
                $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('node_activation_task_handler_initializer_filter'));
 
                // Add shutdown filters
index 86d14cece303d179f566f5c928a518fb9ec6241c..9f4ab76c6df6cd79bc34210d8503b1bdb9696cb6 100644 (file)
@@ -26,10 +26,12 @@ class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements Node
        const DB_TABLE_NODE_INFORMATION = 'node_data';
 
        // Constants for database column names
-       const DB_COLUMN_NODE_NR    = 'node_nr';
-       const DB_COLUMN_NODE_ID    = 'node_id';
-       const DB_COLUMN_SESSION_ID = 'session_id';
-       const DB_COLUMN_NODE_TYPE  = 'node_type';
+       const DB_COLUMN_NODE_NR          = 'node_nr';
+       const DB_COLUMN_NODE_ID          = 'node_id';
+       const DB_COLUMN_SESSION_ID       = 'session_id';
+       const DB_COLUMN_PRIVATE_KEY      = 'private_key';
+       const DB_COLUMN_PRIVATE_KEY_HASH = 'private_key_hash';
+       const DB_COLUMN_NODE_TYPE        = 'node_type';
 
        /**
         * Protected constructor
@@ -83,14 +85,18 @@ class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements Node
         * 'Registers' a new session id along with data provided in the node instance.
         * This may sound confusing but avoids double code very nicely...
         *
-        * @param       $nodeInstance           A node instance
+        * @param       $nodeInstance           An instance of a BaseHubNode class
         * @param       $requestInstance        An instance of a Requestable class
+        * @param       $searchInstance         An instance of a LocalSearchCriteria class
         * @return      void
         */
-       public function registerSessionId (BaseHubNode $nodeInstance, Requestable $requestInstance) {
+       public function registerSessionId (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance) {
                // Get a dataset instance
                $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION));
 
+               // Set search instance
+               $dataSetInstance->setSearchInstance($searchInstance);
+
                // Set the primary key
                $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
 
@@ -98,7 +104,33 @@ class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements Node
                $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance);
 
                // "Insert" this dataset instance completely into the database
-               $this->queryInsertDataSet($dataSetInstance);
+               $this->queryUpdateDataSet($dataSetInstance);
+       }
+
+       /**
+        * 'Registers' a private key along with data provided in the node instance.
+        * This may sound confusing but avoids double code very nicely...
+        *
+        * @param       $nodeInstance           An instance of a BaseHubNode class
+        * @param       $requestInstance        An instance of a Requestable class
+        * @param       $searchInstance         An instance of a LocalSearchCriteria class
+        * @return      void
+        */
+       public function registerPrivateKey (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance) {
+               // Get a dataset instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION));
+
+               // Set the primary key
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
+
+               // Set search instance
+               $dataSetInstance->setSearchInstance($searchInstance);
+
+               // Add registration elements to the dataset
+               $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance);
+
+               // "Insert" this dataset instance completely into the database
+               $this->queryUpdateDataSet($dataSetInstance);
        }
 }
 
index f1bbd6582cbdc134692da439cb9f055a9b842401..13cc689cb1f0fdc62b6fe0a7dabdc4bb19f99dc4 100644 (file)
@@ -57,11 +57,12 @@ class NodeBootstrapGenerateNodeIdFilter extends BaseFilter implements Filterable
                // Get node instance
                $nodeInstance = Registry::getRegistry()->getInstance('node');
 
-               // --------------------- Node-id acquirement phase ---------------------
-               // Acquire a hub-id. This step generates on first launch a new one and
-               // on any later launches it will restore the hub-id from the database.
-               // A passed 'nickname=xxx' argument will be used to add some
-               // 'personality' to the hub.
+               /*
+                * Acquire a hub-id. This step generates on first launch a new one and
+                * on any later launches it will restore the hub-id from the database.
+                * A passed 'nickname=xxx' argument will be used to add some
+                * 'personality' to the hub.
+                */
                $nodeInstance->bootstrapAcquireNodeId($requestInstance, $responseInstance);
        }
 }
diff --git a/application/hub/main/filter/bootstrap/node/class_NodeBootstrapGeneratePrivateKeyFilter.php b/application/hub/main/filter/bootstrap/node/class_NodeBootstrapGeneratePrivateKeyFilter.php
new file mode 100644 (file)
index 0000000..ffa1d3f
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+/**
+ * A GeneratePrivateKey filter for bootstrapping
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Node Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeBootstrapGeneratePrivateKeyFilter extends BaseFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function createNodeBootstrapGeneratePrivateKeyFilter () {
+               // Get a new instance
+               $filterInstance = new NodeBootstrapGeneratePrivateKeyFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               /*
+                * Generate the private key. This will be stored along with the other
+                * node data.
+                */
+               $nodeInstance->bootstrapGeneratePrivateKey();
+       }
+}
+
+// [EOF]
+?>
index 4e0d06fbe0d045d71d6e03a1a82f6df340d77565..d047ff377a90a4f7a6e18c4b42cb6d63999d86be 100644 (file)
@@ -57,9 +57,10 @@ class NodeBootstrapGenerateSessionIdFilter extends BaseFilter implements Filtera
                // Get node instance
                $nodeInstance = Registry::getRegistry()->getInstance('node');
 
-               // ------------------- More generic bootstrap steps -------------------
-               // Generate the session id which will only be stored in RAM and kept for
-               // the whole "session".
+               /*
+                * Generate the session id which will only be stored in RAM and kept for
+                * the whole "session".
+                */
                $nodeInstance->bootstrapGenerateSessionId();
        }
 }
index 821ae67dbb201128cf5cfb1732ca7c8185d43cae..6f015010cb0711f7fee23c0683cd3d93654b60c7 100644 (file)
@@ -91,6 +91,36 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                NodeStateFactory::createNodeStateInstanceByName('init', $this);
        }
 
+       /**
+        * Generates a private key and hashes it (for speeding up things)
+        *
+        * @param       $searchInstance         An instance of a LocalSearchCriteria class
+        * @return void
+        */
+       private function generatePrivateKeyAndHash (LocalSearchCriteria $searchInstance) {
+               // Get an RNG instance (Random Number Generator)
+               $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 (also documented as "hub id")
+               $this->setPrivateKey($cryptoInstance->encryptString($randomString));
+               $this->setPrivateKeyHash($cryptoInstance->hashString($this->getPrivateKey()));
+
+               // Get a wrapper instance
+               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
+
+               // Register the node id with our wrapper
+               $wrapperInstance->registerPrivateKey($this, $this->getRequestInstance(), $searchInstance);
+
+               // Output message
+               $this->debugOutput('BOOTSTRAP: Created new private key with hash: ' . $this->getPrivateKeyHash() . '');
+       }
+
        /**
         * Setter for query instance
         *
@@ -223,7 +253,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                // Now get a search criteria instance
                $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
 
-               // Search for the node number zero which is hard-coded the default
+               // 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);
@@ -268,6 +298,14 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
         * @return      void
         */
        public function bootstrapGenerateSessionId () {
+               // 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 an RNG instance
                $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
 
@@ -284,7 +322,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
 
                // Register the node id with our wrapper
-               $wrapperInstance->registerSessionId($this, $this->getRequestInstance());
+               $wrapperInstance->registerSessionId($this, $this->getRequestInstance(), $searchInstance);
 
                // Output message
                $this->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . '');
@@ -293,6 +331,56 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $this->getStateInstance()->nodeGeneratedSessionId();
        }
 
+       /**
+        * 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($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY));
+                               $this->setPrivateKeyHash($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH));
+
+                               // Output message
+                               $this->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);
+               }
+       }
+
        /**
         * Initializes queues which every node needs
         *
@@ -337,6 +425,12 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                if ($this->getSessionId() != '') {
                        $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, $this->getSessionId());
                } // END - if
+
+               // Add the private key if acquired
+               if ($this->getPrivateKey() != '') {
+                       $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY, $this->getPrivateKey());
+                       $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getPrivateKeyHash());
+               } // END - if
        }
 
        /**
index 361d9c4ea2da9e312addb903482156f03f567133..2aa55ae71b76dc0e12eee66a8a785cf9e4512eba 100644 (file)
@@ -545,7 +545,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         */
        private function generatePackageSignature ($content, $senderId) {
                // Hash content and sender id together, use md5() as last algo
-               $hash = md5($this->getCryptoInstance()->hashString($senderId . $content, $this->getNodeId(), false));
+               $hash = md5($this->getCryptoInstance()->hashString($senderId . $content, $this->getPrivateKey(), false));
 
                // Encrypt the content again with the hash as a key
                $encryptedContent = $this->getCryptoInstance()->encryptString($content, $hash);
index 33c9dc9d316953e86c5ce6a07d142355f6e04869..2e771837f6f4f41615003ddd29b8b17b60a309d8 100644 (file)
@@ -1,14 +1,14 @@
 ### WARNING: THIS FILE IS AUTO-GENERATED BY ./todo-builder.sh ###
 ### DO NOT EDIT THIS FILE. ###
-./application/hub/config.php:589:// @TODO This and the next value is very static again
-./application/hub/config.php:644:// @TODO This is very static, rewrite it to more flexible
+./application/hub/config.php:592:// @TODO This and the next value is very static again
+./application/hub/config.php:653:// @TODO This is very static, rewrite it to more flexible
 ./application/hub/interfaces/chat/class_Chatter.php:10: * @todo                We need to find a better name for this interface
 ./application/hub/interfaces/cruncher/class_CruncherHelper.php:10: * @todo             We need to find a better name for this interface
 ./application/hub/interfaces/helper/connections/class_ConnectionHelper.php:10: * @todo         Please find another name for this interface
 ./application/hub/interfaces/helper/connections/class_ConnectionHelper.php:38:  * @todo        We may want to implement a filter for ease notification of other objects like our pool
 ./application/hub/interfaces/helper/messages/class_MessageHelper.php:10: * @todo               Please find another name for this interface
 ./application/hub/interfaces/nodes/class_NodeHelper.php:10: * @todo            We need to find a better name for this interface
-./application/hub/main/class_BaseHubSystem.php:447:                            // @TODO On some systems it is 134, on some 107?
+./application/hub/main/class_BaseHubSystem.php:489:                            // @TODO On some systems it is 134, on some 107?
 ./application/hub/main/commands/console/class_HubConsoleChatCommand.php:107:    * @todo        Should we add some more filters?
 ./application/hub/main/commands/console/class_HubConsoleChatCommand.php:58:     * @todo        Try to create a ChatActivationTask or so
 ./application/hub/main/commands/console/class_HubConsoleCruncherCommand.php:107:        * @todo        Should we add some more filters?
 ./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:98:         // @TODO Implement this method
 ./application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php:177:    * @todo        Unfinished area
 ./application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php:219:    * @todo        Unfinished area
-./application/hub/main/discovery/package/class_PackageRecipientDiscovery.php:122:       * @todo        Add some validation of recipient field, e.g. ip:port is found
-./application/hub/main/discovery/package/class_PackageRecipientDiscovery.php:123:       * @todo        The if() does only check for TCP, not UDP, e.g. try to get a $handlerInstance here
+./application/hub/main/discovery/package/class_PackageRecipientDiscovery.php:134:       * @todo        Add some validation of recipient field, e.g. ip:port is found
+./application/hub/main/discovery/package/class_PackageRecipientDiscovery.php:135:       * @todo        The if() does only check for TCP, not UDP, e.g. try to get a $handlerInstance here
 ./application/hub/main/factories/socket/class_SocketFactory.php:10: * @todo            Find an interface for hub helper
 ./application/hub/main/filter/bootstrap/chat/class_ChatBootstrapGenericActivationFilter.php:54:         * @todo        Maybe we want to do somthing more here?
 ./application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php:54:    * @todo        0% done
 ./application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapGenericActivationFilter.php:54:         * @todo        Maybe we want to do somthing more here?
+./application/hub/main/filter/bootstrap/node/class_NodeBootstrapGeneratePrivateKeyFilter.php:54:        * @todo        0% done
 ./application/hub/main/filter/chains/class_PackageFilterChain.php:54:   * @todo        This may be slow if a message with a lot tags arrived
 ./application/hub/main/filter/chat/class_ChatInitializationFilter.php:54:       * @todo        0% done
 ./application/hub/main/filter/chat/class_ChatPhpRequirementsFilter.php:55:      * @todo        Add more test and try to add an extra message to the thrown exception
@@ -44,7 +45,7 @@
 ./application/hub/main/filter/shutdown/node/class_NodeShutdownDeinitQueuesFilter.php:55:        * @todo        0% done
 ./application/hub/main/filter/shutdown/node/class_NodeShutdownFlushNodeListFilter.php:55:       * @todo        0% done
 ./application/hub/main/filter/shutdown/node/class_NodeShutdownTaskHandlerFilter.php:55:         * @todo        0% done
-./application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php:90:      * @todo        Exceptions from renderXmlContent() are currently unhandled
+./application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php:91:      * @todo        Exceptions from renderXmlContent() are currently unhandled
 ./application/hub/main/filter/tags/class_PackageAnnouncementTagFilter.php:90:   * @todo        Exceptions from renderXmlContent() are currently unhandled
 ./application/hub/main/filter/tags/class_PackageSelfConnectTagFilter.php:86:    * @todo        Exceptions from renderXmlContent() are currently unhandled
 ./application/hub/main/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php:55:  * @todo        5% done
 ./application/hub/main/nodes/boot/class_HubBootNode.php:102:    * @todo        Unfinished method
 ./application/hub/main/nodes/boot/class_HubBootNode.php:122:           // @TODO Add some filters here
 ./application/hub/main/nodes/boot/class_HubBootNode.php:58:     * @todo        add some more special bootstrap things for this boot node
-./application/hub/main/nodes/class_BaseHubNode.php:349:         * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
-./application/hub/main/nodes/class_BaseHubNode.php:389:         * @todo        Change the first if() block to check for a specific state
-./application/hub/main/nodes/class_BaseHubNode.php:565:                // @TODO Add some criteria, e.g. if the node is active or so
+./application/hub/main/nodes/class_BaseHubNode.php:443:         * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
+./application/hub/main/nodes/class_BaseHubNode.php:483:         * @todo        Change the first if() block to check for a specific state
+./application/hub/main/nodes/class_BaseHubNode.php:656:                // @TODO Add some criteria, e.g. if the node is active or so
+./application/hub/main/nodes/class_BaseHubNode.php:742:         * @todo        Find more to do here
 ./application/hub/main/nodes/list/class_HubListNode.php:58:     * @todo        Implement more bootstrap steps
 ./application/hub/main/nodes/list/class_HubListNode.php:68:     * @todo        Unfinished method
 ./application/hub/main/nodes/list/class_HubListNode.php:91:            // @TODO Add some filters here
 ./application/hub/main/nodes/regular/class_HubRegularNode.php:58:       * @todo        Implement this method
 ./application/hub/main/nodes/regular/class_HubRegularNode.php:68:       * @todo        Unfinished method
 ./application/hub/main/nodes/regular/class_HubRegularNode.php:91:              // @TODO Add some filters here
-./application/hub/main/package/class_NetworkPackage.php:1078:   * @todo        Implement verification of all sent tags here?
+./application/hub/main/package/class_NetworkPackage.php:1079:   * @todo        Implement verification of all sent tags here?
 ./application/hub/main/package/class_NetworkPackage.php:23: * @todo            Needs to add functionality for handling the object's type
 ./application/hub/main/package/class_NetworkPackage.php:300:           // @TODO crc32() is very weak, but it needs to be fast
 ./application/hub/main/package/class_NetworkPackage.php:371:           // @TODO crc32() is very weak, but it needs to be fast
 ./application/hub/main/package/class_NetworkPackage.php:528:                   // @TODO We may want to do somthing more here?
 ./application/hub/main/package/class_NetworkPackage.php:566:    * @todo        Unfinished area, signatures are currently NOT fully supported
-./application/hub/main/package/class_NetworkPackage.php:675:                   // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:807:                   // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:958:    * @todo        This may be enchanced for outgoing packages?
-./application/hub/main/package/class_NetworkPackage.php:989:            * @todo Unsupported feature of "signed" messages commented out
+./application/hub/main/package/class_NetworkPackage.php:676:                   // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:808:                   // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:959:    * @todo        This may be enchanced for outgoing packages?
+./application/hub/main/package/class_NetworkPackage.php:990:            * @todo Unsupported feature of "signed" messages commented out
 ./application/hub/main/package/fragmenter/class_PackageFragmenter.php:275:      * @todo        Implement a way to send non-announcement packages with extra-salt
 ./application/hub/main/package/fragmenter/class_PackageFragmenter.php:427:      * @todo        $helperInstance is unused
 ./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:106:                       // @TODO Do something with it
 ./application/hub/main/tasks/network/class_NetworkPackageWriterTask.php:59:     * @todo        Also visit some sub-objects?
 ./application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php:10: * @todo               This template engine does not make use of setTemplateType()
 ./application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php:10: * @todo          This template engine does not make use of setTemplateType()
-./application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php:257:  * @todo        Find something useful with this!
+./application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php:258:  * @todo        Find something useful with this!
 ./application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php:10: * @todo             This template engine does not make use of setTemplateType()
 ./application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php:249:     * @todo        Find something useful with this!
 ./application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php:10: * @todo          This template engine does not make use of setTemplateType()
 ./inc/classes/main/commands/web/class_WebLoginAreaCommand.php:64:       * @todo        Add some stuff here: Some personal data, app/game related data
 ./inc/classes/main/commands/web/class_WebProblemCommand.php:58:         * @todo        0% done
 ./inc/classes/main/commands/web/class_WebStatusCommand.php:58:  * @todo        0% done
-./inc/classes/main/console/class_ConsoleTools.php:153:  * @todo        This should be moved out to an external class, e.g. HttpClient
-./inc/classes/main/console/class_ConsoleTools.php:154:  * @todo        Make IP, host name, port and script name configurable
-./inc/classes/main/console/class_ConsoleTools.php:161:         // @TODO Add some DNS caching here
+./inc/classes/main/console/class_ConsoleTools.php:219:  * @todo        This should be moved out to an external class, e.g. HttpClient
+./inc/classes/main/console/class_ConsoleTools.php:220:  * @todo        Make IP, host name, port and script name configurable
+./inc/classes/main/console/class_ConsoleTools.php:227:         // @TODO Add some DNS caching here
 ./inc/classes/main/console/class_ConsoleTools.php:45:   * @todo        We should connect this to a caching class to cache DNS requests
 ./inc/classes/main/console/class_ConsoleTools.php:58:          // @TODO Here should the cacher be implemented
 ./inc/classes/main/controller/console/class_ConsoleDefaultController.php:10: * @todo           This controller shall still provide some headlines for sidebars
 ./inc/classes/main/controller/web/class_WebStatusController.php:10: * @todo            This controller shall still provide some headlines for sidebars
 ./inc/classes/main/criteria/search/class_SearchCriteria.php:102:        * @todo        Find a nice casting here. (int) allows until and including 32766.
 ./inc/classes/main/criteria/search/class_SearchCriteria.php:70:         * @todo        Find a nice casting here. (int) allows until and including 32766.
-./inc/classes/main/database/databases/class_LocalFileDatabase.php:292:  * @todo        Do some checks on the database directory and files here
+./inc/classes/main/database/databases/class_LocalFileDatabase.php:304:  * @todo        Do some checks on the database directory and files here
 ./inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php:426:       * @todo        Find something useful with this!
 ./inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php:82:        * @todo        0% done
 ./inc/classes/main/filter/change/class_EmailChangeFilter.php:54:        * @todo        Implement email change of the user here. HINT: Use the User class!
 ./inc/classes/main/result/class_DatabaseResult.php:382:4        * @todo        Find a caching way without modifying the result array
 ./inc/classes/main/rng/class_RandomNumberGenerator.php:161:     * @todo        I had a better random number generator here but now it is somewhere lost :(
 ./inc/classes/main/rng/class_RandomNumberGenerator.php:83:      * @todo        Add site key for stronger salt!
-./inc/classes/main/template/class_BaseTemplateEngine.php:1001:  * @todo        Unfinished work or don't die here.
-./inc/classes/main/template/class_BaseTemplateEngine.php:1026:                         // @TODO Non-string found so we need some deeper analysis...
-./inc/classes/main/template/class_BaseTemplateEngine.php:1104:                 // @TODO This silent abort should be logged, maybe.
-./inc/classes/main/template/class_BaseTemplateEngine.php:1112:                 // @TODO Old behaviour, will become obsolete!
-./inc/classes/main/template/class_BaseTemplateEngine.php:1115:                 // @TODO Yet another old way
-./inc/classes/main/template/class_BaseTemplateEngine.php:1209:  * @todo        Make this code some nicer...
+./inc/classes/main/template/class_BaseTemplateEngine.php:1002:  * @todo        Unfinished work or don't die here.
+./inc/classes/main/template/class_BaseTemplateEngine.php:1027:                         // @TODO Non-string found so we need some deeper analysis...
+./inc/classes/main/template/class_BaseTemplateEngine.php:1105:                 // @TODO This silent abort should be logged, maybe.
+./inc/classes/main/template/class_BaseTemplateEngine.php:1113:                 // @TODO Old behaviour, will become obsolete!
+./inc/classes/main/template/class_BaseTemplateEngine.php:1116:                 // @TODO Yet another old way
+./inc/classes/main/template/class_BaseTemplateEngine.php:1210:  * @todo        Make this code some nicer...
 ./inc/classes/main/template/console/class_ConsoleTemplateEngine.php:10: * @todo                This template engine does not make use of setTemplateType()
 ./inc/classes/main/template/image/class_ImageTemplateEngine.php:215:    * @todo        Find something usefull with this!
 ./inc/classes/main/template/image/class_ImageTemplateEngine.php:235:    * @todo        Add cache creation here