[TASK] Re-work/simplify copyright header in PHP files - Part 9
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / Classes / Storage / SessionStorage.php
1 <?php
2 namespace TYPO3\CMS\Rsaauth\Storage;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16 /**
17 * This class contains a session-based storage for private keys. This storage
18 * is not secure enough because its implementation stores keys completely in the
19 * PHP sessions. PHP sessions usually store data in the file system and it is
20 * easy to extract. This storage is useful only as an example. It is better to
21 * use "split" storage for keys.
22 *
23 * @author Dmitry Dulepov <dmitry@typo3.org>
24 */
25 class SessionStorage extends \TYPO3\CMS\Rsaauth\Storage\AbstractStorage {
26
27 /**
28 * Creates an instance of this class. It checks and initializes PHP
29 * sessions if necessary.
30 *
31 * @return void
32 */
33 public function __construct() {
34 if (!isset($_SESSION) || !is_array($_SESSION)) {
35 session_start();
36 }
37 }
38
39 /**
40 * Obtains key from the session
41 *
42 * @return string The key or NULL
43 * @see \TYPO3\CMS\Rsaauth\Storage\AbstractStorage::get()
44 */
45 public function get() {
46 return isset($_SESSION['tx_rsaauth_key']) ? $_SESSION['tx_rsaauth_key'] : NULL;
47 }
48
49 /**
50 * Puts key to the session
51 *
52 * @param string $key The key
53 * @see \TYPO3\CMS\Rsaauth\Storage\AbstractStorage::put()
54 */
55 public function put($key) {
56 $_SESSION['tx_rsaauth_key'] = $key;
57 }
58
59 }