9b29a542515e6701c7eb4411d10a5dd2f00e960f
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / Classes / Hook / LoginFormHook.php
1 <?php
2 namespace TYPO3\CMS\Rsaauth\Hook;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2009-2013 Dmitry Dulepov <dmitry@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * This class provides a hook to the login form to add extra javascript code
28 * and supply a proper form tag.
29 *
30 * @author Dmitry Dulepov <dmitry@typo3.org>
31 * @author Helmut Hummel <helmut@typo3.org>
32 */
33 class LoginFormHook {
34
35 /**
36 * Adds RSA-specific JavaScript and returns a form tag
37 *
38 * @param array $params
39 * @param \TYPO3\CMS\Backend\Controller\LoginController $pObj
40 * @return string Form tag
41 * @throws \TYPO3\CMS\Core\Error\Exception
42 */
43 public function getLoginFormTag(array $params, \TYPO3\CMS\Backend\Controller\LoginController &$pObj) {
44 $form = NULL;
45 if ($pObj->loginSecurityLevel === 'rsa') {
46 /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
47 $pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
48 $javascriptPath = '../' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::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 'BackendLoginFormRsaEncryption.js'
56 );
57 foreach ($files as $file) {
58 $pageRenderer->addJsFile($javascriptPath . $file);
59 }
60
61 return '<form action="index.php" id="typo3-login-form" method="post" name="loginform">';
62 }
63 return $form;
64 }
65 }