/** * Open a non encrypted file store with the given settings. * * @param handler the data handler * @param name the file name * @param mode the access mode (r, rw, rws, rwd) * @return the created object */ public static FileStorage open(DataHandler handler, String name, String mode) { return open(handler, name, mode, null, null, 0); }
/** * Open an encrypted file store with the given settings. * * @param handler the data handler * @param name the file name * @param mode the access mode (r, rw, rws, rwd) * @param cipher the name of the cipher algorithm * @param key the encryption key * @return the created object */ public static FileStorage open(DataHandler handler, String name, String mode, String cipher, byte[] key) { return open(handler, name, mode, cipher, key, Constants.ENCRYPTION_KEY_HASH_ITERATIONS); }
private FileStorage getFileStorage(int chunkId) { String chunkFileName = btreeStoragePath + File.separator + chunkId + AOStorage.SUFFIX_AO_FILE; FileStorage fileStorage = new FileStorage(); fileStorage.open(chunkFileName, map.config); return fileStorage; }
@Override public FileStorage openFile(String name, String mode, boolean mustExist) { if (mustExist && !FileUtils.exists(name)) { throw DbException.get(ErrorCode.FILE_NOT_FOUND_1, name); } FileStorage fileStorage; if (cipher == null) { fileStorage = FileStorage.open(this, name, mode); } else { fileStorage = FileStorage.open(this, name, mode, cipher, fileEncryptionKey, 0); } fileStorage.setCheckedWriting(false); try { fileStorage.init(); } catch (DbException e) { fileStorage.closeSilently(); throw e; } return fileStorage; }
@Override public FileStorage openFile(String name, String openMode, boolean mustExist) { if (mustExist && !FileUtils.exists(name)) { throw DbException.get(ErrorCode.FILE_NOT_FOUND_1, name); } FileStorage fileStorage = FileStorage.open(this, name, openMode, dbSettings.cipher, dbSettings.filePasswordHash); try { fileStorage.init(); } catch (DbException e) { fileStorage.closeSilently(); throw e; } return fileStorage; }
RedoLogChunk(int id, Map<String, String> config) { this.id = id; this.config = config; String chunkFileName = getChunkFileName(config, id); fileStorage = new FileStorage(); fileStorage.open(chunkFileName, config); queue = new LinkedTransferQueue<>(); pos = fileStorage.size(); if (pos > 0) read(); }
private void initStore() { Database db = session.getDatabase(); byte[] key = null; if (cipher != null && password != null) { char[] pass = password.optimize(session).getValue(session).getString().toCharArray(); key = SHA256.getKeyPasswordHash("script", pass); } String file = getFileName(); fileStorage = FileStorage.open(db, file, "rw", cipher, key); fileStorage.setCheckedWriting(false); fileStorage.init(); }