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:
Closeable,AutoCloseable
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
ConstructorsConstructorDescriptionAesFileInputStream(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
Modifier and TypeMethodDescriptionvoidclose()Close the stream and associated backed streams and clear buffers.protected intfillBuffer(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, skipMethods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
AesFileInputStream
Instantiate a seekable stream from an encrypted file source- Parameters:
salmonFile- The source file.- Throws:
IOException- Thrown if there is an IO error.
-
AesFileInputStream
public AesFileInputStream(AesFile salmonFile, int buffersCount, int bufferSize, int threads, int backOffset) throws 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:
IOException- Thrown if there is an IO error.
-
-
Method Details
-
fillBuffer
Fills a cache buffer with the decrypted data from the encrypted source file.- Overrides:
fillBufferin 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:
IOException- When IO error occurs
-
close
Close the stream and associated backed streams and clear buffers.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStreamWrapper- Throws:
IOException- Thrown if there is an IO error.
-