mirror of
https://github.com/iterate-ch/cyberduck.git
synced 2026-05-26 19:10:49 +00:00
Always pass plain text folder name as argument.
This commit is contained in:
@@ -406,6 +406,10 @@ public class CryptoVault implements Vault {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Path encrypt(final Session<?> session, final Path file, final String directoryId, boolean metadata) throws BackgroundException {
|
public Path encrypt(final Session<?> session, final Path file, final String directoryId, boolean metadata) throws BackgroundException {
|
||||||
|
if(file.getType().contains(Path.Type.encrypted)) {
|
||||||
|
log.warn("Skip file {} because it is already marked as an encrypted path", file);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
final Path encrypted;
|
final Path encrypted;
|
||||||
if(file.isFile() || metadata) {
|
if(file.isFile() || metadata) {
|
||||||
if(file.getType().contains(Path.Type.vault)) {
|
if(file.getType().contains(Path.Type.vault)) {
|
||||||
@@ -416,17 +420,8 @@ public class CryptoVault implements Vault {
|
|||||||
log.warn("Skip vault home {} because the root has no metadata file", file);
|
log.warn("Skip vault home {} because the root has no metadata file", file);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
final Path parent;
|
final Path parent = directoryProvider.toEncrypted(session, file.getParent().attributes().getDirectoryId(), file.getParent());
|
||||||
final String filename;
|
final String filename = directoryProvider.toEncrypted(session, parent.attributes().getDirectoryId(), file.getName(), file.getType());
|
||||||
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());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
parent = directoryProvider.toEncrypted(session, file.getParent().attributes().getDirectoryId(), file.getParent());
|
|
||||||
filename = directoryProvider.toEncrypted(session, parent.attributes().getDirectoryId(), file.getName(), file.getType());
|
|
||||||
}
|
|
||||||
final PathAttributes attributes = new DefaultPathAttributes(file.attributes());
|
final PathAttributes attributes = new DefaultPathAttributes(file.attributes());
|
||||||
attributes.setDirectoryId(null);
|
attributes.setDirectoryId(null);
|
||||||
if(!file.isFile() && !metadata) {
|
if(!file.isFile() && !metadata) {
|
||||||
@@ -446,10 +441,6 @@ public class CryptoVault implements Vault {
|
|||||||
encrypted = new Path(parent, filename, type, attributes);
|
encrypted = new Path(parent, filename, type, attributes);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(file.getType().contains(Path.Type.encrypted)) {
|
|
||||||
log.warn("Skip file {} because it is already marked as an encrypted path", file);
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
if(file.getType().contains(Path.Type.vault)) {
|
if(file.getType().contains(Path.Type.vault)) {
|
||||||
return directoryProvider.toEncrypted(session, home.attributes().getDirectoryId(), home);
|
return directoryProvider.toEncrypted(session, home.attributes().getDirectoryId(), home);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -69,7 +69,7 @@ public class CryptoDirectoryV6Feature<Reply> implements Directory<Reply> {
|
|||||||
target.attributes().setDirectoryId(directoryId);
|
target.attributes().setDirectoryId(directoryId);
|
||||||
target.attributes().setDecrypted(folder);
|
target.attributes().setDecrypted(folder);
|
||||||
// Make reference of encrypted path in attributes of decrypted file point to metadata file
|
// Make reference of encrypted path in attributes of decrypted file point to metadata file
|
||||||
final Path decrypt = vault.decrypt(session, vault.encrypt(session, target, true));
|
final Path decrypt = vault.decrypt(session, vault.encrypt(session, folder, true));
|
||||||
decrypt.attributes().setFileId(directoryMetadataFile.attributes().getFileId());
|
decrypt.attributes().setFileId(directoryMetadataFile.attributes().getFileId());
|
||||||
decrypt.attributes().setVersionId(directoryMetadataFile.attributes().getVersionId());
|
decrypt.attributes().setVersionId(directoryMetadataFile.attributes().getVersionId());
|
||||||
return decrypt;
|
return decrypt;
|
||||||
|
|||||||
+1
-1
@@ -76,7 +76,7 @@ public class CryptoDirectoryV7Feature<Reply> implements Directory<Reply> {
|
|||||||
target.attributes().setDirectoryId(directoryId);
|
target.attributes().setDirectoryId(directoryId);
|
||||||
target.attributes().setDecrypted(folder);
|
target.attributes().setDecrypted(folder);
|
||||||
// Make reference of encrypted path in attributes of decrypted file point to metadata file
|
// Make reference of encrypted path in attributes of decrypted file point to metadata file
|
||||||
final Path decrypt = vault.decrypt(session, vault.encrypt(session, target, true));
|
final Path decrypt = vault.decrypt(session, vault.encrypt(session, folder, true));
|
||||||
decrypt.attributes().setFileId(directoryMetadataFolder.attributes().getFileId());
|
decrypt.attributes().setFileId(directoryMetadataFolder.attributes().getFileId());
|
||||||
decrypt.attributes().setVersionId(directoryMetadataFolder.attributes().getVersionId());
|
decrypt.attributes().setVersionId(directoryMetadataFolder.attributes().getVersionId());
|
||||||
return decrypt;
|
return decrypt;
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ public class CryptoVaultTest {
|
|||||||
vault.encrypt(session, vault.encrypt(session, new Path(home, "dir", EnumSet.of(Path.Type.directory)))).attributes().getDirectoryId()
|
vault.encrypt(session, vault.encrypt(session, new Path(home, "dir", EnumSet.of(Path.Type.directory)))).attributes().getDirectoryId()
|
||||||
);
|
);
|
||||||
assertNull(vault.encrypt(session, new Path(home, "dir", EnumSet.of(Path.Type.directory)), true).attributes().getDirectoryId());
|
assertNull(vault.encrypt(session, new Path(home, "dir", EnumSet.of(Path.Type.directory)), true).attributes().getDirectoryId());
|
||||||
assertNull(vault.encrypt(session, vault.encrypt(session, new Path(home, "dir", EnumSet.of(Path.Type.directory))), true).attributes().getDirectoryId());
|
|
||||||
assertNotEquals(
|
assertNotEquals(
|
||||||
vault.encrypt(session, new Path(home, "dir", EnumSet.of(Path.Type.directory))).attributes().getDirectoryId(),
|
vault.encrypt(session, new Path(home, "dir", EnumSet.of(Path.Type.directory))).attributes().getDirectoryId(),
|
||||||
vault.encrypt(session, new Path(home, "dir", EnumSet.of(Path.Type.directory)), true).attributes().getDirectoryId()
|
vault.encrypt(session, new Path(home, "dir", EnumSet.of(Path.Type.directory)), true).attributes().getDirectoryId()
|
||||||
|
|||||||
Reference in New Issue
Block a user