|
TYPO3 API
SVNRelease
|
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_loginformhook.php 10120 2011-01-18 20:03:36Z ohader $ 00029 */ 00030 00031 require_once(t3lib_extMgm::extPath('rsaauth') . 'sv1/backends/class.tx_rsaauth_backendfactory.php'); 00032 require_once(t3lib_extMgm::extPath('rsaauth', 'sv1/storage/class.tx_rsaauth_storagefactory.php')); 00033 00034 /** 00035 * This class provides a hook to the login form to add extra javascript code 00036 * and supply a proper form tag. 00037 * 00038 * @author Dmitry Dulepov <dmitry@typo3.org> 00039 * @package TYPO3 00040 * @subpackage tx_rsaauth 00041 */ 00042 class tx_rsaauth_loginformhook { 00043 00044 /** 00045 * Adds RSA-specific JavaScript and returns a form tag 00046 * 00047 * @return string Form tag 00048 */ 00049 public function getLoginFormTag(array $params, SC_index& $pObj) { 00050 $form = null; 00051 if ($pObj->loginSecurityLevel == 'rsa') { 00052 00053 // If we can get the backend, we can proceed 00054 $backend = tx_rsaauth_backendfactory::getBackend(); 00055 if (!is_null($backend)) { 00056 00057 // Add form tag 00058 $form = '<form action="index.php" method="post" name="loginform" onsubmit="tx_rsaauth_encrypt();">'; 00059 00060 // Generate a new key pair 00061 $keyPair = $backend->createNewKeyPair(); 00062 00063 // Save private key 00064 $storage = tx_rsaauth_storagefactory::getStorage(); 00065 /* @var $storage tx_rsaauth_abstract_storage */ 00066 $storage->put($keyPair->getPrivateKey()); 00067 00068 // Add RSA hidden fields 00069 $form .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />'; 00070 $form .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />'; 00071 } 00072 } 00073 return $form; 00074 } 00075 00076 00077 /** 00078 * Provides form code for the superchallenged authentication. 00079 * 00080 * @param array $params Parameters to the script 00081 * @param SC_index $pObj Calling object 00082 * @return string The code for the login form 00083 */ 00084 public function getLoginScripts(array $params, SC_index &$pObj) { 00085 $content = ''; 00086 00087 if ($pObj->loginSecurityLevel == 'rsa') { 00088 $javascriptPath = t3lib_extMgm::siteRelPath('rsaauth') . 'resources/'; 00089 $files = array( 00090 'jsbn/jsbn.js', 00091 'jsbn/prng4.js', 00092 'jsbn/rng.js', 00093 'jsbn/rsa.js', 00094 'jsbn/base64.js', 00095 'rsaauth_min.js' 00096 ); 00097 00098 $content = ''; 00099 foreach ($files as $file) { 00100 $content .= '<script type="text/javascript" src="' . 00101 t3lib_div::getIndpEnv('TYPO3_SITE_URL') . 00102 $javascriptPath . $file . '"></script>'; 00103 } 00104 } 00105 00106 return $content; 00107 } 00108 } 00109 00110 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/hooks/class.tx_rsaauth_loginformhook.php'])) { 00111 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rsaauth/hooks/class.tx_rsaauth_loginformhook.php']); 00112 } 00113 00114 ?>
1.8.0