From d03c28275d1c9bfeb86e504acdd9c0fc69105bee Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 29 Mar 2011 15:55:38 +0000 Subject: [PATCH] Added more classes (source for anything 'sourced', etc): - Added some (partly unused) more classes for creating test units - CryptoRandomMessageHelper is currently unused - Added factory to create unit source classes - TODOs.txt updated --- .gitattributes | 17 ++++ application/hub/config.php | 7 +- application/hub/interfaces/messages/.htaccess | 1 + .../messages/class_MessageHelper.php | 28 +++++++ application/hub/interfaces/source/.htaccess | 1 + .../interfaces/source/class_Sourceable.php | 34 ++++++++ .../hub/main/factories/source/.htaccess | 1 + .../hub/main/factories/source/units/.htaccess | 1 + .../source/units/class_UnitSourceFactory.php | 62 +++++++++++++++ .../hub/main/helper/messages/.htaccess | 1 + application/hub/main/helper/messages/class_ | 50 ++++++++++++ .../messages/class_BaseMessageHelper.php | 38 +++++++++ .../hub/main/helper/messages/crypto/.htaccess | 1 + .../class_CryptoRandomMessageHelper.php | 50 ++++++++++++ .../hub/main/producer/class_BaseProducer.php | 28 ++++++- .../class_CruncherTestUnitProducer.php | 25 +++--- application/hub/main/source/.htaccess | 1 + application/hub/main/source/class_ | 60 +++++++++++++++ .../hub/main/source/class_BaseSource.php | 38 +++++++++ application/hub/main/source/units/.htaccess | 1 + .../source/units/class_TestUnitSource.php | 77 +++++++++++++++++++ docs/TODOs.txt | 19 +++-- 22 files changed, 513 insertions(+), 28 deletions(-) create mode 100644 application/hub/interfaces/messages/.htaccess create mode 100644 application/hub/interfaces/messages/class_MessageHelper.php create mode 100644 application/hub/interfaces/source/.htaccess create mode 100644 application/hub/interfaces/source/class_Sourceable.php create mode 100644 application/hub/main/factories/source/.htaccess create mode 100644 application/hub/main/factories/source/units/.htaccess create mode 100644 application/hub/main/factories/source/units/class_UnitSourceFactory.php create mode 100644 application/hub/main/helper/messages/.htaccess create mode 100644 application/hub/main/helper/messages/class_ create mode 100644 application/hub/main/helper/messages/class_BaseMessageHelper.php create mode 100644 application/hub/main/helper/messages/crypto/.htaccess create mode 100644 application/hub/main/helper/messages/crypto/class_CryptoRandomMessageHelper.php create mode 100644 application/hub/main/source/.htaccess create mode 100644 application/hub/main/source/class_ create mode 100644 application/hub/main/source/class_BaseSource.php create mode 100644 application/hub/main/source/units/.htaccess create mode 100644 application/hub/main/source/units/class_TestUnitSource.php diff --git a/.gitattributes b/.gitattributes index aff797b2c..420e1e446 100644 --- a/.gitattributes +++ b/.gitattributes @@ -54,6 +54,8 @@ application/hub/interfaces/lookup/.htaccess -text svneol=unset#text/plain application/hub/interfaces/lookup/class_Lookupable.php svneol=native#text/plain application/hub/interfaces/lookup/peer_states/.htaccess -text svneol=unset#text/plain application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php -text svneol=unset#text/plain +application/hub/interfaces/messages/.htaccess svneol=native#text/plain +application/hub/interfaces/messages/class_MessageHelper.php svneol=native#text/plain application/hub/interfaces/nodes/.htaccess -text svneol=unset#text/plain application/hub/interfaces/nodes/class_NodeHelper.php -text svneol=unset#text/plain application/hub/interfaces/package/.htaccess -text svneol=unset#text/plain @@ -78,6 +80,8 @@ application/hub/interfaces/queues/.htaccess -text svneol=unset#text/plain application/hub/interfaces/queues/class_Queueable.php -text svneol=unset#text/plain application/hub/interfaces/socket/.htaccess -text svneol=unset#text/plain application/hub/interfaces/socket/class_SocketTag.php svneol=native#text/plain +application/hub/interfaces/source/.htaccess svneol=native#text/plain +application/hub/interfaces/source/class_Sourceable.php svneol=native#text/plain application/hub/interfaces/states/.htaccess -text svneol=unset#text/plain application/hub/interfaces/states/class_ -text svneol=unset#text/plain application/hub/interfaces/states/class_Stateable.php -text svneol=unset#text/plain @@ -178,6 +182,9 @@ application/hub/main/factories/package/.htaccess -text svneol=unset#text/plain application/hub/main/factories/package/class_NetworkPackageFactory.php svneol=native#text/plain application/hub/main/factories/socket/.htaccess -text svneol=unset#text/plain application/hub/main/factories/socket/class_SocketFactory.php svneol=native#text/plain +application/hub/main/factories/source/.htaccess svneol=native#text/plain +application/hub/main/factories/source/units/.htaccess svneol=native#text/plain +application/hub/main/factories/source/units/class_UnitSourceFactory.php svneol=native#text/plain application/hub/main/factories/states/.htaccess -text svneol=unset#text/plain application/hub/main/factories/states/class_StateFactory.php -text svneol=unset#text/plain application/hub/main/factories/states/peer/.htaccess -text svneol=unset#text/plain @@ -279,6 +286,11 @@ application/hub/main/helper/hub/class_ -text svneol=unset#text/plain application/hub/main/helper/hub/class_BaseHubHelper.php -text svneol=unset#text/plain application/hub/main/helper/hub/connection/.htaccess -text svneol=unset#text/plain application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php svneol=native#text/plain +application/hub/main/helper/messages/.htaccess svneol=native#text/plain +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/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 @@ -394,6 +406,11 @@ application/hub/main/resolver/state/.htaccess -text svneol=unset#text/plain application/hub/main/resolver/state/class_BaseStateResolver.php -text svneol=unset#text/plain application/hub/main/resolver/state/network/.htaccess -text svneol=unset#text/plain application/hub/main/resolver/state/network/class_NetworkStateResolver.php -text svneol=unset#text/plain +application/hub/main/source/.htaccess svneol=native#text/plain +application/hub/main/source/class_ -text +application/hub/main/source/class_BaseSource.php svneol=native#text/plain +application/hub/main/source/units/.htaccess svneol=native#text/plain +application/hub/main/source/units/class_TestUnitSource.php svneol=native#text/plain application/hub/main/states/.htaccess -text svneol=unset#text/plain application/hub/main/states/class_ -text svneol=unset#text/plain application/hub/main/states/class_BaseState.php -text svneol=unset#text/plain diff --git a/application/hub/config.php b/application/hub/config.php index 198cf29ef..3377f8b2b 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -565,10 +565,13 @@ $cfg->setConfigEntry('cruncher_test_unit_max_count', 1000); $cfg->setConfigEntry('cruncher_unit_db_wrapper_class', 'CruncherUnitDatabaseWrapper'); // CFG: CRUNCHER-RANDOM-SECRET-MESSAGE-LENGTH -$cfg->setConfigEntry('cruncher_random_secret_message_length', 100); +$cfg->setConfigEntry('random_secret_message_length', 100); // CFG: CRUNCHER-RANDOM-SECRET-KEY-LENGTH -$cfg->setConfigEntry('cruncher_random_secret_key_length', 8); +$cfg->setConfigEntry('random_secret_key_length', 8); + +// CFG: TEST-UNIT-SOURCE-CLASS +$cfg->setConfigEntry('test_unit_source_class', 'TestUnitSource'); // [EOF] ?> diff --git a/application/hub/interfaces/messages/.htaccess b/application/hub/interfaces/messages/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/messages/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/messages/class_MessageHelper.php b/application/hub/interfaces/messages/class_MessageHelper.php new file mode 100644 index 000000000..987d10dcf --- /dev/null +++ b/application/hub/interfaces/messages/class_MessageHelper.php @@ -0,0 +1,28 @@ + + * @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 . + */ +interface MessageHelper extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/application/hub/interfaces/source/.htaccess b/application/hub/interfaces/source/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/source/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/source/class_Sourceable.php b/application/hub/interfaces/source/class_Sourceable.php new file mode 100644 index 000000000..53acfd513 --- /dev/null +++ b/application/hub/interfaces/source/class_Sourceable.php @@ -0,0 +1,34 @@ + + * @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 . + */ +interface Sourceable extends FrameworkInterface { + /** + * "Getter" or generator for a message + * + * @return $message A message from our source + */ + function generateMessageFromSource (); +} + +// [EOF] +?> diff --git a/application/hub/main/factories/source/.htaccess b/application/hub/main/factories/source/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/factories/source/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/factories/source/units/.htaccess b/application/hub/main/factories/source/units/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/factories/source/units/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/factories/source/units/class_UnitSourceFactory.php b/application/hub/main/factories/source/units/class_UnitSourceFactory.php new file mode 100644 index 000000000..6c9ded734 --- /dev/null +++ b/application/hub/main/factories/source/units/class_UnitSourceFactory.php @@ -0,0 +1,62 @@ + + * @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 . + */ +class UnitSourceFactory extends ObjectFactory { + /** + * Source instances + */ + private static $sourceInstances = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of a configurable and singleton unit source + * + * @param $unitType Type of the unit source + * @return $sourceInstance A Sourceable class instance + */ + public static final function createUnitSourceInstance ($unitType) { + // Do we have cache? + if (!isset(self::$sourceInstances[$unitType])) { + // Then construct the class' configuraton entry + $className = '' . $unitType . '_unit_source_class'; + + // Get a class from that configuration entry + self::$sourceInstances[$unitType] = self::createObjectByConfiguredName($className); + } // END - if + + // For any purposes, return the source instance + return self::$sourceInstances[$unitType]; + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/messages/.htaccess b/application/hub/main/helper/messages/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/messages/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/messages/class_ b/application/hub/main/helper/messages/class_ new file mode 100644 index 000000000..ef16279e9 --- /dev/null +++ b/application/hub/main/helper/messages/class_ @@ -0,0 +1,50 @@ + + * @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 . + */ +class ???MessageHelper 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 create???MessageHelper () { + // Get new instance + $messageInstance = new ???MessageHelper(); + + // Return the prepared instance + return $messageInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/messages/class_BaseMessageHelper.php b/application/hub/main/helper/messages/class_BaseMessageHelper.php new file mode 100644 index 000000000..8d1b57921 --- /dev/null +++ b/application/hub/main/helper/messages/class_BaseMessageHelper.php @@ -0,0 +1,38 @@ + + * @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 . + */ +abstract class BaseMessageHelper extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/messages/crypto/.htaccess b/application/hub/main/helper/messages/crypto/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/messages/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/messages/crypto/class_CryptoRandomMessageHelper.php b/application/hub/main/helper/messages/crypto/class_CryptoRandomMessageHelper.php new file mode 100644 index 000000000..ac725f662 --- /dev/null +++ b/application/hub/main/helper/messages/crypto/class_CryptoRandomMessageHelper.php @@ -0,0 +1,50 @@ + + * @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 . + */ +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(); + + // Return the prepared instance + return $messageInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/producer/class_BaseProducer.php b/application/hub/main/producer/class_BaseProducer.php index 2b20adeea..81c21284a 100644 --- a/application/hub/main/producer/class_BaseProducer.php +++ b/application/hub/main/producer/class_BaseProducer.php @@ -27,6 +27,11 @@ abstract class BaseProducer extends BaseFrameworkSystem { */ private $outgoingQueueInstance = null; + /** + * Every procuded item/unit/etc. usually have a source + */ + private $sourceInstance = null; + /** * Protected constructor * @@ -45,7 +50,7 @@ abstract class BaseProducer extends BaseFrameworkSystem { } /** - * Setter for out-going work queue + * Setter for out-going work queue * * @param $outgoingQueueInstance The out-going work queue instance * @return void @@ -55,7 +60,7 @@ abstract class BaseProducer extends BaseFrameworkSystem { } /** - * Getter for out-going work queue + * Getter for out-going work queue * * @param $outgoingQueueInstance The out-going work queue instance */ @@ -63,6 +68,25 @@ abstract class BaseProducer extends BaseFrameworkSystem { 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. * diff --git a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php index efd3109ce..02d7052ef 100644 --- a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php +++ b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php @@ -41,6 +41,12 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer, // Get new instance $producerInstance = new CruncherTestUnitProducer(); + // Test units have a 'test' source + $sourceInstance = UnitSourceFactory::createUnitSourceInstance('test'); + + // So set it in the producer + $producerInstance->setSourceInstance($sourceInstance); + // Return the prepared instance return $producerInstance; } @@ -79,7 +85,7 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer, $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); // Add criteria for looking up already created and available test units - $searchInstance->addCriteria(CruncherUnitDatabaseWrapper::DB_COLUMN_UNIT_TYPE, BaseUnitProducer::UNIT_TYPE_TEST_UNIT); + $searchInstance->addCriteria(CruncherUnitDatabaseWrapper::DB_COLUMN_UNIT_TYPE , BaseUnitProducer::UNIT_TYPE_TEST_UNIT); $searchInstance->addCriteria(CruncherUnitDatabaseWrapper::DB_COLUMN_UNIT_STATUS, BaseUnitProducer::UNIT_STATUS_AVAILABLE); $searchInstance->setLimit($this->getConfigInstance()->getConfigEntry('cruncher_test_unit_max_count')); @@ -92,21 +98,8 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer, // @TODO Unfinished work here $this->debugInstance(); } else { - // No entries found, so generate some. First we need a very secret message (a random string) ... - $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); - $secretMessage = base64_encode($rngInstance->randomString($this->getConfigInstance()->getConfigEntry('cruncher_random_secret_message_length'))); - - // Second, we need a secret key - $secretKey = $rngInstance->randomString($this->getConfigInstance()->getConfigEntry('cruncher_random_secret_key_length')); - - // Now encrypt the message with our key and a good (strong) cipher - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); - $encryptedMessage = base64_encode($cryptoInstance->encryptString($secretMessage, $secretKey)); - - // Make sure the secret key and message are removed from memory - unset($secretKey); - unset($secretMessage); - die($encryptedMessage); + // Get an encrypted, random message from our source + $encryptedMessage = $this->getSourceInstance()->generateMessageFromSource(); } } } diff --git a/application/hub/main/source/.htaccess b/application/hub/main/source/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/source/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/source/class_ b/application/hub/main/source/class_ new file mode 100644 index 000000000..eac4b8ccb --- /dev/null +++ b/application/hub/main/source/class_ @@ -0,0 +1,60 @@ + + * @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 . + */ +class ???Source extends BaseSource implements Sourceable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $sourceInstance An instance of a Sourceable class + */ + public final static function create???Source () { + // Get new instance + $sourceInstance = new ???Source(); + + // Return the prepared instance + return $sourceInstance; + } + + /** + * "Getter" or generator for a message + * + * @return $message A message from our source + * @todo 0% done + */ + public function generateMessageFromSource () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/main/source/class_BaseSource.php b/application/hub/main/source/class_BaseSource.php new file mode 100644 index 000000000..e48c542a2 --- /dev/null +++ b/application/hub/main/source/class_BaseSource.php @@ -0,0 +1,38 @@ + + * @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 . + */ +class BaseSource extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/main/source/units/.htaccess b/application/hub/main/source/units/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/source/units/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/source/units/class_TestUnitSource.php b/application/hub/main/source/units/class_TestUnitSource.php new file mode 100644 index 000000000..5a6f1886d --- /dev/null +++ b/application/hub/main/source/units/class_TestUnitSource.php @@ -0,0 +1,77 @@ + + * @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 . + */ +class TestUnitSource extends BaseSource implements Sourceable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $sourceInstance An instance of a Sourceable class + */ + public final static function createTestUnitSource () { + // Get new instance + $sourceInstance = new TestUnitSource(); + + // Create a RNG instance and set it in this source + $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; + } + + /** + * Generates an encrypted random message + * + * @return $encryptedMessage The encrypted random message + */ + public function generateMessageFromSource () { + // 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] +?> diff --git a/docs/TODOs.txt b/docs/TODOs.txt index d7f5b79bb..9d26adc3c 100644 --- a/docs/TODOs.txt +++ b/docs/TODOs.txt @@ -70,7 +70,8 @@ ./application/hub/main/package/class_NetworkPackage.php:383: // @TODO Add some logging here ./application/hub/main/package/class_NetworkPackage.php:409: // @TODO Add some logging here ./application/hub/main/pools/peer/class_DefaultPeerPool.php:148: // @TODO Check for IP -./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:72: * @todo 0% done +./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:78: * @todo ~30% done +./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:98: // @TODO Unfinished work here ./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:68: * @todo ~30% done ./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:80: // @TODO On some systems it is 134, on some 107? ./application/hub/main/tasks/cruncher/class_CruncherTestUnitProducerTask.php:53: * @todo Maybe visit some sub-objects @@ -87,7 +88,7 @@ ./application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php:251: * @todo Find something useful with this! ./application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php:324: * @todo Handle $objectCount ./application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php:10: * @todo This template engine does not make use of setTemplateType() -./application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php:391: * @todo Handle $keyCount +./application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php:433: * @todo Handle $keyCount ./application/hub/main/tools/class_HubTools.php:128: // @TODO We may want to encapsulate this PHP call into an own class ./application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php:105: * @todo Does a query needs to perform some actions as an active task? ./application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php:116: * @todo Does a queue needs to perform some actions as an active task? @@ -96,11 +97,10 @@ ./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:1133: * @todo Write a logging mechanism for productive mode -./inc/classes/main/class_BaseFrameworkSystem.php:1147: // @TODO Finish this part! -./inc/classes/main/class_BaseFrameworkSystem.php:154: // @todo Try to clean these constants up -./inc/classes/main/class_BaseFrameworkSystem.php:233: * @todo This is old code. Do we still need this old lost code? -./inc/classes/main/class_BaseFrameworkSystem.php:301: * @todo SearchableResult and UpdateableResult shall have a super interface to use here +./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/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 @@ -166,7 +166,7 @@ ./inc/classes/main/response/image/class_ImageResponse.php:91: * @todo this will send only one cookie out, the first one. ./inc/classes/main/result/class_DatabaseResult.php:226: * @todo 0% done ./inc/classes/main/result/class_DatabaseResult.php:379:4 * @todo Find a caching way without modifying the result array -./inc/classes/main/rng/class_RandomNumberGenerator.php:150: * @todo I had a better random number generator here but now it is somewhere lost :( +./inc/classes/main/rng/class_RandomNumberGenerator.php:152: * @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:1055: // @TODO This silent abort should be logged, maybe. ./inc/classes/main/template/class_BaseTemplateEngine.php:1063: // @TODO Old behaviour, will become obsolete! @@ -201,6 +201,9 @@ ./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/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/activation/class_HubActivationSelfAnnouncementFilter.php:2:// @DEPRECATED ./application/hub/main/filter/bootstrap/class_HubBootstrapAquireHubIdFilter.php:2:// @DEPRECATED ./application/hub/main/filter/bootstrap/class_HubBootstrapExtraBootstrappingFilter.php:2:// @DEPRECATED -- 2.39.5