|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the tiqr project. |
|
4
|
|
|
* |
|
5
|
|
|
* The tiqr project aims to provide an open implementation for |
|
6
|
|
|
* authentication using mobile devices. It was initiated by |
|
7
|
|
|
* SURFnet and developed by Egeniq. |
|
8
|
|
|
* |
|
9
|
|
|
* More information: http://www.tiqr.org |
|
10
|
|
|
* |
|
11
|
|
|
* @author Ivo Jansch <[email protected]> |
|
12
|
|
|
* |
|
13
|
|
|
* @package tiqr |
|
14
|
|
|
* |
|
15
|
|
|
* @license New BSD License - See LICENSE file for details. |
|
16
|
|
|
* |
|
17
|
|
|
* @copyright (C) 2010-2011 SURFnet BV |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* The Abstract base class for all StateStorage implementations |
|
23
|
|
|
* StateStorages are meant to store the information that is used in the |
|
24
|
|
|
* enrollment and authentication processes, or to keep track of whether |
|
25
|
|
|
* a user is logged in. |
|
26
|
|
|
* @author ivo |
|
27
|
|
|
* |
|
28
|
|
|
*/ |
|
29
|
|
|
abstract class Tiqr_StateStorage_Abstract |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* The options for the storage. Derived classes can access this |
|
33
|
|
|
* to retrieve options configured for the state storage. |
|
34
|
|
|
* @var array |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $_options = array(); |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Store a value with a certain key in the statestorage. |
|
40
|
|
|
* @param String $key The key identifying the data |
|
41
|
|
|
* @param mixed $value The data to store in state storage |
|
42
|
|
|
* @param int $expire The expiration (in seconds) of the data |
|
43
|
|
|
*/ |
|
44
|
|
|
public abstract function setValue($key, $value, $expire=0); |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Remove a value from the state storage |
|
48
|
|
|
* @param String $key The key identifying the data to be removed. |
|
49
|
|
|
*/ |
|
50
|
|
|
public abstract function unsetValue($key); |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Retrieve the data for a certain key. |
|
54
|
|
|
* @param String $key The key identifying the data to be retrieved. |
|
55
|
|
|
* @return mixed The data associated with the key |
|
56
|
|
|
*/ |
|
57
|
|
|
public abstract function getValue($key); |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* An initializer that will be called directly after instantiating |
|
61
|
|
|
* the storage. Derived classes can override this to perform |
|
62
|
|
|
* initialization of the storage. |
|
63
|
|
|
* |
|
64
|
|
|
* Note: this method is ont abstract since not every derived class |
|
65
|
|
|
* will want to implement this. |
|
66
|
|
|
*/ |
|
67
|
|
|
public function init() |
|
68
|
|
|
{ |
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* The constructor to construct a state storage instance. Should not be |
|
74
|
|
|
* called directly, use the Tiqr_StateStorage factory to construct |
|
75
|
|
|
* a state storage instance of a certain type. |
|
76
|
|
|
* @param array $options An array of options for the state storage |
|
77
|
|
|
*/ |
|
78
|
|
|
public function __construct($options=array()) |
|
79
|
|
|
{ |
|
80
|
|
|
$this->_options = $options; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
} |
|
84
|
|
|
|