mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-14 02:24:31 +00:00
37 lines
687 B
PHP
Executable file
37 lines
687 B
PHP
Executable file
<?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");
|
|
}
|
|
}
|
|
}
|