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