@Override public Path encrypt(final Session<?> session, final Path file, boolean metadata) throws BackgroundException { return this.encrypt(session, file, file.attributes().getDirectoryId(), metadata); }
@Override public Path encrypt(final Session<?> session, final Path file) throws BackgroundException { return this.encrypt(session, file, file.attributes().getDirectoryId(), false); }
private String load(final Session<?> session, final Path directory) throws BackgroundException { final Path parent = this.toEncrypted(session, directory.getParent().attributes().getDirectoryId(), directory.getParent()); final String cleartextName = directory.getName(); final String ciphertextName = this.toEncrypted(session, parent.attributes().getDirectoryId(), cleartextName, EnumSet.of(Path.Type.directory)); // Read directory id from file try { if(log.isDebugEnabled()) { log.debug(String.format("Read directory ID for folder %s from %s", directory, ciphertextName)); } final Path metadataFile = new Path(parent, ciphertextName, EnumSet.of(Path.Type.file, Path.Type.encrypted)); return new ContentReader(session).read(metadataFile); } catch(NotfoundException e) { log.warn(String.format("Missing directory ID for folder %s", directory)); return random.random(); } }
if(file.getType().contains(Path.Type.encrypted)) { final Path decrypted = file.attributes().getDecrypted(); parent = directoryProvider.toEncrypted(session, decrypted.getParent().attributes().getDirectoryId(), decrypted.getParent()); filename = directoryProvider.toEncrypted(session, parent.attributes().getDirectoryId(), decrypted.getName(), decrypted.getType()); parent = directoryProvider.toEncrypted(session, file.getParent().attributes().getDirectoryId(), file.getParent()); filename = directoryProvider.toEncrypted(session, parent.attributes().getDirectoryId(), file.getName(), file.getType()); return directoryProvider.toEncrypted(session, home.attributes().getDirectoryId(), home);
try { final String cleartextFilename = cryptor.fileNameCryptor().decryptFilename( ciphertext, file.getParent().attributes().getDirectoryId().getBytes(StandardCharsets.UTF_8)); final PathAttributes attributes = new PathAttributes(file.attributes()); if(inflated.getName().startsWith(DIR_PREFIX)) {
new ContentWriter(session).write(masterkey, masterKeyFileContent.serialize()); this.open(KeyFile.parse(masterKeyFileContent.serialize()), passphrase); final Path secondLevel = directoryProvider.toEncrypted(session, home.attributes().getDirectoryId(), home); final Path firstLevel = secondLevel.getParent(); final Path dataDir = firstLevel.getParent();