From: Roland Häder Date: Sun, 26 Feb 2023 09:17:50 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=d319dc01ba1f01a619180cc539e80d45be0bc346 Continued: - invoke CryptoHelper::getSelfInstance() rather than creating new instances over ObjectFactory - this also removed the overhead of initialization --- diff --git a/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php b/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php index ebb2c5d3..9d4a57d4 100644 --- a/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php +++ b/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php @@ -10,6 +10,7 @@ use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; +use Org\Mxchange\CoreFramework\Helper\Crypto\CryptoHelper; use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; @@ -86,7 +87,7 @@ class HtmlResendLinkCommand extends BaseCommand implements Commandable { $randomString = $rngInstance->randomString(255); // Get a crypto instance - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + $cryptoInstance = CryptoHelper::getSelfInstance(); // Hash and encrypt the string $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString)); diff --git a/framework/main/classes/filter/crypto/class_CaptchaEncryptFilter.php b/framework/main/classes/filter/crypto/class_CaptchaEncryptFilter.php index 97a1f11a..aaab8dff 100644 --- a/framework/main/classes/filter/crypto/class_CaptchaEncryptFilter.php +++ b/framework/main/classes/filter/crypto/class_CaptchaEncryptFilter.php @@ -82,7 +82,7 @@ class CaptchaEncryptFilter extends BaseFilter implements Filterable { $encryptDecoded = base64_decode(str_replace(' ', '+', urldecode($encryptRequest))); // Get a crypto helper and decrypt the string - $decryptedString = ObjectFactory::createObjectByConfiguredName('crypto_class')->decryptString($encryptDecoded); + $decryptedString = CryptoHelper::getSelfInstance()->decryptString($encryptDecoded); // Is it the expected length? if (strlen($decryptedString) != FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('captcha_string_length')) { diff --git a/framework/main/classes/filter/verifier/class_AccountPasswordVerifierFilter.php b/framework/main/classes/filter/verifier/class_AccountPasswordVerifierFilter.php index 6369652f..0d8dfbd5 100644 --- a/framework/main/classes/filter/verifier/class_AccountPasswordVerifierFilter.php +++ b/framework/main/classes/filter/verifier/class_AccountPasswordVerifierFilter.php @@ -7,6 +7,7 @@ use Org\Mxchange\CoreFramework\Filter\BaseFilter; use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException; use Org\Mxchange\CoreFramework\Filter\Filterable; use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Crypto\CryptoHelper; use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Response\Responseable; @@ -109,7 +110,7 @@ class AccountPasswordVerifierFilter extends BaseFilter implements Filterable { $currentHash = $userInstance->getField('pass_hash'); // Get an encryption helper and encrypt the password - $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $currentHash); + $passHash = CryptoHelper::getSelfInstance()->hashString($password, $currentHash); // Does it match? if ($currentHash != $passHash) { diff --git a/framework/main/classes/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php b/framework/main/classes/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php index 2d8c77ee..30936927 100644 --- a/framework/main/classes/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php +++ b/framework/main/classes/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php @@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; use Org\Mxchange\CoreFramework\Filter\BaseFilter; use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException; use Org\Mxchange\CoreFramework\Filter\Filterable; +use Org\Mxchange\CoreFramework\Helper\Crypto\CryptoHelper; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Response\Responseable; @@ -136,7 +137,7 @@ class GraphicalCodeCaptchaVerifierFilter extends BaseFilter implements Filterabl } // Now, both are set hash the given one. First get a crypto instance - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + $cryptoInstance = CryptoHelper::getSelfInstance(); // Then hash the code $hashedCode = $cryptoInstance->hashString($captchaCode, $captchaHash); diff --git a/framework/main/classes/helper/captcha/web/class_GraphicalCodeCaptcha.php b/framework/main/classes/helper/captcha/web/class_GraphicalCodeCaptcha.php index b85536f0..ade0e84c 100644 --- a/framework/main/classes/helper/captcha/web/class_GraphicalCodeCaptcha.php +++ b/framework/main/classes/helper/captcha/web/class_GraphicalCodeCaptcha.php @@ -6,6 +6,7 @@ namespace Org\Mxchange\CoreFramework\Helper\Captcha; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; +use Org\Mxchange\CoreFramework\Helper\Crypto\CryptoHelper; use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate; /** @@ -121,7 +122,7 @@ class GraphicalCodeCaptcha extends BaseCaptcha implements SolveableCaptcha { } // Get crypto instance - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + $cryptoInstance = CryptoHelper::getSelfInstance(); // Hash the CAPTCHA code for later comparison $this->hashedString = $cryptoInstance->hashString($captchaString);