Package com.mku.salmonfs.streams
Class AesFileInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.mku.streams.InputStreamWrapper
-
- com.mku.salmonfs.streams.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.
-
-
Field Summary
-
Fields inherited from class com.mku.streams.InputStreamWrapper
DEFAULT_BACK_OFFSET, DEFAULT_BUFFER_SIZE, DEFAULT_BUFFERS, MAX_BUFFERS
-
-
Constructor Summary
Constructors Constructor Description AesFileInputStream(AesFile salmonFile)
Instantiate a seekable stream from an encrypted file sourceAesFileInputStream(AesFile salmonFile, int buffersCount, int bufferSize, int threads, int backOffset)
Instantiate a seekable stream from an encrypted file source
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the stream and associated backed streams and clear buffers.protected int
fillBuffer(Buffer cacheBuffer, long startPosition, int length)
Fills a cache buffer with the decrypted data from the encrypted source file.-
Methods inherited from class com.mku.streams.InputStreamWrapper
fillBufferPart, getAlignSize, getBackOffset, getBuffersCount, getBufferSize, getLength, getPositionEnd, getPositionStart, getTotalSize, read, read, reset, setBackOffset, setBuffersCount, setPositionEnd, setPositionStart, setTotalSize, skip
-
-
-
-
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 classInputStreamWrapper
- Parameters:
cacheBuffer
- The cache buffer that will store the decrypted contentsstartPosition
- The start positionlength
- 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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classInputStreamWrapper
- Throws:
java.io.IOException
- Thrown if there is an IO error.
-
-