public final class EncryptedRandomAccessBuffer extends java.lang.Object implements LockableRandomAccessBuffer, java.io.Serializable
LockableRandomAccessBuffer.RAFLock| Modifier and Type | Field and Description |
|---|---|
static int |
MAGIC |
| Constructor and Description |
|---|
EncryptedRandomAccessBuffer(EncryptedRandomAccessBufferType type,
LockableRandomAccessBuffer underlying,
MasterSecret masterKey,
boolean newFile)
Creates an instance of EncryptedRandomAccessBuffer wrapping underlyingBuffer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static LockableRandomAccessBuffer |
create(java.io.DataInputStream dis,
FilenameGenerator fg,
PersistentFileTracker persistentFileTracker,
MasterSecret masterKey) |
boolean |
equals(java.lang.Object obj)
Must reimplement equals().
|
void |
free()
Free the underlying resources.
|
int |
hashCode()
Must reimplement hashCode() if we change equals().
|
LockableRandomAccessBuffer.RAFLock |
lockOpen()
Keep the RAF open.
|
void |
onResume(ClientContext context)
Called on resuming, i.e.
|
void |
pread(long fileOffset,
byte[] buf,
int bufOffset,
int length)
Reads the specified section of the underlying RAT and decrypts it.
|
void |
pwrite(long fileOffset,
byte[] buf,
int bufOffset,
int length)
Encrypts the given data and writes it to the underlying RAT.
|
long |
size() |
void |
storeTo(java.io.DataOutputStream dos)
Write enough data to reconstruct the Bucket, or throw UnsupportedOperationException.
|
public static final int MAGIC
public EncryptedRandomAccessBuffer(EncryptedRandomAccessBufferType type, LockableRandomAccessBuffer underlying, MasterSecret masterKey, boolean newFile) throws java.io.IOException, java.security.GeneralSecurityException
type - The algorithms to be used for the ERATunderlyingBuffer - The underlying RAT that will be storing the data. Must be larger than
the footer size specified in type.masterKey - The MasterSecret that will be used to derive various keys.newFile - If true, treat it as a new file, and writer a header. If false, the ERAT must
already have been initialised.java.io.IOExceptionjava.security.GeneralSecurityExceptionpublic long size()
size in interface RandomAccessBufferpublic void pread(long fileOffset,
byte[] buf,
int bufOffset,
int length)
throws java.io.IOException
pread in interface RandomAccessBufferfileOffset - The offset within the file to read from.buf - The buffer to write to.bufOffset - The offset within the buffer to the first read byte.length - The length of data to read.java.io.IOException - If we were unable to read the required number of bytes etc.public void pwrite(long fileOffset,
byte[] buf,
int bufOffset,
int length)
throws java.io.IOException
pwrite in interface RandomAccessBufferjava.io.IOExceptionpublic void close()
close in interface RandomAccessBufferclose in interface java.io.Closeableclose in interface java.lang.AutoCloseablepublic void free()
RandomAccessBufferfree in interface RandomAccessBufferpublic LockableRandomAccessBuffer.RAFLock lockOpen() throws java.io.IOException
LockableRandomAccessBufferlockOpen in interface LockableRandomAccessBufferjava.io.IOExceptionpublic void onResume(ClientContext context) throws ResumeFailedException
LockableRandomAccessBufferonResume in interface LockableRandomAccessBufferResumeFailedExceptionpublic void storeTo(java.io.DataOutputStream dos)
throws java.io.IOException
LockableRandomAccessBufferstoreTo in interface LockableRandomAccessBufferjava.io.IOExceptionpublic static LockableRandomAccessBuffer create(java.io.DataInputStream dis, FilenameGenerator fg, PersistentFileTracker persistentFileTracker, MasterSecret masterKey) throws java.io.IOException, StorageFormatException, ResumeFailedException
java.io.IOExceptionStorageFormatExceptionResumeFailedExceptionpublic int hashCode()
LockableRandomAccessBufferhashCode in interface LockableRandomAccessBufferhashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
LockableRandomAccessBufferequals in interface LockableRandomAccessBufferequals in class java.lang.Object