Package dev.sigstore.tuf
Class FileSystemTufStore
- java.lang.Object
-
- dev.sigstore.tuf.FileSystemTufStore
-
- All Implemented Interfaces:
MetaReader,MetaStore,TargetReader,TargetStore
public class FileSystemTufStore extends java.lang.Object implements MetaStore, TargetStore
Uses a local file system directory to store the trusted TUF metadata.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearMeta(java.lang.String role)Generic method to remove meta, useful when keys rotated in root.java.lang.StringgetIdentifier()A generic string for identifying the local store in debug messages.static FileSystemTufStorenewFileSystemStore(java.nio.file.Path repoBaseDir)static FileSystemTufStorenewFileSystemStore(java.nio.file.Path repoBaseDir, java.nio.file.Path targetsCache)<T extends SignedTufMeta<?>>
java.util.Optional<T>readMeta(java.lang.String roleName, java.lang.Class<T> tClass)Return a named metadata item if there is any.byte[]readTarget(java.lang.String targetName)Reads a TUF target file from the local TUF store.voidwriteMeta(java.lang.String roleName, SignedTufMeta<?> meta)Generic method to store one of theSignedTufMetaresources in the local tuf store.voidwriteTarget(java.lang.String targetName, byte[] targetContents)Writes a TUF target to the local target store.
-
-
-
Method Detail
-
newFileSystemStore
public static FileSystemTufStore newFileSystemStore(java.nio.file.Path repoBaseDir) throws java.io.IOException
- Throws:
java.io.IOException
-
newFileSystemStore
public static FileSystemTufStore newFileSystemStore(java.nio.file.Path repoBaseDir, java.nio.file.Path targetsCache)
-
getIdentifier
public java.lang.String getIdentifier()
Description copied from interface:MetaStoreA 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:
getIdentifierin interfaceMetaStore- Specified by:
getIdentifierin interfaceTargetStore
-
writeTarget
public void writeTarget(java.lang.String targetName, byte[] targetContents) throws java.io.IOExceptionDescription copied from interface:TargetStoreWrites 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:
writeTargetin 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:
java.io.IOException- if an error occurs
-
readTarget
public byte[] readTarget(java.lang.String targetName) throws java.io.IOExceptionDescription copied from interface:TargetReaderReads 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:
readTargetin interfaceTargetReader- Parameters:
targetName- the name of the target file to read (e.g. ctfe.pub)- Returns:
- the content of the file as bytes
- Throws:
java.io.IOException- if an error occurs
-
writeMeta
public void writeMeta(java.lang.String roleName, SignedTufMeta<?> meta) throws java.io.IOExceptionDescription copied from interface:MetaStoreGeneric method to store one of theSignedTufMetaresources in the local tuf store.
-
readMeta
public <T extends SignedTufMeta<?>> java.util.Optional<T> readMeta(java.lang.String roleName, java.lang.Class<T> tClass) throws java.io.IOException
Description copied from interface:MetaReaderReturn a named metadata item if there is any.- Specified by:
readMetain 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:
java.io.IOException- if an error occurs reading from the backing store
-
clearMeta
public void clearMeta(java.lang.String role) throws java.io.IOExceptionDescription copied from interface:MetaStoreGeneric method to remove meta, useful when keys rotated in root. Deletion is not optional, implementers must ensure meta is removed from the storage medium.
-
-