Package org.h2.tools
Class ChangeFileEncryption
- java.lang.Object
-
- org.h2.util.Tool
-
- org.h2.tools.ChangeFileEncryption
-
public class ChangeFileEncryption extends 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
Fields Modifier and Type Field Description private java.lang.StringcipherTypeprivate byte[]decryptKeyprivate java.lang.Stringdirectoryprivate byte[]encryptKey
-
Constructor Summary
Constructors Constructor Description ChangeFileEncryption()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcopyMvStore(java.lang.String fileName, boolean quiet, char[] decryptPassword)static voidexecute(java.lang.String dir, java.lang.String db, java.lang.String cipher, char[] decryptPassword, char[] encryptPassword, boolean quiet)Changes the password for a database.private static java.nio.channels.FileChannelgetFileChannel(java.lang.String fileName, java.lang.String r, byte[] decryptKey)static voidmain(java.lang.String... args)Options are case sensitive.private voidprocess(java.lang.String fileName, boolean quiet, char[] decryptPassword)private voidprocess(java.lang.String dir, java.lang.String db, java.lang.String cipher, char[] decryptPassword, char[] encryptPassword, boolean quiet)voidrunTool(java.lang.String... args)Run the tool with the given output stream and arguments.-
Methods inherited from class org.h2.util.Tool
isOption, printNoDatabaseFilesFound, setOut, showUsage, showUsageAndThrowUnsupportedOption, throwUnsupportedOption
-
-
-
-
Method Detail
-
main
public static void main(java.lang.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- the command line arguments
-
runTool
public void runTool(java.lang.String... args) throws java.sql.SQLExceptionDescription copied from class:ToolRun the tool with the given output stream and arguments.
-
execute
public static void execute(java.lang.String dir, java.lang.String db, java.lang.String cipher, char[] decryptPassword, char[] encryptPassword, boolean quiet) throws java.sql.SQLExceptionChanges 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:
java.sql.SQLException- on failure
-
process
private void process(java.lang.String dir, java.lang.String db, java.lang.String cipher, char[] decryptPassword, char[] encryptPassword, boolean quiet) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
process
private void process(java.lang.String fileName, boolean quiet, char[] decryptPassword) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
copyMvStore
private void copyMvStore(java.lang.String fileName, boolean quiet, char[] decryptPassword) throws java.io.IOException, java.sql.SQLException- Throws:
java.io.IOExceptionjava.sql.SQLException
-
getFileChannel
private static java.nio.channels.FileChannel getFileChannel(java.lang.String fileName, java.lang.String r, byte[] decryptKey) throws java.io.IOException- Throws:
java.io.IOException
-
-