From 3c8db2377424da323d9f1f3b683a03e30bafc31e Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 26 May 2013 14:11:42 +0530 Subject: [PATCH] Fix namespace and use statements. --- .../Component/Auth/AbstractPasswordHasher.php | 1 + .../Controller/Component/Auth/BaseAuthenticate.php | 10 +++++----- .../Component/Auth/BlowfishPasswordHasher.php | 6 ++++-- .../Controller/Component/Auth/SimplePasswordHasher.php | 6 ++++-- .../Component/Auth/BasicAuthenticateTest.php | 4 ++-- .../Controller/Component/Auth/FormAuthenticateTest.php | 2 +- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/Cake/Controller/Component/Auth/AbstractPasswordHasher.php b/lib/Cake/Controller/Component/Auth/AbstractPasswordHasher.php index ed96691a5e9..f8c64a616c7 100644 --- a/lib/Cake/Controller/Component/Auth/AbstractPasswordHasher.php +++ b/lib/Cake/Controller/Component/Auth/AbstractPasswordHasher.php @@ -13,6 +13,7 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +namespace Cake\Controller\Component\Auth; /** * Abstract password hashing class diff --git a/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php index ee30779ddba..dce5644b332 100644 --- a/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php +++ b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php @@ -16,6 +16,7 @@ namespace Cake\Controller\Component\Auth; use Cake\Controller\ComponentCollection; +use Cake\Error; use Cake\Network\Request; use Cake\Network\Response; use Cake\Utility\ClassRegistry; @@ -137,7 +138,7 @@ protected function _findUser($username, $password = null) { * Return password hasher object * * @return AbstractPasswordHasher Password hasher instance - * @throws CakeException If password hasher class not found or + * @throws Cake\Error\Exception If password hasher class not found or * it does not extend AbstractPasswordHasher */ public function passwordHasher() { @@ -154,13 +155,12 @@ public function passwordHasher() { unset($config['className']); } list($plugin, $class) = pluginSplit($class, true); - $className = $class . 'PasswordHasher'; - App::uses($className, $plugin . 'Controller/Component/Auth'); + $className = App::classname($class, 'Controller/Component/Auth', 'PasswordHasher'); if (!class_exists($className)) { - throw new CakeException(__d('cake_dev', 'Password hasher class "%s" was not found.', $class)); + throw new Error\Exception(__d('cake_dev', 'Password hasher class "%s" was not found.', $class)); } if (!is_subclass_of($className, 'AbstractPasswordHasher')) { - throw new CakeException(__d('cake_dev', 'Password hasher must extend AbstractPasswordHasher class.')); + throw new Error\Exception(__d('cake_dev', 'Password hasher must extend AbstractPasswordHasher class.')); } $this->_passwordHasher = new $className($config); return $this->_passwordHasher; diff --git a/lib/Cake/Controller/Component/Auth/BlowfishPasswordHasher.php b/lib/Cake/Controller/Component/Auth/BlowfishPasswordHasher.php index 88b6553833d..3652310169c 100644 --- a/lib/Cake/Controller/Component/Auth/BlowfishPasswordHasher.php +++ b/lib/Cake/Controller/Component/Auth/BlowfishPasswordHasher.php @@ -13,8 +13,10 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('AbstractPasswordHasher', 'Controller/Component/Auth'); -App::uses('Security', 'Utility'); +namespace Cake\Controller\Component\Auth; + +use Cake\Controller\Component\Auth\AbstractPasswordHasher; +use Cake\Utility\Security; /** * Blowfish password hashing class. diff --git a/lib/Cake/Controller/Component/Auth/SimplePasswordHasher.php b/lib/Cake/Controller/Component/Auth/SimplePasswordHasher.php index 1bf2a746073..25557cc3491 100644 --- a/lib/Cake/Controller/Component/Auth/SimplePasswordHasher.php +++ b/lib/Cake/Controller/Component/Auth/SimplePasswordHasher.php @@ -13,8 +13,10 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('AbstractPasswordHasher', 'Controller/Component/Auth'); -App::uses('Security', 'Utility'); +namespace Cake\Controller\Component\Auth; + +use Cake\Controller\Component\Auth\AbstractPasswordHasher; +use Cake\Utility\Security; /** * Simple password hashing class. diff --git a/lib/Cake/Test/TestCase/Controller/Component/Auth/BasicAuthenticateTest.php b/lib/Cake/Test/TestCase/Controller/Component/Auth/BasicAuthenticateTest.php index 7f6475de960..085105cad9f 100644 --- a/lib/Cake/Test/TestCase/Controller/Component/Auth/BasicAuthenticateTest.php +++ b/lib/Cake/Test/TestCase/Controller/Component/Auth/BasicAuthenticateTest.php @@ -198,8 +198,8 @@ public function testAuthenticateWithBlowfish() { $hash = Security::hash('password', 'blowfish'); $this->skipIf(strpos($hash, '$2a$') === false, 'Skipping blowfish tests as hashing is not working'); - $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request = new Request('posts/index'); + $request->addParams(array('pass' => array())); $_SERVER['PHP_AUTH_USER'] = 'mariano'; $_SERVER['PHP_AUTH_PW'] = 'password'; diff --git a/lib/Cake/Test/TestCase/Controller/Component/Auth/FormAuthenticateTest.php b/lib/Cake/Test/TestCase/Controller/Component/Auth/FormAuthenticateTest.php index 6e304e63cf9..19d9cdcf9bb 100644 --- a/lib/Cake/Test/TestCase/Controller/Component/Auth/FormAuthenticateTest.php +++ b/lib/Cake/Test/TestCase/Controller/Component/Auth/FormAuthenticateTest.php @@ -255,7 +255,7 @@ public function testPasswordHasherSettings() { array('User.user' => 'mariano') ); - $request = new CakeRequest('posts/index', false); + $request = new Request('posts/index'); $request->data = array('User' => array( 'user' => 'mariano', 'password' => 'mypass'