| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Jose\Component\Encryption; |
| 6 |
|
| 7 |
use Jose\Component\Core\AlgorithmManagerFactory; |
| 8 |
use Jose\Component\Encryption\Compression\CompressionMethodManagerFactory; |
| 9 |
|
| 10 |
class JWEDecrypterFactory |
| 11 |
{ |
| 12 |
public function __construct( |
| 13 |
private readonly AlgorithmManagerFactory $algorithmManagerFactory, |
| 14 |
private readonly null|CompressionMethodManagerFactory $compressionMethodManagerFactory = null |
| 15 |
) { |
| 16 |
if ($compressionMethodManagerFactory !== null) { |
| 17 |
trigger_deprecation( |
| 18 |
'web-token/jwt-library', |
| 19 |
'3.3.0', |
| 20 |
'The parameter "$compressionMethodManagerFactory" is deprecated and will be removed in 4.0.0. Compression is not recommended for JWE. Please set "null" instead.' |
| 21 |
); |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public function create( |
| 34 |
array $encryptionAlgorithms, |
| 35 |
null|array $contentEncryptionAlgorithms = null, |
| 36 |
null|array $compressionMethods = null |
| 37 |
): JWEDecrypter { |
| 38 |
if ($contentEncryptionAlgorithms !== null) { |
| 39 |
$encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); |
| 40 |
} |
| 41 |
|
| 42 |
$algorithmManager = $this->algorithmManagerFactory->create($encryptionAlgorithms); |
| 43 |
$compressionMethodManager = $compressionMethods === null ? null : $this->compressionMethodManagerFactory?->create( |
| 44 |
$compressionMethods |
| 45 |
); |
| 46 |
|
| 47 |
return new JWEDecrypter($algorithmManager, null, $compressionMethodManager); |
| 48 |
} |
| 49 |
} |