Skip to content

Commit

Permalink
Integration of CryptoFs in testclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Jan 3, 2018
1 parent 539edd5 commit 426439b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Expand Up @@ -52,6 +52,13 @@
</repositories>

<dependencies>
<!-- CryptoFS -->
<dependency>
<groupId>org.cryptomator</groupId>
<artifactId>cryptofs</artifactId>
<version>1.4.5</version>
</dependency>

<!-- FUSE -->
<dependency>
<groupId>com.github.serceman</groupId>
Expand Down
@@ -1,5 +1,9 @@
package org.cryptomator.frontend.fuse;

import org.cryptomator.cryptofs.CryptoFileSystem;
import org.cryptomator.cryptofs.CryptoFileSystemProperties;
import org.cryptomator.cryptofs.CryptoFileSystemProvider;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -17,7 +21,10 @@ public static void main(String[] args) throws IOException {
System.out.println("Enter mount point:");
Path m = Paths.get(scanner.nextLine());
if (Files.isDirectory(p) && Files.isDirectory(m)) {
try (FuseNioAdapter fs = AdapterFactory.createReadWriteAdapter(p)) {
CryptoFileSystemProperties properties = CryptoFileSystemProperties.withPassphrase("asd").withFlags().build();
CryptoFileSystem cfs = CryptoFileSystemProvider.newFileSystem(p, properties);
try (FuseNioAdapter fs = AdapterFactory.createReadWriteAdapter(cfs.getPath("/"))) {
//try (FuseNioAdapter fs = AdapterFactory.createReadWriteAdapter(p)) {
fs.mount(m, false, false, new String[]{"-ouid="+uid, "-ogid="+gid, "-oatomic_o_trunc"});
System.out.println("Mounted successfully. Enter anything to stop the server...");
System.in.read();
Expand Down
@@ -1,5 +1,9 @@
package org.cryptomator.frontend.fuse;

import org.cryptomator.cryptofs.CryptoFileSystem;
import org.cryptomator.cryptofs.CryptoFileSystemProperties;
import org.cryptomator.cryptofs.CryptoFileSystemProvider;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -17,7 +21,10 @@ public static void main(String[] args) throws IOException {
System.out.println("Enter mount point:");
Path m = Paths.get(scanner.nextLine());
if (Files.isDirectory(p) && Files.isDirectory(m)) {
try (FuseNioAdapter fs = AdapterFactory.createReadWriteAdapter(p)) {
CryptoFileSystemProperties properties = CryptoFileSystemProperties.withPassphrase("asd").withFlags().build();
CryptoFileSystem cfs = CryptoFileSystemProvider.newFileSystem(p, properties);
try (FuseNioAdapter fs = AdapterFactory.createReadWriteAdapter(cfs.getPath("/"))) {
//try (FuseNioAdapter fs = AdapterFactory.createReadWriteAdapter(p)) {
fs.mount(m, false, false, new String[]{"-ouid="+uid, "-ogid="+gid, "-ovolname=FUSE-NIO-Adapter", "-oauto_xattr", "-oatomic_o_trunc"});
System.out.println("Mounted successfully. Enter anything to stop the server...");
System.in.read();
Expand Down
@@ -1,5 +1,9 @@
package org.cryptomator.frontend.fuse;

import org.cryptomator.cryptofs.CryptoFileSystem;
import org.cryptomator.cryptofs.CryptoFileSystemProperties;
import org.cryptomator.cryptofs.CryptoFileSystemProvider;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -18,8 +22,11 @@ public static void main(String[] args) throws IOException {
System.out.println("Enter path to the directory you want to mirror:");
Path p = Paths.get(scanner.nextLine());
if (Files.isDirectory(p)) {
try (FuseNioAdapter fs = AdapterFactory.createReadWriteAdapter(p)) {
fs.mount(Paths.get("J:\\"), false, true, new String[] {"-ouid=-1", "-ogid=-1", "-ovolname=FUSE-NIO-Adapter", "-oatomic_o_trunc"});
CryptoFileSystemProperties properties = CryptoFileSystemProperties.withPassphrase("asd").withFlags().build();
CryptoFileSystem cfs = CryptoFileSystemProvider.newFileSystem(p, properties);
try (FuseNioAdapter fs = AdapterFactory.createReadWriteAdapter(cfs.getPath("/"))) {
//try (FuseNioAdapter fs = AdapterFactory.createReadWriteAdapter(p)) {
fs.mount(Paths.get("J:\\"), false, true, new String[]{"-ouid=-1", "-ogid=-1", "-ovolname=FUSE-NIO-Adapter", "-oatomic_o_trunc"});
System.out.println("Mounted successfully. Enter anything to stop the server...");
System.in.read();
fs.umount();
Expand Down

0 comments on commit 426439b

Please sign in to comment.