Cleanup: Updated copyright comments
[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 * [CLASS/FUNCTION INDEX of SCRIPT]
27 *
28 * $Id$
29 */
30
31 require_once(t3lib_extMgm::extPath('rsaauth', 'sv1/storage/class.tx_rsaauth_abstract_storage.php'));
32
33 /**
34 * This class contains a factory for the RSA backends.
35 *
36 * @author Dmitry Dulepov <dmitry@typo3.org>
37 * @package TYPO3
38 * @subpackage tx_rsaauth
39 */
40 class tx_rsaauth_storagefactory {
41
42 /**
43 * A list of all available storages. Currently this list cannot be extended.
44 * This is for security reasons to avoid inserting some dummy storage to
45 * the list.
46 *
47 * @var string
48 */
49 static protected $preferredStorage = 'EXT:rsaauth/sv1/storage/class.tx_rsaauth_split_storage.php:tx_rsaauth_split_storage';
50
51 /**
52 * An instance of the storage. This member is set in the getStorage() function.
53 * It will not be an abstract storage as shown below but a real class, which is
54 * derieved from the tx_rsaauth_abstract_storage.
55 *
56 * <!-- Please, keep the variable type! It helps IDEs to provide autocomple! -->
57 *
58 * @var tx_rsaauth_abstract_storage
59 */
60 static protected $storageInstance = null;
61
62 /**
63 * Obtains a storage. This function will return a non-abstract class, which
64 * is derieved from the tx_rsaauth_abstract_storage. Applications should
65 * not use anoy methods that are not declared in the tx_rsaauth_abstract_storage.
66 *
67 * @return tx_rsaauth_abstract_storage A storage
68 */
69 static public function getStorage() {
70 if (is_null(self::$storageInstance)) {
71 self::$storageInstance = t3lib_div::getUserObj(self::$preferredStorage);
72 }
73 return self::$storageInstance;
74 }
75
76 /**
77 * Sets the preffered storage to the factory. This method can be called from
78 * another extension or ext_localconf.php
79 *
80 * @param string $preferredStorage Preffered storage
81 * @return void
82 */
83 static public function setPreferredStorage($preferredStorage) {
84 self::$preferredStorage = $preferredStorage;
85 }
86 }
87
88 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/storage/class.tx_rsaauth_storagefactory.php'])) {
89 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/storage/class.tx_rsaauth_storagefactory.php']);
90 }
91
92 ?>