1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Xmf\Key; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Xmf\Key\StorageInterface |
16
|
|
|
* |
17
|
|
|
* load a database table |
18
|
|
|
* |
19
|
|
|
* @category Xmf\Key\KeyAbstract |
20
|
|
|
* @package Xmf |
21
|
|
|
* @author Richard Griffith <[email protected]> |
22
|
|
|
* @copyright 2016 XOOPS Project (http://xoops.org) |
23
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
24
|
|
|
* @version Release: 1.0 |
25
|
|
|
* @link http://xoops.org |
26
|
|
|
*/ |
27
|
|
|
abstract class KeyAbstract |
28
|
|
|
{ |
29
|
|
|
/** @var StorageInterface */ |
30
|
|
|
protected $storage; |
31
|
|
|
|
32
|
|
|
/** @var string */ |
33
|
|
|
protected $name; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* KeyAbstract constructor. |
37
|
|
|
* @param StorageInterface $storage key store |
38
|
|
|
* @param string $name case insensitive key name, allow only A-Z, 0-9, _ and - |
39
|
|
|
*/ |
40
|
1 |
|
public function __construct(StorageInterface $storage, $name) |
41
|
|
|
{ |
42
|
1 |
|
$this->storage = $storage; |
43
|
1 |
|
$this->name = strtolower(preg_replace('/[^A-Z0-9_-]/i', '', $name)); |
44
|
1 |
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* get key for use in signing |
48
|
|
|
* |
49
|
|
|
* @return string signing key |
50
|
|
|
*/ |
51
|
|
|
abstract public function getSigning(); |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* get key for use in verifying |
55
|
|
|
* |
56
|
|
|
* @return string verifying key |
57
|
|
|
*/ |
58
|
|
|
abstract public function getVerifying(); |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* create the key and store it for use |
62
|
|
|
* |
63
|
|
|
* @return boolean true if key was created and stored, otherwise false |
64
|
|
|
*/ |
65
|
|
|
abstract public function create(); |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* delete the key |
69
|
|
|
* |
70
|
|
|
* @return boolean true if key was deleted, otherwise false |
71
|
|
|
*/ |
72
|
|
|
abstract public function kill(); |
73
|
|
|
} |
74
|
|
|
|