Skip to content

Commit 6c702ab

Browse files
authored
Php doc (#95)
* PHPDoc updated for all public methods.
1 parent ba5480a commit 6c702ab

File tree

148 files changed

+628
-155
lines changed

Some content is hidden

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

148 files changed

+628
-155
lines changed

src/Bundle/JoseFramework/DataCollector/JWECollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private function collectSupportedJWELoaders(array &$data)
125125
$data['jwe']['jwe_loaders'] = [];
126126
foreach ($this->jweLoaders as $id => $jweLoader) {
127127
$data['jwe']['jwe_loaders'][$id] = [
128-
'serializers' => $jweLoader->getSerializerManager()->list(),
128+
'serializers' => $jweLoader->getSerializerManager()->names(),
129129
'key_encryption_algorithms' => $jweLoader->getJweDecrypter()->getKeyEncryptionAlgorithmManager()->list(),
130130
'content_encryption_algorithms' => $jweLoader->getJweDecrypter()->getContentEncryptionAlgorithmManager()->list(),
131131
'compression_methods' => $jweLoader->getJweDecrypter()->getCompressionMethodManager()->list(),

src/Bundle/JoseFramework/Tests/Functional/Encryption/JWELoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function theWELoaderFactoryCanCreateAJWELoader()
5858
$jwe = $jweLoaderFactory->create(['jwe_compact'], ['RSA1_5'], ['A256GCM'], ['DEF']);
5959

6060
self::assertInstanceOf(JWELoader::class, $jwe);
61-
self::assertEquals(['jwe_compact'], $jwe->getSerializerManager()->list());
61+
self::assertEquals(['jwe_compact'], $jwe->getSerializerManager()->names());
6262
self::assertEquals(['RSA1_5'], $jwe->getJweDecrypter()->getKeyEncryptionAlgorithmManager()->list());
6363
self::assertEquals(['A256GCM'], $jwe->getJweDecrypter()->getContentEncryptionAlgorithmManager()->list());
6464
self::assertEquals(['DEF'], $jwe->getJweDecrypter()->getCompressionMethodManager()->list());

src/Component/Checker/AlgorithmChecker.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313

1414
namespace Jose\Component\Checker;
1515

16-
class AlgorithmChecker implements HeaderChecker
16+
/**
17+
* This class is a header parameter checker.
18+
* When the "alg" header parameter is present, it will check if the value is within the allowed ones.
19+
*/
20+
final class AlgorithmChecker implements HeaderChecker
1721
{
1822
private const HEADER_NAME = 'alg';
1923

src/Component/Checker/AudienceChecker.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313

1414
namespace Jose\Component\Checker;
1515

16-
class AudienceChecker implements ClaimChecker, HeaderChecker
16+
/**
17+
* This class is a header parameter and claim checker.
18+
* When the "aud" header parameter or claim is present, it will check if the value is within the allowed ones.
19+
*/
20+
final class AudienceChecker implements ClaimChecker, HeaderChecker
1721
{
1822
private const CLAIM_NAME = 'aud';
1923

src/Component/Checker/ClaimChecker.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@
1616
interface ClaimChecker
1717
{
1818
/**
19+
* When the token has the applicable claim, the value is checked.
20+
* If for some reason the value is not valid, an InvalidClaimException must be thrown.
21+
*
1922
* @param mixed $value
2023
*
21-
* @throws \InvalidArgumentException
24+
* @throws InvalidClaimException
2225
*/
2326
public function checkClaim($value);
2427

2528
/**
29+
* The method returns the claim to be checked.
30+
*
2631
* @return string
2732
*/
2833
public function supportedClaim(): string;

src/Component/Checker/ClaimCheckerManager.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
namespace Jose\Component\Checker;
1515

16+
/**
17+
* This manager handles as many claim checkers as needed.
18+
*/
1619
class ClaimCheckerManager
1720
{
1821
/**
@@ -33,6 +36,9 @@ private function __construct(array $checkers)
3336
}
3437

3538
/**
39+
* This method creates the ClaimCheckerManager.
40+
* The argument is a list of claim checkers objects.
41+
*
3642
* @param ClaimChecker[] $checkers
3743
*
3844
* @return ClaimCheckerManager
@@ -56,6 +62,8 @@ private function add(ClaimChecker $checker): self
5662
}
5763

5864
/**
65+
* This method returns all checkers handled by this manager.
66+
*
5967
* @return ClaimChecker[]
6068
*/
6169
public function getCheckers(): array
@@ -64,8 +72,17 @@ public function getCheckers(): array
6472
}
6573

6674
/**
75+
* This method checks all the claims passed as argument.
76+
* All claims are checked against the claim checkers.
77+
* If one fails, the InvalidClaimException is thrown.
78+
*
79+
* This method returns an array with all checked claims.
80+
* It is up to the implementor to decide use the claims that have not been checked.
81+
*
6782
* @param array $claims
6883
*
84+
* @throws InvalidClaimException
85+
*
6986
* @return array
7087
*/
7188
public function check(array $claims): array

src/Component/Checker/ClaimCheckerManagerFactory.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class ClaimCheckerManagerFactory
2121
private $checkers = [];
2222

2323
/**
24+
* This method creates a Claim Checker Manager and populate it with the claim checkers found based on the alias.
25+
* If the alias is not supported, an InvalidArgumentException is thrown.
26+
*
2427
* @param string[] $aliases
2528
*
2629
* @return ClaimCheckerManager
@@ -40,6 +43,8 @@ public function create(array $aliases): ClaimCheckerManager
4043
}
4144

4245
/**
46+
* This method adds a claim checker to this factory.
47+
*
4348
* @param string $alias
4449
* @param ClaimChecker $checker
4550
*
@@ -53,6 +58,8 @@ public function add(string $alias, ClaimChecker $checker): self
5358
}
5459

5560
/**
61+
* Returns all claim checker aliases supported by this factory.
62+
*
5663
* @return string[]
5764
*/
5865
public function aliases(): array
@@ -61,6 +68,8 @@ public function aliases(): array
6168
}
6269

6370
/**
71+
* Returns all claim checkers supported by this factory.
72+
*
6473
* @return ClaimChecker[]
6574
*/
6675
public function all(): array

src/Component/Checker/ExpirationTimeChecker.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313

1414
namespace Jose\Component\Checker;
1515

16-
class ExpirationTimeChecker implements ClaimChecker
16+
/**
17+
* This class is a claim checker.
18+
* When the "exp" is present, it will compare the value with the current timestamp.
19+
*
20+
* A time drift is allowed but its use is NOT recommended.
21+
*/
22+
final class ExpirationTimeChecker implements ClaimChecker
1723
{
1824
private const CLAIM_NAME = 'exp';
1925

src/Component/Checker/HeaderChecker.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,25 @@
1616
interface HeaderChecker
1717
{
1818
/**
19+
* This method is called when the header parameter is present.
20+
* If for some reason the value is not valid, an InvalidHeaderException must be thrown.
21+
*
1922
* @param mixed $value
2023
*
21-
* @throws \InvalidArgumentException
24+
* @throws InvalidHeaderException
2225
*/
2326
public function checkHeader($value);
2427

2528
/**
29+
* The method returns the header parameter to be checked.
30+
*
2631
* @return string
2732
*/
2833
public function supportedHeader(): string;
2934

3035
/**
36+
* When true, the header parameter to be checked MUST be set in the protected header of the token.
37+
*
3138
* @return bool
3239
*/
3340
public function protectedHeaderOnly(): bool;

src/Component/Checker/HeaderCheckerManager.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ private function __construct(array $checkers, array $tokenTypes)
4444
}
4545

4646
/**
47+
* This method creates the HeaderCheckerManager.
48+
* The first argument is a list of header parameter checkers objects.
49+
* The second argument is a list of token type support objects.
50+
* It is recommended to support only one token type per manager.
51+
*
4752
* @param HeaderChecker[] $checkers
4853
* @param TokenTypeSupport[] $tokenTypes
4954
*
@@ -55,6 +60,8 @@ public static function create(array $checkers, array $tokenTypes): self
5560
}
5661

5762
/**
63+
* This method returns all checkers handled by this manager.
64+
*
5865
* @return HeaderChecker[]
5966
*/
6067
public function getCheckers(): array
@@ -88,18 +95,22 @@ private function add(HeaderChecker $checker): self
8895
}
8996

9097
/**
98+
* This method checks all the header parameters passed as argument.
99+
* All header parameters are checked against the header parameter checkers.
100+
* If one fails, the InvalidHeaderException is thrown.
101+
*
91102
* @param JWT $jwt
92-
* @param int $component
103+
* @param int $index
93104
*
94105
* @throws InvalidHeaderException
95106
*/
96-
public function check(JWT $jwt, int $component)
107+
public function check(JWT $jwt, int $index)
97108
{
98109
foreach ($this->tokenTypes as $tokenType) {
99110
if ($tokenType->supports($jwt)) {
100111
$protected = [];
101112
$unprotected = [];
102-
$tokenType->retrieveTokenHeaders($jwt, $component, $protected, $unprotected);
113+
$tokenType->retrieveTokenHeaders($jwt, $index, $protected, $unprotected);
103114
$this->checkDuplicatedHeaderParameters($protected, $unprotected);
104115
$this->checkHeaders($protected, $unprotected);
105116

0 commit comments

Comments
 (0)