org.cryptomator.cryptofs.attr.CryptoFileOwnerAttributeView Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cryptofs Show documentation
Show all versions of cryptofs Show documentation
This library provides the Java filesystem provider used by Cryptomator.
/*******************************************************************************
* Copyright (c) 2016 Sebastian Stenzel and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the accompanying LICENSE.txt.
*
* Contributors:
* Sebastian Stenzel - initial API and implementation
*******************************************************************************/
package org.cryptomator.cryptofs.attr;
import org.cryptomator.cryptofs.CryptoPath;
import org.cryptomator.cryptofs.CryptoPathMapper;
import org.cryptomator.cryptofs.ReadonlyFlag;
import org.cryptomator.cryptofs.Symlinks;
import org.cryptomator.cryptofs.fh.OpenCryptoFiles;
import javax.inject.Inject;
import java.io.IOException;
import java.nio.file.LinkOption;
import java.nio.file.attribute.FileOwnerAttributeView;
import java.nio.file.attribute.UserPrincipal;
@AttributeViewScoped
final class CryptoFileOwnerAttributeView extends AbstractCryptoFileAttributeView implements FileOwnerAttributeView {
private final ReadonlyFlag readonlyFlag;
@Inject
public CryptoFileOwnerAttributeView(CryptoPath cleartextPath, CryptoPathMapper pathMapper, LinkOption[] linkOptions, Symlinks symlinks, OpenCryptoFiles openCryptoFiles, ReadonlyFlag readonlyFlag) {
super(cleartextPath, pathMapper, linkOptions, symlinks, openCryptoFiles);
this.readonlyFlag = readonlyFlag;
}
@Override
public String name() {
return "owner";
}
@Override
public UserPrincipal getOwner() throws IOException {
return getCiphertextAttributeView(FileOwnerAttributeView.class).getOwner();
}
@Override
public void setOwner(UserPrincipal owner) throws IOException {
readonlyFlag.assertWritable();
getCiphertextAttributeView(FileOwnerAttributeView.class).setOwner(owner);
}
}