2013-05-20 06:44:35 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2017-06-10 21:33:55 +00:00
|
|
|
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
2017-06-10 22:10:52 +00:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2013-05-20 06:44:35 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2017-06-10 22:10:52 +00:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2017-06-10 21:33:55 +00:00
|
|
|
* @link https://cakephp.org CakePHP(tm) Project
|
2013-06-02 19:34:00 +00:00
|
|
|
* @since CakePHP(tm) v 2.4.0
|
2017-06-10 22:23:14 +00:00
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License
|
2013-05-20 06:44:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract password hashing class
|
|
|
|
*
|
|
|
|
* @package Cake.Controller.Component.Auth
|
|
|
|
*/
|
|
|
|
abstract class AbstractPasswordHasher {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Configurations for this object. Settings passed from authenticator class to
|
|
|
|
* the constructor are merged with this property.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $_config = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param array $config Array of config.
|
|
|
|
*/
|
|
|
|
public function __construct($config = array()) {
|
|
|
|
$this->config($config);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get/Set the config
|
|
|
|
*
|
|
|
|
* @param array $config Sets config, if null returns existing config
|
|
|
|
* @return array Returns configs
|
|
|
|
*/
|
|
|
|
public function config($config = null) {
|
|
|
|
if (is_array($config)) {
|
|
|
|
$this->_config = array_merge($this->_config, $config);
|
|
|
|
}
|
|
|
|
return $this->_config;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates password hash.
|
|
|
|
*
|
|
|
|
* @param string|array $password Plain text password to hash or array of data
|
|
|
|
* required to generate password hash.
|
|
|
|
* @return string Password hash
|
|
|
|
*/
|
|
|
|
abstract public function hash($password);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check hash. Generate hash from user provided password string or data array
|
|
|
|
* and check against existing hash.
|
|
|
|
*
|
|
|
|
* @param string|array $password Plain text password to hash or data array.
|
2014-05-31 21:36:05 +00:00
|
|
|
* @param string $hashedPassword Existing hashed password.
|
2014-07-03 13:36:42 +00:00
|
|
|
* @return bool True if hashes match else false.
|
2013-05-20 06:44:35 +00:00
|
|
|
*/
|
|
|
|
abstract public function check($password, $hashedPassword);
|
|
|
|
|
|
|
|
}
|