diff --git a/cake/libs/security.php b/cake/libs/security.php index 2bbc559b86b..6b89e952a7d 100644 --- a/cake/libs/security.php +++ b/cake/libs/security.php @@ -24,7 +24,7 @@ * @package cake * @subpackage cake.cake.libs */ -class Security extends Object { +class Security { /** * Default hash method @@ -32,22 +32,7 @@ class Security extends Object { * @var string * @access public */ - public $hashType = null; - -/** - * Singleton implementation to get object instance. - * - * @return object - * @access public - * @static - */ - function &getInstance() { - static $instance = array(); - if (!$instance) { - $instance[0] =& new Security; - } - return $instance[0]; - } + public static $hashType = null; /** * Get allowed minutes of inactivity based on security level. @@ -111,8 +96,6 @@ function validateAuthKey($authKey) { * @static */ public static function hash($string, $type = null, $salt = false) { - $_this =& Security::getInstance(); - if ($salt) { if (is_string($salt)) { $string = $salt . $string; @@ -122,7 +105,7 @@ public static function hash($string, $type = null, $salt = false) { } if (empty($type)) { - $type = $_this->hashType; + $type = self::$hashType; } $type = strtolower($type); @@ -155,8 +138,7 @@ public static function hash($string, $type = null, $salt = false) { * @see Security::hash() */ public static function setHash($hash) { - $_this =& Security::getInstance(); - $_this->hashType = $hash; + self::$hashType = $hash; } /** diff --git a/cake/tests/cases/libs/security.test.php b/cake/tests/cases/libs/security.test.php index 434bdf8b28c..641e675ec96 100644 --- a/cake/tests/cases/libs/security.test.php +++ b/cake/tests/cases/libs/security.test.php @@ -35,16 +35,6 @@ class SecurityTest extends CakeTestCase { */ public $sut = null; -/** - * setUp method - * - * @access public - * @return void - */ - function setUp() { - $this->sut =& Security::getInstance(); - } - /** * testInactiveMins method * @@ -90,8 +80,7 @@ function testValidateAuthKey() { * @return void */ function testHash() { - $Security =& Security::getInstance(); - $_hashType = $Security->hashType; + $_hashType = Security::$hashType; $key = 'someKey'; $hash = 'someHash'; @@ -109,7 +98,7 @@ function testHash() { $hashType = 'sha1'; Security::setHash($hashType); - $this->assertIdentical($this->sut->hashType, $hashType); + $this->assertIdentical(Security::$hashType, $hashType); $this->assertIdentical(strlen(Security::hash($key, null, true)), 40); $this->assertIdentical(strlen(Security::hash($key, null, false)), 40); @@ -118,7 +107,7 @@ function testHash() { $hashType = 'md5'; Security::setHash($hashType); - $this->assertIdentical($this->sut->hashType, $hashType); + $this->assertIdentical(Security::$hashType, $hashType); $this->assertIdentical(strlen(Security::hash($key, null, false)), 32); $this->assertIdentical(strlen(Security::hash($key, null, true)), 32);