1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the tmilos/jose-jwt package. |
5
|
|
|
* |
6
|
|
|
* (c) Milos Tomic <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Tmilos\JoseJwt\Context; |
13
|
|
|
|
14
|
|
|
use Tmilos\JoseJwt\Json\JsonMapper; |
15
|
|
|
use Tmilos\JoseJwt\Jwe\JweAlgorithmCollection; |
16
|
|
|
use Tmilos\JoseJwt\Jwe\JweEncryptionCollection; |
17
|
|
|
use Tmilos\JoseJwt\Jws\JwsAlgorithmCollection; |
18
|
|
|
|
19
|
|
|
class DefaultContext implements Context |
20
|
|
|
{ |
21
|
|
|
/** @var JsonMapper|null */ |
22
|
|
|
private $jsonMapper; |
23
|
|
|
|
24
|
|
|
/** @var JwsAlgorithmCollection */ |
25
|
|
|
private $jwsAlgorithms; |
26
|
|
|
|
27
|
|
|
/** @var JweAlgorithmCollection */ |
28
|
|
|
private $jweAlgorithms; |
29
|
|
|
|
30
|
|
|
/** @var JweEncryptionCollection */ |
31
|
|
|
private $jweEncryptions; |
32
|
|
|
|
33
|
|
|
public function __construct() |
34
|
|
|
{ |
35
|
|
|
$this->jwsAlgorithms = new JwsAlgorithmCollection(); |
36
|
|
|
$this->jweAlgorithms = new JweAlgorithmCollection(); |
37
|
|
|
$this->jweEncryptions = new JweEncryptionCollection(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return JsonMapper|null |
42
|
|
|
*/ |
43
|
|
|
public function jsonMapper() |
44
|
|
|
{ |
45
|
|
|
return $this->jsonMapper; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return JwsAlgorithmCollection |
50
|
|
|
*/ |
51
|
|
|
public function jwsAlgorithms() |
52
|
|
|
{ |
53
|
|
|
return $this->jwsAlgorithms; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return JweAlgorithmCollection |
58
|
|
|
*/ |
59
|
|
|
public function jweAlgorithms() |
60
|
|
|
{ |
61
|
|
|
return $this->jweAlgorithms; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return JweEncryptionCollection |
66
|
|
|
*/ |
67
|
|
|
public function jweEncryptions() |
68
|
|
|
{ |
69
|
|
|
return $this->jweEncryptions; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param JsonMapper|null $jsonMapper |
74
|
|
|
* |
75
|
|
|
* @return DefaultContext |
76
|
|
|
*/ |
77
|
|
|
public function setJsonMapper(JsonMapper $jsonMapper = null) |
78
|
|
|
{ |
79
|
|
|
$this->jsonMapper = $jsonMapper; |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|