Class AesFileInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class AesFileInputStream
    extends InputStreamWrapper
    InputStream wrapper for seeking and reading an encrypted AesFile. This class provides a seekable source with parallel streams and cached buffers for performance.
    • Constructor Detail

      • AesFileInputStream

        public AesFileInputStream​(AesFile salmonFile)
                           throws java.io.IOException
        Instantiate a seekable stream from an encrypted file source
        Parameters:
        salmonFile - The source file.
        Throws:
        java.io.IOException - Thrown if there is an IO error.
      • AesFileInputStream

        public AesFileInputStream​(AesFile salmonFile,
                                  int buffersCount,
                                  int bufferSize,
                                  int threads,
                                  int backOffset)
                           throws java.io.IOException
        Instantiate a seekable stream from an encrypted file source
        Parameters:
        salmonFile - The source file.
        buffersCount - Number of buffers to use.
        bufferSize - The length of each buffer.
        threads - The number of threads/streams to source the file in parallel.
        backOffset - The back offset.
        Throws:
        java.io.IOException - Thrown if there is an IO error.
    • Method Detail

      • fillBuffer

        protected int fillBuffer​(Buffer cacheBuffer,
                                 long startPosition,
                                 int length)
                          throws java.io.IOException
        Fills a cache buffer with the decrypted data from the encrypted source file.
        Overrides:
        fillBuffer in class InputStreamWrapper
        Parameters:
        cacheBuffer - The cache buffer that will store the decrypted contents
        startPosition - The start position
        length - The length of the data requested
        Returns:
        The number of bytes read
        Throws:
        java.io.IOException - When IO error occurs
      • close

        public void close()
                   throws java.io.IOException
        Close the stream and associated backed streams and clear buffers.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class InputStreamWrapper
        Throws:
        java.io.IOException - Thrown if there is an IO error.