call me THE DESTROYER!!!

first compile-clean but totally fubar version
This commit is contained in:
Sebastian Stenzel
2016-12-16 17:20:56 +01:00
parent 28fedafb59
commit 79b825aaad
311 changed files with 675 additions and 25029 deletions
-1
View File
@@ -1 +0,0 @@
/target/
-27
View File
@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2016 Sebastian Stenzel
This file is licensed under the terms of the MIT license.
See the LICENSE.txt file for more info.
Contributors:
Sebastian Stenzel - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.cryptomator</groupId>
<artifactId>main</artifactId>
<version>1.3.0-SNAPSHOT</version>
</parent>
<artifactId>frontend-api</artifactId>
<name>Cryptomator frontend: API</name>
<description>API for filesystem frontends</description>
<dependencies>
<dependency>
<groupId>org.cryptomator</groupId>
<artifactId>filesystem-api</artifactId>
</dependency>
</dependencies>
</project>
@@ -1,24 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014, 2016 Sebastian Stenzel
* This file is licensed under the terms of the MIT license.
* See the LICENSE.txt file for more info.
*
* Contributors:
* Sebastian Stenzel - initial API and implementation
* Markus Kreusch - Refactored WebDavMounter to use strategy pattern
******************************************************************************/
package org.cryptomator.frontend;
public class CommandFailedException extends Exception {
private static final long serialVersionUID = 5784853630182321479L;
public CommandFailedException(String message) {
super(message);
}
public CommandFailedException(Throwable cause) {
super(cause);
}
}
@@ -1,37 +0,0 @@
/*******************************************************************************
* Copyright (c) 2016 Sebastian Stenzel and others.
* This file is licensed under the terms of the MIT license.
* See the LICENSE.txt file for more info.
*
* Contributors:
* Sebastian Stenzel - initial API and implementation
*******************************************************************************/
package org.cryptomator.frontend;
import java.util.Map;
import java.util.Optional;
public interface Frontend extends AutoCloseable {
public enum MountParam {
MOUNT_NAME, HOSTNAME, WIN_DRIVE_LETTER,
/**
* "dav" or "webdav"
*/
PREFERRED_GVFS_SCHEME
}
void mount(Map<MountParam, Optional<String>> map) throws CommandFailedException;
/**
* Unmounts the file system and stops any file system handler threads.
*/
void close() throws Exception;
void reveal() throws CommandFailedException;
// For now let's assume every single frontend knows what a WebDAV url is ;-)
String getWebDavUrl();
}
@@ -1,17 +0,0 @@
/*******************************************************************************
* Copyright (c) 2016 Sebastian Stenzel and others.
* This file is licensed under the terms of the MIT license.
* See the LICENSE.txt file for more info.
*
* Contributors:
* Sebastian Stenzel - initial API and implementation
*******************************************************************************/
package org.cryptomator.frontend;
public class FrontendCreationFailedException extends Exception {
public FrontendCreationFailedException(Throwable cause) {
super(cause);
}
}
@@ -1,26 +0,0 @@
/*******************************************************************************
* Copyright (c) 2016 Sebastian Stenzel and others.
* This file is licensed under the terms of the MIT license.
* See the LICENSE.txt file for more info.
*
* Contributors:
* Sebastian Stenzel - initial API and implementation
*******************************************************************************/
package org.cryptomator.frontend;
import org.cryptomator.filesystem.Folder;
public interface FrontendFactory {
/**
* Provides a new frontend to access the given folder.
*
* @param root Root resource accessible through this frontend.
* @param id unique id of the frontend, i.e. used to generate a unique uri
* @param name Name of the frontend, i.e. used to generate a readable/recognizable name of a common virtual drive
* @return A new frontend
* @throws FrontendCreationFailedException If creation was not possible.
*/
Frontend create(Folder root, FrontendId id, String name) throws FrontendCreationFailedException;
}
@@ -1,85 +0,0 @@
package org.cryptomator.frontend;
import static java.util.UUID.randomUUID;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.UUID;
public class FrontendId implements Serializable {
public static final String FRONTEND_ID_PATTERN = "[a-zA-Z0-9_-]{12}";
public static FrontendId generate() {
return new FrontendId();
}
public static FrontendId from(String value) {
return new FrontendId(value);
}
private final String value;
private FrontendId() {
this(generateId());
}
private FrontendId(String value) {
if (!value.matches(FRONTEND_ID_PATTERN)) {
throw new IllegalArgumentException("Invalid frontend id " + value);
}
this.value = value;
}
private static String generateId() {
return asBase64String(nineBytesFrom(randomUUID()));
}
private static String asBase64String(ByteBuffer bytes) {
ByteBuffer base64Buffer = Base64.getUrlEncoder().encode(bytes);
return new String(asByteArray(base64Buffer), StandardCharsets.US_ASCII);
}
private static ByteBuffer nineBytesFrom(UUID uuid) {
ByteBuffer uuidBuffer = ByteBuffer.allocate(9);
uuidBuffer.putLong(uuid.getMostSignificantBits());
uuidBuffer.put((byte) (uuid.getLeastSignificantBits() & 0xFF));
uuidBuffer.flip();
return uuidBuffer;
}
private static byte[] asByteArray(ByteBuffer buffer) {
if (buffer.hasArray()) {
return buffer.array();
} else {
byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes);
return bytes;
}
}
@Override
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) {
return false;
}
return obj == this || internalEquals((FrontendId) obj);
}
private boolean internalEquals(FrontendId obj) {
return value.equals(obj.value);
}
@Override
public int hashCode() {
return value.hashCode();
}
@Override
public String toString() {
return value;
}
}
@@ -1,12 +0,0 @@
/*******************************************************************************
* Copyright (c) 2015, 2016 Sebastian Stenzel and others.
* This file is licensed under the terms of the MIT license.
* See the LICENSE.txt file for more info.
*
* Contributors:
* Sebastian Stenzel - initial API and implementation
*******************************************************************************/
/**
* Provides frontends for {@link org.cryptomator.filesystem.FileSystem FileSystems}.
*/
package org.cryptomator.frontend;