[TASK] Use extension's name in documentation
[Packages/TYPO3.CMS.git] / typo3 / sysext / saltedpasswords / Classes / Autoloader.php
1 <?php
2 namespace TYPO3\CMS\Saltedpasswords;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011-2013 Helmut Hummel <helmut.hummel@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 * Autoloader included from Install Tool that lets saltedpasswords load itself
31 *
32 * @author Helmut Hummel <helmut.hummel@typo3.org>
33 */
34 class Autoloader {
35
36 /**
37 * Activates saltedpasswords if it is supported.
38 *
39 * @param \TYPO3\CMS\Install\Installer $instObj
40 * @return void
41 */
42 public function execute(\TYPO3\CMS\Install\Installer $instObj) {
43 switch ($instObj->step) {
44 case 4:
45 if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('saltedpasswords') && $this->isSaltedPasswordsSupported()) {
46 $this->activateSaltedPasswords();
47 }
48 break;
49 }
50 }
51
52 /**
53 * Checks whether the OpenSSL PHP extension is working properly.
54 *
55 * Before automatically enabling saltedpasswords, we check for a working OpenSSL PHP extension. As we enable rsaauth
56 * in the process of automatically enabling saltedpasswords, working OpenSSL is a requirement for this.
57 * Availability of the command line openssl binary is not checked here, thus saltedpasswords is NOT enabled
58 * automatically in this case.
59 *
60 * @return boolean TRUE, in case of OpenSSL works and requirements for saltedpasswords are met.
61 * @see \TYPO3\CMS\Rsaauth\Backend\PhpBackend
62 */
63 protected function isSaltedPasswordsSupported() {
64 $isSupported = FALSE;
65 if (is_callable('openssl_pkey_new')) {
66 $testKey = @openssl_pkey_new();
67 if (is_resource($testKey)) {
68 openssl_free_key($testKey);
69 $isSupported = TRUE;
70 }
71 }
72 return $isSupported;
73 }
74
75 /**
76 * Activates saltedpasswords.
77 *
78 * @return void
79 */
80 protected function activateSaltedPasswords() {
81 if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('rsaauth')) {
82 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtension('rsaauth');
83 }
84 if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('saltedpasswords')) {
85 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtension('saltedpasswords');
86 }
87 \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager')->setLocalConfigurationValueByPath('EXT/extConf/saltedpasswords', 'a:2:{s:3:"FE.";a:2:{s:7:"enabled";s:1:"1";s:21:"saltedPWHashingMethod";s:28:"tx_saltedpasswords_salts_md5";}s:3:"BE.";a:2:{s:7:"enabled";s:1:"1";s:21:"saltedPWHashingMethod";s:28:"tx_saltedpasswords_salts_md5";}}');
88 \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager')->setLocalConfigurationValueByPath('BE/loginSecurityLevel', 'rsa');
89 \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager')->setLocalConfigurationValueByPath('FE/loginSecurityLevel', 'rsa');
90 }
91
92 }
93
94
95 ?>