rngInstance is now located in BaseFrameworkSystem
authorRoland Häder <roland@mxchange.org>
Fri, 7 Aug 2009 23:14:52 +0000 (23:14 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 7 Aug 2009 23:14:52 +0000 (23:14 +0000)
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/crypto/class_CryptoHelper.php
inc/classes/main/helper/captcha/class_BaseCaptcha.php
inc/classes/main/streams/class_BaseStream.php

index a3edd83f849d377d9df6466bdff450f08e594d91..16c04ed9a653dc81955ce9997c3095f809381efa 100644 (file)
@@ -73,10 +73,15 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private $controllerInstance = null;
 
         */
        private $controllerInstance = null;
 
+       /**
+        * Instance of an RNG
+        */
+       private $rngInstance = null;
+
        /**
         * The real class name
         */
        /**
         * The real class name
         */
-       private $realClass      = 'FrameworkSystem';
+       private $realClass      = 'BaseFrameworkSystem';
 
        /**
         * Thousands seperator
 
        /**
         * Thousands seperator
@@ -1140,6 +1145,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Return result
                return $isLoaded;
        }
                // Return result
                return $isLoaded;
        }
+
+       /**
+        * Setter for RNG instance
+        *
+        * @param       $rngInstance    An instance of a random number generator (RNG)
+        * @return      void
+        */
+       protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
+               $this->rngInstance = $rngInstance;
+       }
+
+       /**
+        * Getter for RNG instance
+        *
+        * @return      $rngInstance    An instance of a random number generator (RNG)
+        */
+       public final function getRngInstance () {
+               return $this->rngInstance;
+       }
 }
 
 // [EOF]
 }
 
 // [EOF]
index 2335f5dc5a534855c556de2034d315fe8b2c1206..c135b18971cdf4bb0f75d154d24d5c212765b678 100644 (file)
@@ -105,7 +105,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
                // Do we have mcrypt loaded?
                if ($this->isPhpExtensionLoaded('mcrypt')) {
                        // Then use it
                // Do we have mcrypt loaded?
                if ($this->isPhpExtensionLoaded('mcrypt')) {
                        // Then use it
-                       $this->cryptoStreamInstance = ObjectFactory::createObjectByName('McryptStream', array($this->rngInstance()));
+                       $this->cryptoStreamInstance = ObjectFactory::createObjectByName('McryptStream', array($this->getRngInstance()));
                } else {
                        // If nothing works ...
                        $this->cryptoStreamInstance = ObjectFactory::createObjectByName('NullCryptoStream');
                } else {
                        // If nothing works ...
                        $this->cryptoStreamInstance = ObjectFactory::createObjectByName('NullCryptoStream');
@@ -119,7 +119,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         */
        protected function initHasher () {
                // Initialize the random number generator which is required by some crypto methods
         */
        protected function initHasher () {
                // Initialize the random number generator which is required by some crypto methods
-               $this->rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
+               $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class'));
 
                // Generate a salt for the hasher
                $this->generateSalt();
 
                // Generate a salt for the hasher
                $this->generateSalt();
@@ -132,7 +132,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         */
        private function generateSalt () {
                // Get a random string from the RNG
         */
        private function generateSalt () {
                // Get a random string from the RNG
-               $randomString = $this->rngInstance->randomString();
+               $randomString = $this->getRngInstance()->randomString();
 
                // Get config entry for salt length
                $length = $this->getConfigInstance()->getConfigEntry('salt_length');
 
                // Get config entry for salt length
                $length = $this->getConfigInstance()->getConfigEntry('salt_length');
@@ -171,7 +171,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
                //* DEBUG: */ echo "salt=".$salt."/plain=".$str."<br />\n";
                $hashed = $salt . md5(sprintf($this->getConfigInstance()->getConfigEntry('hash_mask'),
                        $salt,
                //* DEBUG: */ echo "salt=".$salt."/plain=".$str."<br />\n";
                $hashed = $salt . md5(sprintf($this->getConfigInstance()->getConfigEntry('hash_mask'),
                        $salt,
-                       $this->rngInstance->getFixedSalt(),
+                       $this->getRngInstance()->getFixedSalt(),
                        $str
                ));
 
                        $str
                ));
 
index 9cef2076fb7cebc05b757fe2597198c94a4403f7..e619058853a594d28fbde4821afffb8a065d880a 100644 (file)
@@ -27,11 +27,6 @@ class BaseCaptcha extends BaseHelper {
         */
        private $helperInstance = null;
 
         */
        private $helperInstance = null;
 
-       /**
-        * Instance of an RNG
-        */
-       private $rngInstance = null;
-
        /**
         * Protected constructor
         *
        /**
         * Protected constructor
         *
@@ -51,16 +46,7 @@ class BaseCaptcha extends BaseHelper {
         */
        protected final function initializeRandomNumberGenerator (FrameworkInterface $extraInstance = null) {
                // Get an RNG from factory
         */
        protected final function initializeRandomNumberGenerator (FrameworkInterface $extraInstance = null) {
                // Get an RNG from factory
-               $this->rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class', array($extraInstance));
-       }
-
-       /**
-        * Getter for RNG instance
-        *
-        * @return      $rngInstance    An instance of a random number generator (RNG)
-        */
-       public final function getRngInstance () {
-               return $this->rngInstance;
+               $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', array($extraInstance)));
        }
 
        /**
        }
 
        /**
index 728e6c3e4c4c72a6fbe789ccc4f10fdad458281d..e226545a11863b7596788345d1b1c0ea5d064e2e 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseStream extends BaseFrameworkSystem {
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseStream extends BaseFrameworkSystem {
-       /**
-        * Random number generator instance (RNG)
-        */
-       private $rngInstance = null;
-
        /**
         * Protected constructor
         *
        /**
         * Protected constructor
         *
@@ -41,25 +36,6 @@ class BaseStream extends BaseFrameworkSystem {
                $this->removeNumberFormaters();
                $this->removeSystemArray();
        }
                $this->removeNumberFormaters();
                $this->removeSystemArray();
        }
-
-       /**
-        * Setter for RNG instance
-        *
-        * @param       $rngInstance    An RNG instance
-        * @return      void
-        */
-       protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
-               $this->rngInstance = $rngInstance;
-       }
-
-       /**
-        * Getter for RNG instance
-        *
-        * @return      $rngInstance    An RNG instance
-        */
-       protected final function getRngInstance () {
-               return $this->rngInstance;
-       }
 }
 
 // [EOF]
 }
 
 // [EOF]