Package dev.sigstore.tuf
Class FileSystemTufStore
java.lang.Object
dev.sigstore.tuf.FileSystemTufStore
- All Implemented Interfaces:
MetaReader
,MetaStore
,TargetReader
,TargetStore
Uses a local file system directory to store the trusted TUF metadata.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Generic method to remove meta, useful when keys rotated in root.A generic string for identifying the local store in debug messages.getTargetInputSteam
(String targetName) Returns an input stream to a TUF target file in the local TUF store.boolean
Checks if the local TUF store actually contains a target file with name.static FileSystemTufStore
newFileSystemStore
(Path repoBaseDir) static FileSystemTufStore
newFileSystemStore
(Path repoBaseDir, Path targetsCache) <T extends SignedTufMeta<?>>
Optional<T>Return a named metadata item if there is any.byte[]
readTarget
(String targetName) Reads a TUF target file from the local TUF store.void
writeMeta
(String roleName, SignedTufMeta<?> meta) Generic method to store one of theSignedTufMeta
resources in the local tuf store.void
writeTarget
(String targetName, byte[] targetContents) Writes a TUF target to the local target store.
-
Method Details
-
newFileSystemStore
- Throws:
IOException
-
newFileSystemStore
-
getIdentifier
Description copied from interface:MetaStore
A generic string for identifying the local store in debug messages. A file system based implementation might return the path being used for storage, while an in-memory store may just return something like 'in-memory'.- Specified by:
getIdentifier
in interfaceMetaStore
- Specified by:
getIdentifier
in interfaceTargetStore
-
writeTarget
Description copied from interface:TargetStore
Writes a TUF target to the local target store. Target names may include path elements and the storage engine should be consistent when handling writing and reading these.- Specified by:
writeTarget
in interfaceTargetStore
- Parameters:
targetName
- the name of the target file to write (e.g. ctfe.pub)targetContents
- the content of the target file as bytes- Throws:
IOException
- if an error occurs
-
readTarget
Description copied from interface:TargetReader
Reads a TUF target file from the local TUF store. Target names may include path elements and the storage engine should be consistent when handling writing and reading these.- Specified by:
readTarget
in interfaceTargetReader
- Parameters:
targetName
- the name of the target file to read (e.g. ctfe.pub)- Returns:
- the content of the file as bytes
- Throws:
IOException
- if an error occurs
-
getTargetInputSteam
Description copied from interface:TargetReader
Returns an input stream to a TUF target file in the local TUF store. Target names may include path elements and the storage engine should be consistent when handling writing and reading these.- Specified by:
getTargetInputSteam
in interfaceTargetReader
- Parameters:
targetName
- the name of the target file to read (e.g. ctfe.pub)- Returns:
- an input steam to the target file in the local store, the consumer must close the input stream
- Throws:
IOException
- if an error occurs
-
hasTarget
Description copied from interface:TargetReader
Checks if the local TUF store actually contains a target file with name.- Specified by:
hasTarget
in interfaceTargetReader
- Parameters:
targetName
- the name of the target file to read (e.g. ctfe.pub)- Returns:
- true if the target exists locally
- Throws:
IOException
- if an error occurs
-
writeMeta
Description copied from interface:MetaStore
Generic method to store one of theSignedTufMeta
resources in the local tuf store.- Specified by:
writeMeta
in interfaceMetaStore
- Parameters:
roleName
- the name of the rolemeta
- the metadata to store- Throws:
IOException
- if writing the resource causes an IO error
-
readMeta
public <T extends SignedTufMeta<?>> Optional<T> readMeta(String roleName, Class<T> tClass) throws IOException Description copied from interface:MetaReader
Return a named metadata item if there is any.- Specified by:
readMeta
in interfaceMetaReader
- Parameters:
roleName
- the name of the role to load (root, timestamp, snapshot, targets, or a delegated target role)tClass
- the class type- Returns:
- an instance of the signed metadata for the role if it was found
- Throws:
IOException
- if an error occurs reading from the backing store
-
clearMeta
Description copied from interface:MetaStore
Generic method to remove meta, useful when keys rotated in root. Deletion is not optional, implementers must ensure meta is removed from the storage medium.- Specified by:
clearMeta
in interfaceMetaStore
- Throws:
IOException
- implementations that read/write IO to clear the data may throwIOException
- See Also:
-
getRepoBaseDir
-
getTargetsDir
-