[TASK] Re-work/simplify copyright header in PHP files - Part 9
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / Classes / Hook / FrontendLoginHook.php
1 <?php
2 namespace TYPO3\CMS\Rsaauth\Hook;
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 hook to implement RSA authentication for the TYPO3
18 * Frontend. Warning: felogin must be USER_INT for this to work!
19 *
20 * @author Dmitry Dulepov <dmitry@typo3.org>
21 */
22 class FrontendLoginHook {
23
24 /**
25 * Hooks to the felogin extension to provide additional code for FE login
26 *
27 * @return array 0 => onSubmit function, 1 => extra fields and required files
28 */
29 public function loginFormHook() {
30 $result = array(0 => '', 1 => '');
31 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['loginSecurityLevel']) === 'rsa') {
32 $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
33 if ($backend) {
34 $result[0] = 'return TYPO3FrontendLoginFormRsaEncryption.submitForm(this, TYPO3FrontendLoginFormRsaEncryptionPublicKeyUrl);';
35 $javascriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('rsaauth') . 'resources/';
36 $files = array(
37 'jsbn/jsbn.js',
38 'jsbn/prng4.js',
39 'jsbn/rng.js',
40 'jsbn/rsa.js',
41 'jsbn/base64.js',
42 'FrontendLoginFormRsaEncryption.min.js'
43 );
44 $eIdUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($GLOBALS['TSFE']->absRefPrefix . 'index.php?eID=FrontendLoginRsaPublicKey');
45 $additionalHeader = '<script type="text/javascript">var TYPO3FrontendLoginFormRsaEncryptionPublicKeyUrl = ' . $eIdUrl . ';</script>';
46 foreach ($files as $file) {
47 $additionalHeader .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>';
48 }
49 $GLOBALS['TSFE']->additionalHeaderData['rsaauth_js'] = $additionalHeader;
50 }
51 }
52 return $result;
53 }
54
55 }