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 TypeMethodDescriptionvoidGeneric 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.booleanChecks if the local TUF store actually contains a target file with name.static FileSystemTufStorenewFileSystemStore(Path repoBaseDir) static FileSystemTufStorenewFileSystemStore(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.voidwriteMeta(String roleName, SignedTufMeta<?> meta) Generic method to store one of theSignedTufMetaresources in the local tuf store.voidwriteTarget(String targetName, byte[] targetContents) Writes a TUF target to the local target store.
-
Method Details
-
newFileSystemStore
- Throws:
IOException
-
newFileSystemStore
-
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
Description 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:
IOException- if an error occurs
-
readTarget
Description 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:
IOException- if an error occurs
-
getTargetInputSteam
Description copied from interface:TargetReaderReturns 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:
getTargetInputSteamin 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:TargetReaderChecks if the local TUF store actually contains a target file with name.- Specified by:
hasTargetin 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:MetaStoreGeneric method to store one of theSignedTufMetaresources in the local tuf store.- Specified by:
writeMetain 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, JsonParseException 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:
IOException- if an error occurs reading from the backing storeJsonParseException
-
clearMeta
Description 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.- Specified by:
clearMetain interfaceMetaStore- Throws:
IOException- implementations that read/write IO to clear the data may throwIOException- See Also:
-
getRepoBaseDir
-
getTargetsDir
-