Top Description Fields Constructors Methods
org.h2.security

public Class SecureFileStore

extends FileStore
Class Inheritance
Static Imports
org.h2.util.Bits.LONG_VH_BE

A file store that encrypts all data before writing, and decrypts all data after reading. Areas that were never written to (for example after calling setLength to enlarge the file) are not encrypted (contains 0 bytes).

Field Summary

Modifier and TypeField and Description
private byte[]
private final byte[]
private final BlockCipher
private final BlockCipher
private byte[]
private final int
private long
Inherited from org.h2.store.FileStore:
HEADER_LENGTHname

Constructor Summary

AccessConstructor and Description
public
SecureFileStore(DataHandler handler, String name, String mode, String cipher, byte[] key, int keyIterations)

Method Summary

Modifier and TypeMethod and Description
protected byte[]
generateSalt()

Overrides org.h2.store.FileStore.generateSalt.

Generate the random salt bytes if required.

protected void
initKey(byte[]
the salt
salt
)

Overrides org.h2.store.FileStore.initKey.

Initialize the key using the given salt.

public void
readFully(byte[]
the target buffer
b
,
int
the offset
off
,
int
the number of bytes to read
len
)

Overrides org.h2.store.FileStore.readFully.

Read a number of bytes.

public void
readFullyDirect(byte[]
the target buffer
b
,
int
the offset
off
,
int
the number of bytes to read
len
)

Overrides org.h2.store.FileStore.readFullyDirect.

Read a number of bytes without decrypting.

public void
seek(long
the location
x
)

Overrides org.h2.store.FileStore.seek.

Go to the specified file location.

public void
write(byte[]
the source buffer
b
,
int
the offset
off
,
int
the number of bytes to write
len
)

Overrides org.h2.store.FileStore.write.

Write a number of bytes.

protected void
writeDirect(byte[]
the source buffer
b
,
int
the offset
off
,
int
the number of bytes to write
len
)

Overrides org.h2.store.FileStore.writeDirect.

Write a number of bytes without encrypting.

private void
xorInitVector(byte[] b, int off, int len, long p)

Inherited from org.h2.store.FileStore:
autoDeleteclosecloseAndDeleteSilentlycloseFilecloseSilentlygetFilePointerinitlengthopenopenopenopenFilereleaseLocksetCheckedWritingsetLengthstopAutoDeletesynctryLock

Field Detail

bufferback to summary
private byte[] buffer
bufferForInitVectorback to summary
private final byte[] bufferForInitVector
cipherback to summary
private final BlockCipher cipher
cipherForInitVectorback to summary
private final BlockCipher cipherForInitVector
keyback to summary
private byte[] key
keyIterationsback to summary
private final int keyIterations
posback to summary
private long pos

Constructor Detail

SecureFileStoreback to summary
public SecureFileStore(DataHandler handler, String name, String mode, String cipher, byte[] key, int keyIterations)

Method Detail

generateSaltback to summary
protected byte[] generateSalt()

Overrides org.h2.store.FileStore.generateSalt.

Doc from org.h2.store.FileStore.generateSalt.

Generate the random salt bytes if required.

Returns:byte[]

the random salt or the magic

Annotations
@Override
initKeyback to summary
protected void initKey(byte[] salt)

Overrides org.h2.store.FileStore.initKey.

Doc from org.h2.store.FileStore.initKey.

Initialize the key using the given salt.

Parameters
salt:byte[]

the salt

Annotations
@Override
readFullyback to summary
public void readFully(byte[] b, int off, int len)

Overrides org.h2.store.FileStore.readFully.

Doc from org.h2.store.FileStore.readFully.

Read a number of bytes.

Parameters
b:byte[]

the target buffer

off:int

the offset

len:int

the number of bytes to read

Annotations
@Override
readFullyDirectback to summary
public void readFullyDirect(byte[] b, int off, int len)

Overrides org.h2.store.FileStore.readFullyDirect.

Doc from org.h2.store.FileStore.readFullyDirect.

Read a number of bytes without decrypting.

Parameters
b:byte[]

the target buffer

off:int

the offset

len:int

the number of bytes to read

Annotations
@Override
seekback to summary
public void seek(long x)

Overrides org.h2.store.FileStore.seek.

Doc from org.h2.store.FileStore.seek.

Go to the specified file location.

Parameters
x:long

the location

Annotations
@Override
writeback to summary
public void write(byte[] b, int off, int len)

Overrides org.h2.store.FileStore.write.

Doc from org.h2.store.FileStore.write.

Write a number of bytes.

Parameters
b:byte[]

the source buffer

off:int

the offset

len:int

the number of bytes to write

Annotations
@Override
writeDirectback to summary
protected void writeDirect(byte[] b, int off, int len)

Overrides org.h2.store.FileStore.writeDirect.

Doc from org.h2.store.FileStore.writeDirect.

Write a number of bytes without encrypting.

Parameters
b:byte[]

the source buffer

off:int

the offset

len:int

the number of bytes to write

Annotations
@Override
xorInitVectorback to summary
private void xorInitVector(byte[] b, int off, int len, long p)