-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
NestedTokenBuilderFactory.php
45 lines (39 loc) · 1.64 KB
/
NestedTokenBuilderFactory.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
45
<?php
declare(strict_types=1);
namespace Jose\Component\NestedToken;
use Jose\Component\Encryption\JWEBuilderFactory;
use Jose\Component\Encryption\Serializer\JWESerializerManagerFactory;
use Jose\Component\Signature\JWSBuilderFactory;
use Jose\Component\Signature\Serializer\JWSSerializerManagerFactory;
class NestedTokenBuilderFactory
{
public function __construct(
private readonly JWEBuilderFactory $jweBuilderFactory,
private readonly JWESerializerManagerFactory $jweSerializerManagerFactory,
private readonly JWSBuilderFactory $jwsBuilderFactory,
private readonly JWSSerializerManagerFactory $jwsSerializerManagerFactory
) {
}
/**
* This method creates a Nested Token Builder with the given encryption/signature algorithms, serializers and
* compression methods.
*/
public function create(
array $jwe_serializers,
array $keyEncryptionAlgorithms,
array $contentEncryptionAlgorithms,
array $compressionMethods,
array $jws_serializers,
array $signatureAlgorithms
): NestedTokenBuilder {
$jweBuilder = $this->jweBuilderFactory->create(
$keyEncryptionAlgorithms,
$contentEncryptionAlgorithms,
$compressionMethods
);
$jweSerializerManager = $this->jweSerializerManagerFactory->create($jwe_serializers);
$jwsBuilder = $this->jwsBuilderFactory->create($signatureAlgorithms);
$jwsSerializerManager = $this->jwsSerializerManagerFactory->create($jws_serializers);
return new NestedTokenBuilder($jweBuilder, $jweSerializerManager, $jwsBuilder, $jwsSerializerManager);
}
}