[TASK] Use autoloader in rsaauth system extension
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / sv1 / backends / class.tx_rsaauth_abstract_backend.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 an abstract SSL backend for the TYPO3 RSA authentication
28 * service.
29 *
30 * There are two steps:
31 * - prepare data for encoding
32 * - decode incoming data
33 *
34 * To prepare data for encoding, the createNewKeyPair() method should be called.
35 * This method returns an instance of tx_rsaauth_keypair class, which contains
36 * the private and public keys. Public key is sent to the client to encode data.
37 * Private key should be stored somewhere (preferrably in user's session).
38 *
39 * To decode data, the decrypt() method should be called with the private key
40 * created at the previous step and the data to decode. If the data is decoded
41 * successfully, the result is a string. Otherwise it is NULL.
42 *
43 * @author Dmitry Dulepov <dmitry@typo3.org>
44 * @package TYPO3
45 * @subpackage tx_rsaauth
46 */
47 abstract class tx_rsaauth_abstract_backend {
48
49 /**
50 * Error message for the last operation. Derieved classes should always set
51 * or clear this variable inside the createNewKeyPair() or decypt().
52 *
53 * @var string
54 */
55 protected $error = '';
56
57 /**
58 * Creates a new key pair for the encryption.
59 *
60 * @return tx_rsaauth_keypair A new key pair or NULL in case of error
61 */
62 abstract public function createNewKeyPair();
63
64 /**
65 * Decripts the data using the private key.
66 *
67 * @param string $privateKey The private key (obtained from a call to createNewKeyPair())
68 * @param string $data Data to decrypt (base64-encoded)
69 * @return string Decrypted data or NULL in case of a error
70 */
71 abstract public function decrypt($privateKey, $data);
72
73 /**
74 * Checks if this backend is available for calling.
75 *
76 * @return void
77 */
78 abstract public function isAvailable();
79
80 /**
81 * Retrieves a error message.
82 *
83 * @return string A error message or empty string if there were no error
84 */
85 public function getLastError() {
86 return $this->error;
87 }
88 }
89
90 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/backend/class.tx_rsaauth_abstract_backend.php'])) {
91 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/backend/class.tx_rsaauth_abstract_backend.php']);
92 }
93
94 ?>