1 | <?php |
||
19 | final class JWEFactory |
||
20 | { |
||
21 | /** |
||
22 | * @param mixed $payload |
||
23 | * @param array $shared_protected_headers |
||
24 | * @param array $shared_headers |
||
25 | * @param null|string $aad |
||
26 | * |
||
27 | * @return \Jose\Object\JWEInterface |
||
28 | */ |
||
29 | public static function createJWE($payload, array $shared_protected_headers = [], array $shared_headers = [], $aad = null) |
||
30 | { |
||
31 | $jwe = new JWE(); |
||
32 | $jwe = $jwe->withSharedProtectedHeaders($shared_protected_headers); |
||
33 | $jwe = $jwe->withSharedHeaders($shared_headers); |
||
34 | $jwe = $jwe->withPayload($payload); |
||
35 | |||
36 | if (null !== $aad) { |
||
37 | $jwe = $jwe->withAAD($aad); |
||
38 | } |
||
39 | |||
40 | return $jwe; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @param mixed $payload |
||
45 | * @param \Jose\Object\JWKInterface $recipient_key |
||
46 | * @param array $shared_protected_headers |
||
47 | * @param \Psr\Log\LoggerInterface|null $logger |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | public static function createJWEToCompactJSON($payload, JWKInterface $recipient_key, array $shared_protected_headers, LoggerInterface $logger = null) |
||
57 | |||
58 | /** |
||
59 | * @param mixed $payload |
||
60 | * @param \Jose\Object\JWKInterface $recipient_key |
||
61 | * @param array $shared_protected_headers |
||
62 | * @param array $shared_headers |
||
63 | * @param array $recipient_headers |
||
64 | * @param string|null $aad |
||
65 | * @param \Psr\Log\LoggerInterface|null $logger |
||
66 | * |
||
67 | * @return \Jose\Object\JWSInterface |
||
68 | */ |
||
69 | public static function createJWEToFlattenedJSON($payload, JWKInterface $recipient_key, array $shared_protected_headers = [], $shared_headers = [], $recipient_headers = [], $aad = null, LoggerInterface $logger = null) |
||
75 | |||
76 | /** |
||
77 | * @param mixed $payload |
||
78 | * @param \Jose\Object\JWKInterface $recipient_key |
||
79 | * @param array $shared_protected_headers |
||
80 | * @param array $shared_headers |
||
81 | * @param array $recipient_headers |
||
82 | * @param string|null $aad |
||
83 | * @param \Psr\Log\LoggerInterface|null $logger |
||
84 | * |
||
85 | * @return \Jose\Object\JWSInterface |
||
86 | */ |
||
87 | private static function createJWEAndEncrypt($payload, JWKInterface $recipient_key, array $shared_protected_headers = [], $shared_headers = [], $recipient_headers = [], $aad = null, LoggerInterface $logger = null) |
||
102 | } |
||
103 |