Made message signing in Cryptography use SHA512 as the message content for... #1

Closed
netkas wants to merge 421 commits from master into dev
Showing only changes of commit cd4a45c811 - Show all commits

View file

@ -0,0 +1,50 @@
<?php
namespace Socialbox\Classes\StandardMethods\Settings;
use Exception;
use InvalidArgumentException;
use ncc\ThirdParty\Symfony\Uid\Uuid;
use Socialbox\Abstracts\Method;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\SigningKeysManager;
use Socialbox\Objects\ClientRequest;
use Socialbox\Objects\RpcRequest;
class SettingsSignatureExists extends Method
{
/**
* @inheritDoc
*/
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
{
if(!$rpcRequest->containsParameter('uuid'))
{
throw new MissingRpcArgumentException('uuid');
}
try
{
$uuid = Uuid::fromString($rpcRequest->getParameter('uuid'));
}
catch(InvalidArgumentException)
{
throw new InvalidRpcArgumentException('uuid');
}
try
{
return $rpcRequest->produceResponse(SigningKeysManager::signingKeyExists($request->getPeer()->getUuid(), $uuid));
}
catch(DatabaseOperationException $e)
{
throw new StandardRpcException('Failed to check the signing key existence', StandardError::INTERNAL_SERVER_ERROR, $e);
}
}
}