TYPO3 CMS  TYPO3_8-7
RsaAuthService.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Rsaauth;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
27 {
31  protected $rsaEncryptionDecoder = null;
32 
39  public $extKey = 'rsaauth';
40 
47  public $prefixId = 'tx_rsaauth_sv1';
48 
57  public function processLoginData(array &$loginData, $passwordTransmissionStrategy)
58  {
59  $isProcessed = false;
60  if ($passwordTransmissionStrategy === 'rsa') {
61  $password = $loginData['uident'];
62  if (substr($password, 0, 4) === 'rsa:') {
63  $decryptedPassword = $this->getRsaEncryptionDecoder()->decrypt($password);
64  if ($decryptedPassword !== $password) {
65  $loginData['uident_text'] = $decryptedPassword;
66  $isProcessed = true;
67  } else {
68  if ($this->pObj->writeDevLog) {
69  GeneralUtility::devLog('Process login data: Failed to RSA decrypt password', self::class);
70  }
71  }
72  } else {
73  if ($this->pObj->writeDevLog) {
74  GeneralUtility::devLog('Process login data: passwordTransmissionStrategy has been set to "rsa" but no rsa encrypted password has been found.', self::class);
75  }
76  }
77  }
78  return $isProcessed;
79  }
80 
86  public function init()
87  {
88  return parent::init() && $this->getRsaEncryptionDecoder()->isAvailable();
89  }
90 
94  protected function getRsaEncryptionDecoder()
95  {
96  if ($this->rsaEncryptionDecoder === null) {
97  $this->rsaEncryptionDecoder = GeneralUtility::makeInstance(RsaEncryptionDecoder::class);
98  }
99 
101  }
102 }
static devLog($msg, $extKey, $severity=0, $dataVar=false)
processLoginData(array &$loginData, $passwordTransmissionStrategy)
static makeInstance($className,... $constructorArguments)