Refactor Signature and SigningKeyRecord classes to allow nullable name property and update related methods
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
This commit is contained in:
parent
200b6a7c1f
commit
66ed368d75
4 changed files with 18 additions and 15 deletions
|
@ -2,7 +2,7 @@ create table signing_keys
|
|||
(
|
||||
peer_uuid varchar(36) not null comment 'The UUID of the peer',
|
||||
uuid varchar(36) default uuid() not null comment 'The UUID of the key record',
|
||||
name varchar(64) not null comment 'Optional. User provided name for the key',
|
||||
name varchar(64) null comment 'Optional. User provided name for the key',
|
||||
public_key varchar(64) not null comment 'The Public Signature Key',
|
||||
state enum ('ACTIVE', 'EXPIRED') default 'ACTIVE' not null comment 'The state of the public key',
|
||||
expires timestamp null comment 'The Timestamp for when this key expires, null = Never expires',
|
||||
|
|
|
@ -55,12 +55,12 @@
|
|||
*
|
||||
* @param string|PeerDatabaseRecord $peerUuid The unique identifier of the peer associated with the signing key.
|
||||
* @param string $publicKey The public signing key to be added. Must be valid according to the Cryptography::validatePublicSigningKey method.
|
||||
* @param string $name Optional name associated with the signing key. Must not exceed 64 characters in length.
|
||||
* @param string|null $name Optional name associated with the signing key. Must not exceed 64 characters in length.
|
||||
* @param int|null $expires Optional expiration timestamp for the signing key. Can be null if the key does not expire.
|
||||
* @return string The UUID of the newly added signing key.
|
||||
* @throws DatabaseOperationException If the operation to add the signing key to the database fails.
|
||||
*/
|
||||
public static function addSigningKey(string|PeerDatabaseRecord $peerUuid, string $publicKey, string $name, ?int $expires=null): string
|
||||
public static function addSigningKey(string|PeerDatabaseRecord $peerUuid, string $publicKey, ?string $name=null, ?int $expires=null): string
|
||||
{
|
||||
if($peerUuid instanceof PeerDatabaseRecord)
|
||||
{
|
||||
|
@ -76,6 +76,8 @@
|
|||
throw new InvalidArgumentException('The public key is invalid');
|
||||
}
|
||||
|
||||
if($name !== null)
|
||||
{
|
||||
if(empty($name))
|
||||
{
|
||||
throw new InvalidArgumentException('The name cannot be empty');
|
||||
|
@ -85,6 +87,7 @@
|
|||
{
|
||||
throw new InvalidArgumentException('The name is too long');
|
||||
}
|
||||
}
|
||||
|
||||
if($expires !== null)
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
{
|
||||
private string $peerUuid;
|
||||
private string $uuid;
|
||||
private string $name;
|
||||
private ?string $name;
|
||||
private string $publicKey;
|
||||
private SigningKeyState $state;
|
||||
private int $expires;
|
||||
|
@ -35,7 +35,7 @@
|
|||
{
|
||||
$this->peerUuid = $data['peer_uuid'];
|
||||
$this->uuid = $data['uuid'];
|
||||
$this->name = $data['name'];
|
||||
$this->name = $data['name'] ?? null;
|
||||
$this->publicKey = $data['public_key'];
|
||||
$this->state = SigningKeyState::tryFrom($data['state']);
|
||||
|
||||
|
@ -115,9 +115,9 @@
|
|||
/**
|
||||
* Retrieves the name.
|
||||
*
|
||||
* @return string The name, or null if not set.
|
||||
* @return string|null The name, or null if not set.
|
||||
*/
|
||||
public function getName(): string
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
class Signature implements SerializableInterface
|
||||
{
|
||||
private string $uuid;
|
||||
private string $name;
|
||||
private ?string $name;
|
||||
private string $publicKey;
|
||||
private SigningKeyState $state;
|
||||
private int $expires;
|
||||
|
@ -35,7 +35,7 @@
|
|||
public function __construct(array $data)
|
||||
{
|
||||
$this->uuid = $data['uuid'];
|
||||
$this->name = $data['name'];
|
||||
$this->name = $data['name'] ?? null;
|
||||
$this->publicKey = $data['public_key'];
|
||||
$this->state = SigningKeyState::from($data['state']);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue