Package org.h2.tools
Class ChangeFileEncryption
java.lang.Object
org.h2.util.Tool
org.h2.tools.ChangeFileEncryption
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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
copyMvStore
(String fileName, boolean quiet, char[] decryptPassword) static void
execute
(String dir, String db, String cipher, char[] decryptPassword, char[] encryptPassword, boolean quiet) Changes the password for a database.private static FileChannel
getFileChannel
(String fileName, String r, byte[] decryptKey) static void
Options are case sensitive.private void
private void
process
(String dir, String db, String cipher, char[] decryptPassword, char[] encryptPassword, boolean quiet) void
Run the tool with the given output stream and arguments.Methods inherited from class org.h2.util.Tool
isOption, printNoDatabaseFilesFound, setOut, showUsage, showUsageAndThrowUnsupportedOption, throwUnsupportedOption
-
Field Details
-
directory
-
cipherType
-
decryptKey
private byte[] decryptKey -
encryptKey
private byte[] encryptKey
-
-
Constructor Details
-
ChangeFileEncryption
public ChangeFileEncryption()
-
-
Method Details
-
main
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
- the command line arguments
-
runTool
Description copied from class:Tool
Run the tool with the given output stream and arguments.- Specified by:
runTool
in classTool
- Parameters:
args
- the argument list- Throws:
SQLException
- on failure
-
execute
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
- the directory (. for the current directory)db
- the database name (null for all databases)cipher
- the cipher (AES)decryptPassword
- the decryption password as a char arrayencryptPassword
- the encryption password as a char arrayquiet
- don't print progress information- Throws:
SQLException
- on failure
-
process
private void process(String dir, String db, String cipher, char[] decryptPassword, char[] encryptPassword, boolean quiet) throws SQLException - Throws:
SQLException
-
process
- Throws:
SQLException
-
copyMvStore
private void copyMvStore(String fileName, boolean quiet, char[] decryptPassword) throws IOException, SQLException - Throws:
IOException
SQLException
-
getFileChannel
private static FileChannel getFileChannel(String fileName, String r, byte[] decryptKey) throws IOException - Throws:
IOException
-