Class KabOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.tccc.kos.commons.kab.KabOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class KabOutputStream extends FilterOutputStream
Output stream for creating an archive.
Version:
Jun-18-22
  • Constructor Details

    • KabOutputStream

      public KabOutputStream(OutputStream os, String identifier, String type, String qualifier, String name, String version, KeySet keySet, KabAccessProvider accessProvider) throws IOException
      Create an output stream that writes a kab file. The certPath and key parameters much match in that key must be the private key for the first cert in certPath as the private key is used to generate the signature and the certPath is used to verify it.
      Parameters:
      os - the underlying output stream to write to
      identifier - unique kab identifier (typically uuid or hash)
      type - kab type
      qualifier - user specified qualifier
      name - display name
      version - version of kab contents
      keySet - used to sign the kab
      accessProvider - provide access control data to entries (optional)
      Throws:
      IOException - if there is an underlying stream error
    • KabOutputStream

      public KabOutputStream(File file, String identifier, String type, String qualifier, String name, String version, KeySet keySet, KabAccessProvider accessProvider) throws IOException
      Output a kab to the specified file.
      Parameters:
      file - the file to write to
      identifier - unique kab identifier (typically uuid or hash)
      type - kab type
      qualifier - user specified qualifier
      name - display name
      version - version of kab contents
      keySet - used to sign the kab
      accessProvider - provide access control data to entries (optional)
      Throws:
      IOException - if there is an underlying stream error
  • Method Details

    • addFile

      public void addFile(String path)
      Create a new file entry. If the path is the same as a previous entry, it will replace it but won't delete the content from the output stream.
      Parameters:
      path - the path of the file
    • addDir

      public void addDir(String path)
      Create a new dir entry.
      Parameters:
      path - the path of the directory
    • removeEntry

      public void removeEntry(String path)
      Remove an existing entry. This simply removes the entry from the master archive directory but leaves the bytes in the file which makes them unaccessible.
      Parameters:
      path - the path of the entry to remove
    • copy

      public void copy(InputStream is) throws IOException
      Copy the specified input stream to the output stream. This is an easy way to create an entry and then copy a file to the kab. This does not close the input stream when done.
      Parameters:
      is - the input stream to copy to the kab
      Throws:
      IOException
    • write

      public void write(int b) throws IOException
      Overrides:
      write in class FilterOutputStream
      Throws:
      IOException
    • write

      public void write(byte[] b, int off, int len) throws IOException
      Overrides:
      write in class FilterOutputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class FilterOutputStream
      Throws:
      IOException