Skip to content

Commit 8dcfd90

Browse files
chenkinsdkocher
authored andcommitted
Add UVF implementation.
1 parent 2bdbb46 commit 8dcfd90

File tree

46 files changed

+1794
-659
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1794
-659
lines changed

core/src/main/java/ch/cyberduck/core/PathAttributes.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public class PathAttributes extends Attributes implements Serializable {
156156
/**
157157
* Unique identifier for cryptomator
158158
*/
159-
private String directoryId;
159+
private byte[] directoryId;
160160

161161
private Map<String, String> custom = Collections.emptyMap();
162162

@@ -480,11 +480,11 @@ public PathAttributes setLockId(final String lockId) {
480480
return this;
481481
}
482482

483-
public String getDirectoryId() {
483+
public byte[] getDirectoryId() {
484484
return directoryId;
485485
}
486486

487-
public PathAttributes setDirectoryId(final String directoryId) {
487+
public PathAttributes setDirectoryId(final byte[] directoryId) {
488488
this.directoryId = directoryId;
489489
return this;
490490
}
@@ -803,7 +803,7 @@ public PathAttributes setLockId(final String lockId) {
803803
}
804804

805805
@Override
806-
public PathAttributes setDirectoryId(final String directoryId) {
806+
public PathAttributes setDirectoryId(final byte[] directoryId) {
807807
return this;
808808
}
809809

cryptomator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<packaging>jar</packaging>
2626

2727
<properties>
28-
<cryptolib.version>2.1.2.1</cryptolib.version>
28+
<cryptolib.version>2.3.0.uvfdraft-SNAPSHOT</cryptolib.version>
2929
</properties>
3030

3131
<dependencies>

cryptomator/src/main/java/ch/cyberduck/core/cryptomator/AbstractVault.java

Lines changed: 422 additions & 0 deletions
Large diffs are not rendered by default.

cryptomator/src/main/java/ch/cyberduck/core/cryptomator/ContentReader.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
import ch.cyberduck.core.Session;
2222
import ch.cyberduck.core.exception.BackgroundException;
2323
import ch.cyberduck.core.features.Read;
24+
import ch.cyberduck.core.io.StreamCopier;
2425
import ch.cyberduck.core.transfer.TransferStatus;
2526

2627
import org.apache.commons.io.IOUtils;
2728

29+
import java.io.ByteArrayOutputStream;
2830
import java.io.IOException;
2931
import java.io.InputStream;
3032
import java.io.InputStreamReader;
@@ -49,6 +51,19 @@ public String read(final Path file) throws BackgroundException {
4951
}
5052
}
5153

54+
public byte[] readBytes(final Path file) throws BackgroundException {
55+
final Read read = session._getFeature(Read.class);
56+
final TransferStatus status = new TransferStatus().setLength(file.attributes().getSize());
57+
try (final InputStream in = read.read(file, status, new DisabledConnectionCallback())) {
58+
final ByteArrayOutputStream out = new ByteArrayOutputStream();
59+
new StreamCopier(status, status).transfer(in, out);
60+
return out.toByteArray();
61+
}
62+
catch(IOException e) {
63+
throw new DefaultIOExceptionMappingService().map(e);
64+
}
65+
}
66+
5267
public Reader getReader(final Path file) throws BackgroundException {
5368
final Read read = session._getFeature(Read.class);
5469
return new InputStreamReader(read.read(file, new TransferStatus().setLength(file.attributes().getSize()), new DisabledConnectionCallback()), StandardCharsets.UTF_8);

cryptomator/src/main/java/ch/cyberduck/core/cryptomator/CryptoAclPermission.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@
2222
import ch.cyberduck.core.features.AclPermission;
2323
import ch.cyberduck.core.transfer.TransferStatus;
2424

25-
import java.util.EnumSet;
2625
import java.util.List;
2726

2827
public class CryptoAclPermission implements AclPermission {
2928

3029
private final Session<?> session;
3130
private final AclPermission delegate;
32-
private final CryptoVault cryptomator;
31+
private final AbstractVault cryptomator;
3332

34-
public CryptoAclPermission(final Session<?> session, final AclPermission delegate, final CryptoVault cryptomator) {
33+
public CryptoAclPermission(final Session<?> session, final AclPermission delegate, final AbstractVault cryptomator) {
3534

3635
this.session = session;
3736
this.delegate = delegate;

cryptomator/src/main/java/ch/cyberduck/core/cryptomator/CryptoDirectory.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,29 @@ public interface CryptoDirectory {
2727
* Get encrypted filename for given clear text filename with id of parent encrypted directory.
2828
*
2929
* @param session Connection
30-
* @param directoryId Parent folder directory id
30+
* @param parent Parent folder
3131
* @param filename Clear text filename
3232
* @param type File type
3333
* @return Encrypted filename
3434
*/
35-
String toEncrypted(Session<?> session, String directoryId, String filename, EnumSet<Path.Type> type) throws BackgroundException;
35+
String toEncrypted(Session<?> session, Path parent, String filename, EnumSet<Path.Type> type) throws BackgroundException;
3636

3737
/**
3838
* Get encrypted reference for clear text directory path.
3939
*
40-
* @param session Connection
41-
* @param directoryId Directory ID or null to read directory id from metadata file
42-
* @param directory Clear text
40+
* @param session Connection
41+
* @param directory Clear text
4342
*/
44-
Path toEncrypted(Session<?> session, String directoryId, Path directory) throws BackgroundException;
43+
Path toEncrypted(Session<?> session, Path directory) throws BackgroundException;
4544

4645
/**
4746
* Remove from cache
4847
*/
4948
void delete(Path directory);
5049

5150
void destroy();
51+
52+
byte[] getOrCreateDirectoryId(Session<?> session, Path directory) throws BackgroundException;
53+
54+
byte[] createDirectoryId(final Path directory);
5255
}

cryptomator/src/main/java/ch/cyberduck/core/cryptomator/CryptoTransferStatus.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
public class CryptoTransferStatus extends ProxyTransferStatus implements StreamCancelation, StreamProgress {
2828
private static final Logger log = LogManager.getLogger(CryptoTransferStatus.class);
2929

30-
private final CryptoVault vault;
30+
private final AbstractVault vault;
3131

32-
public CryptoTransferStatus(final CryptoVault vault, final TransferStatus proxy) {
32+
public CryptoTransferStatus(final AbstractVault vault, final TransferStatus proxy) {
3333
super(proxy);
3434
this.vault = vault;
3535
this.setLength(vault.toCiphertextSize(proxy.getOffset(), proxy.getLength()))

0 commit comments

Comments
 (0)