Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit ef4e030

Browse files
Merge branch 'release/0.2.0' into main
2 parents 12c2537 + 7ada7ba commit ef4e030

Some content is hidden

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

42 files changed

+3631
-1908
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
build:
88
name: Build and Test
99
runs-on: ubuntu-latest
10-
outputs:
11-
artifact-version: ${{ steps.setversion.outputs.version }}
1210
env:
1311
BUILD_VERSION: SNAPSHOT
12+
outputs:
13+
artifact-version: ${{ steps.setversion.outputs.version }}
1414
steps:
1515
- uses: actions/checkout@v2
1616
- uses: actions/setup-java@v1
@@ -36,14 +36,15 @@ jobs:
3636
echo "::set-output name=version::${v}"
3737
- name: Build and Test
3838
run: mvn -B install
39-
- name: Upload snapshot artifact cloud-access-${{ env.BUILD_VERSION }}.jar
39+
- name: Upload snapshot artifact cloud-access-${{ env.BUILD_VERSION }}.jar build on Linux
40+
if: runner.os == 'Linux' # The build artifacts are the same on all os, therefore we upload from the "cheapest" runner
4041
uses: actions/upload-artifact@v2
4142
with:
4243
name: cloud-access-${{ env.BUILD_VERSION }}.jar
4344
path: target/cloud-access-*.jar
44-
- name: Deploy to jcenter
45-
run: mvn -B deploy
45+
- name: Build and deploy to jcenter
4646
if: startsWith(github.ref, 'refs/tags/')
47+
run: mvn -B deploy -DskipTests
4748
env:
4849
BINTRAY_USERNAME: cryptobot
4950
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}

pom.xml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>org.cryptomator</groupId>
77
<artifactId>cloud-access</artifactId>
8-
<version>0.1.0</version>
8+
<version>0.2.0</version>
99

1010
<name>Cryptomator CloudAccess in Java</name>
1111
<description>CloudAccess is used in e.g. Cryptomator for Android to access different cloud providers.</description>
@@ -16,6 +16,13 @@
1616
<url>[email protected]:cryptomator/cloud-access-java.git</url>
1717
</scm>
1818
<developers>
19+
<developer>
20+
<name>Armin Schrenk</name>
21+
<email>[email protected]</email>
22+
<timezone>+1</timezone>
23+
<organization>Skymatic GmbH</organization>
24+
<organizationUrl>http://skymatic.de</organizationUrl>
25+
</developer>
1926
<developer>
2027
<name>Julian Raufelder</name>
2128
<email>[email protected]</email>
@@ -37,7 +44,7 @@
3744
<guava.version>29.0-jre</guava.version>
3845

3946
<okhttp.version>4.7.2</okhttp.version>
40-
<okhttp-digest.version>2.3</okhttp-digest.version>
47+
<okhttp-digest.version>2.4</okhttp-digest.version>
4148
<okhttp.mockwebserver.version>4.7.2</okhttp.mockwebserver.version>
4249
<kxml2.version>2.3.0</kxml2.version>
4350

@@ -78,19 +85,18 @@
7885
<artifactId>guava</artifactId>
7986
<version>${guava.version}</version>
8087
</dependency>
88+
<dependency>
89+
<groupId>org.cryptomator</groupId>
90+
<artifactId>cryptolib</artifactId>
91+
<version>1.4.0-beta3</version>
92+
</dependency>
8193

8294
<!-- Logging -->
8395
<dependency>
8496
<groupId>org.slf4j</groupId>
8597
<artifactId>slf4j-api</artifactId>
8698
<version>${slf4j.version}</version>
8799
</dependency>
88-
<dependency>
89-
<groupId>org.slf4j</groupId>
90-
<artifactId>slf4j-simple</artifactId>
91-
<version>${slf4j.version}</version>
92-
<scope>test</scope>
93-
</dependency>
94100

95101
<!-- WebDAV -->
96102
<dependency>
@@ -129,6 +135,12 @@
129135
<version>${okhttp.mockwebserver.version}</version>
130136
<scope>test</scope>
131137
</dependency>
138+
<dependency>
139+
<groupId>org.slf4j</groupId>
140+
<artifactId>slf4j-simple</artifactId>
141+
<version>${slf4j.version}</version>
142+
<scope>test</scope>
143+
</dependency>
132144
</dependencies>
133145

134146
<build>

src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
requires java.xml;
77
requires com.google.common;
8+
requires org.cryptomator.cryptolib;
89
requires org.slf4j;
910
requires okhttp3;
1011
requires okhttp.digest;

src/main/java/org/cryptomator/cloudaccess/CloudAccess.java

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,58 @@
11
package org.cryptomator.cloudaccess;
22

3-
import java.net.URL;
4-
import java.nio.file.Path;
5-
3+
import org.cryptomator.cloudaccess.api.CloudPath;
64
import org.cryptomator.cloudaccess.api.CloudProvider;
5+
import org.cryptomator.cloudaccess.api.exceptions.CloudProviderException;
76
import org.cryptomator.cloudaccess.localfs.LocalFsCloudProvider;
7+
import org.cryptomator.cloudaccess.vaultformat8.VaultFormat8ProviderDecorator;
88
import org.cryptomator.cloudaccess.webdav.WebDavCloudProvider;
99
import org.cryptomator.cloudaccess.webdav.WebDavCredential;
10+
import org.cryptomator.cryptolib.Cryptors;
11+
12+
import java.net.URL;
13+
import java.nio.file.Path;
14+
import java.security.NoSuchAlgorithmException;
15+
import java.security.SecureRandom;
16+
import java.util.stream.Collectors;
17+
import java.util.stream.IntStream;
1018

1119
public class CloudAccess {
1220

1321
private CloudAccess() {
1422
}
1523

24+
/**
25+
* Decorates an existing CloudProvider by encrypting paths and file contents using Cryptomator's Vault Format 8.
26+
* Uses an externally managed masterkey, i.e. it will only validate the vault version but not parse any vault config.
27+
*
28+
* @param cloudProvider A CloudProvider providing access to a storage space on which to store ciphertext data
29+
* @param pathToVault Path that can be used within the given <code>cloudProvider</code> leading to the vault's root
30+
* @param rawKey 512 bit key used for cryptographic operations
31+
* @return A cleartext view on the given CloudProvider
32+
*/
33+
public static CloudProvider vaultFormat8GCMCloudAccess(CloudProvider cloudProvider, CloudPath pathToVault, byte[] rawKey) {
34+
try {
35+
var csprng = SecureRandom.getInstanceStrong();
36+
var cryptor = Cryptors.version2(csprng).createFromRawKey(rawKey);
37+
// TODO validate vaultFormat.jwt before creating decorator
38+
VaultFormat8ProviderDecorator provider = new VaultFormat8ProviderDecorator(cloudProvider, pathToVault.resolve("d"), cryptor);
39+
provider.initialize();
40+
return provider;
41+
} catch (NoSuchAlgorithmException e) {
42+
throw new IllegalStateException("JVM doesn't supply a CSPRNG", e);
43+
} catch (InterruptedException e) {
44+
Thread.currentThread().interrupt();
45+
throw new CloudProviderException("Vault initialization interrupted.", e);
46+
}
47+
}
48+
1649
/**
1750
* Creates a new CloudProvider which provides access to the given URL via WebDAV.
1851
*
19-
* @param url Base URL leading to the root resource
52+
* @param url Base URL leading to the root resource
2053
* @param username Username used during basic or digest auth challenges
2154
* @param password Password used during basic or digest auth challenges
22-
* @return A cloud access provider that provides access to the given WebDAV URL.
55+
* @return A cloud access provider that provides access to the given WebDAV URL
2356
*/
2457
public static CloudProvider toWebDAV(URL url, String username, CharSequence password) {
2558
// TODO can we pass though CharSequence to the auth mechanism?
@@ -29,8 +62,8 @@ public static CloudProvider toWebDAV(URL url, String username, CharSequence pass
2962
/**
3063
* Creates a new CloudProvider which provides access to the given <code>folder</code>. Mainly for test purposes.
3164
*
32-
* @param folder An existing folder on the (local) default file system.
33-
* @return A cloud access provider that provides access to the given local directory.
65+
* @param folder An existing folder on the (local) default file system
66+
* @return A cloud access provider that provides access to the given local directory
3467
*/
3568
public static CloudProvider toLocalFileSystem(Path folder) {
3669
return new LocalFsCloudProvider(folder);

src/main/java/org/cryptomator/cloudaccess/api/CloudItemMetadata.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,33 @@
22

33
import com.google.common.base.Objects;
44

5-
import java.nio.file.Path;
65
import java.time.Instant;
76
import java.util.Optional;
87

98
public class CloudItemMetadata {
109
private final String name;
11-
private final Path path;
10+
private final CloudPath path;
1211
private final CloudItemType itemType;
1312
private final Optional<Instant> lastModifiedDate;
1413
private final Optional<Long> size;
1514

16-
public CloudItemMetadata(String name, Path path, CloudItemType itemType, Optional<Instant> lastModifiedDate, Optional<Long> size) {
15+
public CloudItemMetadata(String name, CloudPath path, CloudItemType itemType, Optional<Instant> lastModifiedDate, Optional<Long> size) {
1716
this.name = name;
1817
this.path = path;
1918
this.itemType = itemType;
2019
this.lastModifiedDate = lastModifiedDate;
2120
this.size = size;
2221
}
2322

24-
public CloudItemMetadata(String name, Path path, CloudItemType itemType) {
23+
public CloudItemMetadata(String name, CloudPath path, CloudItemType itemType) {
2524
this(name, path, itemType, Optional.empty(), Optional.empty());
2625
}
2726

2827
public String getName() {
2928
return name;
3029
}
3130

32-
public Path getPath() {
31+
public CloudPath getPath() {
3332
return path;
3433
}
3534

@@ -61,4 +60,9 @@ public boolean equals(Object o) {
6160
public int hashCode() {
6261
return Objects.hashCode(name, path, itemType, lastModifiedDate, size);
6362
}
63+
64+
@Override
65+
public String toString() {
66+
return "CloudItemMetadata{itemType=" + itemType + ", path=" + path + ", name=" + name + '}';
67+
}
6468
}

0 commit comments

Comments
 (0)