d961ab3ab3635d2d4d728a44ca62207921ad1ac9
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / sv1 / storage / class.tx_rsaauth_storagefactory.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2011 Dmitry Dulepov <dmitry@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25
26 /**
27 * This class contains a factory for the RSA backends.
28 *
29 * @author Dmitry Dulepov <dmitry@typo3.org>
30 * @package TYPO3
31 * @subpackage tx_rsaauth
32 */
33 class tx_rsaauth_storagefactory {
34
35 /**
36 * A list of all available storages. Currently this list cannot be extended.
37 * This is for security reasons to avoid inserting some dummy storage to
38 * the list.
39 *
40 * @var string
41 */
42 static protected $preferredStorage = 'EXT:rsaauth/sv1/storage/class.tx_rsaauth_split_storage.php:tx_rsaauth_split_storage';
43
44 /**
45 * An instance of the storage. This member is set in the getStorage() function.
46 * It will not be an abstract storage as shown below but a real class, which is
47 * derieved from the tx_rsaauth_abstract_storage.
48 *
49 * <!-- Please, keep the variable type! It helps IDEs to provide autocomple! -->
50 *
51 * @var tx_rsaauth_abstract_storage
52 */
53 static protected $storageInstance = NULL;
54
55 /**
56 * Obtains a storage. This function will return a non-abstract class, which
57 * is derieved from the tx_rsaauth_abstract_storage. Applications should
58 * not use anoy methods that are not declared in the tx_rsaauth_abstract_storage.
59 *
60 * @return tx_rsaauth_abstract_storage A storage
61 */
62 static public function getStorage() {
63 if (is_null(self::$storageInstance)) {
64 self::$storageInstance = t3lib_div::getUserObj(self::$preferredStorage);
65 }
66 return self::$storageInstance;
67 }
68
69 /**
70 * Sets the preffered storage to the factory. This method can be called from
71 * another extension or ext_localconf.php
72 *
73 * @param string $preferredStorage Preffered storage
74 * @return void
75 */
76 static public function setPreferredStorage($preferredStorage) {
77 self::$preferredStorage = $preferredStorage;
78 }
79 }
80 ?>