TYPO3 API  SVNRelease
class.tx_rsaauth_session_storage.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2009-2011 Dmitry Dulepov <dmitry@typo3.org>
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *
00017 *  This script is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00024 
00025 /**
00026  * [CLASS/FUNCTION INDEX of SCRIPT]
00027  *
00028  * $Id: class.tx_rsaauth_session_storage.php 10120 2011-01-18 20:03:36Z ohader $
00029  */
00030 
00031 require_once(t3lib_extMgm::extPath('rsaauth', 'sv1/storage/class.tx_rsaauth_abstract_storage.php'));
00032 
00033 /**
00034  * This class contains a session-based storage for private keys. This storage
00035  * is not secure enough because its implementation stores keys completely in the
00036  * PHP sessions. PHP sessions usually store data in the file system and it is
00037  * easy to extract. This storage is useful only as an example. It is better to
00038  * use "split" storage for keys.
00039  *
00040  * @author  Dmitry Dulepov <dmitry@typo3.org>
00041  * @package TYPO3
00042  * @subpackage  tx_rsaauth
00043  */
00044 class tx_rsaauth_session_storage extends tx_rsaauth_abstract_storage {
00045 
00046     /**
00047      * Creates an instance of this class. It checks and initializes PHP
00048      * sessions if necessary.
00049      *
00050      * @return  void
00051      */
00052     public function __construct() {
00053         if (!isset($_SESSION) || !is_array($_SESSION)) {
00054             session_start();
00055         }
00056     }
00057 
00058     /**
00059      * Obtains key from the session
00060      *
00061      * @return string   The key or null
00062      * @see tx_rsaauth_abstract_storage::get()
00063      */
00064     public function get() {
00065         return (isset($_SESSION['tx_rsaauth_key']) ? $_SESSION['tx_rsaauth_key'] : null);
00066     }
00067 
00068     /**
00069      * Puts key to the session
00070      *
00071      * @param string    $key    The key
00072      * @see tx_rsaauth_abstract_storage::put()
00073      */
00074     public function put($key) {
00075         $_SESSION['tx_rsaauth_key'] = $key;
00076     }
00077 }
00078 
00079 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/storage/class.tx_rsaauth_session_storage.php'])) {
00080     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/sv1/storage/class.tx_rsaauth_session_storage.php']);
00081 }
00082 
00083 ?>