| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/c/o/o/coopiak/amisdesseniors-fr/catalog/libraries/vendor/php-tuf/php-tuf/src/ |
Upload File : |
<?php
namespace Tuf;
use Tuf\Metadata\ConstraintsTrait;
/**
* Class that represents a TUF role.
*/
class Role
{
use ConstraintsTrait;
/**
* Role constructor.
*
* @param string $name
* The name of the role.
* @param int $threshold
* The role threshold.
* @param array $keyIds
* The key IDs.
*/
protected function __construct(protected string $name, protected int $threshold, protected array $keyIds)
{
}
/**
* Creates a role object from TUF metadata.
*
* @param array $roleInfo
* The role information from TUF metadata.
* @param string $name
* The name of the role.
*
* @return static
*
* @see https://theupdateframework.github.io/specification/v1.0.32#document-formats
*/
public static function createFromMetadata(array $roleInfo, string $name): Role
{
self::validate($roleInfo, static::getRoleConstraints());
return new static(
$name,
$roleInfo['threshold'],
$roleInfo['keyids']
);
}
/**
* Checks if this role's key IDs match another role's.
*
* @param \Tuf\Role $other
*
* @return bool
*/
public function keysMatch(Role $other): bool
{
return $this->keyIds === $other->keyIds;
}
/**
* Gets the role name.
*
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* Gets the threshold required.
*
* @return int
* The threshold number of signatures required for the role.
*/
public function getThreshold(): int
{
return $this->threshold;
}
/**
* Checks whether the given key is authorized for the role.
*
* @param string $keyId
* The key ID to check.
*
* @return boolean
* TRUE if the key is authorized for the given role, or FALSE
* otherwise.
*/
public function isKeyIdAcceptable(string $keyId): bool
{
return in_array($keyId, $this->keyIds, true);
}
}