|
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-2012 SURFnet BV |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
use Psr\Log\LoggerInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class implementing a factory to retrieve user data. |
|
24
|
|
|
* |
|
25
|
|
|
* @author ivo |
|
26
|
|
|
*/ |
|
27
|
|
|
class Tiqr_UserStorage |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* Get a storage of a certain type (default: 'file') |
|
31
|
|
|
* |
|
32
|
|
|
* @param String $type The type of storage to create. Supported |
|
33
|
|
|
* types are 'file', 'pdo' or the full class name of a custom solution. |
|
34
|
|
|
* @param array $options The options to pass to the storage |
|
35
|
|
|
* instance. See the documentation |
|
36
|
|
|
* in the UserStorage/ subdirectory for |
|
37
|
|
|
* options per type. |
|
38
|
|
|
* @param LoggerInterface $logger |
|
39
|
|
|
* |
|
40
|
|
|
* @return Tiqr_UserStorage_Interface |
|
41
|
|
|
* |
|
42
|
|
|
* @throws Exception An exception if an unknown user storage is requested. |
|
43
|
|
|
*/ |
|
44
|
5 |
|
public static function getStorage($type="file", $options=array(), LoggerInterface $logger) |
|
45
|
|
|
{ |
|
46
|
5 |
|
switch ($type) { |
|
47
|
5 |
|
case "file": |
|
48
|
1 |
|
require_once("Tiqr/UserStorage/File.php"); |
|
49
|
1 |
|
return new Tiqr_UserStorage_File($options, $logger); |
|
50
|
4 |
|
case "pdo": |
|
51
|
2 |
|
require_once("Tiqr/UserStorage/Pdo.php"); |
|
52
|
2 |
|
return new Tiqr_UserStorage_Pdo($options, $logger); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
2 |
|
throw new RuntimeException(sprintf('Unable to create a UserStorage instance of type: %s', $type)); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|