[FEATURE] Add autofocus attribute to BE login
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / EidHandler.php
1 <?php
2 namespace TYPO3\CMS\Install;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2009-2013 Marcus Krause, Helmut Hummel (security@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 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * This is the eID handler for install tool AJAX calls.
31 *
32 * @author Marcus Krause <security@typo3.org>
33 */
34 class EidHandler {
35
36 /**
37 * Keeps content to be printed.
38 *
39 * @var string
40 * @todo Define visibility
41 */
42 public $content;
43
44 /**
45 * Keeps command to process.
46 *
47 * @var string
48 * @todo Define visibility
49 */
50 public $cmd = '';
51
52 /**
53 * Init function, setting the input vars in the class scope.
54 *
55 * @return void
56 * @todo Define visibility
57 */
58 public function init() {
59 $this->cmd = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cmd');
60 }
61
62 /**
63 * Main function which creates the AJAX call return string.
64 * It is stored in $this->content.
65 *
66 * @return void
67 * @todo Define visibility
68 */
69 public function main() {
70 // Create output:
71 switch ($this->cmd) {
72 case 'encryptionKey':
73
74 default:
75 $this->content = $this->createEncryptionKey();
76 $this->addTempContentHttpHeaders();
77 break;
78 }
79 }
80
81 /**
82 * Outputs the content from $this->content
83 *
84 * @return void
85 * @todo Define visibility
86 */
87 public function printContent() {
88 if (!headers_sent()) {
89 header('Content-Length: ' . strlen($this->content));
90 }
91 echo $this->content;
92 }
93
94 /**
95 * Returns a newly created TYPO3 encryption key with a given length.
96 *
97 * @param integer $keyLength desired key length
98 * @return string
99 * @todo Define visibility
100 */
101 public function createEncryptionKey($keyLength = 96) {
102 if (!headers_sent()) {
103 header('Content-type: text/plain');
104 }
105 return \TYPO3\CMS\Core\Utility\GeneralUtility::getRandomHexString($keyLength);
106 }
107
108 /**
109 * Sends cache control headers that prevent caching in user agents.
110 *
111 * @todo Define visibility
112 */
113 public function addTempContentHttpHeaders() {
114 if (!headers_sent()) {
115 // see RFC 2616
116 // see Microsoft Knowledge Base #234067
117 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
118 header('Cache-Control: no-cache, must-revalidate');
119 header('Pragma: no-cache');
120 header('Expires: -1');
121 }
122 }
123
124 }
125
126
127 ?>