TYPO3 CMS  TYPO3_6-2
UserSetupHook.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Rsaauth\Hook;
3 
23 
30  public function decryptPassword(array $parameters) {
31  if ($this->isRsaAvailable()) {
32  $be_user_data = &$parameters['be_user_data'];
33  if (substr($be_user_data['password'], 0, 4) === 'rsa:' && substr($be_user_data['password2'], 0, 4) === 'rsa:') {
34  $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
37  $key = $storage->get();
38  $password = $backend->decrypt($key, substr($be_user_data['password'], 4));
39  $password2 = $backend->decrypt($key, substr($be_user_data['password2'], 4));
40  $be_user_data['password'] = $password ?: $be_user_data['password'];
41  $be_user_data['password2'] = $password2 ?: $be_user_data['password2'];
42  }
43  }
44  }
45 
53  public function getLoginScripts(array $parameters, \TYPO3\CMS\Setup\Controller\SetupModuleController $userSetupObject) {
54  $content = '';
55  if ($this->isRsaAvailable()) {
56  // If we can get the backend, we can proceed
57  $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
58  $javascriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('rsaauth') . 'resources/';
59  $files = array(
60  'jsbn/jsbn.js',
61  'jsbn/prng4.js',
62  'jsbn/rng.js',
63  'jsbn/rsa.js',
64  'jsbn/base64.js',
65  'rsaauth_min.js'
66  );
67  $content = '';
68  foreach ($files as $file) {
69  $content .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>';
70  }
71  // Generate a new key pair
72  $keyPair = $backend->createNewKeyPair();
73  // Save private key
76  $storage->put($keyPair->getPrivateKey());
77  // Add form tag
78  $form = '<form action="' . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('user_setup') . '" method="post" name="usersetup" enctype="application/x-www-form-urlencoded" onsubmit="tx_rsaauth_encryptUserSetup();">';
79  // Add RSA hidden fields
80  $form .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />';
81  $form .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />';
82  $userSetupObject->doc->form = $form;
83  }
84  return $content;
85  }
86 
92  protected function isRsaAvailable() {
93  return trim($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) === 'rsa' && \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend() !== NULL;
94  }
95 
96 }
$parameters
Definition: FileDumpEID.php:15
static getModuleUrl($moduleName, $urlParameters=array(), $backPathOverride=FALSE, $returnAbsoluteUrl=FALSE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]