@NotThreadSafe public abstract class CipherReadOnlyFile extends DecoratingReadOnlyFile
init(SeekableBlockCipher, long, long)
before it can actually read anything!
Note that this class implements its own virtual file pointer.
Thus, if you would like to access the underlying ReadOnlyFile
again after you have finished working with an instance of this class,
you should synchronize their file pointers using the pattern as described
in the base class DecoratingReadOnlyFile.
CipherOutputStreamdelegate| Modifier | Constructor and Description |
|---|---|
protected |
CipherReadOnlyFile(ReadOnlyFile rof)
Creates a read only file for transparent random read access to an
encrypted file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this read only file and releases any resources associated with it.
|
protected byte[] |
computeMac(Mac mac)
Returns the authentication code of the encrypted data in this cipher
read-only file using the given Message Authentication Code (MAC) object.
|
long |
getFilePointer() |
protected void |
init(SeekableBlockCipher cipher,
long start,
long length)
Initializes this cipher read only file - must be called before first
read access!
|
long |
length() |
int |
read() |
int |
read(byte[] dst,
int offset,
int remaining) |
void |
seek(long pos) |
toStringread, readFully, readFully@CreatesObligation protected CipherReadOnlyFile(@Nullable@WillCloseWhenClosed ReadOnlyFile rof)
init(SeekableBlockCipher, long, long)
before it can actually read anything!rof - A read-only file.
This may be null, but must be properly initialized
before a call to init(de.schlichtherle.truezip.crypto.SeekableBlockCipher, long, long).public void close()
throws IOException
IOException.close in interface ReadOnlyFileclose in interface Closeableclose in interface AutoCloseableclose in class DecoratingReadOnlyFileIOException - If an I/O error occurs.protected byte[] computeMac(Mac mac) throws IOException
mac - a properly initialized MAC object.IOException - on any I/O error.public long getFilePointer()
throws IOException
getFilePointer in interface ReadOnlyFilegetFilePointer in class DecoratingReadOnlyFileIOExceptionprotected final void init(SeekableBlockCipher cipher, long start, long length) throws IOException
cipher - the seekable block cipher.start - the start offset of the encrypted data in this file.length - the length of the encrypted data in this file.IOException - If this read only file has already been closed.
This exception is not recoverable.IllegalStateException - if DecoratingReadOnlyFile.delegate is null or
if this object has already been initialized.IllegalArgumentException - if cipher is null or
if start or length are less than zero.public long length()
throws IOException
length in interface ReadOnlyFilelength in class DecoratingReadOnlyFileIOExceptionpublic int read()
throws IOException
read in interface ReadOnlyFileread in class DecoratingReadOnlyFileIOExceptionpublic int read(byte[] dst,
int offset,
int remaining)
throws IOException
read in interface ReadOnlyFileread in class DecoratingReadOnlyFileIOExceptionpublic void seek(long pos)
throws IOException
seek in interface ReadOnlyFileseek in class DecoratingReadOnlyFileIOExceptionCopyright © 2005–2013 Schlichtherle IT Services. All rights reserved.