__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
declare(strict_types=1);
namespace Jose\Component\Checker;
use function array_key_exists;
use function count;
/**
* This manager handles as many claim checkers as needed.
*
* @see \Jose\Tests\Component\Checker\ClaimCheckerManagerTest
*/
class ClaimCheckerManager
{
/**
* @var ClaimChecker[]
*/
private array $checkers = [];
/**
* @param ClaimChecker[] $checkers
*/
public function __construct(iterable $checkers)
{
foreach ($checkers as $checker) {
$this->add($checker);
}
}
/**
* This method returns all checkers handled by this manager.
*
* @return ClaimChecker[]
*/
public function getCheckers(): array
{
return $this->checkers;
}
/**
* This method checks all the claims passed as argument. All claims are checked against the claim checkers. If one
* fails, the InvalidClaimException is thrown.
*
* This method returns an array with all checked claims. It is up to the implementor to decide use the claims that
* have not been checked.
*
* @param string[] $mandatoryClaims
*/
public function check(array $claims, array $mandatoryClaims = []): array
{
$this->checkMandatoryClaims($mandatoryClaims, $claims);
$checkedClaims = [];
foreach ($this->checkers as $claim => $checker) {
if (array_key_exists($claim, $claims)) {
$checker->checkClaim($claims[$claim]);
$checkedClaims[$claim] = $claims[$claim];
}
}
return $checkedClaims;
}
private function add(ClaimChecker $checker): void
{
$claim = $checker->supportedClaim();
$this->checkers[$claim] = $checker;
}
/**
* @param string[] $mandatoryClaims
*/
private function checkMandatoryClaims(array $mandatoryClaims, array $claims): void
{
if (count($mandatoryClaims) === 0) {
return;
}
$diff = array_keys(array_diff_key(array_flip($mandatoryClaims), $claims));
if (count($diff) !== 0) {
throw new MissingMandatoryClaimException(sprintf(
'The following claims are mandatory: %s.',
implode(', ', $diff)
), $diff);
}
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| AlgorithmChecker.php | File | 1.14 KB | 0664 |
|
| AudienceChecker.php | File | 1.6 KB | 0664 |
|
| CallableChecker.php | File | 1.58 KB | 0664 |
|
| ClaimChecker.php | File | 438 B | 0664 |
|
| ClaimCheckerManager.php | File | 2.26 KB | 0664 |
|
| ClaimCheckerManagerFactory.php | File | 1.6 KB | 0664 |
|
| ClaimExceptionInterface.php | File | 188 B | 0664 |
|
| ExpirationTimeChecker.php | File | 2.09 KB | 0664 |
|
| HeaderChecker.php | File | 619 B | 0664 |
|
| HeaderCheckerManager.php | File | 5.72 KB | 0664 |
|
| HeaderCheckerManagerFactory.php | File | 2.12 KB | 0664 |
|
| InternalClock.php | File | 296 B | 0664 |
|
| InvalidClaimException.php | File | 742 B | 0664 |
|
| InvalidHeaderException.php | File | 755 B | 0664 |
|
| IsEqualChecker.php | File | 1.44 KB | 0664 |
|
| IssuedAtChecker.php | File | 2.12 KB | 0664 |
|
| IssuerChecker.php | File | 1.39 KB | 0664 |
|
| MissingMandatoryClaimException.php | File | 555 B | 0664 |
|
| MissingMandatoryHeaderParameterException.php | File | 556 B | 0664 |
|
| NotBeforeChecker.php | File | 2.11 KB | 0664 |
|
| TokenTypeSupport.php | File | 976 B | 0664 |
|
| UnencodedPayloadChecker.php | File | 789 B | 0664 |
|