From 6ccf0ec13d112c75c1efcab673af9ef44142b2ac Mon Sep 17 00:00:00 2001 From: Wouter Wolters <typo3@wouterwolters.nl> Date: Fri, 22 Jun 2012 19:52:48 +0200 Subject: [PATCH] [TASK] Clean up phpDoc comments in typo3/sysext/rsaauth * Provide correct parameter names in phpDoc * Provide correct data types in phpDoc * CGLify phpDoc (remove tabs) Change-Id: Icd78ad5235b537134e0a5684de8405d2c581769f Resolves: #38317 Releases: 6.0 Reviewed-on: http://review.typo3.org/12299 Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn --- typo3/sysext/rsaauth/ext_localconf.php | 16 +++--- typo3/sysext/rsaauth/ext_tables.php | 6 +- .../class.tx_rsaauth_backendwarnings.php | 38 ++++++------- .../hooks/class.tx_rsaauth_feloginhook.php | 17 +++--- .../hooks/class.tx_rsaauth_loginformhook.php | 27 +++++---- .../hooks/class.tx_rsaauth_usersetuphook.php | 19 +++---- .../class.tx_rsaauth_abstract_backend.php | 23 ++++---- .../class.tx_rsaauth_backendfactory.php | 25 ++++---- .../class.tx_rsaauth_cmdline_backend.php | 57 +++++++++---------- .../sv1/backends/class.tx_rsaauth_keypair.php | 37 ++++++------ .../backends/class.tx_rsaauth_php_backend.php | 39 +++++++------ .../rsaauth/sv1/class.tx_rsaauth_sv1.php | 36 ++++++------ .../class.tx_rsaauth_abstract_storage.php | 11 ++-- .../class.tx_rsaauth_session_storage.php | 13 ++--- .../class.tx_rsaauth_split_storage.php | 39 ++++++------- .../class.tx_rsaauth_storagefactory.php | 17 +++--- 16 files changed, 201 insertions(+), 219 deletions(-) diff --git a/typo3/sysext/rsaauth/ext_localconf.php b/typo3/sysext/rsaauth/ext_localconf.php index a0998196813f..73903eea1b58 100644 --- a/typo3/sysext/rsaauth/ext_localconf.php +++ b/typo3/sysext/rsaauth/ext_localconf.php @@ -1,9 +1,9 @@ <?php -if (!defined ('TYPO3_MODE')) { - die ('Access denied.'); +if (!defined('TYPO3_MODE')) { + die('Access denied.'); } -// Add the service + // Add the service t3lib_extMgm::addService($_EXTKEY, 'auth' /* sv type */, 'tx_rsaauth_sv1' /* sv key */, array( 'title' => 'RSA authentication', @@ -23,20 +23,20 @@ t3lib_extMgm::addService($_EXTKEY, 'auth' /* sv type */, 'tx_rsaauth_sv1' /* sv ) ); -// Add a hook to the BE login form + // Add a hook to the BE login form $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginFormHook'][$_EXTKEY] = 'EXT:' . $_EXTKEY . '/hooks/class.tx_rsaauth_loginformhook.php:tx_rsaauth_loginformhook->getLoginFormTag'; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'][$_EXTKEY] = 'EXT:' . $_EXTKEY . '/hooks/class.tx_rsaauth_loginformhook.php:tx_rsaauth_loginformhook->getLoginScripts'; -// Add hook for user setup module + // Add hook for user setup module $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/setup/mod/index.php']['setupScriptHook'][$_EXTKEY] = 'EXT:' . $_EXTKEY . '/hooks/class.tx_rsaauth_usersetuphook.php:tx_rsaauth_usersetuphook->getLoginScripts'; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/setup/mod/index.php']['modifyUserDataBeforeSave'][$_EXTKEY] = 'EXT:' . $_EXTKEY . '/hooks/class.tx_rsaauth_usersetuphook.php:tx_rsaauth_usersetuphook->decryptPassword'; -// Add a hook to the FE login form (felogin system extension) + // Add a hook to the FE login form (felogin system extension) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['loginFormOnSubmitFuncs'][$_EXTKEY] = 'EXT:' . $_EXTKEY . '/hooks/class.tx_rsaauth_feloginhook.php:tx_rsaauth_feloginhook->loginFormHook'; -// Add a hook to show Backend warnings + // Add a hook to show Backend warnings $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'][$_EXTKEY] = 'EXT:' . $_EXTKEY . '/hooks/class.tx_rsaauth_backendwarnings.php:tx_rsaauth_backendwarnings'; -// Use popup window to refresh login instead of the AJAX relogin: + // Use popup window to refresh login instead of the AJAX relogin: $TYPO3_CONF_VARS['BE']['showRefreshLoginPopup'] = 1; ?> \ No newline at end of file diff --git a/typo3/sysext/rsaauth/ext_tables.php b/typo3/sysext/rsaauth/ext_tables.php index 59d254edc8d8..43a6acb601a3 100644 --- a/typo3/sysext/rsaauth/ext_tables.php +++ b/typo3/sysext/rsaauth/ext_tables.php @@ -1,10 +1,10 @@ <?php -if (!defined ('TYPO3_MODE')) { +if (!defined('TYPO3_MODE')) { die('Access denied.'); } -// Define the table for keys. Make sure that it cannot be edited or seen by -// any user in any way. + // Define the table for keys. Make sure that it cannot be edited or seen by + // any user in any way. $TCA['tx_rsaauth_keys'] = array ( 'ctrl' => array ( 'adminOnly' => TRUE, diff --git a/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_backendwarnings.php b/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_backendwarnings.php index b2fa64aa0b9f..a861577c31ec 100644 --- a/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_backendwarnings.php +++ b/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_backendwarnings.php @@ -22,53 +22,47 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class contains a hook to the backend warnings collection. It checks * RSA configuration and create a warning if the configuration is wrong. * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ - class tx_rsaauth_backendwarnings { /** * Checks RSA configuration and creates warnings if necessary. * - * @param array $warnings Warnings - * @return void + * @param array $warnings Warnings + * @return void * @see t3lib_BEfunc::displayWarningMessages() */ public function displayWarningMessages_postProcess(array &$warnings) { $backend = tx_rsaauth_backendfactory::getBackend(); if ($backend instanceof tx_rsaauth_cmdline_backend) { - // Not using the PHP extension! + // Not using the PHP extension! $warnings['rsaauth_cmdline'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_using_cmdline'); - // Check the path + // Check the path $extconf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rsaauth']); $path = trim($extconf['temporaryDirectory']); if ($path == '') { - // Path is empty + // Path is empty $warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_empty_directory'); - } - elseif (!t3lib_div::isAbsPath($path)) { - // Path is not absolute + } elseif (!t3lib_div::isAbsPath($path)) { + // Path is not absolute $warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_not_absolute'); - } - elseif (!@is_dir($path)) { - // Path does not represent a directory + } elseif (!@is_dir($path)) { + // Path does not represent a directory $warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_not_exist'); - } - elseif (!@is_writable($path)) { - // Directory is not writable + } elseif (!@is_writable($path)) { + // Directory is not writable $warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_not_writable'); - } - elseif (substr($path, 0, strlen(PATH_site)) == PATH_site) { - // Directory is inside the site root + } elseif (substr($path, 0, strlen(PATH_site)) == PATH_site) { + // Directory is inside the site root $warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_inside_siteroot'); } } diff --git a/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_feloginhook.php b/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_feloginhook.php index c06ba0408568..4c1955633312 100644 --- a/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_feloginhook.php +++ b/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_feloginhook.php @@ -22,21 +22,20 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class contains a hook to implement RSA authentication for the TYPO3 * Frontend. Warning: felogin must be USER_INT for this to work! * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ class tx_rsaauth_feloginhook { /** * Hooks to the felogin extension to provide additional code for FE login * - * @return array 0 => onSubmit function, 1 => extra fields and required files + * @return array 0 => onSubmit function, 1 => extra fields and required files */ public function loginFormHook() { $result = array(0 => '', 1 => ''); @@ -62,15 +61,15 @@ class tx_rsaauth_feloginhook { $javascriptPath . $file . '"></script>'; } - // Generate a new key pair + // Generate a new key pair $keyPair = $backend->createNewKeyPair(); - // Save private key + // Save private key $storage = tx_rsaauth_storagefactory::getStorage(); - /* @var $storage tx_rsaauth_abstract_storage */ + /** @var $storage tx_rsaauth_abstract_storage */ $storage->put($keyPair->getPrivateKey()); - // Add RSA hidden fields + // Add RSA hidden fields $result[1] .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />'; $result[1] .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />'; } diff --git a/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_loginformhook.php b/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_loginformhook.php index c681e8d0c3bf..715012f03919 100644 --- a/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_loginformhook.php +++ b/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_loginformhook.php @@ -22,42 +22,41 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class provides a hook to the login form to add extra javascript code * and supply a proper form tag. * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ class tx_rsaauth_loginformhook { /** * Adds RSA-specific JavaScript and returns a form tag * - * @return string Form tag + * @return string Form tag */ public function getLoginFormTag(array $params, SC_index& $pObj) { $form = NULL; if ($pObj->loginSecurityLevel == 'rsa') { - // If we can get the backend, we can proceed + // If we can get the backend, we can proceed $backend = tx_rsaauth_backendfactory::getBackend(); if (!is_null($backend)) { - // Add form tag + // Add form tag $form = '<form action="index.php" method="post" name="loginform" onsubmit="tx_rsaauth_encrypt();">'; - // Generate a new key pair + // Generate a new key pair $keyPair = $backend->createNewKeyPair(); - // Save private key + // Save private key $storage = tx_rsaauth_storagefactory::getStorage(); - /* @var $storage tx_rsaauth_abstract_storage */ + /** @var $storage tx_rsaauth_abstract_storage */ $storage->put($keyPair->getPrivateKey()); - // Add RSA hidden fields + // Add RSA hidden fields $form .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />'; $form .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />'; } else { @@ -74,9 +73,9 @@ class tx_rsaauth_loginformhook { /** * Provides form code for the superchallenged authentication. * - * @param array $params Parameters to the script - * @param SC_index $pObj Calling object - * @return string The code for the login form + * @param array $params Parameters to the script + * @param SC_index $pObj Calling object + * @return string The code for the login form */ public function getLoginScripts(array $params, SC_index &$pObj) { $content = ''; diff --git a/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_usersetuphook.php b/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_usersetuphook.php index 26a55cd8a584..9cb8b00edf9f 100644 --- a/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_usersetuphook.php +++ b/typo3/sysext/rsaauth/hooks/class.tx_rsaauth_usersetuphook.php @@ -22,14 +22,13 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class provides a hook to the login form to add extra javascript code * and supply a proper form tag. * - * @author Helmut Hummel <helmut.hummel@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Helmut Hummel <helmut.hummel@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ class tx_rsaauth_usersetuphook { @@ -46,8 +45,8 @@ class tx_rsaauth_usersetuphook { if (substr($be_user_data['password'], 0, 4) === 'rsa:' && substr($be_user_data['password2'], 0, 4) === 'rsa:') { $backend = tx_rsaauth_backendfactory::getBackend(); + /** @var $storage tx_rsaauth_abstract_storage */ $storage = tx_rsaauth_storagefactory::getStorage(); - /* @var $storage tx_rsaauth_abstract_storage */ $key = $storage->get(); @@ -90,17 +89,17 @@ class tx_rsaauth_usersetuphook { t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>'; } - // Generate a new key pair + // Generate a new key pair $keyPair = $backend->createNewKeyPair(); // Save private key $storage = tx_rsaauth_storagefactory::getStorage(); - /* @var $storage tx_rsaauth_abstract_storage */ + /** @var $storage tx_rsaauth_abstract_storage */ $storage->put($keyPair->getPrivateKey()); - // Add form tag + // Add form tag $form = '<form action="' . t3lib_BEfunc::getModuleUrl('user_setup') . '" method="post" name="usersetup" enctype="application/x-www-form-urlencoded" onsubmit="tx_rsaauth_encryptUserSetup();">'; - // Add RSA hidden fields + // Add RSA hidden fields $form .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />'; $form .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />'; @@ -112,7 +111,7 @@ class tx_rsaauth_usersetuphook { /** * Rsa is available if loginSecurityLevel is set and rsa backend is working. * - * @return bool + * @return boolean */ protected function isRsaAvailable() { return (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) === 'rsa') && (tx_rsaauth_backendfactory::getBackend() !== NULL); diff --git a/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_abstract_backend.php b/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_abstract_backend.php index c01c3ad6132d..796fa18807ed 100644 --- a/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_abstract_backend.php +++ b/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_abstract_backend.php @@ -22,7 +22,6 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class contains an abstract SSL backend for the TYPO3 RSA authentication * service. @@ -40,9 +39,9 @@ * created at the previous step and the data to decode. If the data is decoded * successfully, the result is a string. Otherwise it is NULL. * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ abstract class tx_rsaauth_abstract_backend { @@ -50,37 +49,37 @@ abstract class tx_rsaauth_abstract_backend { * Error message for the last operation. Derieved classes should always set * or clear this variable inside the createNewKeyPair() or decypt(). * - * @var string + * @var string */ - protected $error = ''; + protected $error = ''; /** * Creates a new key pair for the encryption. * - * @return tx_rsaauth_keypair A new key pair or NULL in case of error + * @return tx_rsaauth_keypair A new key pair or NULL in case of error */ abstract public function createNewKeyPair(); /** * Decripts the data using the private key. * - * @param string $privateKey The private key (obtained from a call to createNewKeyPair()) - * @param string $data Data to decrypt (base64-encoded) - * @return string Decrypted data or NULL in case of a error + * @param string $privateKey The private key (obtained from a call to createNewKeyPair()) + * @param string $data Data to decrypt (base64-encoded) + * @return string Decrypted data or NULL in case of a error */ abstract public function decrypt($privateKey, $data); /** * Checks if this backend is available for calling. * - * @return void + * @return void */ abstract public function isAvailable(); /** * Retrieves a error message. * - * @return string A error message or empty string if there were no error + * @return string A error message or empty string if there were no error */ public function getLastError() { return $this->error; diff --git a/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_backendfactory.php b/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_backendfactory.php index cdc6e08a4e38..9cf48c8bf085 100644 --- a/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_backendfactory.php +++ b/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_backendfactory.php @@ -22,13 +22,12 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class contains a factory for the RSA backends. * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ class tx_rsaauth_backendfactory { @@ -37,7 +36,7 @@ class tx_rsaauth_backendfactory { * This is for security reasons to avoid inserting some dummy backend to * the list. * - * @var array + * @var array */ static protected $availableBackends = array( 'EXT:rsaauth/sv1/backends/class.tx_rsaauth_php_backend.php:tx_rsaauth_php_backend', @@ -48,7 +47,7 @@ class tx_rsaauth_backendfactory { * A flag that tells if the factory is initialized. This is to prevent * continious creation of backends in case if none of them is available. * - * @var boolean + * @var boolean */ static protected $initialized = FALSE; @@ -59,7 +58,7 @@ class tx_rsaauth_backendfactory { * * <!-- Please, keep the variable type! It helps IDEs to provide autocomple! --> * - * @var tx_rsaauth_abstract_backend + * @var tx_rsaauth_abstract_backend */ static protected $selectedBackend = NULL; @@ -68,23 +67,23 @@ class tx_rsaauth_backendfactory { * is derieved from the tx_rsaauth_abstract_backend. Applications should * not use anoy methods that are not declared in the tx_rsaauth_abstract_backend. * - * @return tx_rsaauth_abstract_backend A backend + * @return tx_rsaauth_abstract_backend A backend */ static public function getBackend() { if (!self::$initialized) { - // Backend does not exist yet. Create it. + // Backend does not exist yet. Create it. foreach (self::$availableBackends as $backend) { $backendObject = t3lib_div::getUserObj($backend); - // Check that it is derieved from the proper base class + // Check that it is derieved from the proper base class if ($backendObject instanceof tx_rsaauth_abstract_backend) { - /* @var $backendObject tx_rsaauth_abstract_backend */ + /** @var $backendObject tx_rsaauth_abstract_backend */ if ($backendObject->isAvailable()) { - // The backend is available, save it and stop the loop + // The backend is available, save it and stop the loop self::$selectedBackend = $backendObject; self::$initialized = TRUE; break; } - // Attempt to force destruction of the object + // Attempt to force destruction of the object unset($backend); } } diff --git a/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_cmdline_backend.php b/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_cmdline_backend.php index 78317d2e5c61..1ac9aec4c3b4 100644 --- a/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_cmdline_backend.php +++ b/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_cmdline_backend.php @@ -22,45 +22,44 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class contains a OpenSSL backend for the TYPO3 RSA authentication * service. It uses shell version of OpenSSL to perform tasks. See class * tx_rsaauth_abstract_backend for the information on using backends. * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ class tx_rsaauth_cmdline_backend extends tx_rsaauth_abstract_backend { /** * A path to the openssl binary or FALSE if the binary does not exist * - * @var mixed + * @var mixed */ - protected $opensslPath; + protected $opensslPath; /** * Temporary directory. It is best of it is outside of the web site root and * not publically readable. * For now we use typo3temp/. * - * @var string + * @var string */ - protected $temporaryDirectory; + protected $temporaryDirectory; /** * Creates an instance of this class. It obtains a path to the OpenSSL * binary. * - * @return void + * @return void */ public function __construct() { $this->opensslPath = t3lib_exec::getCommand('openssl'); $this->temporaryDirectory = PATH_site . 'typo3temp'; - // Get temporary directory from the configuration + // Get temporary directory from the configuration $extconf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rsaauth']); if ($extconf['temporaryDirectory'] != '' && $extconf['temporaryDirectory']{0} == '/' && @@ -72,37 +71,37 @@ class tx_rsaauth_cmdline_backend extends tx_rsaauth_abstract_backend { /** * - * @return tx_rsaauth_keypair A new key pair or NULL in case of error + * @return tx_rsaauth_keypair A new key pair or NULL in case of error * @see tx_rsaauth_abstract_backend::createNewKeyPair() */ public function createNewKeyPair() { $result = NULL; - // Create a temporary file. Security: tempnam() sets permissions to 0600 + // Create a temporary file. Security: tempnam() sets permissions to 0600 $privateKeyFile = tempnam($this->temporaryDirectory, uniqid()); - // Generate the private key. - // - // PHP generates 1024 bit key files. We force command line version - // to do the same and use the F4 (0x10001) exponent. This is the most - // secure. + // Generate the private key. + // + // PHP generates 1024 bit key files. We force command line version + // to do the same and use the F4 (0x10001) exponent. This is the most + // secure. $command = $this->opensslPath . ' genrsa -out ' . escapeshellarg($privateKeyFile) . ' 1024'; t3lib_utility_Command::exec($command); - // Test that we got a private key + // Test that we got a private key $privateKey = file_get_contents($privateKeyFile); if (FALSE !== strpos($privateKey, 'BEGIN RSA PRIVATE KEY')) { - // Ok, we got the private key. Get the modulus. + // Ok, we got the private key. Get the modulus. $command = $this->opensslPath . ' rsa -noout -modulus -in ' . escapeshellarg($privateKeyFile); $value = t3lib_utility_Command::exec($command); if (substr($value, 0, 8) === 'Modulus=') { $publicKey = substr($value, 8); - // Create a result object + // Create a result object $result = t3lib_div::makeInstance('tx_rsaauth_keypair'); - /* @var $result tx_rsa_keypair */ + /** @var $result tx_rsa_keypair */ $result->setExponent(0x10001); $result->setPrivateKey($privateKey); $result->setPublicKey($publicKey); @@ -116,30 +115,30 @@ class tx_rsaauth_cmdline_backend extends tx_rsaauth_abstract_backend { /** * - * @param string $privateKey The private key (obtained from a call to createNewKeyPair()) - * @param string $data Data to decrypt (base64-encoded) - * @return string Decrypted data or NULL in case of a error + * @param string $privateKey The private key (obtained from a call to createNewKeyPair()) + * @param string $data Data to decrypt (base64-encoded) + * @return string Decrypted data or NULL in case of a error * @see tx_rsaauth_abstract_backend::decrypt() */ public function decrypt($privateKey, $data) { - // Key must be put to the file + // Key must be put to the file $privateKeyFile = tempnam($this->temporaryDirectory, uniqid()); file_put_contents($privateKeyFile, $privateKey); $dataFile = tempnam($this->temporaryDirectory, uniqid()); file_put_contents($dataFile, base64_decode($data)); - // Prepare the command + // Prepare the command $command = $this->opensslPath . ' rsautl -inkey ' . escapeshellarg($privateKeyFile) . ' -in ' . escapeshellarg($dataFile) . ' -decrypt'; - // Execute the command and capture the result + // Execute the command and capture the result $output = array(); t3lib_utility_Command::exec($command, $output); - // Remove the file + // Remove the file @unlink($privateKeyFile); @unlink($dataFile); @@ -156,7 +155,7 @@ class tx_rsaauth_cmdline_backend extends tx_rsaauth_abstract_backend { public function isAvailable() { $result = FALSE; if ($this->opensslPath) { - // If path exists, test that command runs and can produce output + // If path exists, test that command runs and can produce output $test = t3lib_utility_Command::exec($this->opensslPath . ' version'); $result = (substr($test, 0, 8) == 'OpenSSL '); } diff --git a/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_keypair.php b/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_keypair.php index 87c38ad8006d..b77f3016269c 100644 --- a/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_keypair.php +++ b/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_keypair.php @@ -22,42 +22,41 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class contain an RSA keypair class. Its purpose is to keep to keys * and trasnfer these keys between other PHP classes. * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ final class tx_rsaauth_keypair { /** * RSA public exponent (3 or 0x10001) * - * @var int + * @var integer */ - protected $exponent = 0x10001; + protected $exponent = 0x10001; /** * The private key * - * @var string + * @var string */ - protected $privateKey = ''; + protected $privateKey = ''; /** * The public key modulus * - * @var string + * @var string */ - protected $publicKeyModulus = ''; + protected $publicKeyModulus = ''; /** * Retrieves the exponent. * - * @return string The exponent + * @return string The exponent */ public function getExponent() { return $this->exponent; @@ -66,8 +65,8 @@ final class tx_rsaauth_keypair { /** * Sets the private key * - * @param string $privateKey The new private key - * @return void + * @param string $privateKey The new private key + * @return void */ public function setExponent($exponent) { $this->exponent = $exponent; @@ -76,7 +75,7 @@ final class tx_rsaauth_keypair { /** * Retrieves the private key. * - * @return string The private key + * @return string The private key */ public function getPrivateKey() { return $this->privateKey; @@ -85,8 +84,8 @@ final class tx_rsaauth_keypair { /** * Sets the private key * - * @param string $privateKey The new private key - * @return void + * @param string $privateKey The new private key + * @return void */ public function setPrivateKey($privateKey) { $this->privateKey = $privateKey; @@ -95,7 +94,7 @@ final class tx_rsaauth_keypair { /** * Retrieves the public key modulus * - * @return string The public key modulus + * @return string The public key modulus */ public function getPublicKeyModulus() { return $this->publicKeyModulus; @@ -104,8 +103,8 @@ final class tx_rsaauth_keypair { /** * Sets the public key modulus * - * @param string $publicKeyModulus The new public key modulus - * @return void + * @param string $publicKeyModulus The new public key modulus + * @return void */ public function setPublicKey($publicKeyModulus) { $this->publicKeyModulus = $publicKeyModulus; diff --git a/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_php_backend.php b/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_php_backend.php index 4c1c63509596..b4f8f3399472 100644 --- a/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_php_backend.php +++ b/typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_php_backend.php @@ -22,49 +22,48 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class contains a PHP OpenSSL backend for the TYPO3 RSA authentication * service. See class tx_rsaauth_abstract_backend for the information on using * backends. * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ class tx_rsaauth_php_backend extends tx_rsaauth_abstract_backend { /** * Creates a new public/private key pair using PHP OpenSSL extension. * - * @return tx_rsaauth_keypair A new key pair or NULL in case of error + * @return tx_rsaauth_keypair A new key pair or NULL in case of error * @see tx_rsaauth_abstract_backend::createNewKeyPair() */ public function createNewKeyPair() { $result = NULL; $privateKey = @openssl_pkey_new(); if ($privateKey) { - // Create private key as string + // Create private key as string $privateKeyStr = ''; openssl_pkey_export($privateKey, $privateKeyStr); - // Prepare public key information + // Prepare public key information $exportedData = ''; $csr = openssl_csr_new(array(), $privateKey); openssl_csr_export($csr, $exportedData, FALSE); - // Get public key (in fact modulus) and exponent + // Get public key (in fact modulus) and exponent $publicKey = $this->extractPublicKeyModulus($exportedData); $exponent = $this->extractExponent($exportedData); - // Create result object + // Create result object $result = t3lib_div::makeInstance('tx_rsaauth_keypair'); - /* @var $result tx_rsaauth_keypair */ + /** @var $result tx_rsaauth_keypair */ $result->setExponent($exponent); $result->setPrivateKey($privateKeyStr); $result->setPublicKey($publicKey); - // Clean up all resources + // Clean up all resources openssl_free_key($privateKey); } return $result; @@ -74,9 +73,9 @@ class tx_rsaauth_php_backend extends tx_rsaauth_abstract_backend { * Decrypts data using the private key. This implementation uses PHP OpenSSL * extension. * - * @param string $privateKey The private key (obtained from a call to createNewKeyPair()) - * @param string $data Data to decrypt (base64-encoded) - * @return string Decrypted data or NULL in case of a error + * @param string $privateKey The private key (obtained from a call to createNewKeyPair()) + * @param string $data Data to decrypt (base64-encoded) + * @return string Decrypted data or NULL in case of a error * @see tx_rsaauth_abstract_backend::decrypt() */ public function decrypt($privateKey, $data) { @@ -112,21 +111,21 @@ class tx_rsaauth_php_backend extends tx_rsaauth_abstract_backend { /** * Extracts the exponent from the OpenSSL CSR * - * @param string $data The result of openssl_csr_export() - * @return int The exponent as a number + * @param string $data The result of openssl_csr_export() + * @return integer The exponent as a number */ protected function extractExponent($data) { $index = strpos($data, 'Exponent: '); - // We do not check for '$index === FALSE' because the exponent is - // always there! + // We do not check for '$index === FALSE' because the exponent is + // always there! return intval(substr($data, $index + 10)); } /** * Extracts public key modulus from the OpenSSL CSR. * - * @param string $data The result of openssl_csr_export() - * @return string Modulus as uppercase hex string + * @param string $data The result of openssl_csr_export() + * @return string Modulus as uppercase hex string */ protected function extractPublicKeyModulus($data) { $fragment = preg_replace('/.*Modulus.*?\n(.*)Exponent:.*/ms', '\1', $data); diff --git a/typo3/sysext/rsaauth/sv1/class.tx_rsaauth_sv1.php b/typo3/sysext/rsaauth/sv1/class.tx_rsaauth_sv1.php index fef046584f68..547b6383d7b1 100644 --- a/typo3/sysext/rsaauth/sv1/class.tx_rsaauth_sv1.php +++ b/typo3/sysext/rsaauth/sv1/class.tx_rsaauth_sv1.php @@ -24,7 +24,7 @@ require_once(t3lib_extMgm::extPath('sv') . 'class.tx_sv_auth.php'); -// Include backends + // Include backends /** * Service "RSA authentication" for the "rsaauth" extension. This service will @@ -33,40 +33,42 @@ require_once(t3lib_extMgm::extPath('sv') . 'class.tx_sv_auth.php'); * the password and then pass it to the parent service ('sv'). This ensures that it * always works, even if other TYPO3 internals change. * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ class tx_rsaauth_sv1 extends tx_sv_auth { /** * An RSA backend. * - * @var tx_rsaauth_abstract_backend + * @var tx_rsaauth_abstract_backend */ - protected $backend = NULL; + protected $backend = NULL; /** * Standard extension key for the service + * The extension key. * - * @var string + * @var string */ - public $extKey = 'rsaauth'; // The extension key. + public $extKey = 'rsaauth'; /** * Standard prefix id for the service + * Same as class name * - * @var string + * @var string */ - public $prefixId = 'tx_rsaauth_sv1'; // Same as class name + public $prefixId = 'tx_rsaauth_sv1'; /** * Standard relative path for the service + * Path to this script relative to the extension dir. * - * @var string + * @var string */ - public $scriptRelPath = 'sv1/class.tx_rsaauth_sv1.php'; // Path to this script relative to the extension dir. - + public $scriptRelPath = 'sv1/class.tx_rsaauth_sv1.php'; /** * Process the submitted credentials. @@ -74,7 +76,7 @@ class tx_rsaauth_sv1 extends tx_sv_auth { * * @param array $loginData Credentials that are submitted and potentially modified by other services * @param string $passwordTransmissionStrategy Keyword of how the password has been hashed or encrypted before submission - * @return bool + * @return boolean */ public function processLoginData(array &$loginData, $passwordTransmissionStrategy) { @@ -82,7 +84,7 @@ class tx_rsaauth_sv1 extends tx_sv_auth { if ($passwordTransmissionStrategy === 'rsa') { $storage = tx_rsaauth_storagefactory::getStorage(); - /* @var $storage tx_rsaauth_abstract_storage */ + /** @var $storage tx_rsaauth_abstract_storage */ // Decrypt the password $password = $loginData['uident']; @@ -113,12 +115,12 @@ class tx_rsaauth_sv1 extends tx_sv_auth { /** * Initializes the service. * - * @return boolean + * @return boolean */ public function init() { $available = parent::init(); if ($available) { - // Get the backend + // Get the backend $this->backend = tx_rsaauth_backendfactory::getBackend(); if (is_null($this->backend)) { $available = FALSE; diff --git a/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_abstract_storage.php b/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_abstract_storage.php index 5a3e36f04193..4543625b544e 100644 --- a/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_abstract_storage.php +++ b/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_abstract_storage.php @@ -22,27 +22,26 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class contains the abstract storage for the RSA private keys * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ abstract class tx_rsaauth_abstract_storage { /** * Retrieves the key from the storage * - * @return string The key or NULL + * @return string The key or NULL */ abstract public function get(); /** * Stores the key in the storage * - * @param string $key The key + * @param string $key The key */ abstract public function put($key); } diff --git a/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_session_storage.php b/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_session_storage.php index 9b77a892fb25..f24a426c2b44 100644 --- a/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_session_storage.php +++ b/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_session_storage.php @@ -22,7 +22,6 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class contains a session-based storage for private keys. This storage * is not secure enough because its implementation stores keys completely in the @@ -30,9 +29,9 @@ * easy to extract. This storage is useful only as an example. It is better to * use "split" storage for keys. * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ class tx_rsaauth_session_storage extends tx_rsaauth_abstract_storage { @@ -40,7 +39,7 @@ class tx_rsaauth_session_storage extends tx_rsaauth_abstract_storage { * Creates an instance of this class. It checks and initializes PHP * sessions if necessary. * - * @return void + * @return void */ public function __construct() { if (!isset($_SESSION) || !is_array($_SESSION)) { @@ -51,7 +50,7 @@ class tx_rsaauth_session_storage extends tx_rsaauth_abstract_storage { /** * Obtains key from the session * - * @return string The key or NULL + * @return string The key or NULL * @see tx_rsaauth_abstract_storage::get() */ public function get() { @@ -61,7 +60,7 @@ class tx_rsaauth_session_storage extends tx_rsaauth_abstract_storage { /** * Puts key to the session * - * @param string $key The key + * @param string $key The key * @see tx_rsaauth_abstract_storage::put() */ public function put($key) { diff --git a/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_split_storage.php b/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_split_storage.php index 05e50649eba9..ee9797fb5d92 100644 --- a/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_split_storage.php +++ b/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_split_storage.php @@ -22,22 +22,19 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class contains a "split" storage for the data. It keeps part of the data * in the database, part in the database. * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ class tx_rsaauth_split_storage extends tx_rsaauth_abstract_storage { /** * Creates an instance of this class. It checks and initializes PHP * sessions if necessary. - * - * @return void */ public function __construct() { if (session_id() === '') { @@ -48,7 +45,7 @@ class tx_rsaauth_split_storage extends tx_rsaauth_abstract_storage { /** * Obtains a key from the database * - * @return string The key or NULL + * @return string The key or NULL * @see tx_rsaauth_abstract_storage::get() */ public function get() { @@ -57,7 +54,7 @@ class tx_rsaauth_split_storage extends tx_rsaauth_abstract_storage { list($keyId, $keyPart1) = $_SESSION['tx_rsaauth_key']; if (t3lib_utility_Math::canBeInterpretedAsInteger($keyId)) { - // Remove expired keys (more than 30 minutes old) + // Remove expired keys (more than 30 minutes old) $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_rsaauth_keys', 'crdate<' . ($GLOBALS['EXEC_TIME'] - 30 * 60)); @@ -74,13 +71,13 @@ class tx_rsaauth_split_storage extends tx_rsaauth_abstract_storage { /** * Adds a key to the storage or removes existing key * - * @param string $key The key - * @return void + * @param string $key The key + * @return void * @see tx_rsaauth_abstract_storage::put() */ public function put($key) { if ($key == NULL) { - // Remove existing key + // Remove existing key list($keyId) = $_SESSION['tx_rsaauth_key']; if (t3lib_utility_Math::canBeInterpretedAsInteger($keyId)) { @@ -90,21 +87,21 @@ class tx_rsaauth_split_storage extends tx_rsaauth_abstract_storage { } } else { - // Add key + // Add key - // Get split point. First part is always smaller than the second - // because it goes to the file system + // Get split point. First part is always smaller than the second + // because it goes to the file system $keyLength = strlen($key); $splitPoint = rand(intval($keyLength/10), intval($keyLength/2)); - // Get key parts + // Get key parts $keyPart1 = substr($key, 0, $splitPoint); $keyPart2 = substr($key, $splitPoint); - // Store part of the key in the database - // - // Notice: we may not use TCEmain below to insert key part into the - // table because TCEmain requires a valid BE user! + // Store part of the key in the database + // + // Notice: we may not use TCEmain below to insert key part into the + // table because TCEmain requires a valid BE user! $time = $GLOBALS['EXEC_TIME']; $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_rsaauth_keys', array( 'pid' => 0, @@ -113,11 +110,11 @@ class tx_rsaauth_split_storage extends tx_rsaauth_abstract_storage { )); $keyId = $GLOBALS['TYPO3_DB']->sql_insert_id(); - // Store another part in session + // Store another part in session $_SESSION['tx_rsaauth_key'] = array($keyId, $keyPart1); } - // Remove expired keys (more than 30 minutes old) + // Remove expired keys (more than 30 minutes old) $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_rsaauth_keys', 'crdate<' . ($GLOBALS['EXEC_TIME'] - 30 * 60)); } diff --git a/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_storagefactory.php b/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_storagefactory.php index d961ab3ab363..1e6f9b61ed3c 100644 --- a/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_storagefactory.php +++ b/typo3/sysext/rsaauth/sv1/storage/class.tx_rsaauth_storagefactory.php @@ -22,13 +22,12 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * This class contains a factory for the RSA backends. * - * @author Dmitry Dulepov <dmitry@typo3.org> - * @package TYPO3 - * @subpackage tx_rsaauth + * @author Dmitry Dulepov <dmitry@typo3.org> + * @package TYPO3 + * @subpackage tx_rsaauth */ class tx_rsaauth_storagefactory { @@ -37,7 +36,7 @@ class tx_rsaauth_storagefactory { * This is for security reasons to avoid inserting some dummy storage to * the list. * - * @var string + * @var string */ static protected $preferredStorage = 'EXT:rsaauth/sv1/storage/class.tx_rsaauth_split_storage.php:tx_rsaauth_split_storage'; @@ -48,7 +47,7 @@ class tx_rsaauth_storagefactory { * * <!-- Please, keep the variable type! It helps IDEs to provide autocomple! --> * - * @var tx_rsaauth_abstract_storage + * @var tx_rsaauth_abstract_storage */ static protected $storageInstance = NULL; @@ -57,7 +56,7 @@ class tx_rsaauth_storagefactory { * is derieved from the tx_rsaauth_abstract_storage. Applications should * not use anoy methods that are not declared in the tx_rsaauth_abstract_storage. * - * @return tx_rsaauth_abstract_storage A storage + * @return tx_rsaauth_abstract_storage A storage */ static public function getStorage() { if (is_null(self::$storageInstance)) { @@ -70,8 +69,8 @@ class tx_rsaauth_storagefactory { * Sets the preffered storage to the factory. This method can be called from * another extension or ext_localconf.php * - * @param string $preferredStorage Preffered storage - * @return void + * @param string $preferredStorage Preffered storage + * @return void */ static public function setPreferredStorage($preferredStorage) { self::$preferredStorage = $preferredStorage; -- GitLab