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 array $secretoptions The options to pass to the secret storage |
39
|
|
|
* instance. See the documentation |
40
|
|
|
* in the UserSecretStorage/ subdirectory for |
41
|
|
|
* options per type. |
42
|
|
|
* |
43
|
|
|
* @return Tiqr_UserStorage_Interface |
44
|
|
|
* |
45
|
3 |
|
* @throws Exception |
46
|
|
|
*/ |
47
|
3 |
|
public static function getStorage($type="file", $options=array(), $secretoptions=array(), LoggerInterface $logger) |
48
|
3 |
|
{ |
49
|
1 |
|
switch ($type) { |
50
|
1 |
|
case "file": |
51
|
1 |
|
require_once("Tiqr/UserStorage/File.php"); |
52
|
2 |
|
return new Tiqr_UserStorage_File($options, $logger, $secretoptions); |
|
|
|
|
53
|
|
|
case "pdo": |
54
|
|
|
require_once("Tiqr/UserStorage/Pdo.php"); |
55
|
|
|
return new Tiqr_UserStorage_Pdo($options, $logger, $secretoptions); |
|
|
|
|
56
|
2 |
|
} |
57
|
2 |
|
|
58
|
2 |
|
throw new RuntimeException(sprintf('Unable to create a UserStorage instance of type: %s', $type)); |
59
|
2 |
|
} |
60
|
|
|
} |
61
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.