From 23e91f0b477533375a0a6acec04fe02367ab5bda Mon Sep 17 00:00:00 2001 From: Bui Sy Nguyen Date: Fri, 22 Jan 2016 14:23:15 +0700 Subject: [PATCH] Implement #6: remove Zend_Session** class and use fproject\amf\session\** classes instead --- fproject/Zend/Amf/Server.php | 10 +- fproject/Zend/Loader/Autoloader/Interface.php | 43 - fproject/Zend/Session/Exception.php | 74 -- .../Zend/Session/SaveHandler/Interface.php | 81 -- fproject/Zend/Session/Validator/Interface.php | 52 -- fproject/amf/session/Session.php | 850 ++++++++++++++++++ .../session/SessionAbstract.php} | 77 +- fproject/amf/session/SessionException.php | 65 ++ .../session/SessionNamespace.php} | 190 ++-- .../session/SessionSaveHandlerInterface.php | 70 ++ .../amf/session/SessionValidatorInterface.php | 41 + tests/Zend/Amf/ServerTest.php | 7 +- 12 files changed, 1114 insertions(+), 446 deletions(-) delete mode 100644 fproject/Zend/Loader/Autoloader/Interface.php delete mode 100644 fproject/Zend/Session/Exception.php delete mode 100644 fproject/Zend/Session/SaveHandler/Interface.php delete mode 100644 fproject/Zend/Session/Validator/Interface.php create mode 100644 fproject/amf/session/Session.php rename fproject/{Zend/Session/Abstract.php => amf/session/SessionAbstract.php} (71%) create mode 100644 fproject/amf/session/SessionException.php rename fproject/{Zend/Session/Namespace.php => amf/session/SessionNamespace.php} (66%) create mode 100644 fproject/amf/session/SessionSaveHandlerInterface.php create mode 100644 fproject/amf/session/SessionValidatorInterface.php diff --git a/fproject/Zend/Amf/Server.php b/fproject/Zend/Amf/Server.php index 106cc9b..2f343bc 100644 --- a/fproject/Zend/Amf/Server.php +++ b/fproject/Zend/Amf/Server.php @@ -43,9 +43,6 @@ /** @see Zend_Amf_Parse_TypeLoader */ require_once 'Zend/Amf/Parse/TypeLoader.php'; -/** @see Zend_Auth */ -require_once 'Zend/Auth.php'; - use fproject\amf\auth\AuthAbstract; /** @@ -213,7 +210,6 @@ public function isProduction() */ public function setSession($namespace = 'Zend_Amf') { - require_once 'Zend/Session.php'; $this->_session = true; return $this; } @@ -255,7 +251,7 @@ protected function _checkAcl($object, $function) $class = null; } - $auth = Zend_Auth::getInstance(); + $auth = \fproject\amf\auth\Auth::getInstance(); if($auth->hasIdentity()) { $role = $auth->getIdentity()->role; } else { @@ -407,7 +403,7 @@ protected function _loadCommandMessage(Zend_Amf_Value_Messaging_CommandMessage $ break; case Zend_Amf_Value_Messaging_CommandMessage::LOGOUT_OPERATION : if($this->_auth) { - Zend_Auth::getInstance()->clearIdentity(); + \fproject\amf\auth\Auth::getInstance()->clearIdentity(); } $return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message); break; @@ -466,7 +462,7 @@ protected function _handleAuth( $userId, $password) return true; } $this->_auth->setCredentials($userId, $password); - $auth = Zend_Auth::getInstance(); + $auth = \fproject\amf\auth\Auth::getInstance(); $result = $auth->authenticate($this->_auth); if ($result->isValid()) { if (!$this->isSession()) { diff --git a/fproject/Zend/Loader/Autoloader/Interface.php b/fproject/Zend/Loader/Autoloader/Interface.php deleted file mode 100644 index 768b734..0000000 --- a/fproject/Zend/Loader/Autoloader/Interface.php +++ /dev/null @@ -1,43 +0,0 @@ -0 - already called session_regenerate_id() + * + * @var int + */ + private static $_regenerateIdState = 0; + + /** + * Private list of php's ini values for ext/session + * null values will default to the php.ini value, otherwise + * the value below will overwrite the default ini value, unless + * the user has set an option explicity with setOptions() + * + * @var array + */ + private static $_defaultOptions = array( + 'save_path' => null, + 'name' => null, /* this should be set to a unique value for each application */ + 'save_handler' => null, + //'auto_start' => null, /* intentionally excluded (see manual) */ + 'gc_probability' => null, + 'gc_divisor' => null, + 'gc_maxlifetime' => null, + 'serialize_handler' => null, + 'cookie_lifetime' => null, + 'cookie_path' => null, + 'cookie_domain' => null, + 'cookie_secure' => null, + 'cookie_httponly' => null, + 'use_cookies' => null, + 'use_only_cookies' => 'on', + 'referer_check' => null, + 'entropy_file' => null, + 'entropy_length' => null, + 'cache_limiter' => null, + 'cache_expire' => null, + 'use_trans_sid' => null, + 'bug_compat_42' => null, + 'bug_compat_warn' => null, + 'hash_function' => null, + 'hash_bits_per_character' => null + ); + + /** + * List of options pertaining to Zend_Session that can be set by developers + * using Zend_Session::setOptions(). This list intentionally duplicates + * the individual declaration of static "class" variables by the same names. + * + * @var array + */ + private static $_localOptions = array( + 'strict' => '_strict', + 'remember_me_seconds' => '_rememberMeSeconds', + 'throw_startup_exceptions' => '_throwStartupExceptions' + ); + + /** + * Whether or not write close has been performed. + * + * @var bool + */ + private static $_writeClosed = false; + + /** + * Whether or not session id cookie has been deleted + * + * @var bool + */ + private static $_sessionCookieDeleted = false; + + /** + * Whether or not session has been destroyed via session_destroy() + * + * @var bool + */ + private static $_destroyed = false; + + /** + * Whether or not session must be initiated before usage + * + * @var bool + */ + private static $_strict = false; + + /** + * Default number of seconds the session will be remembered for when asked to be remembered + * + * @var int + */ + private static $_rememberMeSeconds = 1209600; // 2 weeks + + /** + * Whether the default options listed in Zend_Session::$_localOptions have been set + * + * @var bool + */ + private static $_defaultOptionsSet = false; + + /** + * A reference to the set session save handler + * + * @var SessionSaveHandlerInterface + */ + private static $_saveHandler = null; + + + /** + * Constructor overriding - make sure that a developer cannot instantiate + */ + protected function __construct() + { + } + + + /** + * setOptions - set both the class specified + * + * @param array $userOptions - pass-by-keyword style array of