-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJWEBuilderFactory.php
43 lines (37 loc) · 1.48 KB
/
JWEBuilderFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace Jose\Bundle\JoseFramework\Services;
use Jose\Component\Core\AlgorithmManagerFactory;
use Jose\Component\Encryption\Compression\CompressionMethodManagerFactory;
use Psr\EventDispatcher\EventDispatcherInterface;
final class JWEBuilderFactory
{
public function __construct(
private readonly AlgorithmManagerFactory $algorithmManagerFactory,
private readonly CompressionMethodManagerFactory $compressionMethodManagerFactory,
private readonly EventDispatcherInterface $eventDispatcher
) {
}
/**
* This method creates a JWEBuilder using the given algorithm aliases.
*
* @param string[] $keyEncryptionAlgorithms
* @param string[] $contentEncryptionAlgorithm
* @param string[] $compressionMethods
*/
public function create(
array $keyEncryptionAlgorithms,
array $contentEncryptionAlgorithm,
array $compressionMethods
): JWEBuilder {
$keyEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($keyEncryptionAlgorithms);
$contentEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($contentEncryptionAlgorithm);
$compressionMethodManager = $this->compressionMethodManagerFactory->create($compressionMethods);
return new JWEBuilder(
$keyEncryptionAlgorithmManager,
$contentEncryptionAlgorithmManager,
$compressionMethodManager,
$this->eventDispatcher
);
}
}