[TASK] Use autoloader in rsaauth system extension
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / sv1 / storage / class.tx_rsaauth_session_storage.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 a session-based storage for private keys. This storage
28 * is not secure enough because its implementation stores keys completely in the
29 * PHP sessions. PHP sessions usually store data in the file system and it is
30 * easy to extract. This storage is useful only as an example. It is better to
31 * use "split" storage for keys.
32 *
33 * @author Dmitry Dulepov <dmitry@typo3.org>
34 * @package TYPO3
35 * @subpackage tx_rsaauth
36 */
37 class tx_rsaauth_session_storage extends tx_rsaauth_abstract_storage {
38
39 /**
40 * Creates an instance of this class. It checks and initializes PHP
41 * sessions if necessary.
42 *
43 * @return void
44 */
45 public function __construct() {
46 if (!isset($_SESSION) || !is_array($_SESSION)) {
47 session_start();
48 }
49 }
50
51 /**
52 * Obtains key from the session
53 *
54 * @return string The key or NULL
55 * @see tx_rsaauth_abstract_storage::get()
56 */
57 public function get() {
58 return (isset($_SESSION['tx_rsaauth_key']) ? $_SESSION['tx_rsaauth_key'] : NULL);
59 }
60
61 /**
62 * Puts key to the session
63 *
64 * @param string $key The key
65 * @see tx_rsaauth_abstract_storage::put()
66 */
67 public function put($key) {
68 $_SESSION['tx_rsaauth_key'] = $key;
69 }
70 }
71
72 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/storage/class.tx_rsaauth_session_storage.php'])) {
73 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/storage/class.tx_rsaauth_session_storage.php']);
74 }
75
76 ?>