|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.io.rof.AbstractReadOnlyFile
de.schlichtherle.io.rof.FilterReadOnlyFile
de.schlichtherle.crypto.io.CipherReadOnlyFile
public abstract class CipherReadOnlyFile
A read only file for transparent random read access to an encrypted file.
The client must call 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 FilterReadOnlyFile.
| Field Summary |
|---|
| Fields inherited from class de.schlichtherle.io.rof.FilterReadOnlyFile |
|---|
rof |
| Constructor Summary | |
|---|---|
CipherReadOnlyFile(ReadOnlyFile rof)
Creates a read only file for transparent random read access to an encrypted file. |
|
| Method Summary | |
|---|---|
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()
|
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[] buf,
int off,
int len)
Reads up to len bytes of data from this read only file into
the given array. |
void |
seek(long fp)
Sets the file pointer offset, measured from the beginning of this file, at which the next read occurs. |
| Methods inherited from class de.schlichtherle.io.rof.AbstractReadOnlyFile |
|---|
read, readFully, readFully, skipBytes |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CipherReadOnlyFile(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 init before
the call to init().| Method Detail |
|---|
public void init(SeekableBlockCipher cipher,
long start,
long length)
throws IOException
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 this object has already been
initialized.
This exception is not recoverable.
NullPointerException - If FilterReadOnlyFile.rof is null
or cipher is null.
This exception is recoverable.
protected byte[] computeMac(Mac mac)
throws IOException
mac - A properly initialized MAC object.
IOException - On any I/O related issue.
public long length()
throws IOException
length in interface ReadOnlyFilelength in class FilterReadOnlyFileIOException
public long getFilePointer()
throws IOException
getFilePointer in interface ReadOnlyFilegetFilePointer in class FilterReadOnlyFileIOException
public void seek(long fp)
throws IOException
ReadOnlyFileSimpleReadOnlyFile subclasses
RandomAccessFile and passes "r" as a
parameter to the superclass constructor.
On the Windows platform, this implementation allows to seek past the
end of file, but on the Linux platform it doesn't.
seek in interface ReadOnlyFileseek in class FilterReadOnlyFilefp - The offset position, measured in bytes from the beginning
of the file, at which to set the file pointer.
IOException - If pos is less than 0 or if
an I/O error occurs.
public int read()
throws IOException
read in interface ReadOnlyFileread in class FilterReadOnlyFileIOException
public int read(byte[] buf,
int off,
int len)
throws IOException
ReadOnlyFilelen bytes of data from this read only file into
the given array.
This method blocks until at least one byte of input is available.
read in interface ReadOnlyFileread in class FilterReadOnlyFilebuf - The buffer to fill with data.off - The start offset of the data.len - The maximum number of bytes to read.
-1 if there is
no more data because the end of the file has been reached.
IOException - On any I/O related issue.
public void close()
throws IOException
IOException.
close in interface ReadOnlyFileclose in class FilterReadOnlyFileIOException - If an I/O error occurs.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||