class_CaptchaEncryptFilter.php

Go to the documentation of this file.
00001 <?php
00024 class CaptchaEncryptFilter extends BaseFilter implements Filterable {
00030         protected function __construct () {
00031                 // Call parent constructor
00032                 parent::__construct(__CLASS__);
00033         }
00034 
00040         public final static function createCaptchaEncryptFilter () {
00041                 // Get a new instance
00042                 $filterInstance = new CaptchaEncryptFilter();
00043 
00044                 // Return the instance
00045                 return $filterInstance;
00046         }
00047 
00056         public function execute (Requestable $requestInstance, Responseable $responseInstance) {
00057                 // Get "encrypt" string barely from the request
00058                 $encryptRequest = $requestInstance->getRequestElement('encrypt');
00059 
00060                 // Is it there?
00061                 if (is_null($encryptRequest)) {
00062                         // Not found, so request is invalid
00063                         $requestInstance->requestIsValid(false);
00064 
00065                         // Throw exception
00066                         throw new EncryptMissingException($this, CryptoHelper::EXCEPTION_ENCRYPT_MISSING);
00067                 } // END - if
00068 
00069                 // Decode it fully
00070                 $encryptDecoded = base64_decode(str_replace(" ", "+", urldecode($encryptRequest)));
00071 
00072                 // Get a crypto helper and decrypt the string
00073                 $decryptedString = ObjectFactory::createObjectByConfiguredName('crypto_class')->decryptString($encryptDecoded);
00074 
00075                 // Is it the expected length?
00076                 if (strlen($decryptedString) != $this->getConfigInstance()->readConfig('captcha_string_length')) {
00077                         // Not found, so request is invalid
00078                         $requestInstance->requestIsValid(false);
00079 
00080                         // Throw exception
00081                         throw new EncryptInvalidLengthException($this, CryptoHelper::EXCEPTION_ENCRYPT_INVALID);
00082                 } // END - if
00083 
00084                 // Write it to the request
00085                 $requestInstance->setRequestElement('decrypted', $decryptedString);
00086         }
00087 }
00088 
00089 // [EOF]
00090 ?>

Generated on Mon Dec 8 01:06:45 2008 for Ship-Simulator by  doxygen 1.5.6