|
TYPO3 API
SVNRelease
|
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_backendfactory.php 10120 2011-01-18 20:03:36Z ohader $ 00029 */ 00030 00031 require_once(t3lib_extMgm::extPath('rsaauth', 'sv1/backends/class.tx_rsaauth_abstract_backend.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_backendfactory { 00041 00042 /** 00043 * A list of all available backends. Currently this list cannot be extended. 00044 * This is for security reasons to avoid inserting some dummy backend to 00045 * the list. 00046 * 00047 * @var array 00048 */ 00049 static protected $availableBackends = array( 00050 'EXT:rsaauth/sv1/backends/class.tx_rsaauth_php_backend.php:tx_rsaauth_php_backend', 00051 'EXT:rsaauth/sv1/backends/class.tx_rsaauth_cmdline_backend.php:tx_rsaauth_cmdline_backend' 00052 ); 00053 00054 /** 00055 * A flag that tells if the factory is initialized. This is to prevent 00056 * continious creation of backends in case if none of them is available. 00057 * 00058 * @var boolean 00059 */ 00060 static protected $initialized = false; 00061 00062 /** 00063 * A selected backend. This member is set in the getBackend() function. It 00064 * will not be an abstract backend as shown below but a real class, which is 00065 * derieved from the tx_rsaauth_abstract_backend. 00066 * 00067 * <!-- Please, keep the variable type! It helps IDEs to provide autocomple! --> 00068 * 00069 * @var tx_rsaauth_abstract_backend 00070 */ 00071 static protected $selectedBackend = null; 00072 00073 /** 00074 * Obtains a backend. This function will return a non-abstract class, which 00075 * is derieved from the tx_rsaauth_abstract_backend. Applications should 00076 * not use anoy methods that are not declared in the tx_rsaauth_abstract_backend. 00077 * 00078 * @return tx_rsaauth_abstract_backend A backend 00079 */ 00080 static public function getBackend() { 00081 if (!self::$initialized) { 00082 // Backend does not exist yet. Create it. 00083 foreach (self::$availableBackends as $backend) { 00084 $backendObject = t3lib_div::getUserObj($backend); 00085 // Check that it is derieved from the proper base class 00086 if ($backendObject instanceof tx_rsaauth_abstract_backend) { 00087 /* @var $backendObject tx_rsaauth_abstract_backend */ 00088 if ($backendObject->isAvailable()) { 00089 // The backend is available, save it and stop the loop 00090 self::$selectedBackend = $backendObject; 00091 self::$initialized = true; 00092 break; 00093 } 00094 // Attempt to force destruction of the object 00095 unset($backend); 00096 } 00097 } 00098 } 00099 return self::$selectedBackend; 00100 } 00101 00102 } 00103 00104 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/backends/class.tx_rsaauth_backendfactory.php'])) { 00105 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/backends/class.tx_rsaauth_backendfactory.php']); 00106 } 00107 00108 ?>
1.8.0