__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Tuf\Metadata;
/**
* Defines a base class for saving and loading trusted TUF metadata.
*/
abstract class StorageBase implements StorageInterface
{
/**
* Reads raw metadata.
*
* @param string $name
* The name of the metadata to read (e.g., `root`, `targets`), without
* file extension.
*
* @return string|null
* The metadata, as a string, or null if the metadata is unavailable.
*/
abstract protected function read(string $name): ?string;
/**
* Writes trusted metadata as a string.
*
* @param string $name
* The name of the metadata to write (e.g., `root`, `targets`), without
* file extension.
* @param string $data
* The metadata to write, fully encoded and normalized as desired.
*/
abstract protected function write(string $name, string $data): void;
/**
* {@inheritdoc}
*/
public function getRoot(): RootMetadata
{
$data = $this->read(RootMetadata::TYPE);
if ($data) {
return RootMetadata::createFromJson($data)->trust();
}
throw new \LogicException("Could not load root metadata.");
}
/**
* {@inheritdoc}
*/
public function getTimestamp(): ?TimestampMetadata
{
$data = $this->read(TimestampMetadata::TYPE);
return $data ? TimestampMetadata::createFromJson($data)->trust() : null;
}
/**
* {@inheritdoc}
*/
public function getSnapshot(): ?SnapshotMetadata
{
$data = $this->read(SnapshotMetadata::TYPE);
return $data ? SnapshotMetadata::createFromJson($data)->trust() : null;
}
/**
* {@inheritdoc}
*/
public function getTargets(string $role = 'targets'): ?TargetsMetadata
{
$data = $this->read($role);
return $data ? TargetsMetadata::createFromJson($data, $role)->trust() : null;
}
/**
* {@inheritdoc}
*/
public function save(MetadataBase $metadata): void
{
$metadata->ensureIsTrusted();
$this->write($metadata->getRole(), $metadata->getSource());
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Verifier | Folder | 0775 |
|
|
| ConstraintsTrait.php | File | 5.04 KB | 0664 |
|
| FileInfoMetadataBase.php | File | 794 B | 0664 |
|
| MetadataBase.php | File | 7.36 KB | 0664 |
|
| RootMetadata.php | File | 2.85 KB | 0664 |
|
| SnapshotMetadata.php | File | 1.38 KB | 0664 |
|
| StorageBase.php | File | 2.08 KB | 0664 |
|
| StorageInterface.php | File | 1.67 KB | 0664 |
|
| TargetsMetadata.php | File | 7.87 KB | 0664 |
|
| TimestampMetadata.php | File | 1.17 KB | 0664 |
|