java.lang.Object
java.nio.file.spi.FileSystemProvider
org.cryptomator.cryptofs.CryptoFileSystemProvider
A FileSystemProvider for CryptoFileSystems.
All FileSystem instances created by CryptoFileSystemProvider are instances of CryptoFileSystem.
Usage
It is recommended to use newFileSystem(Path, CryptoFileSystemProperties) to create a CryptoFileSystem. To do this:
Path storageLocation = Paths.get("/home/cryptobot/vault");
FileSystem fileSystem = CryptoFileSystemProvider.newFileSystem(
storageLocation,
cryptoFileSystemProperties()
.withPassword("password")
.withFlags(FileSystemFlags.READONLY)
.build());
Afterwards you can use the created FileSystem to create paths, do directory listings, create files and so on.
To create a new FileSystem from a URI using FileSystems.newFileSystem(URI, Map) you may have a look at CryptoFileSystemUri.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckAccess(Path cleartextPath, AccessMode... modes) static DirStructurecheckDirStructureForVault(Path pathToAssumedVault, String vaultConfigFilename, String masterkeyFilename) Delegate toDirStructure.checkDirStructure(Path, String, String).voidcopy(Path cleartextSource, Path cleartextTarget, CopyOption... options) voidcreateDirectory(Path cleartextDir, FileAttribute<?>... attrs) voidcreateSymbolicLink(Path cleartextPath, Path target, FileAttribute<?>... attrs) void<V extends FileAttributeView>
VgetFileAttributeView(Path cleartextPath, Class<V> type, LinkOption... options) getFileStore(Path cleartextPath) getFileSystem(URI uri) static voidinitialize(Path pathToVault, CryptoFileSystemProperties properties, URI keyId) Creates a new vault at the given directory path.booleanbooleanisSameFile(Path cleartextPath, Path cleartextPath2) voidmove(Path cleartextSource, Path cleartextTarget, CopyOption... options) newAsynchronousFileChannel(Path cleartextPath, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs) newByteChannel(Path cleartextPath, Set<? extends OpenOption> options, FileAttribute<?>... attrs) newDirectoryStream(Path cleartextDir, DirectoryStream.Filter<? super Path> filter) newFileChannel(Path cleartextPath, Set<? extends OpenOption> optionsSet, FileAttribute<?>... attrs) newFileSystem(URI uri, Map<String, ?> rawProperties) static CryptoFileSystemnewFileSystem(Path pathToVault, CryptoFileSystemProperties properties) Typesafe alternative toFileSystems.newFileSystem(URI, Map).<A extends BasicFileAttributes>
AreadAttributes(Path cleartextPath, Class<A> type, LinkOption... options) readAttributes(Path cleartextPath, String attributes, LinkOption... options) readSymbolicLink(Path cleartextPath) voidsetAttribute(Path cleartextPath, String attribute, Object value, LinkOption... options) Methods inherited from class java.nio.file.spi.FileSystemProvider
createLink, deleteIfExists, installedProviders, newFileSystem, newInputStream, newOutputStream
-
Constructor Details
-
CryptoFileSystemProvider
public CryptoFileSystemProvider()
-
-
Method Details
-
newFileSystem
public static CryptoFileSystem newFileSystem(Path pathToVault, CryptoFileSystemProperties properties) throws FileSystemNeedsMigrationException, IOException, org.cryptomator.cryptolib.api.MasterkeyLoadingFailedException Typesafe alternative toFileSystems.newFileSystem(URI, Map). Default way to retrieve a CryptoFS instance.- Parameters:
pathToVault- Path to this vault's storage locationproperties- Parameters used during initialization of the file system- Returns:
- a new file system
- Throws:
FileSystemNeedsMigrationException- if the vault format needs to get updated andpropertiesdid not contain a flag for implicit migration.FileSystemCapabilityChecker.MissingCapabilityException- If the underlying filesystem lacks features required to store a vaultIOException- if an I/O error occurs creating the file systemorg.cryptomator.cryptolib.api.MasterkeyLoadingFailedException- if the masterkey for this vault could not be loaded
-
initialize
public static void initialize(Path pathToVault, CryptoFileSystemProperties properties, URI keyId) throws NotDirectoryException, IOException, org.cryptomator.cryptolib.api.MasterkeyLoadingFailedException Creates a new vault at the given directory path.- Parameters:
pathToVault- Path to an existing directoryproperties- Parameters to use when writing the vault configurationkeyId- ID of the master key to use for this vault- Throws:
NotDirectoryException- If the given path is not an existing directory.IOException- If the vault structure could not be initialized due to I/O errorsorg.cryptomator.cryptolib.api.MasterkeyLoadingFailedException- If thrown by the supplied keyLoader- Since:
- 2.0.0
-
checkDirStructureForVault
public static DirStructure checkDirStructureForVault(Path pathToAssumedVault, String vaultConfigFilename, String masterkeyFilename) throws IOException Delegate toDirStructure.checkDirStructure(Path, String, String).- Parameters:
pathToAssumedVault-vaultConfigFilename-masterkeyFilename-- Returns:
- a
DirStructureobject - Throws:
IOException- Since:
- 2.0.0
-
getScheme
- Specified by:
getSchemein classFileSystemProvider
-
newFileSystem
public CryptoFileSystem newFileSystem(URI uri, Map<String, ?> rawProperties) throws IOException, org.cryptomator.cryptolib.api.MasterkeyLoadingFailedException- Specified by:
newFileSystemin classFileSystemProvider- Throws:
IOExceptionorg.cryptomator.cryptolib.api.MasterkeyLoadingFailedException
-
getFileSystem
- Specified by:
getFileSystemin classFileSystemProvider
-
getPath
- Specified by:
getPathin classFileSystemProvider
-
newAsynchronousFileChannel
public AsynchronousFileChannel newAsynchronousFileChannel(Path cleartextPath, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs) throws IOException - Overrides:
newAsynchronousFileChannelin classFileSystemProvider- Throws:
IOException
-
newFileChannel
public FileChannel newFileChannel(Path cleartextPath, Set<? extends OpenOption> optionsSet, FileAttribute<?>... attrs) throws IOException - Overrides:
newFileChannelin classFileSystemProvider- Throws:
IOException
-
newByteChannel
public SeekableByteChannel newByteChannel(Path cleartextPath, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException - Specified by:
newByteChannelin classFileSystemProvider- Throws:
IOException
-
newDirectoryStream
public DirectoryStream<Path> newDirectoryStream(Path cleartextDir, DirectoryStream.Filter<? super Path> filter) throws IOException - Specified by:
newDirectoryStreamin classFileSystemProvider- Throws:
IOException
-
createDirectory
- Specified by:
createDirectoryin classFileSystemProvider- Throws:
IOException
-
delete
- Specified by:
deletein classFileSystemProvider- Throws:
IOException
-
copy
public void copy(Path cleartextSource, Path cleartextTarget, CopyOption... options) throws IOException - Specified by:
copyin classFileSystemProvider- Throws:
IOException
-
move
public void move(Path cleartextSource, Path cleartextTarget, CopyOption... options) throws IOException - Specified by:
movein classFileSystemProvider- Throws:
IOException
-
isSameFile
- Specified by:
isSameFilein classFileSystemProvider- Throws:
IOException
-
isHidden
- Specified by:
isHiddenin classFileSystemProvider- Throws:
IOException
-
getFileStore
- Specified by:
getFileStorein classFileSystemProvider
-
checkAccess
- Specified by:
checkAccessin classFileSystemProvider- Throws:
IOException
-
createSymbolicLink
public void createSymbolicLink(Path cleartextPath, Path target, FileAttribute<?>... attrs) throws IOException - Overrides:
createSymbolicLinkin classFileSystemProvider- Throws:
IOException
-
readSymbolicLink
- Overrides:
readSymbolicLinkin classFileSystemProvider- Throws:
IOException
-
getFileAttributeView
public <V extends FileAttributeView> V getFileAttributeView(Path cleartextPath, Class<V> type, LinkOption... options) - Specified by:
getFileAttributeViewin classFileSystemProvider
-
readAttributes
public <A extends BasicFileAttributes> A readAttributes(Path cleartextPath, Class<A> type, LinkOption... options) throws IOException - Specified by:
readAttributesin classFileSystemProvider- Throws:
IOException
-
readAttributes
public Map<String,Object> readAttributes(Path cleartextPath, String attributes, LinkOption... options) throws IOException - Specified by:
readAttributesin classFileSystemProvider- Throws:
IOException
-
setAttribute
public void setAttribute(Path cleartextPath, String attribute, Object value, LinkOption... options) throws IOException - Specified by:
setAttributein classFileSystemProvider- Throws:
IOException
-