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

Closed
netkas wants to merge 421 commits from master into dev
4 changed files with 59 additions and 7 deletions
Showing only changes of commit 7bf5419ce3 - Show all commits

View file

@ -0,0 +1,46 @@
<?php
namespace Socialbox\Classes\CliCommands;
use Socialbox\Classes\Configuration;
use Socialbox\Classes\Logger;
use Socialbox\Interfaces\CliCommandInterface;
class DnsRecordCommand implements CliCommandInterface
{
/**
* @inheritDoc
*/
public static function execute(array $args): int
{
$txt_record = sprintf('v=socialbox;sb-rpc=%s;sb-key=%s',
Configuration::getInstanceConfiguration()->getRpcEndpoint(),
Configuration::getInstanceConfiguration()->getPublicKey()
);
Logger::getLogger()->info('Please set the following DNS TXT record for the domain:');
Logger::getLogger()->info(sprintf(' %s', $txt_record));
return 0;
}
/**
* @inheritDoc
*/
public static function getHelpMessage(): string
{
return <<<HELP
Usage: socialbox dns-record
Displays the DNS TXT record that should be set for the domain.
HELP;
}
/**
* @inheritDoc
*/
public static function getShortHelpMessage(): string
{
return 'Displays the DNS TXT record that should be set for the domain.';
}
}

View file

@ -3,7 +3,6 @@
namespace Socialbox\Classes; namespace Socialbox\Classes;
use LogLib\Log; use LogLib\Log;
use function Symfony\Component\String\s;
class Logger class Logger
{ {

View file

@ -2,13 +2,13 @@
namespace Socialbox\Enums; namespace Socialbox\Enums;
use Socialbox\Classes\CliCommands\HelpCommand; use Socialbox\Classes\CliCommands\DnsRecordCommand;
use Socialbox\Classes\CliCommands\InitializeCommand; use Socialbox\Classes\CliCommands\InitializeCommand;
enum CliCommands : string enum CliCommands : string
{ {
case INITIALIZE = 'init'; case INITIALIZE = 'init';
case CLIENT = 'client'; case DNS_RECORD = 'dns-record';
/** /**
* Handles the command execution, returns the exit code. * Handles the command execution, returns the exit code.
@ -21,14 +21,15 @@ enum CliCommands : string
return match ($this) return match ($this)
{ {
self::INITIALIZE => InitializeCommand::execute($args), self::INITIALIZE => InitializeCommand::execute($args),
self::CLIENT => ClientCommand::execute($args) self::DNS_RECORD => DnsRecordCommand::execute($args)
}; };
} }
public function getHelpMessage(): string public function getHelpMessage(): string
{ {
return match ($this) return match ($this)
{ {
self::INITIALIZE => InitializeCommand::getHelpMessage() self::INITIALIZE => InitializeCommand::getHelpMessage(),
self::DNS_RECORD => DnsRecordCommand::getHelpMessage()
}; };
} }
@ -36,7 +37,8 @@ enum CliCommands : string
{ {
return match ($this) return match ($this)
{ {
self::INITIALIZE => InitializeCommand::getShortHelpMessage() self::INITIALIZE => InitializeCommand::getShortHelpMessage(),
self::DNS_RECORD => DnsRecordCommand::getShortHelpMessage()
}; };
} }
} }

View file

@ -33,7 +33,7 @@
return 0; return 0;
} }
print($command->getHelpMessage()); print($command->getHelpMessage() . "\n");
return 0; return 0;
} }
@ -42,6 +42,11 @@
return CliCommands::INITIALIZE->handle($args); return CliCommands::INITIALIZE->handle($args);
} }
if(isset($args[CliCommands::DNS_RECORD->value]))
{
return CliCommands::DNS_RECORD->handle($args);
}
return self::displayHelp(); return self::displayHelp();
} }