]> git.mxchange.org Git - hub.git/commitdiff
Swapped code, moved/renamed classes and interfaces:
authorRoland Häder <roland@mxchange.org>
Tue, 29 Mar 2011 16:31:30 +0000 (16:31 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 29 Mar 2011 16:31:30 +0000 (16:31 +0000)
- Swapped code between TestUnitSource and CryptoRandomUnitMessageHelper, the
  helper is now encapsulating and the source is now a source for the helper
- Introduced generic Helper interface to existing helper interfaces (from latest
  'core' changes)
- Renamed/moved some classes/interfaces
- TODOs.txt updated

14 files changed:
.gitattributes
application/hub/config.php
application/hub/interfaces/helper/hub/class_HelpableHub.php
application/hub/interfaces/helper/messages/.htaccess [new file with mode: 0644]
application/hub/interfaces/helper/messages/class_MessageHelper.php [new file with mode: 0644]
application/hub/interfaces/messages/class_MessageHelper.php
application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php
application/hub/main/helper/connection/udp/class_UdpConnectionHelper.php
application/hub/main/helper/messages/crypto/class_CryptoRandomMessageHelper.php
application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php [new file with mode: 0644]
application/hub/main/producer/class_BaseProducer.php
application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php
application/hub/main/source/units/class_TestUnitSource.php
docs/TODOs.txt

index 420e1e446ed8c2bf93dd965bd75529a63eb6833e..463b9931ac1a48b79f596344a55e468f41f436e6 100644 (file)
@@ -46,6 +46,8 @@ application/hub/interfaces/handler/task/class_HandleableTask.php -text svneol=un
 application/hub/interfaces/helper/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/helper/hub/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/helper/hub/class_HelpableHub.php svneol=native#text/plain
+application/hub/interfaces/helper/messages/.htaccess svneol=native#text/plain
+application/hub/interfaces/helper/messages/class_MessageHelper.php svneol=native#text/plain
 application/hub/interfaces/listener/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/listener/class_Listenable.php -text svneol=unset#text/plain
 application/hub/interfaces/lists/.htaccess -text svneol=unset#text/plain
@@ -291,6 +293,7 @@ application/hub/main/helper/messages/class_ -text
 application/hub/main/helper/messages/class_BaseMessageHelper.php svneol=native#text/plain
 application/hub/main/helper/messages/crypto/.htaccess svneol=native#text/plain
 application/hub/main/helper/messages/crypto/class_CryptoRandomMessageHelper.php svneol=native#text/plain
+application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php svneol=native#text/plain
 application/hub/main/helper/work_units/.htaccess svneol=native#text/plain
 application/hub/main/helper/work_units/class_ -text
 application/hub/main/helper/work_units/class_BaseWorkUnitHelper.php svneol=native#text/plain
index 88fefc51fc91f935db8e0f4252e0de1e2ff18c00..50351b2a32fd3c5a4e9da3ddb888586888beca27 100644 (file)
@@ -574,7 +574,7 @@ $cfg->setConfigEntry('random_secret_key_length', 8);
 $cfg->setConfigEntry('test_unit_source_class', 'TestUnitSource');
 
 // CFG: CRYPTO-RANDOM-MESSAGE-HELPER-CLASS
-$cfg->setConfigEntry('crypto_random_message_helper_class', 'CryptoRandomMessageHelper');
+$cfg->setConfigEntry('crypto_random_message_helper_class', 'CryptoRandomUnitMessageHelper');
 
 // [EOF]
 ?>
index 5ee605b3cf98daf7cb6fca49621a87e820f25c1c..4fa719ff54a9358d60b282177f9cb851fe9c1348 100644 (file)
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-interface HelpableHub extends FrameworkInterface {
+interface HelpableHub extends Helper {
        /**
         * Loads the descriptor XML file
         *
diff --git a/application/hub/interfaces/helper/messages/.htaccess b/application/hub/interfaces/helper/messages/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/helper/messages/class_MessageHelper.php b/application/hub/interfaces/helper/messages/class_MessageHelper.php
new file mode 100644 (file)
index 0000000..81057a7
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * An interface for message helper
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub 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/>.
+ */
+interface MessageHelper extends Helper {
+}
+
+// [EOF]
+?>
index 987d10dcf44a7ce003eaae21a963477b9816f148..f551ef47b7591c74e7b59193e56a1fa6505a87ab 100644 (file)
@@ -1,28 +1,3 @@
 <?php
-/**
- * An interface for message helper
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub 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/>.
- */
-interface MessageHelper extends FrameworkInterface {
-}
-
-// [EOF]
+// @DEPRECATED
 ?>
index 0a820872f3388a539d45c21599fd7a004cee068d..9d6b550150f86c4ff7b7599a51914ec03abb8809 100644 (file)
@@ -22,7 +22,7 @@
  * 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 TcpConnectionHelper extends BaseConnectionHelper {
+class TcpConnectionHelper extends BaseConnectionHelper implements Helper {
        /**
         * Protected constructor
         *
index 0e70ca2c9446dcd2feb0583c28832714ca68a9fb..01761f96a60d8e393ec2ac376b25a90bcc01f3c8 100644 (file)
@@ -22,7 +22,7 @@
  * 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 UdpConnectionHelper extends BaseConnectionHelper {
+class UdpConnectionHelper extends BaseConnectionHelper implements Helper {
        /**
         * Protected constructor
         *
index 758006d52ae6fa005bcd14570abd43b80904fbb6..f551ef47b7591c74e7b59193e56a1fa6505a87ab 100644 (file)
@@ -1,77 +1,3 @@
 <?php
-/**
- * A CryptoRandom message helper
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub 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 CryptoRandomMessageHelper extends BaseMessageHelper implements MessageHelper {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $messageInstance        An instance of a UnitHelper class
-        */
-       public final static function createCryptoRandomMessageHelper () {
-               // Get new instance
-               $messageInstance = new CryptoRandomMessageHelper();
-
-               // Create a RNG instance and set it in this class
-               $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
-               $messageInstance->setRngInstance($rngInstance);
-
-               // And also a crypto instance (for our encrypted messages)
-               $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
-               $messageInstance->setCryptoInstance($cryptoInstance);
-
-               // Return the prepared instance
-               return $messageInstance;
-       }
-
-       /**
-        * Generates an encrypted random message
-        *
-        * @return      $encryptedMessage       The encrypted random message
-        */
-       public function generateRandomMessage () {
-               // Get a very secret message by encoding and random string with BASE64
-               $secretMessage = base64_encode($this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('random_secret_message_length')));
-
-               // Get a random, secret key
-               $secretKey = $this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('random_secret_key_length'));
-
-               // Now encrypt the message with our key and a good (strong) cipher
-               $encryptedMessage = base64_encode($this->getCryptoInstance()->encryptString($secretMessage, $secretKey));
-
-               // Return it
-               return $encryptedMessage;
-       }
-}
-
-// [EOF]
+// @DEPRECATED
 ?>
diff --git a/application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php b/application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php
new file mode 100644 (file)
index 0000000..9ec203c
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * A CryptoRandom message helper
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub 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 CryptoRandomUnitMessageHelper extends BaseMessageHelper implements MessageHelper {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $sourceType                     Type of the source
+        * @return      $messageInstance        An instance of a UnitHelper class
+        */
+       public final static function createCryptoRandomUnitMessageHelper ($sourceType) {
+               // Get new instance
+               $messageInstance = new CryptoRandomUnitMessageHelper();
+
+               // Generate a source instance
+               $sourceInstance = UnitSourceFactory::createUnitSourceInstance($sourceType);
+
+               // Set the source instance
+               $messageInstance->setSourceInstance($sourceInstance);
+
+               // Return the prepared instance
+               return $messageInstance;
+       }
+
+       /**
+        * Generates an encrypted random message
+        *
+        * @return      $encryptedMessage       The encrypted random message
+        */
+       public function generateRandomMessage () {
+               // Get the message from our source
+               $encryptedMessage = $this->getSourceInstance()->generateMessageFromSource();
+
+               // Return it
+               return $encryptedMessage;
+       }
+}
+
+// [EOF]
+?>
index 81c21284a219fd63261fb1ff30445e8f01566d06..920c38b66f71b0fbad4a938fa7fba34dbdf50e00 100644 (file)
@@ -27,11 +27,6 @@ abstract class BaseProducer extends BaseFrameworkSystem {
         */
        private $outgoingQueueInstance = null;
 
-       /**
-        * Every procuded item/unit/etc. usually have a source
-        */
-       private $sourceInstance = null;
-
        /**
         * Protected constructor
         *
@@ -55,7 +50,7 @@ abstract class BaseProducer extends BaseFrameworkSystem {
         * @param       $outgoingQueueInstance  The out-going work queue instance
         * @return      void
         */
-       private function setOutgoingQueueInstance (Stackable $outgoingQueueInstance) {
+       private final function setOutgoingQueueInstance (Stackable $outgoingQueueInstance) {
                $this->outgoingQueueInstance = $outgoingQueueInstance;
        }
 
@@ -64,29 +59,10 @@ abstract class BaseProducer extends BaseFrameworkSystem {
         *
         * @param       $outgoingQueueInstance  The out-going work queue instance
         */
-       protected function getOutgoingQueueInstance () {
+       protected final function getOutgoingQueueInstance () {
                return $this->outgoingQueueInstance;
        }
 
-       /**
-        * Setter for a Sourceable instance
-        *
-        * @param       $sourceInstance The Sourceable instance
-        * @return      void
-        */
-       protected function setSourceInstance (Sourceable $sourceInstance) {
-               $this->sourceInstance = $sourceInstance;
-       }
-
-       /**
-        * Getter for a Sourceable instance
-        *
-        * @param       $sourceInstance The Sourceable instance
-        */
-       protected function getSourceInstance () {
-               return $this->sourceInstance;
-       }
-
        /**
         * Initializes this producer, this method must be overwritten.
         *
index f735b6be66e66314c536b7bbc1a637430a73a7db..0f2b55b732969ae872defde13b0c5abee8f1cd0b 100644 (file)
@@ -41,11 +41,11 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer,
                // Get new instance
                $producerInstance = new CruncherTestUnitProducer();
 
-               // Test units have a 'test' source
-               $sourceInstance = UnitSourceFactory::createUnitSourceInstance('test');
+               // Test units have a helper class that wraps the source
+               $helperInstance = ObjectFactory::createObjectByConfiguredName('crypto_random_message_helper_class', array('test'));
 
                // So set it in the producer
-               $producerInstance->setSourceInstance($sourceInstance);
+               $producerInstance->setHelperInstance($helperInstance);
 
                // Return the prepared instance
                return $producerInstance;
@@ -99,7 +99,7 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer,
                        $this->debugInstance();
                } else {
                        // Get an encrypted, random message from our source
-                       $encryptedMessage = $this->getSourceInstance()->generateMessageFromSource();
+                       $encryptedMessage = $this->getHelperInstance()->generateRandomMessage();
                        die($encryptedMessage."\n");
                }
        }
index 8aaac2f4edcd6ecc7832064b7ca628c01e9bffaf..804b06c2ea262b8a0846dcfa747717484e6c5372 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class TestUnitSource extends BaseSource implements Sourceable {
-       /**
-        * Message helper instance
-        */
-       private $messageInstance = null;
-
        /**
         * Protected constructor
         *
@@ -46,6 +41,14 @@ class TestUnitSource extends BaseSource implements Sourceable {
                // Get new instance
                $sourceInstance = new TestUnitSource();
 
+               // Create a RNG instance and set it in this class
+               $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
+               $sourceInstance->setRngInstance($rngInstance);
+
+               // And also a crypto instance (for our encrypted messages)
+               $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
+               $sourceInstance->setCryptoInstance($cryptoInstance);
+
                // Return the prepared instance
                return $sourceInstance;
        }
@@ -56,14 +59,14 @@ class TestUnitSource extends BaseSource implements Sourceable {
         * @return      $encryptedMessage       The encrypted random message
         */
        public function generateMessageFromSource () {
-               // Is the instance set?
-               if (is_null($this->messageInstance)) {
-                       // No, then create a new instance
-                       $this->messageInstance = ObjectFactory::createObjectByConfiguredName('crypto_random_message_helper_class');
-               } // END - if
+               // Get a very secret message by encoding and random string with BASE64
+               $secretMessage = base64_encode($this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('random_secret_message_length')));
+
+               // Get a random, secret key
+               $secretKey = $this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('random_secret_key_length'));
 
-               // Get the message from the message helper
-               $encryptedMessage = $this->messageInstance->generateRandomMessage();
+               // Now encrypt the message with our key and a good (strong) cipher
+               $encryptedMessage = base64_encode($this->getCryptoInstance()->encryptString($secretMessage, $secretKey));
 
                // Return it
                return $encryptedMessage;
index 9d26adc3cbd086c0569cb8a3c94f7b7b1f5fdcea..7096d7682e228ce08b63c134134dc566e0885679 100644 (file)
 ./inc/classes/exceptions/main/class_MissingMethodException.php:13: * @todo             Try to rewrite user/guest login classes and mark this exception as deprecated
 ./inc/classes/exceptions/main/class_NoConfigEntryException.php:10: * @todo             Rename this class to NoFoundEntryException
 ./inc/classes/interfaces/class_FrameworkInterface.php:11: * @todo              Find a better name for this interface
-./inc/classes/main/class_BaseFrameworkSystem.php:1168:  * @todo        Write a logging mechanism for productive mode
-./inc/classes/main/class_BaseFrameworkSystem.php:1182:                 // @TODO Finish this part!
-./inc/classes/main/class_BaseFrameworkSystem.php:159:  // @todo Try to clean these constants up
-./inc/classes/main/class_BaseFrameworkSystem.php:345:   * @todo        SearchableResult and UpdateableResult shall have a super interface to use here
+./inc/classes/main/class_BaseFrameworkSystem.php:1178:  * @todo        Write a logging mechanism for productive mode
+./inc/classes/main/class_BaseFrameworkSystem.php:1192:                 // @TODO Finish this part!
+./inc/classes/main/class_BaseFrameworkSystem.php:169:  // @todo Try to clean these constants up
+./inc/classes/main/class_BaseFrameworkSystem.php:355:   * @todo        SearchableResult and UpdateableResult shall have a super interface to use here
 ./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/selector.php:11: * @todo         We should minimize these includes
 ./index.php:59:         * @todo        This method is old code and needs heavy rewrite
 ### ### DEPRECATION FOLLOWS: ### ###
+./application/hub/interfaces/messages/class_MessageHelper.php:2:// @DEPRECATED
 ./application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php:2:// @DEPRECATED
 ./application/hub/main/database/wrapper/class_NodeListDatabaseWrapper.php:2:// @DEPRECATED
 ./application/hub/main/database/wrapper/class_PeerStateLookupDatabaseWrapper.php:2:// @DEPRECATED
 ./application/hub/main/filter/task/class_CruncherTaskHandlerInitializerFilter.php:2:// @DEPRECATED
 ./application/hub/main/filter/task/class_HubTaskHandlerInitializerFilter.php:2:// @DEPRECATED
 ./application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php:2:// @DEPRECATED
+./application/hub/main/helper/messages/crypto/class_CryptoRandomMessageHelper.php:2:// @DEPRECATED
 ./application/hub/main/nodes/class_BaseHubNode.php:50:  * @deprecated
 ./application/hub/main/template/announcement/class_AnnouncementTemplateEngine.php:2:// @DEPRECATED
 ./application/hub/main/template/connect/class_SelfConnectTemplateEngine.php:2:// @DEPRECATED
 ./inc/classes/exceptions/language/class_MissingLanguageHandlerException.php:2:// @DEPRECATED
 ./inc/classes/exceptions/main/class_ClassNotFoundException.php:2:// @DEPRECATED
 ./inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php:2:// @DEPRECATED
+./inc/classes/interfaces/helper/class_HelpableLogin.php:2:// @DEPRECATED
+./inc/classes/interfaces/helper/class_HelpableTemplate.php:2:// @DEPRECATED
 ./inc/classes.php:9: * @deprecated
 ./inc/database.php:10: * @deprecated
 ./inc/file_io.php:2:// @DEPRECATED