| Total Complexity | 6 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class AbstractRsaSigner implements Signer |
||
| 12 | { |
||
| 13 | use Algorithm; |
||
| 14 | |||
| 15 | protected RsaPrivateKey $privateKey; |
||
| 16 | |||
| 17 | public function __construct(RsaPrivateKey $publicKey) |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @inheritdoc |
||
| 24 | */ |
||
| 25 | public function sign(string $message): string |
||
| 26 | { |
||
| 27 | $signature = ''; |
||
| 28 | |||
| 29 | if (openssl_sign($message, $signature, $this->privateKey->getResource(), $this->algorithm()) === true) { |
||
| 30 | return $signature; |
||
| 31 | } |
||
| 32 | |||
| 33 | throw new SigningException(openssl_error_string() ?: "OpenSSL cannot sign the token."); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @inheritDoc |
||
| 38 | */ |
||
| 39 | public function kid(): ?string |
||
| 42 | } |
||
| 43 | |||
| 44 | public function getPrivateKey(): RsaPrivateKey |
||
| 47 | } |
||
| 48 | } |
||
| 49 |