Skip to content

Commit b6d22a4

Browse files
authored
Preparation 3.0 (#323)
* Preparation 3.0 * Update with ECS and Rector * Bugs fixed
1 parent 4fbb49e commit b6d22a4

File tree

151 files changed

+1508
-2729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+1508
-2729
lines changed

Controller/JWKSetController.php

+3-17
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,15 @@
22

33
declare(strict_types=1);
44

5-
/*
6-
* The MIT License (MIT)
7-
*
8-
* Copyright (c) 2014-2020 Spomky-Labs
9-
*
10-
* This software may be modified and distributed under the terms
11-
* of the MIT license. See the LICENSE file for details.
12-
*/
13-
145
namespace Jose\Bundle\JoseFramework\Controller;
156

167
use Symfony\Component\HttpFoundation\Response;
178

189
class JWKSetController
1910
{
20-
/**
21-
* @var string
22-
*/
23-
private $jwkset;
24-
25-
public function __construct(string $jwkset)
26-
{
27-
$this->jwkset = $jwkset;
11+
public function __construct(
12+
private string $jwkset
13+
) {
2814
}
2915

3016
public function __invoke(): Response

Controller/JWKSetControllerFactory.php

-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22

33
declare(strict_types=1);
44

5-
/*
6-
* The MIT License (MIT)
7-
*
8-
* Copyright (c) 2014-2020 Spomky-Labs
9-
*
10-
* This software may be modified and distributed under the terms
11-
* of the MIT license. See the LICENSE file for details.
12-
*/
13-
145
namespace Jose\Bundle\JoseFramework\Controller;
156

167
use Jose\Component\Core\JWKSet;

DataCollector/AlgorithmCollector.php

+19-22
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22

33
declare(strict_types=1);
44

5-
/*
6-
* The MIT License (MIT)
7-
*
8-
* Copyright (c) 2014-2020 Spomky-Labs
9-
*
10-
* This software may be modified and distributed under the terms
11-
* of the MIT license. See the LICENSE file for details.
12-
*/
13-
145
namespace Jose\Bundle\JoseFramework\DataCollector;
156

167
use function array_key_exists;
@@ -27,14 +18,9 @@
2718

2819
final class AlgorithmCollector implements Collector
2920
{
30-
/**
31-
* @var AlgorithmManagerFactory
32-
*/
33-
private $algorithmManagerFactory;
34-
35-
public function __construct(AlgorithmManagerFactory $algorithmManagerFactory)
36-
{
37-
$this->algorithmManagerFactory = $algorithmManagerFactory;
21+
public function __construct(
22+
private AlgorithmManagerFactory $algorithmManagerFactory
23+
) {
3824
}
3925

4026
public function collect(array &$data, Request $request, Response $response, ?Throwable $exception = null): void
@@ -49,8 +35,14 @@ public function collect(array &$data, Request $request, Response $response, ?Thr
4935
$keyEncryptionAlgorithms = 0;
5036
$contentEncryptionAlgorithms = 0;
5137
foreach ($algorithms as $alias => $algorithm) {
52-
$type = $this->getAlgorithmType($algorithm, $signatureAlgorithms, $macAlgorithms, $keyEncryptionAlgorithms, $contentEncryptionAlgorithms);
53-
if (!array_key_exists($type, $data['algorithm']['algorithms'])) {
38+
$type = $this->getAlgorithmType(
39+
$algorithm,
40+
$signatureAlgorithms,
41+
$macAlgorithms,
42+
$keyEncryptionAlgorithms,
43+
$contentEncryptionAlgorithms
44+
);
45+
if (! array_key_exists($type, $data['algorithm']['algorithms'])) {
5446
$data['algorithm']['algorithms'][$type] = [];
5547
}
5648
$data['algorithm']['algorithms'][$type][$alias] = [
@@ -66,8 +58,13 @@ public function collect(array &$data, Request $request, Response $response, ?Thr
6658
];
6759
}
6860

69-
private function getAlgorithmType(Algorithm $algorithm, int &$signatureAlgorithms, int &$macAlgorithms, int &$keyEncryptionAlgorithms, int &$contentEncryptionAlgorithms): string
70-
{
61+
private function getAlgorithmType(
62+
Algorithm $algorithm,
63+
int &$signatureAlgorithms,
64+
int &$macAlgorithms,
65+
int &$keyEncryptionAlgorithms,
66+
int &$contentEncryptionAlgorithms
67+
): string {
7168
switch (true) {
7269
case $algorithm instanceof SignatureAlgorithm:
7370
$signatureAlgorithms++;
@@ -198,7 +195,7 @@ private function getAlgorithmMessages(): array
198195
'message' => 'This algorithm is not secured (known attacks). See <a target="_blank" href="https://tools.ietf.org/html/draft-irtf-cfrg-webcrypto-algorithms-00#section-5">https://tools.ietf.org/html/draft-irtf-cfrg-webcrypto-algorithms-00#section-5</a>.',
199196
],
200197
];
201-
if (!function_exists('openssl_pkey_derive')) {
198+
if (! function_exists('openssl_pkey_derive')) {
202199
$messages += [
203200
'ECDH-ES' => [
204201
'severity' => 'severity-medium',

DataCollector/CheckerCollector.php

+13-44
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22

33
declare(strict_types=1);
44

5-
/*
6-
* The MIT License (MIT)
7-
*
8-
* Copyright (c) 2014-2020 Spomky-Labs
9-
*
10-
* This software may be modified and distributed under the terms
11-
* of the MIT license. See the LICENSE file for details.
12-
*/
13-
145
namespace Jose\Bundle\JoseFramework\DataCollector;
156

167
use Jose\Bundle\JoseFramework\Event\ClaimCheckedFailureEvent;
@@ -29,50 +20,28 @@
2920

3021
class CheckerCollector implements Collector, EventSubscriberInterface
3122
{
32-
/**
33-
* @var null|ClaimCheckerManagerFactory
34-
*/
35-
private $claimCheckerManagerFactory;
36-
37-
/**
38-
* @var null|HeaderCheckerManagerFactory
39-
*/
40-
private $headerCheckerManagerFactory;
41-
42-
/**
43-
* @var array
44-
*/
45-
private $headerCheckedSuccesses = [];
23+
private array $headerCheckedSuccesses = [];
4624

47-
/**
48-
* @var array
49-
*/
50-
private $headerCheckedFailures = [];
25+
private array $headerCheckedFailures = [];
5126

52-
/**
53-
* @var array
54-
*/
55-
private $claimCheckedSuccesses = [];
27+
private array $claimCheckedSuccesses = [];
5628

57-
/**
58-
* @var array
59-
*/
60-
private $claimCheckedFailures = [];
29+
private array $claimCheckedFailures = [];
6130

6231
/**
6332
* @var HeaderCheckerManager[]
6433
*/
65-
private $headerCheckerManagers = [];
34+
private array $headerCheckerManagers = [];
6635

6736
/**
6837
* @var ClaimCheckerManager[]
6938
*/
70-
private $claimCheckerManagers = [];
39+
private array $claimCheckerManagers = [];
7140

72-
public function __construct(?ClaimCheckerManagerFactory $claimCheckerManagerFactory = null, ?HeaderCheckerManagerFactory $headerCheckerManagerFactory = null)
73-
{
74-
$this->claimCheckerManagerFactory = $claimCheckerManagerFactory;
75-
$this->headerCheckerManagerFactory = $headerCheckerManagerFactory;
41+
public function __construct(
42+
private ?ClaimCheckerManagerFactory $claimCheckerManagerFactory = null,
43+
private ?HeaderCheckerManagerFactory $headerCheckerManagerFactory = null
44+
) {
7645
}
7746

7847
public function collect(array &$data, Request $request, Response $response, ?Throwable $exception = null): void
@@ -94,7 +63,7 @@ public function addClaimCheckerManager(string $id, ClaimCheckerManager $claimChe
9463
$this->claimCheckerManagers[$id] = $claimCheckerManager;
9564
}
9665

97-
public static function getSubscribedEvents()
66+
public static function getSubscribedEvents(): array
9867
{
9968
return [
10069
HeaderCheckedSuccessEvent::class => ['catchHeaderCheckSuccess'],
@@ -145,7 +114,7 @@ private function collectHeaderCheckerManagers(array &$data): void
145114
private function collectSupportedHeaderCheckers(array &$data): void
146115
{
147116
$data['checker']['header_checkers'] = [];
148-
if (null !== $this->headerCheckerManagerFactory) {
117+
if ($this->headerCheckerManagerFactory !== null) {
149118
$aliases = $this->headerCheckerManagerFactory->all();
150119
foreach ($aliases as $alias => $checker) {
151120
$data['checker']['header_checkers'][$alias] = [
@@ -172,7 +141,7 @@ private function collectClaimCheckerManagers(array &$data): void
172141
private function collectSupportedClaimCheckers(array &$data): void
173142
{
174143
$data['checker']['claim_checkers'] = [];
175-
if (null !== $this->claimCheckerManagerFactory) {
144+
if ($this->claimCheckerManagerFactory !== null) {
176145
$aliases = $this->claimCheckerManagerFactory->all();
177146
foreach ($aliases as $alias => $checker) {
178147
$data['checker']['claim_checkers'][$alias] = [

DataCollector/Collector.php

-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22

33
declare(strict_types=1);
44

5-
/*
6-
* The MIT License (MIT)
7-
*
8-
* Copyright (c) 2014-2020 Spomky-Labs
9-
*
10-
* This software may be modified and distributed under the terms
11-
* of the MIT license. See the LICENSE file for details.
12-
*/
13-
145
namespace Jose\Bundle\JoseFramework\DataCollector;
156

167
use Symfony\Component\HttpFoundation\Request;

0 commit comments

Comments
 (0)