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