Skip to content

Commit f43c2df

Browse files
Merge branch 'release/2.0.0' into release/2.1.0
2 parents fe0f776 + f5e9748 commit f43c2df

31 files changed

+281
-267
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1818

1919
<!-- dependencies -->
20-
<cryptolib.version>2.0.0-beta6</cryptolib.version>
20+
<cryptolib.version>2.0.0-beta7</cryptolib.version>
2121
<jwt.version>3.12.0</jwt.version>
2222
<dagger.version>2.31</dagger.version>
2323
<guava.version>30.1-jre</guava.version>

src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ boolean isHidden(CryptoPath cleartextPath) throws IOException {
281281

282282
void createDirectory(CryptoPath cleartextDir, FileAttribute<?>... attrs) throws IOException {
283283
readonlyFlag.assertWritable();
284+
assertCleartextNameLengthAllowed(cleartextDir);
284285
CryptoPath cleartextParentDir = cleartextDir.getParent();
285286
if (cleartextParentDir == null) {
286287
return;
@@ -292,7 +293,6 @@ void createDirectory(CryptoPath cleartextDir, FileAttribute<?>... attrs) throws
292293
cryptoPathMapper.assertNonExisting(cleartextDir);
293294
CiphertextFilePath ciphertextPath = cryptoPathMapper.getCiphertextFilePath(cleartextDir);
294295
Path ciphertextDirFile = ciphertextPath.getDirFilePath();
295-
assertCiphertextPathLengthMeetsLimitations(ciphertextDirFile);
296296
CiphertextDirectory ciphertextDir = cryptoPathMapper.getCiphertextDir(cleartextDir);
297297
// atomically check for FileAlreadyExists and create otherwise:
298298
Files.createDirectory(ciphertextPath.getRawPath());
@@ -348,9 +348,11 @@ private FileChannel newFileChannelFromSymlink(CryptoPath cleartextPath, Effectiv
348348
}
349349

350350
private FileChannel newFileChannelFromFile(CryptoPath cleartextFilePath, EffectiveOpenOptions options, FileAttribute<?>... attrs) throws IOException {
351+
if (options.create() || options.createNew()) {
352+
assertCleartextNameLengthAllowed(cleartextFilePath);
353+
}
351354
CiphertextFilePath ciphertextPath = cryptoPathMapper.getCiphertextFilePath(cleartextFilePath);
352355
Path ciphertextFilePath = ciphertextPath.getFilePath();
353-
assertCiphertextPathLengthMeetsLimitations(ciphertextFilePath);
354356
if (options.createNew() && openCryptoFiles.get(ciphertextFilePath).isPresent()) {
355357
throw new FileAlreadyExistsException(cleartextFilePath.toString());
356358
} else {
@@ -400,6 +402,7 @@ private void deleteDirectory(CryptoPath cleartextPath, CiphertextFilePath cipher
400402

401403
void copy(CryptoPath cleartextSource, CryptoPath cleartextTarget, CopyOption... options) throws IOException {
402404
readonlyFlag.assertWritable();
405+
assertCleartextNameLengthAllowed(cleartextTarget);
403406
if (cleartextSource.equals(cleartextTarget)) {
404407
return;
405408
}
@@ -418,7 +421,6 @@ private void copySymlink(CryptoPath cleartextSource, CryptoPath cleartextTarget,
418421
if (ArrayUtils.contains(options, LinkOption.NOFOLLOW_LINKS)) {
419422
CiphertextFilePath ciphertextSourceFile = cryptoPathMapper.getCiphertextFilePath(cleartextSource);
420423
CiphertextFilePath ciphertextTargetFile = cryptoPathMapper.getCiphertextFilePath(cleartextTarget);
421-
assertCiphertextPathLengthMeetsLimitations(ciphertextTargetFile.getSymlinkFilePath());
422424
CopyOption[] resolvedOptions = ArrayUtils.without(options, LinkOption.NOFOLLOW_LINKS).toArray(CopyOption[]::new);
423425
Files.createDirectories(ciphertextTargetFile.getRawPath());
424426
Files.copy(ciphertextSourceFile.getSymlinkFilePath(), ciphertextTargetFile.getSymlinkFilePath(), resolvedOptions);
@@ -434,7 +436,6 @@ private void copySymlink(CryptoPath cleartextSource, CryptoPath cleartextTarget,
434436
private void copyFile(CryptoPath cleartextSource, CryptoPath cleartextTarget, CopyOption[] options) throws IOException {
435437
CiphertextFilePath ciphertextSource = cryptoPathMapper.getCiphertextFilePath(cleartextSource);
436438
CiphertextFilePath ciphertextTarget = cryptoPathMapper.getCiphertextFilePath(cleartextTarget);
437-
assertCiphertextPathLengthMeetsLimitations(ciphertextTarget.getFilePath());
438439
if (ciphertextTarget.isShortened()) {
439440
Files.createDirectories(ciphertextTarget.getRawPath());
440441
}
@@ -498,6 +499,7 @@ private void copyAttributes(Path src, Path dst) throws IOException {
498499

499500
void move(CryptoPath cleartextSource, CryptoPath cleartextTarget, CopyOption... options) throws IOException {
500501
readonlyFlag.assertWritable();
502+
assertCleartextNameLengthAllowed(cleartextTarget);
501503
if (cleartextSource.equals(cleartextTarget)) {
502504
return;
503505
}
@@ -517,7 +519,6 @@ private void moveSymlink(CryptoPath cleartextSource, CryptoPath cleartextTarget,
517519
// "the symbolic link itself, not the target of the link, is moved"
518520
CiphertextFilePath ciphertextSource = cryptoPathMapper.getCiphertextFilePath(cleartextSource);
519521
CiphertextFilePath ciphertextTarget = cryptoPathMapper.getCiphertextFilePath(cleartextTarget);
520-
assertCiphertextPathLengthMeetsLimitations(ciphertextTarget.getSymlinkFilePath());
521522
try (OpenCryptoFiles.TwoPhaseMove twoPhaseMove = openCryptoFiles.prepareMove(ciphertextSource.getRawPath(), ciphertextTarget.getRawPath())) {
522523
Files.move(ciphertextSource.getRawPath(), ciphertextTarget.getRawPath(), options);
523524
if (ciphertextTarget.isShortened()) {
@@ -534,7 +535,6 @@ private void moveFile(CryptoPath cleartextSource, CryptoPath cleartextTarget, Co
534535
// we need to re-map the OpenCryptoFile entry.
535536
CiphertextFilePath ciphertextSource = cryptoPathMapper.getCiphertextFilePath(cleartextSource);
536537
CiphertextFilePath ciphertextTarget = cryptoPathMapper.getCiphertextFilePath(cleartextTarget);
537-
assertCiphertextPathLengthMeetsLimitations(ciphertextTarget.getFilePath());
538538
try (OpenCryptoFiles.TwoPhaseMove twoPhaseMove = openCryptoFiles.prepareMove(ciphertextSource.getRawPath(), ciphertextTarget.getRawPath())) {
539539
if (ciphertextTarget.isShortened()) {
540540
Files.createDirectory(ciphertextTarget.getRawPath());
@@ -553,7 +553,6 @@ private void moveDirectory(CryptoPath cleartextSource, CryptoPath cleartextTarge
553553
// Hence there is no need to re-map OpenCryptoFile entries.
554554
CiphertextFilePath ciphertextSource = cryptoPathMapper.getCiphertextFilePath(cleartextSource);
555555
CiphertextFilePath ciphertextTarget = cryptoPathMapper.getCiphertextFilePath(cleartextTarget);
556-
assertCiphertextPathLengthMeetsLimitations(ciphertextTarget.getDirFilePath());
557556
if (ArrayUtils.contains(options, StandardCopyOption.REPLACE_EXISTING)) {
558557
// check if not attempting to move atomically:
559558
if (ArrayUtils.contains(options, StandardCopyOption.ATOMIC_MOVE)) {
@@ -593,8 +592,8 @@ CryptoFileStore getFileStore() {
593592

594593
void createSymbolicLink(CryptoPath cleartextPath, Path target, FileAttribute<?>... attrs) throws IOException {
595594
assertOpen();
596-
CiphertextFilePath ciphertextFilePath = cryptoPathMapper.getCiphertextFilePath(cleartextPath);
597-
assertCiphertextPathLengthMeetsLimitations(ciphertextFilePath.getSymlinkFilePath());
595+
readonlyFlag.assertWritable();
596+
assertCleartextNameLengthAllowed(cleartextPath);
598597
symlinks.createSymbolicLink(cleartextPath, target, attrs);
599598
}
600599

@@ -612,13 +611,11 @@ CryptoPath getRootPath() {
612611
CryptoPath getEmptyPath() {
613612
return emptyPath;
614613
}
615-
616-
void assertCiphertextPathLengthMeetsLimitations(Path cdrFilePath) throws FileNameTooLongException {
617-
Path vaultRelativePath = pathToVault.relativize(cdrFilePath);
618-
String fileName = vaultRelativePath.getName(3).toString(); // fourth path element (d/xx/yyyyy/file.c9r/symlink.c9r)
619-
String path = vaultRelativePath.toString();
620-
if (fileName.length() > fileSystemProperties.maxNameLength() || path.length() > fileSystemProperties.maxPathLength()) {
621-
throw new FileNameTooLongException(path, fileSystemProperties.maxPathLength(), fileSystemProperties.maxNameLength());
614+
615+
void assertCleartextNameLengthAllowed(CryptoPath cleartextPath) throws FileNameTooLongException {
616+
String filename = cleartextPath.getFileName().toString();
617+
if (filename.length() > fileSystemProperties.maxCleartextNameLength()) {
618+
throw new FileNameTooLongException(cleartextPath.toString(), fileSystemProperties.maxCleartextNameLength());
622619
}
623620
}
624621

src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java

Lines changed: 28 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@
99
package org.cryptomator.cryptofs;
1010

1111
import com.google.common.base.Strings;
12-
import org.cryptomator.cryptofs.common.Constants;
1312
import org.cryptomator.cryptolib.api.MasterkeyLoader;
14-
import org.cryptomator.cryptolib.api.MasterkeyLoadingFailedException;
1513

1614
import java.net.URI;
1715
import java.nio.file.FileSystems;
1816
import java.nio.file.Path;
1917
import java.util.AbstractMap;
2018
import java.util.Collection;
2119
import java.util.EnumSet;
22-
import java.util.HashSet;
2320
import java.util.Map;
2421
import java.util.Set;
2522
import java.util.function.Consumer;
@@ -38,31 +35,20 @@
3835
public class CryptoFileSystemProperties extends AbstractMap<String, Object> {
3936

4037
/**
41-
* Maximum ciphertext path length.
38+
* Maximum cleartext filename length.
4239
*
43-
* @since 1.9.8
44-
*/
45-
public static final String PROPERTY_MAX_PATH_LENGTH = "maxPathLength";
46-
47-
static final int DEFAULT_MAX_PATH_LENGTH = Constants.MAX_CIPHERTEXT_PATH_LENGTH;
48-
49-
/**
50-
* Maximum filename length of .c9r files.
51-
*
52-
* @since 1.9.9
40+
* @since 2.0.0
5341
*/
54-
public static final String PROPERTY_MAX_NAME_LENGTH = "maxNameLength";
42+
public static final String PROPERTY_MAX_CLEARTEXT_NAME_LENGTH = "maxCleartextNameLength";
5543

56-
static final int DEFAULT_MAX_NAME_LENGTH = Constants.MAX_CIPHERTEXT_NAME_LENGTH;
44+
static final int DEFAULT_MAX_CLEARTEXT_NAME_LENGTH = LongFileNameProvider.MAX_FILENAME_BUFFER_SIZE;
5745

5846
/**
5947
* Key identifying the key loader used during initialization.
6048
*
6149
* @since 2.0.0
6250
*/
63-
public static final String PROPERTY_KEYLOADERS = "keyLoaders";
64-
65-
static final Collection<MasterkeyLoader> DEFAULT_KEYLOADERS = Set.of();
51+
public static final String PROPERTY_KEYLOADER = "keyLoader";
6652

6753
/**
6854
* Key identifying the name of the vault config file located inside the vault directory.
@@ -111,34 +97,17 @@ public enum FileSystemFlags {
11197

11298
private CryptoFileSystemProperties(Builder builder) {
11399
this.entries = Set.of( //
114-
Map.entry(PROPERTY_KEYLOADERS, builder.keyLoaders), //
100+
Map.entry(PROPERTY_KEYLOADER, builder.keyLoader), //
115101
Map.entry(PROPERTY_FILESYSTEM_FLAGS, builder.flags), //
116102
Map.entry(PROPERTY_VAULTCONFIG_FILENAME, builder.vaultConfigFilename), //
117103
Map.entry(PROPERTY_MASTERKEY_FILENAME, builder.masterkeyFilename), //
118-
Map.entry(PROPERTY_MAX_PATH_LENGTH, builder.maxPathLength), //
119-
Map.entry(PROPERTY_MAX_NAME_LENGTH, builder.maxNameLength), //
104+
Map.entry(PROPERTY_MAX_CLEARTEXT_NAME_LENGTH, builder.maxCleartextNameLength), //
120105
Map.entry(PROPERTY_CIPHER_COMBO, builder.cipherCombo) //
121106
);
122107
}
123108

124-
Collection<MasterkeyLoader> keyLoaders() {
125-
return (Collection<MasterkeyLoader>) get(PROPERTY_KEYLOADERS);
126-
}
127-
128-
/**
129-
* Selects the first applicable MasterkeyLoader that supports the given scheme.
130-
*
131-
* @param scheme An URI scheme used in key IDs
132-
* @return A key loader
133-
* @throws MasterkeyLoadingFailedException If the scheme is not supported by any key loader
134-
*/
135-
MasterkeyLoader keyLoader(String scheme) throws MasterkeyLoadingFailedException {
136-
for (MasterkeyLoader loader : keyLoaders()) {
137-
if (loader.supportsScheme(scheme)) {
138-
return loader;
139-
}
140-
}
141-
throw new MasterkeyLoadingFailedException("No key loader for key type: " + scheme);
109+
MasterkeyLoader keyLoader() {
110+
return (MasterkeyLoader) get(PROPERTY_KEYLOADER);
142111
}
143112

144113
public VaultCipherCombo cipherCombo() {
@@ -162,12 +131,8 @@ String masterkeyFilename() {
162131
return (String) get(PROPERTY_MASTERKEY_FILENAME);
163132
}
164133

165-
int maxPathLength() {
166-
return (int) get(PROPERTY_MAX_PATH_LENGTH);
167-
}
168-
169-
int maxNameLength() {
170-
return (int) get(PROPERTY_MAX_NAME_LENGTH);
134+
int maxCleartextNameLength() {
135+
return (int) get(PROPERTY_MAX_CLEARTEXT_NAME_LENGTH);
171136
}
172137

173138
@Override
@@ -219,23 +184,21 @@ public static CryptoFileSystemProperties wrap(Map<String, ?> properties) {
219184
public static class Builder {
220185

221186
public VaultCipherCombo cipherCombo = DEFAULT_CIPHER_COMBO;
222-
private Collection<MasterkeyLoader> keyLoaders = new HashSet<>(DEFAULT_KEYLOADERS);
187+
private MasterkeyLoader keyLoader = null;
223188
private final Set<FileSystemFlags> flags = EnumSet.copyOf(DEFAULT_FILESYSTEM_FLAGS);
224189
private String vaultConfigFilename = DEFAULT_VAULTCONFIG_FILENAME;
225190
private String masterkeyFilename = DEFAULT_MASTERKEY_FILENAME;
226-
private int maxPathLength = DEFAULT_MAX_PATH_LENGTH;
227-
private int maxNameLength = DEFAULT_MAX_NAME_LENGTH;
191+
private int maxCleartextNameLength = DEFAULT_MAX_CLEARTEXT_NAME_LENGTH;
228192

229193
private Builder() {
230194
}
231195

232196
private Builder(Map<String, ?> properties) {
233-
checkedSet(Collection.class, PROPERTY_KEYLOADERS, properties, this::withKeyLoaders);
197+
checkedSet(MasterkeyLoader.class, PROPERTY_KEYLOADER, properties, this::withKeyLoader);
234198
checkedSet(String.class, PROPERTY_VAULTCONFIG_FILENAME, properties, this::withVaultConfigFilename);
235199
checkedSet(String.class, PROPERTY_MASTERKEY_FILENAME, properties, this::withMasterkeyFilename);
236200
checkedSet(Set.class, PROPERTY_FILESYSTEM_FLAGS, properties, this::withFlags);
237-
checkedSet(Integer.class, PROPERTY_MAX_PATH_LENGTH, properties, this::withMaxPathLength);
238-
checkedSet(Integer.class, PROPERTY_MAX_NAME_LENGTH, properties, this::withMaxNameLength);
201+
checkedSet(Integer.class, PROPERTY_MAX_CLEARTEXT_NAME_LENGTH, properties, this::withMaxCleartextNameLength);
239202
checkedSet(VaultCipherCombo.class, PROPERTY_CIPHER_COMBO, properties, this::withCipherCombo);
240203
}
241204

@@ -250,28 +213,17 @@ private <T> void checkedSet(Class<T> type, String key, Map<String, ?> properties
250213
}
251214
}
252215

253-
254-
/**
255-
* Sets the maximum ciphertext path length for a CryptoFileSystem.
256-
*
257-
* @param maxPathLength The maximum ciphertext path length allowed
258-
* @return this
259-
* @since 1.9.8
260-
*/
261-
public Builder withMaxPathLength(int maxPathLength) {
262-
this.maxPathLength = maxPathLength;
263-
return this;
264-
}
265-
266216
/**
267-
* Sets the maximum ciphertext filename length for a CryptoFileSystem.
217+
* Sets the maximum cleartext filename length for a CryptoFileSystem. This value is checked during write
218+
* operations. Read access to nodes with longer names should be unaffected. Setting this value to {@code 0} or
219+
* a negative value effectively disables write access.
268220
*
269-
* @param maxNameLength The maximum ciphertext filename length allowed
221+
* @param maxCleartextNameLength The maximum cleartext filename length allowed
270222
* @return this
271-
* @since 1.9.9
223+
* @since 2.0.0
272224
*/
273-
public Builder withMaxNameLength(int maxNameLength) {
274-
this.maxNameLength = maxNameLength;
225+
public Builder withMaxCleartextNameLength(int maxCleartextNameLength) {
226+
this.maxCleartextNameLength = maxCleartextNameLength;
275227
return this;
276228
}
277229

@@ -289,26 +241,14 @@ public Builder withCipherCombo(VaultCipherCombo cipherCombo) {
289241
}
290242

291243
/**
292-
* Sets the keyLoaders for a CryptoFileSystem.
293-
*
294-
* @param keyLoaders A set of keyLoaders to load the key configured in the vault configuration
295-
* @return this
296-
* @since 2.0.0
297-
*/
298-
public Builder withKeyLoaders(MasterkeyLoader... keyLoaders) {
299-
return withKeyLoaders(asList(keyLoaders));
300-
}
301-
302-
/**
303-
* Sets the keyLoaders for a CryptoFileSystem.
244+
* Sets the keyloader for a CryptoFileSystem.
304245
*
305-
* @param keyLoaders A set of keyLoaders to load the key configured in the vault configuration
246+
* @param keyLoader A factory creating a {@link MasterkeyLoader} capable of handling the given {@code scheme}.
306247
* @return this
307248
* @since 2.0.0
308249
*/
309-
public Builder withKeyLoaders(Collection<MasterkeyLoader> keyLoaders) {
310-
this.keyLoaders.clear();
311-
this.keyLoaders.addAll(keyLoaders);
250+
public Builder withKeyLoader(MasterkeyLoader keyLoader) {
251+
this.keyLoader = keyLoader;
312252
return this;
313253
}
314254

@@ -372,8 +312,8 @@ public CryptoFileSystemProperties build() {
372312
}
373313

374314
private void validate() {
375-
if (keyLoaders.isEmpty()) {
376-
throw new IllegalStateException("at least one keyloader is required");
315+
if (keyLoader == null) {
316+
throw new IllegalStateException("keyLoader is required");
377317
}
378318
if (Strings.nullToEmpty(masterkeyFilename).trim().isEmpty()) {
379319
throw new IllegalStateException("masterkeyFilename is required");

src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ public static void initialize(Path pathToVault, CryptoFileSystemProperties prope
141141
throw new NotDirectoryException(pathToVault.toString());
142142
}
143143
byte[] rawKey = new byte[0];
144-
var config = VaultConfig.createNew().cipherCombo(properties.cipherCombo()).maxFilenameLength(properties.maxNameLength()).build();
145-
try (Masterkey key = properties.keyLoader(keyId.getScheme()).loadKey(keyId);
144+
var config = VaultConfig.createNew().cipherCombo(properties.cipherCombo()).shorteningThreshold(Constants.DEFAULT_SHORTENING_THRESHOLD).build();
145+
try (Masterkey key = properties.keyLoader().loadKey(keyId);
146146
Cryptor cryptor = config.getCipherCombo().getCryptorProvider(strongSecureRandom()).withKey(key)) {
147147
rawKey = key.getEncoded();
148148
// save vault config:

src/main/java/org/cryptomator/cryptofs/CryptoFileSystems.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public CryptoFileSystemImpl create(CryptoFileSystemProvider provider, Path pathT
4949

5050
var configLoader = VaultConfig.decode(token);
5151
var keyId = configLoader.getKeyId();
52-
try (Masterkey key = properties.keyLoader(keyId.getScheme()).loadKey(keyId)) {
52+
try (Masterkey key = properties.keyLoader().loadKey(keyId)) {
5353
var config = configLoader.verify(key.getEncoded(), Constants.VAULT_VERSION);
5454
var adjustedProperties = adjustForCapabilities(pathToVault, properties);
5555
var cryptor = config.getCipherCombo().getCryptorProvider(csprng).withKey(key.clone());

src/main/java/org/cryptomator/cryptofs/CryptoPathMapper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,19 @@ public class CryptoPathMapper {
4848
private final Path dataRoot;
4949
private final DirectoryIdProvider dirIdProvider;
5050
private final LongFileNameProvider longFileNameProvider;
51+
private final VaultConfig vaultConfig;
5152
private final LoadingCache<DirIdAndName, String> ciphertextNames;
5253
private final Cache<CryptoPath, CiphertextDirectory> ciphertextDirectories;
5354

5455
private final CiphertextDirectory rootDirectory;
5556

5657
@Inject
57-
CryptoPathMapper(@PathToVault Path pathToVault, Cryptor cryptor, DirectoryIdProvider dirIdProvider, LongFileNameProvider longFileNameProvider) {
58+
CryptoPathMapper(@PathToVault Path pathToVault, Cryptor cryptor, DirectoryIdProvider dirIdProvider, LongFileNameProvider longFileNameProvider, VaultConfig vaultConfig) {
5859
this.dataRoot = pathToVault.resolve(DATA_DIR_NAME);
5960
this.cryptor = cryptor;
6061
this.dirIdProvider = dirIdProvider;
6162
this.longFileNameProvider = longFileNameProvider;
63+
this.vaultConfig = vaultConfig;
6264
this.ciphertextNames = CacheBuilder.newBuilder().maximumSize(MAX_CACHED_CIPHERTEXT_NAMES).build(CacheLoader.from(this::getCiphertextFileName));
6365
this.ciphertextDirectories = CacheBuilder.newBuilder().maximumSize(MAX_CACHED_DIR_PATHS).expireAfterWrite(MAX_CACHE_AGE).build();
6466
this.rootDirectory = resolveDirectory(Constants.ROOT_DIR_ID);
@@ -127,7 +129,7 @@ public CiphertextFilePath getCiphertextFilePath(CryptoPath cleartextPath) throws
127129
public CiphertextFilePath getCiphertextFilePath(Path parentCiphertextDir, String parentDirId, String cleartextName) {
128130
String ciphertextName = ciphertextNames.getUnchecked(new DirIdAndName(parentDirId, cleartextName));
129131
Path c9rPath = parentCiphertextDir.resolve(ciphertextName);
130-
if (ciphertextName.length() > Constants.MAX_CIPHERTEXT_NAME_LENGTH) {
132+
if (ciphertextName.length() > vaultConfig.getShorteningThreshold()) {
131133
LongFileNameProvider.DeflatedFileName deflatedFileName = longFileNameProvider.deflate(c9rPath);
132134
return new CiphertextFilePath(deflatedFileName.c9sPath, Optional.of(deflatedFileName));
133135
} else {

0 commit comments

Comments
 (0)