|
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_abstract_backend.php 10120 2011-01-18 20:03:36Z ohader $ 00029 */ 00030 00031 require_once(t3lib_extMgm::extPath('rsaauth', 'sv1/backends/class.tx_rsaauth_keypair.php')); 00032 00033 /** 00034 * This class contains an abstract SSL backend for the TYPO3 RSA authentication 00035 * service. 00036 * 00037 * There are two steps: 00038 * - prepare data for encoding 00039 * - decode incoming data 00040 * 00041 * To prepare data for encoding, the createNewKeyPair() method should be called. 00042 * This method returns an instance of tx_rsaauth_keypair class, which contains 00043 * the private and public keys. Public key is sent to the client to encode data. 00044 * Private key should be stored somewhere (preferrably in user's session). 00045 * 00046 * To decode data, the decrypt() method should be called with the private key 00047 * created at the previous step and the data to decode. If the data is decoded 00048 * successfully, the result is a string. Otherwise it is null. 00049 * 00050 * @author Dmitry Dulepov <dmitry@typo3.org> 00051 * @package TYPO3 00052 * @subpackage tx_rsaauth 00053 */ 00054 abstract class tx_rsaauth_abstract_backend { 00055 00056 /** 00057 * Error message for the last operation. Derieved classes should always set 00058 * or clear this variable inside the createNewKeyPair() or decypt(). 00059 * 00060 * @var string 00061 */ 00062 protected $error = ''; 00063 00064 /** 00065 * Creates a new key pair for the encryption. 00066 * 00067 * @return tx_rsaauth_keypair A new key pair or null in case of error 00068 */ 00069 abstract public function createNewKeyPair(); 00070 00071 /** 00072 * Decripts the data using the private key. 00073 * 00074 * @param string $privateKey The private key (obtained from a call to createNewKeyPair()) 00075 * @param string $data Data to decrypt (base64-encoded) 00076 * @return string Decrypted data or null in case of a error 00077 */ 00078 abstract public function decrypt($privateKey, $data); 00079 00080 /** 00081 * Checks if this backend is available for calling. 00082 * 00083 * @return void 00084 */ 00085 abstract public function isAvailable(); 00086 00087 /** 00088 * Retrieves a error message. 00089 * 00090 * @return string A error message or empty string if there were no error 00091 */ 00092 public function getLastError() { 00093 return $this->error; 00094 } 00095 } 00096 00097 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/backend/class.tx_rsaauth_abstract_backend.php'])) { 00098 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/backend/class.tx_rsaauth_abstract_backend.php']); 00099 } 00100 00101 ?>
1.8.0