Top Description Fields Constructors Methods
org.h2.tools

public Class ChangeFileEncryption

extends Tool
Class Inheritance
Imports
java.io.IOException, .InputStream, .OutputStream, java.nio.channels.Channels, .FileChannel, java.sql.SQLException, java.util.ArrayList, java.util.concurrent.TimeUnit, org.h2.engine.Constants, org.h2.message.DbException, org.h2.mvstore.MVStore, org.h2.store.FileLister, org.h2.store.fs.FilePath, .FileUtils, org.h2.store.fs.encrypt.FileEncrypt, .FilePathEncrypt, org.h2.util.Tool

Allows changing the database file encryption password or algorithm. This tool can not be used to change a password of a user. The database must be closed before using this tool.

Field Summary

Modifier and TypeField and Description
private String
private byte[]
private String
private byte[]
Inherited from org.h2.util.Tool:
out

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
copyMvStore(String fileName, boolean quiet, char[] decryptPassword)

public static void
execute(String
the directory (. for the current directory)
dir
,
String
the database name (null for all databases)
db
,
String
the cipher (AES)
cipher
,
char[]
the decryption password as a char array
decryptPassword
,
char[]
the encryption password as a char array
encryptPassword
,
boolean
don't print progress information
quiet
)

Changes the password for a database.

private static FileChannel
getFileChannel(String fileName, String r, byte[] decryptKey)

public static void
main(String...
the command line arguments
args
)

Options are case sensitive.

private void
process(String dir, String db, String cipher, char[] decryptPassword, char[] encryptPassword, boolean quiet)

private void
process(String fileName, boolean quiet, char[] decryptPassword)

public void
runTool(String...
the argument list
args
)

Implements abstract org.h2.util.Tool.runTool.

Run the tool with the given output stream and arguments.

Inherited from org.h2.util.Tool:
getMainClassNameisOptionprintNoDatabaseFilesFoundsetOutshowUsageshowUsageAndThrowUnsupportedOptionthrowUnsupportedOption

Field Detail

cipherTypeback to summary
private String cipherType
decryptKeyback to summary
private byte[] decryptKey
directoryback to summary
private String directory
encryptKeyback to summary
private byte[] encryptKey

Constructor Detail

ChangeFileEncryptionback to summary
public ChangeFileEncryption()

Method Detail

copyMvStoreback to summary
private void copyMvStore(String fileName, boolean quiet, char[] decryptPassword) throws IOException, SQLException
executeback to summary
public static void execute(String dir, String db, String cipher, char[] decryptPassword, char[] encryptPassword, boolean quiet) throws SQLException

Changes the password for a database. The passwords must be supplied as char arrays and are cleaned in this method. The database must be closed before calling this method.

Parameters
dir:String

the directory (. for the current directory)

db:String

the database name (null for all databases)

cipher:String

the cipher (AES)

decryptPassword:char[]

the decryption password as a char array

encryptPassword:char[]

the encryption password as a char array

quiet:boolean

don't print progress information

Exceptions
SQLException:
on failure
getFileChannelback to summary
private static FileChannel getFileChannel(String fileName, String r, byte[] decryptKey) throws IOException
mainback to summary
public static void main(String... args)

Options are case sensitive.

Supported options
[-help] or [-?] Print the list of options
[-cipher type] The encryption type (AES)
[-dir <dir>] The database directory (default: .)
[-db <database>] Database name (all databases if not set)
[-decrypt <pwd>] The decryption password (if not set: not yet encrypted)
[-encrypt <pwd>] The encryption password (if not set: do not encrypt)
[-quiet] Do not print progress information
Parameters
args:String[]

the command line arguments

processback to summary
private void process(String dir, String db, String cipher, char[] decryptPassword, char[] encryptPassword, boolean quiet) throws SQLException
processback to summary
private void process(String fileName, boolean quiet, char[] decryptPassword) throws SQLException
runToolback to summary
public void runTool(String... args) throws SQLException

Implements abstract org.h2.util.Tool.runTool.

Doc from org.h2.util.Tool.runTool.

Run the tool with the given output stream and arguments.

Parameters
args:String[]

the argument list

Annotations
@Override
Exceptions
SQLException:
on failure