mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
687 B
PHP
37 lines
687 B
PHP
<?php
|
|
|
|
namespace App\Util\HttpSignatures;
|
|
|
|
class KeyStore implements KeyStoreInterface
|
|
{
|
|
/** @var Key[] */
|
|
private $keys;
|
|
|
|
/**
|
|
* @param array $keys
|
|
*/
|
|
public function __construct($keys)
|
|
{
|
|
$this->keys = [];
|
|
foreach ($keys as $id => $key) {
|
|
$this->keys[$id] = new Key($id, $key);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param string $keyId
|
|
*
|
|
* @return Key
|
|
*
|
|
* @throws KeyStoreException
|
|
*/
|
|
public function fetch($keyId)
|
|
{
|
|
if (isset($this->keys[$keyId])) {
|
|
return $this->keys[$keyId];
|
|
} else {
|
|
throw new KeyStoreException("Key '$keyId' not found");
|
|
}
|
|
}
|
|
}
|