-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJWELoaderFactory.php
44 lines (38 loc) · 1.46 KB
/
JWELoaderFactory.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
44
<?php
declare(strict_types=1);
namespace Jose\Component\Encryption;
use Jose\Component\Checker\HeaderCheckerManagerFactory;
use Jose\Component\Encryption\Serializer\JWESerializerManagerFactory;
class JWELoaderFactory
{
public function __construct(
private readonly JWESerializerManagerFactory $jweSerializerManagerFactory,
private readonly JWEDecrypterFactory $jweDecrypterFactory,
private readonly ?HeaderCheckerManagerFactory $headerCheckerManagerFactory
) {
}
/**
* Creates a JWELoader using the given serializer aliases, encryption algorithm aliases, compression method aliases
* and header checker aliases.
*/
public function create(
array $serializers,
array $keyEncryptionAlgorithms,
array $contentEncryptionAlgorithms,
array $compressionMethods,
array $headerCheckers = []
): JWELoader {
$serializerManager = $this->jweSerializerManagerFactory->create($serializers);
$jweDecrypter = $this->jweDecrypterFactory->create(
$keyEncryptionAlgorithms,
$contentEncryptionAlgorithms,
$compressionMethods
);
if ($this->headerCheckerManagerFactory !== null) {
$headerCheckerManager = $this->headerCheckerManagerFactory->create($headerCheckers);
} else {
$headerCheckerManager = null;
}
return new JWELoader($serializerManager, $jweDecrypter, $headerCheckerManager);
}
}