mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-27 08:43:17 +00:00
39 lines
882 B
PHP
39 lines
882 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Util\HttpSignatures;
|
||
|
|
||
|
use Psr\Http\Message\RequestInterface;
|
||
|
|
||
|
class Signature
|
||
|
{
|
||
|
/** @var Key */
|
||
|
private $key;
|
||
|
|
||
|
/** @var AlgorithmInterface */
|
||
|
private $algorithm;
|
||
|
|
||
|
/** @var SigningString */
|
||
|
private $signingString;
|
||
|
|
||
|
/**
|
||
|
* @param RequestInterface $message
|
||
|
* @param Key $key
|
||
|
* @param AlgorithmInterface $algorithm
|
||
|
* @param HeaderList $headerList
|
||
|
*/
|
||
|
public function __construct($message, Key $key, AlgorithmInterface $algorithm, HeaderList $headerList)
|
||
|
{
|
||
|
$this->key = $key;
|
||
|
$this->algorithm = $algorithm;
|
||
|
$this->signingString = new SigningString($headerList, $message);
|
||
|
}
|
||
|
|
||
|
public function string()
|
||
|
{
|
||
|
return $this->algorithm->sign(
|
||
|
$this->key->getSigningKey(),
|
||
|
$this->signingString->string()
|
||
|
);
|
||
|
}
|
||
|
}
|