1 | <?php |
||
5 | abstract class SignatureAbstract |
||
6 | { |
||
7 | /** |
||
8 | * @var string |
||
9 | */ |
||
10 | protected $secretKey; |
||
11 | |||
12 | /** |
||
13 | * @var \Acquia\Rest\NoncerInterface |
||
14 | */ |
||
15 | private $noncer; |
||
16 | |||
17 | /** |
||
18 | * @var int |
||
19 | */ |
||
20 | private $requestTime = 0; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | */ |
||
25 | protected $noncerLength = NoncerAbstract::DEFAULT_LENGTH; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected static $defaultNoncerClass = 'Acquia\Rest\RandomStringNoncer'; |
||
31 | |||
32 | /** |
||
33 | * @param string $secretKey |
||
34 | */ |
||
35 | 87 | public function __construct($secretKey) |
|
39 | |||
40 | /** |
||
41 | * @param mixed $data |
||
42 | * |
||
43 | * @return string |
||
44 | */ |
||
45 | abstract public function generate($data); |
||
46 | |||
47 | /** |
||
48 | * Returns the shared secret. |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | 54 | public function getSecretKey() |
|
56 | |||
57 | /** |
||
58 | * @param string $class |
||
59 | */ |
||
60 | 30 | public static function setDefaultNoncerClass($class) |
|
64 | |||
65 | /** |
||
66 | * @return string |
||
67 | */ |
||
68 | 3 | public static function getDefaultNoncerClass() |
|
72 | |||
73 | /** |
||
74 | * Returns a noncer, instantiates it if it doesn't exist. |
||
75 | * |
||
76 | * @return \Acquia\Rest\NoncerInterface |
||
77 | * |
||
78 | * @throws \UnexpectedValueException |
||
79 | */ |
||
80 | 57 | public function getNoncer() |
|
90 | |||
91 | /** |
||
92 | * @return string |
||
93 | */ |
||
94 | 51 | public function generateNonce() |
|
98 | |||
99 | /** |
||
100 | * Returns the last nonce that was generated. |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | 42 | public function getNonce() |
|
108 | |||
109 | /** |
||
110 | * @param int $requestTime |
||
111 | * |
||
112 | * @return \Acquia\Rest\SignatureAbstract |
||
113 | */ |
||
114 | 21 | public function setRequestTime($requestTime) |
|
119 | |||
120 | /** |
||
121 | * @return \Acquia\Rest\SignatureAbstract |
||
122 | */ |
||
123 | 12 | public function unsetRequestTime() |
|
128 | |||
129 | /** |
||
130 | * @return int |
||
131 | */ |
||
132 | 54 | public function getRequestTime() |
|
137 | } |
||
138 |