[TASK] Clean up phpDoc comments in typo3/sysext/rsaauth
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / sv1 / class.tx_rsaauth_sv1.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2011 Dmitry Dulepov <dmitry@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 require_once(t3lib_extMgm::extPath('sv') . 'class.tx_sv_auth.php');
26
27 // Include backends
28
29 /**
30 * Service "RSA authentication" for the "rsaauth" extension. This service will
31 * authenticate a user using hos password encoded with one time public key. It
32 * uses the standard TYPO3 service to do all dirty work. Firsts, it will decode
33 * the password and then pass it to the parent service ('sv'). This ensures that it
34 * always works, even if other TYPO3 internals change.
35 *
36 * @author Dmitry Dulepov <dmitry@typo3.org>
37 * @package TYPO3
38 * @subpackage tx_rsaauth
39 */
40 class tx_rsaauth_sv1 extends tx_sv_auth {
41
42 /**
43 * An RSA backend.
44 *
45 * @var tx_rsaauth_abstract_backend
46 */
47 protected $backend = NULL;
48
49 /**
50 * Standard extension key for the service
51 * The extension key.
52 *
53 * @var string
54 */
55 public $extKey = 'rsaauth';
56
57 /**
58 * Standard prefix id for the service
59 * Same as class name
60 *
61 * @var string
62 */
63 public $prefixId = 'tx_rsaauth_sv1';
64
65 /**
66 * Standard relative path for the service
67 * Path to this script relative to the extension dir.
68 *
69 * @var string
70 */
71 public $scriptRelPath = 'sv1/class.tx_rsaauth_sv1.php';
72
73 /**
74 * Process the submitted credentials.
75 * In this case decrypt the password if it is RSA encrypted.
76 *
77 * @param array $loginData Credentials that are submitted and potentially modified by other services
78 * @param string $passwordTransmissionStrategy Keyword of how the password has been hashed or encrypted before submission
79 * @return boolean
80 */
81 public function processLoginData(array &$loginData, $passwordTransmissionStrategy) {
82
83 $isProcessed = FALSE;
84
85 if ($passwordTransmissionStrategy === 'rsa') {
86 $storage = tx_rsaauth_storagefactory::getStorage();
87 /** @var $storage tx_rsaauth_abstract_storage */
88
89 // Decrypt the password
90 $password = $loginData['uident'];
91 $key = $storage->get();
92 if ($key != NULL && substr($password, 0, 4) === 'rsa:') {
93 // Decode password and store it in loginData
94 $decryptedPassword = $this->backend->decrypt($key, substr($password, 4));
95 if ($decryptedPassword != NULL) {
96 $loginData['uident_text'] = $decryptedPassword;
97 $isProcessed = TRUE;
98 } else {
99 if ($this->pObj->writeDevLog) {
100 t3lib_div::devLog('Process login data: Failed to RSA decrypt password', 'tx_rsaauth_sv1');
101 }
102 }
103 // Remove the key
104 $storage->put(NULL);
105 } else {
106 if ($this->pObj->writeDevLog) {
107 t3lib_div::devLog('Process login data: passwordTransmissionStrategy has been set to "rsa" but no rsa encrypted password has been found.', 'tx_rsaauth_sv1');
108 }
109 }
110 }
111
112 return $isProcessed;
113 }
114
115 /**
116 * Initializes the service.
117 *
118 * @return boolean
119 */
120 public function init() {
121 $available = parent::init();
122 if ($available) {
123 // Get the backend
124 $this->backend = tx_rsaauth_backendfactory::getBackend();
125 if (is_null($this->backend)) {
126 $available = FALSE;
127 }
128 }
129
130 return $available;
131 }
132 }
133 ?>