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 <richard@geekwright.com>
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: * @link http://xoops.org
25: */
26: abstract class KeyAbstract
27: {
28: /** @var StorageInterface */
29: protected $storage;
30:
31: /** @var string */
32: protected $name;
33:
34: /**
35: * KeyAbstract constructor.
36: * @param StorageInterface $storage key store
37: * @param string $name case insensitive key name, allow only A-Z, 0-9, _ and -
38: */
39: public function __construct(StorageInterface $storage, $name)
40: {
41: $this->storage = $storage;
42: $this->name = strtolower(preg_replace('/[^A-Z0-9_-]/i', '', $name));
43: }
44:
45: /**
46: * get key for use in signing
47: *
48: * @return string signing key
49: */
50: abstract public function getSigning();
51:
52: /**
53: * get key for use in verifying
54: *
55: * @return string verifying key
56: */
57: abstract public function getVerifying();
58:
59: /**
60: * create the key and store it for use
61: *
62: * @return boolean true if key was created and stored, otherwise false
63: */
64: abstract public function create();
65:
66: /**
67: * delete the key
68: *
69: * @return boolean true if key was deleted, otherwise false
70: */
71: abstract public function kill();
72: }
73: