[TASK] Clean up phpDoc comments in typo3/sysext/rsaauth
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / hooks / class.tx_rsaauth_feloginhook.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 * This class contains a hook to implement RSA authentication for the TYPO3
27 * Frontend. Warning: felogin must be USER_INT for this to work!
28 *
29 * @author Dmitry Dulepov <dmitry@typo3.org>
30 * @package TYPO3
31 * @subpackage tx_rsaauth
32 */
33 class tx_rsaauth_feloginhook {
34
35 /**
36 * Hooks to the felogin extension to provide additional code for FE login
37 *
38 * @return array 0 => onSubmit function, 1 => extra fields and required files
39 */
40 public function loginFormHook() {
41 $result = array(0 => '', 1 => '');
42
43 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['loginSecurityLevel']) === 'rsa') {
44 $backend = tx_rsaauth_backendfactory::getBackend();
45 if ($backend) {
46 $result[0] = 'tx_rsaauth_feencrypt(this);';
47
48 $javascriptPath = t3lib_extMgm::siteRelPath('rsaauth') . 'resources/';
49 $files = array(
50 'jsbn/jsbn.js',
51 'jsbn/prng4.js',
52 'jsbn/rng.js',
53 'jsbn/rsa.js',
54 'jsbn/base64.js',
55 'rsaauth_min.js'
56 );
57
58 foreach ($files as $file) {
59 $result[1] .= '<script type="text/javascript" src="' .
60 t3lib_div::getIndpEnv('TYPO3_SITE_URL') .
61 $javascriptPath . $file . '"></script>';
62 }
63
64 // Generate a new key pair
65 $keyPair = $backend->createNewKeyPair();
66
67 // Save private key
68 $storage = tx_rsaauth_storagefactory::getStorage();
69 /** @var $storage tx_rsaauth_abstract_storage */
70 $storage->put($keyPair->getPrivateKey());
71
72 // Add RSA hidden fields
73 $result[1] .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />';
74 $result[1] .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />';
75 }
76 }
77 return $result;
78 }
79 }
80 ?>