Class FileSystemTufStore

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearMeta​(java.lang.String role)
      Generic method to remove meta, useful when keys rotated in root.
      java.lang.String getIdentifier()
      A generic string for identifying the local store in debug messages.
      static FileSystemTufStore newFileSystemStore​(java.nio.file.Path repoBaseDir)  
      static FileSystemTufStore newFileSystemStore​(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.
      void writeMeta​(java.lang.String roleName, SignedTufMeta<?> meta)
      Generic method to store one of the SignedTufMeta resources in the local tuf store.
      void writeTarget​(java.lang.String targetName, byte[] targetContents)
      Writes a TUF target to the local target store.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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: 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 interface MetaStore
        Specified by:
        getIdentifier in interface TargetStore
      • writeTarget

        public void writeTarget​(java.lang.String targetName,
                                byte[] targetContents)
                         throws java.io.IOException
        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 interface TargetStore
        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.IOException
        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 interface TargetReader
        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.IOException
        Description copied from interface: MetaStore
        Generic method to store one of the SignedTufMeta resources in the local tuf store.
        Specified by:
        writeMeta in interface MetaStore
        Parameters:
        roleName - the name of the role
        meta - the metadata to store
        Throws:
        java.io.IOException - if writing the resource causes an IO error
      • 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: MetaReader
        Return a named metadata item if there is any.
        Specified by:
        readMeta in interface MetaReader
        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.IOException
        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 interface MetaStore
        Throws:
        java.io.IOException - implementations that read/write IO to clear the data may throw IOException
        See Also:
        5.3.11