Extract public key from private pem file at runtime

This commit is contained in:
ErickSkrauch
2024-06-14 03:03:10 +02:00
parent ca304261a3
commit 0a666e1e12
12 changed files with 33 additions and 80 deletions

View File

@ -6,21 +6,24 @@ namespace api\components\Tokens;
use api\components\Tokens\Algorithms\AlgorithmInterface;
use Webmozart\Assert\Assert;
class AlgorithmsManager {
final class AlgorithmsManager {
/**
* @var AlgorithmInterface[]
*/
private $algorithms = [];
private array $algorithms = [];
/**
* @param AlgorithmInterface[] $algorithms
*/
public function __construct(array $algorithms = []) {
array_map([$this, 'add'], $algorithms);
}
public function add(AlgorithmInterface $algorithm): self {
$id = $algorithm->getAlgorithmId();
$id = $algorithm->getSigner()->getAlgorithmId();
Assert::keyNotExists($this->algorithms, $id, 'passed algorithm is already exists');
$this->algorithms[$algorithm->getSigner()->getAlgorithmId()] = $algorithm;
$this->algorithms[$id] = $algorithm;
return $this;
}