TYPO3 CMS  TYPO3_8-7
Keypair.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 
22 {
28  protected $exponent = 0;
29 
35  protected $privateKey = '';
36 
42  protected $publicKeyModulus = 0;
43 
49  public function isReady()
50  {
51  return $this->hasExponent() && $this->hasPrivateKey() && $this->hasPublicKeyModulus();
52  }
53 
59  public function getExponent()
60  {
61  return $this->exponent;
62  }
63 
72  public function setExponent($exponent)
73  {
74  if ($this->hasExponent()) {
75  throw new \BadMethodCallException('setExponent() must not be called more than one time.', 1296062830);
76  }
77 
78  $this->exponent = $exponent;
79  }
80 
86  protected function hasExponent()
87  {
88  return $this->getExponent() !== 0;
89  }
90 
96  public function getPrivateKey()
97  {
98  return $this->privateKey;
99  }
100 
109  public function setPrivateKey($privateKey)
110  {
111  if ($this->hasPrivateKey()) {
112  throw new \BadMethodCallException('setPrivateKey() must not be called more than one time.', 1296062831);
113  }
114 
115  $this->privateKey = $privateKey;
116  }
117 
123  protected function hasPrivateKey()
124  {
125  return $this->getPrivateKey() !== '';
126  }
127 
133  public function getPublicKeyModulus()
134  {
136  }
137 
147  {
148  if ($this->hasPublicKeyModulus()) {
149  throw new \BadMethodCallException('setPublicKey() must not be called more than one time.', 1296062832);
150  }
151 
152  $this->publicKeyModulus = $publicKeyModulus;
153  }
154 
160  protected function hasPublicKeyModulus()
161  {
162  return $this->getPublicKeyModulus() !== 0;
163  }
164 }
setExponent($exponent)
Definition: Keypair.php:72
setPrivateKey($privateKey)
Definition: Keypair.php:109
setPublicKey($publicKeyModulus)
Definition: Keypair.php:146