TYPO3 API  SVNRelease
class.tx_rsaauth_storagefactory.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2009-2011 Dmitry Dulepov <dmitry@typo3.org>
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *
00017 *  This script is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00024 
00025 /**
00026  * [CLASS/FUNCTION INDEX of SCRIPT]
00027  *
00028  * $Id: class.tx_rsaauth_storagefactory.php 10120 2011-01-18 20:03:36Z ohader $
00029  */
00030 
00031 require_once(t3lib_extMgm::extPath('rsaauth', 'sv1/storage/class.tx_rsaauth_abstract_storage.php'));
00032 
00033 /**
00034  * This class contains a factory for the RSA backends.
00035  *
00036  * @author  Dmitry Dulepov <dmitry@typo3.org>
00037  * @package TYPO3
00038  * @subpackage  tx_rsaauth
00039  */
00040 class tx_rsaauth_storagefactory {
00041 
00042     /**
00043      * A list of all available storages. Currently this list cannot be extended.
00044      * This is for security reasons to avoid inserting some dummy storage to
00045      * the list.
00046      *
00047      * @var string
00048      */
00049     static protected $preferredStorage = 'EXT:rsaauth/sv1/storage/class.tx_rsaauth_split_storage.php:tx_rsaauth_split_storage';
00050 
00051     /**
00052      * An instance of the storage. This member is set in the getStorage() function.
00053      * It will not be an abstract storage as shown below but a real class, which is
00054      * derieved from the tx_rsaauth_abstract_storage.
00055      *
00056      * <!-- Please, keep the variable type! It helps IDEs to provide autocomple! -->
00057      *
00058      * @var tx_rsaauth_abstract_storage
00059      */
00060     static protected $storageInstance = null;
00061 
00062     /**
00063      * Obtains a storage. This function will return a non-abstract class, which
00064      * is derieved from the tx_rsaauth_abstract_storage. Applications should
00065      * not use anoy methods that are not declared in the tx_rsaauth_abstract_storage.
00066      *
00067      * @return  tx_rsaauth_abstract_storage A storage
00068      */
00069     static public function getStorage() {
00070         if (is_null(self::$storageInstance)) {
00071             self::$storageInstance = t3lib_div::getUserObj(self::$preferredStorage);
00072         }
00073         return self::$storageInstance;
00074     }
00075 
00076     /**
00077      * Sets the preffered storage to the factory. This method can be called from
00078      * another extension or ext_localconf.php
00079      *
00080      * @param   string  $preferredStorage   Preffered storage
00081      * @return  void
00082      */
00083     static public function setPreferredStorage($preferredStorage) {
00084         self::$preferredStorage = $preferredStorage;
00085     }
00086 }
00087 
00088 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/storage/class.tx_rsaauth_storagefactory.php'])) {
00089     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/storage/class.tx_rsaauth_storagefactory.php']);
00090 }
00091 
00092 ?>