統計
| ブランチ: | リビジョン:

pictcode / lib / Cake / Controller / Component / Auth / AbstractPasswordHasher.php @ 635eef61

履歴 | 表示 | アノテート | ダウンロード (1.931 KB)

1 635eef61 spyder1211
<?php
2
/**
3
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
5
 *
6
 * Licensed under The MIT License
7
 * For full copyright and license information, please see the LICENSE.txt
8
 * Redistributions of files must retain the above copyright notice.
9
 *
10
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11
 * @link          http://cakephp.org CakePHP(tm) Project
12
 * @since         CakePHP(tm) v 2.4.0
13
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
14
 */
15
16
/**
17
 * Abstract password hashing class
18
 *
19
 * @package       Cake.Controller.Component.Auth
20
 */
21
abstract class AbstractPasswordHasher {
22
23
/**
24
 * Configurations for this object. Settings passed from authenticator class to
25
 * the constructor are merged with this property.
26
 *
27
 * @var array
28
 */
29
        protected $_config = array();
30
31
/**
32
 * Constructor
33
 *
34
 * @param array $config Array of config.
35
 */
36
        public function __construct($config = array()) {
37
                $this->config($config);
38
        }
39
40
/**
41
 * Get/Set the config
42
 *
43
 * @param array $config Sets config, if null returns existing config
44
 * @return array Returns configs
45
 */
46
        public function config($config = null) {
47
                if (is_array($config)) {
48
                        $this->_config = array_merge($this->_config, $config);
49
                }
50
                return $this->_config;
51
        }
52
53
/**
54
 * Generates password hash.
55
 *
56
 * @param string|array $password Plain text password to hash or array of data
57
 *   required to generate password hash.
58
 * @return string Password hash
59
 */
60
        abstract public function hash($password);
61
62
/**
63
 * Check hash. Generate hash from user provided password string or data array
64
 * and check against existing hash.
65
 *
66
 * @param string|array $password Plain text password to hash or data array.
67
 * @param string $hashedPassword Existing hashed password.
68
 * @return bool True if hashes match else false.
69
 */
70
        abstract public function check($password, $hashedPassword);
71
72
}