From 3cb8b4f78b5566c4ad416c1ed5cfbf0d983d8c05 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Thu, 8 Jun 2017 15:34:17 +0200 Subject: [PATCH 1/4] Updated documentation [ci skip] --- README.md | 38 +++++++++++-------- .../cryptofs/CryptoFileSystemProperties.java | 14 +++++++ 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a8ce1a93..6b9f2e1c 100644 --- a/README.md +++ b/README.md @@ -25,30 +25,36 @@ For more information on the security details visit [cryptomator.org](https://cry CryptoFS depends on a Java 8 JRE/JDK. In addition the JCE unlimited strength policy files (needed for 256-bit keys) must be installed. -### Construction +### Vault initialization + +```java +Path storageLocation = Paths.get("/home/cryptobot/vault"); +Files.createDirectories(storageLocation); +CryptoFileSystemProvider.initialize(storageLocation, "masterkey.cryptomator", "password"); +``` + +### Obtaining a FileSystem instance You have the option to use the convenience method ``CryptoFileSystemProvider#newFileSystem`` as follows: ```java -Path storageLocation = Paths.get("/home/cryptobot/vault"); FileSystem fileSystem = CryptoFileSystemProvider.newFileSystem( storageLocation, CryptoFileSystemProperties.cryptoFileSystemProperties() .withPassphrase("password") - .withReadonlyFlag() // readonly flag is optional of course + .withFlags(FileSystemFlags.READONLY) // readonly flag is optional of course .build()); ``` or to use one of the standard methods from ``FileSystems#newFileSystem``: ```java -Path storageLocation = Paths.get("/home/cryptobot/vault"); URI uri = CryptoFileSystemUri.create(storageLocation); FileSystem fileSystem = FileSystems.newFileSystem( uri, CryptoFileSystemProperties.cryptoFileSystemProperties() .withPassphrase("password") - .withReadonlyFlag() // readonly flag is optional of course + .withFlags(FileSystemFlags.READONLY) // readonly flag is optional of course .build()); ``` @@ -59,20 +65,22 @@ For more details on construction have a look at the javadoc of ``CryptoFileSytem ### Using the constructed file system ```java -FileSystem fileSystem = ...; // see above +try (FileSystem fileSystem = ...) { // see above + + // obtain a path to a test file + Path testFile = fileSystem.getPath("/foo/bar/test"); -// obtain a path to a test file -Path testFile = fileSystem.getPath("/foo/bar/test"); + // create all parent directories + Files.createDirectories(testFile.getParent()); -// create all parent directories -Files.createDirectories(testFile.getParent()); + // Write data to the file + Files.write(testFile, "test".getBytes()); -// Write data to the file -Files.write(testFile, "test".getBytes()); + // List all files present in a directory + try (Stream listing = Files.list(testFile.getParent())) { + listing.forEach(System.out::println); + } -// List all files present in a directory -try (Stream listing = Files.list(testFile.getParent())) { - listing.forEach(System.out::println); } ``` diff --git a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java index e311fe21..655c43fa 100644 --- a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java +++ b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java @@ -205,10 +205,22 @@ public Builder withPassphrase(CharSequence passphrase) { return this; } + /** + * Sets the flags for a CryptoFileSystem. + * + * @return this + * @since 1.3.1 + */ public Builder withFlags(FileSystemFlags... flags) { return withFlags(asList(flags)); } + /** + * Sets the flags for a CryptoFileSystem. + * + * @return this + * @since 1.3.0 + */ public Builder withFlags(Collection flags) { this.flags.clear(); this.flags.addAll(flags); @@ -219,7 +231,9 @@ public Builder withFlags(Collection flags) { * Sets the readonly flag for a CryptoFileSystem. * * @return this + * @deprecated Will be removed in 2.0.0. Use {@link #withFlags(FileSystemFlags.READONLY)} */ + @Deprecated public Builder withReadonlyFlag() { flags.add(FileSystemFlags.READONLY); return this; From ec3cafb50c6d70edad26180cbb3fb29e553b2060 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 16 Jun 2017 15:40:04 +0200 Subject: [PATCH 2/4] Added API for initializing and accessing vaults, whose masterkey is derived using a pepper. --- .../cryptofs/CryptoFileSystemModule.java | 2 +- .../cryptofs/CryptoFileSystemProperties.java | 29 ++++++++++ .../cryptofs/CryptoFileSystemProvider.java | 17 +++++- .../CryptoFileSystemPropertiesTest.java | 28 ++++++++-- ...yptoFileSystemProviderIntegrationTest.java | 53 +++++++++++++++++-- .../CryptoFileSystemProviderTest.java | 6 +-- 6 files changed, 121 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemModule.java b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemModule.java index 5bed84c0..5f90778e 100644 --- a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemModule.java +++ b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemModule.java @@ -33,7 +33,7 @@ public Cryptor provideCryptor(CryptorProvider cryptorProvider, @PathToVault Path Path backupKeyPath = pathToVault.resolve(properties.masterkeyFilename() + Constants.MASTERKEY_BACKUP_SUFFIX); assert Files.exists(masterKeyPath); // since 1.3.0 a file system can only be created for existing vaults. initialization is done before. byte[] keyFileContents = Files.readAllBytes(masterKeyPath); - Cryptor cryptor = cryptorProvider.createFromKeyFile(KeyFile.parse(keyFileContents), properties.passphrase(), Constants.VAULT_VERSION); + Cryptor cryptor = cryptorProvider.createFromKeyFile(KeyFile.parse(keyFileContents), properties.passphrase(), properties.pepper(), Constants.VAULT_VERSION); Files.copy(masterKeyPath, backupKeyPath, REPLACE_EXISTING); return cryptor; }); diff --git a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java index 655c43fa..23a0a693 100644 --- a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java +++ b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java @@ -23,6 +23,7 @@ import java.util.function.Consumer; import org.apache.commons.lang3.StringUtils; +import org.cryptomator.cryptofs.CryptoFileSystemProperties.FileSystemFlags; /** * Properties to pass to @@ -40,6 +41,15 @@ public class CryptoFileSystemProperties extends AbstractMap { */ public static final String PROPERTY_PASSPHRASE = "passphrase"; + /** + * Key identifying the pepper used during key derivation. + * + * @since 1.3.2 + */ + public static final String PROPERTY_PEPPER = "pepper"; + + static final byte[] DEFAULT_PEPPER = new byte[0]; + /** * Key identifying the name of the masterkey file located inside the vault directory. * @@ -77,6 +87,7 @@ public enum FileSystemFlags { private CryptoFileSystemProperties(Builder builder) { this.entries = unmodifiableSet(new HashSet<>(asList( // entry(PROPERTY_PASSPHRASE, builder.passphrase), // + entry(PROPERTY_PEPPER, builder.pepper), // entry(PROPERTY_FILESYSTEM_FLAGS, builder.flags), // entry(PROPERTY_MASTERKEY_FILENAME, builder.masterkeyFilename) // ))); @@ -86,6 +97,10 @@ CharSequence passphrase() { return (CharSequence) get(PROPERTY_PASSPHRASE); } + byte[] pepper() { + return (byte[]) get(PROPERTY_PEPPER); + } + @SuppressWarnings("unchecked") Set flags() { return (Set) get(PROPERTY_FILESYSTEM_FLAGS); @@ -171,6 +186,7 @@ public static CryptoFileSystemProperties wrap(Map properties) { public static class Builder { private CharSequence passphrase; + public byte[] pepper = DEFAULT_PEPPER; private final Set flags = EnumSet.copyOf(DEFAULT_FILESYSTEM_FLAGS); private String masterkeyFilename = DEFAULT_MASTERKEY_FILENAME; @@ -179,6 +195,7 @@ private Builder() { private Builder(Map properties) { checkedSet(CharSequence.class, PROPERTY_PASSPHRASE, properties, this::withPassphrase); + checkedSet(byte[].class, PROPERTY_PEPPER, properties, this::withPepper); checkedSet(String.class, PROPERTY_MASTERKEY_FILENAME, properties, this::withMasterkeyFilename); checkedSet(Set.class, PROPERTY_FILESYSTEM_FLAGS, properties, this::withFlags); } @@ -205,6 +222,18 @@ public Builder withPassphrase(CharSequence passphrase) { return this; } + /** + * Sets the pepper for a CryptoFileSystem. + * + * @param pepper A pepper used during key derivation + * @return this + * @since 1.3.2 + */ + public Builder withPepper(byte[] pepper) { + this.pepper = pepper; + return this; + } + /** * Sets the flags for a CryptoFileSystem. * diff --git a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProvider.java b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProvider.java index 82de9cbf..86427f40 100644 --- a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProvider.java +++ b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProvider.java @@ -113,13 +113,28 @@ public static CryptoFileSystem newFileSystem(Path pathToVault, CryptoFileSystemP * @since 1.3.0 */ public static void initialize(Path pathToVault, String masterkeyFilename, CharSequence passphrase) throws NotDirectoryException, IOException { + initialize(pathToVault, masterkeyFilename, new byte[0], passphrase); + } + + /** + * Creates a new vault at the given directory path. + * + * @param pathToVault Path to a not yet existing directory + * @param masterkeyFilename Name of the masterkey file + * @param pepper Application-specific pepper used during key derivation + * @param passphrase Passphrase that should be used to unlock the vault + * @throws NotDirectoryException If the given path is not an existing directory. + * @throws IOException If the vault structure could not be initialized due to I/O errors + * @since 1.3.2 + */ + public static void initialize(Path pathToVault, String masterkeyFilename, byte[] pepper, CharSequence passphrase) throws NotDirectoryException, IOException { if (!Files.isDirectory(pathToVault)) { throw new NotDirectoryException(pathToVault.toString()); } try (Cryptor cryptor = CRYPTOR_PROVIDER.createNew()) { // save masterkey file: Path masterKeyPath = pathToVault.resolve(masterkeyFilename); - byte[] keyFileContents = cryptor.writeKeysToMasterkeyFile(passphrase, Constants.VAULT_VERSION).serialize(); + byte[] keyFileContents = cryptor.writeKeysToMasterkeyFile(passphrase, pepper, Constants.VAULT_VERSION).serialize(); Files.write(masterKeyPath, keyFileContents, CREATE_NEW, WRITE); // create "d/RO/OTDIRECTORY": String rootDirHash = cryptor.fileNameCryptor().hashDirectoryId(Constants.ROOT_DIR_ID); diff --git a/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemPropertiesTest.java b/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemPropertiesTest.java index 258b3d6e..89f12f7c 100644 --- a/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemPropertiesTest.java +++ b/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemPropertiesTest.java @@ -1,9 +1,11 @@ package org.cryptomator.cryptofs; import static org.cryptomator.cryptofs.CryptoFileSystemProperties.DEFAULT_MASTERKEY_FILENAME; +import static org.cryptomator.cryptofs.CryptoFileSystemProperties.DEFAULT_PEPPER; import static org.cryptomator.cryptofs.CryptoFileSystemProperties.PROPERTY_FILESYSTEM_FLAGS; import static org.cryptomator.cryptofs.CryptoFileSystemProperties.PROPERTY_MASTERKEY_FILENAME; import static org.cryptomator.cryptofs.CryptoFileSystemProperties.PROPERTY_PASSPHRASE; +import static org.cryptomator.cryptofs.CryptoFileSystemProperties.PROPERTY_PEPPER; import static org.cryptomator.cryptofs.CryptoFileSystemProperties.cryptoFileSystemProperties; import static org.cryptomator.cryptofs.CryptoFileSystemProperties.cryptoFileSystemPropertiesFrom; import static org.hamcrest.CoreMatchers.sameInstance; @@ -11,6 +13,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; +import java.nio.charset.StandardCharsets; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; @@ -37,7 +40,7 @@ public void testSetNoPassphrase() { } @Test - @SuppressWarnings({"unchecked", "deprecation"}) + @SuppressWarnings({ "unchecked", "deprecation" }) public void testSetOnlyPassphrase() { String passphrase = "aPassphrase"; CryptoFileSystemProperties inTest = cryptoFileSystemProperties() // @@ -51,12 +54,13 @@ public void testSetOnlyPassphrase() { assertThat(inTest.entrySet(), containsInAnyOrder( // anEntry(PROPERTY_PASSPHRASE, passphrase), // + anEntry(PROPERTY_PEPPER, DEFAULT_PEPPER), // anEntry(PROPERTY_MASTERKEY_FILENAME, DEFAULT_MASTERKEY_FILENAME), // anEntry(PROPERTY_FILESYSTEM_FLAGS, EnumSet.of(FileSystemFlags.INIT_IMPLICITLY)))); } @Test - @SuppressWarnings({"unchecked", "deprecation"}) + @SuppressWarnings({ "unchecked", "deprecation" }) public void testSetPassphraseAndReadonlyFlag() { String passphrase = "aPassphrase"; CryptoFileSystemProperties inTest = cryptoFileSystemProperties() // @@ -71,12 +75,13 @@ public void testSetPassphraseAndReadonlyFlag() { assertThat(inTest.entrySet(), containsInAnyOrder( // anEntry(PROPERTY_PASSPHRASE, passphrase), // + anEntry(PROPERTY_PEPPER, DEFAULT_PEPPER), // anEntry(PROPERTY_MASTERKEY_FILENAME, DEFAULT_MASTERKEY_FILENAME), // anEntry(PROPERTY_FILESYSTEM_FLAGS, EnumSet.of(FileSystemFlags.READONLY, FileSystemFlags.INIT_IMPLICITLY)))); } @Test - @SuppressWarnings({"unchecked", "deprecation"}) + @SuppressWarnings({ "unchecked", "deprecation" }) public void testSetPassphraseAndMasterkeyFilenameAndReadonlyFlag() { String passphrase = "aPassphrase"; String masterkeyFilename = "aMasterkeyFilename"; @@ -93,17 +98,20 @@ public void testSetPassphraseAndMasterkeyFilenameAndReadonlyFlag() { assertThat(inTest.entrySet(), containsInAnyOrder( // anEntry(PROPERTY_PASSPHRASE, passphrase), // + anEntry(PROPERTY_PEPPER, DEFAULT_PEPPER), // anEntry(PROPERTY_MASTERKEY_FILENAME, masterkeyFilename), // anEntry(PROPERTY_FILESYSTEM_FLAGS, EnumSet.of(FileSystemFlags.READONLY, FileSystemFlags.INIT_IMPLICITLY)))); } @Test - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({ "unchecked" }) public void testFromMap() { Map map = new HashMap<>(); String passphrase = "aPassphrase"; + byte[] pepper = "aPepper".getBytes(StandardCharsets.US_ASCII); String masterkeyFilename = "aMasterkeyFilename"; map.put(PROPERTY_PASSPHRASE, passphrase); + map.put(PROPERTY_PEPPER, pepper); map.put(PROPERTY_MASTERKEY_FILENAME, masterkeyFilename); map.put(PROPERTY_FILESYSTEM_FLAGS, EnumSet.of(FileSystemFlags.READONLY)); CryptoFileSystemProperties inTest = cryptoFileSystemPropertiesFrom(map).build(); @@ -115,6 +123,7 @@ public void testFromMap() { assertThat(inTest.entrySet(), containsInAnyOrder( // anEntry(PROPERTY_PASSPHRASE, passphrase), // + anEntry(PROPERTY_PEPPER, pepper), // anEntry(PROPERTY_MASTERKEY_FILENAME, masterkeyFilename), // anEntry(PROPERTY_FILESYSTEM_FLAGS, EnumSet.of(FileSystemFlags.READONLY)))); } @@ -124,8 +133,10 @@ public void testFromMap() { public void testWrapMapWithTrueReadonly() { Map map = new HashMap<>(); String passphrase = "aPassphrase"; + byte[] pepper = "aPepper".getBytes(StandardCharsets.US_ASCII); String masterkeyFilename = "aMasterkeyFilename"; map.put(PROPERTY_PASSPHRASE, passphrase); + map.put(PROPERTY_PEPPER, pepper); map.put(PROPERTY_MASTERKEY_FILENAME, masterkeyFilename); map.put(PROPERTY_FILESYSTEM_FLAGS, EnumSet.of(FileSystemFlags.READONLY)); CryptoFileSystemProperties inTest = CryptoFileSystemProperties.wrap(map); @@ -137,6 +148,7 @@ public void testWrapMapWithTrueReadonly() { assertThat(inTest.entrySet(), containsInAnyOrder( // anEntry(PROPERTY_PASSPHRASE, passphrase), // + anEntry(PROPERTY_PEPPER, pepper), // anEntry(PROPERTY_MASTERKEY_FILENAME, masterkeyFilename), // anEntry(PROPERTY_FILESYSTEM_FLAGS, EnumSet.of(FileSystemFlags.READONLY)))); } @@ -146,8 +158,10 @@ public void testWrapMapWithTrueReadonly() { public void testWrapMapWithFalseReadonly() { Map map = new HashMap<>(); String passphrase = "aPassphrase"; + byte[] pepper = "aPepper".getBytes(StandardCharsets.US_ASCII); String masterkeyFilename = "aMasterkeyFilename"; map.put(PROPERTY_PASSPHRASE, passphrase); + map.put(PROPERTY_PEPPER, pepper); map.put(PROPERTY_MASTERKEY_FILENAME, masterkeyFilename); map.put(PROPERTY_FILESYSTEM_FLAGS, EnumSet.noneOf(FileSystemFlags.class)); CryptoFileSystemProperties inTest = CryptoFileSystemProperties.wrap(map); @@ -159,6 +173,7 @@ public void testWrapMapWithFalseReadonly() { assertThat(inTest.entrySet(), containsInAnyOrder( // anEntry(PROPERTY_PASSPHRASE, passphrase), // + anEntry(PROPERTY_PEPPER, pepper), // anEntry(PROPERTY_MASTERKEY_FILENAME, masterkeyFilename), // anEntry(PROPERTY_FILESYSTEM_FLAGS, EnumSet.noneOf(FileSystemFlags.class)))); } @@ -197,11 +212,13 @@ public void testWrapMapWithInvalidPassphrase() { } @Test - @SuppressWarnings({"unchecked", "deprecation"}) + @SuppressWarnings({ "unchecked", "deprecation" }) public void testWrapMapWithoutReadonly() { Map map = new HashMap<>(); String passphrase = "aPassphrase"; + byte[] pepper = "aPepper".getBytes(StandardCharsets.US_ASCII); map.put(PROPERTY_PASSPHRASE, passphrase); + map.put(PROPERTY_PEPPER, pepper); CryptoFileSystemProperties inTest = CryptoFileSystemProperties.wrap(map); assertThat(inTest.passphrase(), is(passphrase)); @@ -211,6 +228,7 @@ public void testWrapMapWithoutReadonly() { assertThat(inTest.entrySet(), containsInAnyOrder( // anEntry(PROPERTY_PASSPHRASE, passphrase), // + anEntry(PROPERTY_PEPPER, pepper), // anEntry(PROPERTY_MASTERKEY_FILENAME, DEFAULT_MASTERKEY_FILENAME), // anEntry(PROPERTY_FILESYSTEM_FLAGS, EnumSet.of(FileSystemFlags.INIT_IMPLICITLY)))); } diff --git a/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemProviderIntegrationTest.java b/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemProviderIntegrationTest.java index c879ed48..3be36b17 100644 --- a/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemProviderIntegrationTest.java +++ b/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemProviderIntegrationTest.java @@ -18,6 +18,7 @@ import java.io.IOException; import java.net.URI; import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Files; @@ -25,14 +26,23 @@ import java.nio.file.StandardOpenOption; import java.util.EnumSet; +import org.cryptomator.cryptolib.api.InvalidPassphraseException; import org.junit.After; import org.junit.Assert; import org.junit.Assume; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; + +import com.google.common.jimfs.Configuration; +import com.google.common.jimfs.Jimfs; public class CryptoFileSystemProviderIntegrationTest { + @Rule + public ExpectedException thrown = ExpectedException.none(); + private Path tmpPath; @Before @@ -55,6 +65,41 @@ public void testGetFsViaNioApi() throws IOException { Assert.assertSame(fs, fs2); } + @Test + public void testInitAndOpenFsWithPepper() throws IOException { + FileSystem fs = Jimfs.newFileSystem(Configuration.unix()); + Path pathToVault = fs.getPath("/vaultDir"); + Path masterkeyFile = pathToVault.resolve("masterkey.cryptomator"); + Path dataDir = pathToVault.resolve("d"); + byte[] pepper = "pepper".getBytes(StandardCharsets.US_ASCII); + + // Initialize vault: + Files.createDirectory(pathToVault); + CryptoFileSystemProvider.initialize(pathToVault, "masterkey.cryptomator", pepper, "asd"); + Assert.assertTrue(Files.isDirectory(dataDir)); + Assert.assertTrue(Files.isRegularFile(masterkeyFile)); + + // Attempt 1: Correct pepper: + CryptoFileSystemProperties properties = cryptoFileSystemProperties() // + .withFlags() // + .withMasterkeyFilename("masterkey.cryptomator") // + .withPassphrase("asd") // + .withPepper(pepper) // + .build(); + try (CryptoFileSystem cryptoFs = CryptoFileSystemProvider.newFileSystem(pathToVault, properties)) { + Assert.assertNotNull(cryptoFs); + } + + // Attempt 2: Invalid pepper resulting in InvalidPassphraseException: + CryptoFileSystemProperties wrongProperties = cryptoFileSystemProperties() // + .withFlags() // + .withMasterkeyFilename("masterkey.cryptomator") // + .withPassphrase("asd") // + .build(); + thrown.expect(InvalidPassphraseException.class); + CryptoFileSystemProvider.newFileSystem(pathToVault, wrongProperties); + } + @Test public void testOpenAndCloseFileChannel() throws IOException { FileSystem fs = CryptoFileSystemProvider.newFileSystem(tmpPath, cryptoFileSystemProperties().withPassphrase("asd").build()); @@ -65,7 +110,7 @@ public void testOpenAndCloseFileChannel() throws IOException { @Test public void testCopyFileFromOneCryptoFileSystemToAnother() throws IOException { - byte[] data = new byte[] {1, 2, 3, 4, 5, 6, 7}; + byte[] data = new byte[] { 1, 2, 3, 4, 5, 6, 7 }; Path fs1Location = tmpPath.resolve("foo"); Path fs2Location = tmpPath.resolve("bar"); @@ -87,8 +132,8 @@ public void testCopyFileFromOneCryptoFileSystemToAnother() throws IOException { @Test public void testCopyFileByRelacingExistingFromOneCryptoFileSystemToAnother() throws IOException { - byte[] data = new byte[] {1, 2, 3, 4, 5, 6, 7}; - byte[] data2 = new byte[] {10, 11, 12}; + byte[] data = new byte[] { 1, 2, 3, 4, 5, 6, 7 }; + byte[] data2 = new byte[] { 10, 11, 12 }; Path fs1Location = tmpPath.resolve("foo"); Path fs2Location = tmpPath.resolve("bar"); @@ -111,7 +156,7 @@ public void testCopyFileByRelacingExistingFromOneCryptoFileSystemToAnother() thr @Test public void testMoveFileFromOneCryptoFileSystemToAnother() throws IOException { - byte[] data = new byte[] {1, 2, 3, 4, 5, 6, 7}; + byte[] data = new byte[] { 1, 2, 3, 4, 5, 6, 7 }; Path fs1Location = tmpPath.resolve("foo"); Path fs2Location = tmpPath.resolve("bar"); diff --git a/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemProviderTest.java b/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemProviderTest.java index 06809a26..7dd60d3b 100644 --- a/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemProviderTest.java +++ b/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemProviderTest.java @@ -147,7 +147,8 @@ public void setup() { } @Theory - public void testInvocationsWithPathFromOtherProviderFailWithProviderMismatchException(@FromDataPoints("shouldFailWithProviderMismatch") InvocationWhichShouldFail shouldFailWithProviderMismatch) throws IOException { + public void testInvocationsWithPathFromOtherProviderFailWithProviderMismatchException(@FromDataPoints("shouldFailWithProviderMismatch") InvocationWhichShouldFail shouldFailWithProviderMismatch) + throws IOException { thrown.expect(ProviderMismatchException.class); shouldFailWithProviderMismatch.invoke(inTest, otherPath); @@ -242,10 +243,9 @@ public void testImplicitInitialization() throws IOException { @Test public void testNewFileSystemInvokesFileSystemsCreate() throws IOException { Path pathToVault = get("a").toAbsolutePath(); - Files.createDirectory(pathToVault); URI uri = CryptoFileSystemUri.create(pathToVault); - CryptoFileSystemProperties properties = cryptoFileSystemProperties().withPassphrase("asd").build(); + CryptoFileSystemProperties properties = cryptoFileSystemProperties().withPassphrase("asd").withFlags().build(); when(fileSystems.create(eq(pathToVault), eq(properties))).thenReturn(cryptoFileSystem); FileSystem result = inTest.newFileSystem(uri, properties); From 15a28da99274e3eaf46d26a59f2f5e82ca84f24a Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 16 Jun 2017 15:45:44 +0200 Subject: [PATCH 3/4] preparing release 1.3.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 55d520e6..eab31c5d 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.cryptomator cryptofs - 1.4.0-SNAPSHOT + 1.3.2 Cryptomator Crypto Filesystem This library provides the Java filesystem provider used by Cryptomator. https://github.com/cryptomator/cryptofs From 630db0d74f48bd28f56b68cbd25f8a09deb07fef Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 16 Jun 2017 15:51:59 +0200 Subject: [PATCH 4/4] Updated JavaDoc --- .../org/cryptomator/cryptofs/CryptoFileSystemProperties.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java index 23a0a693..64cad408 100644 --- a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java +++ b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java @@ -23,7 +23,6 @@ import java.util.function.Consumer; import org.apache.commons.lang3.StringUtils; -import org.cryptomator.cryptofs.CryptoFileSystemProperties.FileSystemFlags; /** * Properties to pass to @@ -237,6 +236,7 @@ public Builder withPepper(byte[] pepper) { /** * Sets the flags for a CryptoFileSystem. * + * @param flags File system flags * @return this * @since 1.3.1 */ @@ -247,6 +247,7 @@ public Builder withFlags(FileSystemFlags... flags) { /** * Sets the flags for a CryptoFileSystem. * + * @param flags collection of file system flags * @return this * @since 1.3.0 */ @@ -260,7 +261,7 @@ public Builder withFlags(Collection flags) { * Sets the readonly flag for a CryptoFileSystem. * * @return this - * @deprecated Will be removed in 2.0.0. Use {@link #withFlags(FileSystemFlags.READONLY)} + * @deprecated Will be removed in 2.0.0. Use {@link #withFlags(FileSystemFlags...) withFlags(FileSystemFlags.READONLY)} */ @Deprecated public Builder withReadonlyFlag() {