Rename crypto maxFileNameLength to shorteningThreshold
This commit is contained in:
parent
300ee61d58
commit
b304d6e828
@ -38,7 +38,7 @@ class CryptoCloudContentRepository implements CloudContentRepository<CryptoCloud
|
|||||||
this.cryptoImpl = new CryptoImplVaultFormat7(context, cryptor, cloudContentRepository, vaultLocation, new DirIdCacheFormat7());
|
this.cryptoImpl = new CryptoImplVaultFormat7(context, cryptor, cloudContentRepository, vaultLocation, new DirIdCacheFormat7());
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
this.cryptoImpl = new CryptoImplVaultFormat8(context, cryptor, cloudContentRepository, vaultLocation, new DirIdCacheFormat7(), cloud.getVault().getMaxFileNameLength());
|
this.cryptoImpl = new CryptoImplVaultFormat8(context, cryptor, cloudContentRepository, vaultLocation, new DirIdCacheFormat7(), cloud.getVault().getShorteningThreshold());
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
case 5:
|
case 5:
|
||||||
|
@ -54,20 +54,20 @@ abstract class CryptoImplDecorator {
|
|||||||
final CloudContentRepository cloudContentRepository;
|
final CloudContentRepository cloudContentRepository;
|
||||||
final Context context;
|
final Context context;
|
||||||
final DirIdCache dirIdCache;
|
final DirIdCache dirIdCache;
|
||||||
final int maxFileNameLength;
|
final int shorteningThreshold;
|
||||||
|
|
||||||
private final Supplier<Cryptor> cryptor;
|
private final Supplier<Cryptor> cryptor;
|
||||||
private final CloudFolder storageLocation;
|
private final CloudFolder storageLocation;
|
||||||
|
|
||||||
private RootCryptoFolder root;
|
private RootCryptoFolder root;
|
||||||
|
|
||||||
CryptoImplDecorator(Context context, Supplier<Cryptor> cryptor, CloudContentRepository cloudContentRepository, CloudFolder storageLocation, DirIdCache dirIdCache, int maxFileNameLength) {
|
CryptoImplDecorator(Context context, Supplier<Cryptor> cryptor, CloudContentRepository cloudContentRepository, CloudFolder storageLocation, DirIdCache dirIdCache, int shorteningThreshold) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.cryptor = cryptor;
|
this.cryptor = cryptor;
|
||||||
this.cloudContentRepository = cloudContentRepository;
|
this.cloudContentRepository = cloudContentRepository;
|
||||||
this.storageLocation = storageLocation;
|
this.storageLocation = storageLocation;
|
||||||
this.dirIdCache = dirIdCache;
|
this.dirIdCache = dirIdCache;
|
||||||
this.maxFileNameLength = maxFileNameLength;
|
this.shorteningThreshold = shorteningThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract CryptoFolder folder(CryptoFolder cryptoParent, String cleartextName) throws BackendException;
|
abstract CryptoFolder folder(CryptoFolder cryptoParent, String cleartextName) throws BackendException;
|
||||||
|
@ -67,8 +67,8 @@ class CryptoImplVaultFormat7 extends CryptoImplDecorator {
|
|||||||
super(context, cryptor, cloudContentRepository, storageLocation, dirIdCache, CryptoConstants.DEFAULT_MAX_FILE_NAME);
|
super(context, cryptor, cloudContentRepository, storageLocation, dirIdCache, CryptoConstants.DEFAULT_MAX_FILE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoImplVaultFormat7(Context context, Supplier<Cryptor> cryptor, CloudContentRepository cloudContentRepository, CloudFolder storageLocation, DirIdCache dirIdCache, int maxFileNameLength) {
|
CryptoImplVaultFormat7(Context context, Supplier<Cryptor> cryptor, CloudContentRepository cloudContentRepository, CloudFolder storageLocation, DirIdCache dirIdCache, int shorteningThreshold) {
|
||||||
super(context, cryptor, cloudContentRepository, storageLocation, dirIdCache, maxFileNameLength);
|
super(context, cryptor, cloudContentRepository, storageLocation, dirIdCache, shorteningThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -85,7 +85,7 @@ class CryptoImplVaultFormat7 extends CryptoImplDecorator {
|
|||||||
.fileNameCryptor() //
|
.fileNameCryptor() //
|
||||||
.encryptFilename(BASE64, name, dirIdInfo(cryptoFolder).getId().getBytes(UTF_8)) + CLOUD_NODE_EXT;
|
.encryptFilename(BASE64, name, dirIdInfo(cryptoFolder).getId().getBytes(UTF_8)) + CLOUD_NODE_EXT;
|
||||||
|
|
||||||
if (ciphertextName.length() > maxFileNameLength) {
|
if (ciphertextName.length() > shorteningThreshold) {
|
||||||
ciphertextName = deflate(cryptoFolder, ciphertextName);
|
ciphertextName = deflate(cryptoFolder, ciphertextName);
|
||||||
}
|
}
|
||||||
return ciphertextName;
|
return ciphertextName;
|
||||||
|
@ -9,8 +9,8 @@ import org.cryptomator.util.Supplier;
|
|||||||
|
|
||||||
public class CryptoImplVaultFormat8 extends CryptoImplVaultFormat7 {
|
public class CryptoImplVaultFormat8 extends CryptoImplVaultFormat7 {
|
||||||
|
|
||||||
CryptoImplVaultFormat8(Context context, Supplier<Cryptor> cryptor, CloudContentRepository cloudContentRepository, CloudFolder storageLocation, DirIdCache dirIdCache, int maxFileNameLength) {
|
CryptoImplVaultFormat8(Context context, Supplier<Cryptor> cryptor, CloudContentRepository cloudContentRepository, CloudFolder storageLocation, DirIdCache dirIdCache, int shorteningThreshold) {
|
||||||
super(context, cryptor, cloudContentRepository, storageLocation, dirIdCache, maxFileNameLength);
|
super(context, cryptor, cloudContentRepository, storageLocation, dirIdCache, shorteningThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ import static org.cryptomator.util.Encodings.UTF_8;
|
|||||||
|
|
||||||
final class CryptoImplVaultFormatPre7 extends CryptoImplDecorator {
|
final class CryptoImplVaultFormatPre7 extends CryptoImplDecorator {
|
||||||
|
|
||||||
static final int MAX_FILE_NAME_LENGTH = 129;
|
static final int SHORTENING_THRESHOLD = 129;
|
||||||
private static final String DIR_PREFIX = "0";
|
private static final String DIR_PREFIX = "0";
|
||||||
private static final String SYMLINK_PREFIX = "1S";
|
private static final String SYMLINK_PREFIX = "1S";
|
||||||
private static final String LONG_NAME_FILE_EXT = ".lng";
|
private static final String LONG_NAME_FILE_EXT = ".lng";
|
||||||
@ -45,7 +45,7 @@ final class CryptoImplVaultFormatPre7 extends CryptoImplDecorator {
|
|||||||
private static final Pattern BASE32_ENCRYPTED_NAME_PATTERN = Pattern.compile("^(0|1S)?(([A-Z2-7]{8})*[A-Z2-7=]{8})$");
|
private static final Pattern BASE32_ENCRYPTED_NAME_PATTERN = Pattern.compile("^(0|1S)?(([A-Z2-7]{8})*[A-Z2-7=]{8})$");
|
||||||
|
|
||||||
CryptoImplVaultFormatPre7(Context context, Supplier<Cryptor> cryptor, CloudContentRepository cloudContentRepository, CloudFolder storageLocation, DirIdCache dirIdCache) {
|
CryptoImplVaultFormatPre7(Context context, Supplier<Cryptor> cryptor, CloudContentRepository cloudContentRepository, CloudFolder storageLocation, DirIdCache dirIdCache) {
|
||||||
super(context, cryptor, cloudContentRepository, storageLocation, dirIdCache, MAX_FILE_NAME_LENGTH);
|
super(context, cryptor, cloudContentRepository, storageLocation, dirIdCache, SHORTENING_THRESHOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -74,7 +74,7 @@ final class CryptoImplVaultFormatPre7 extends CryptoImplDecorator {
|
|||||||
|
|
||||||
private String encryptName(CryptoFolder cryptoParent, String name, String prefix) throws BackendException {
|
private String encryptName(CryptoFolder cryptoParent, String name, String prefix) throws BackendException {
|
||||||
String ciphertextName = prefix + cryptor().fileNameCryptor().encryptFilename(name, dirIdInfo(cryptoParent).getId().getBytes(UTF_8));
|
String ciphertextName = prefix + cryptor().fileNameCryptor().encryptFilename(name, dirIdInfo(cryptoParent).getId().getBytes(UTF_8));
|
||||||
if (ciphertextName.length() > maxFileNameLength) {
|
if (ciphertextName.length() > shorteningThreshold) {
|
||||||
ciphertextName = deflate(ciphertextName);
|
ciphertextName = deflate(ciphertextName);
|
||||||
}
|
}
|
||||||
return ciphertextName;
|
return ciphertextName;
|
||||||
@ -139,7 +139,7 @@ final class CryptoImplVaultFormatPre7 extends CryptoImplDecorator {
|
|||||||
if (ciphertextName.endsWith(LONG_NAME_FILE_EXT)) {
|
if (ciphertextName.endsWith(LONG_NAME_FILE_EXT)) {
|
||||||
try {
|
try {
|
||||||
ciphertextName = inflate(ciphertextName);
|
ciphertextName = inflate(ciphertextName);
|
||||||
if (ciphertextName.length() <= maxFileNameLength) {
|
if (ciphertextName.length() <= shorteningThreshold) {
|
||||||
cloudFile = inflatePermanently(cloudFile, ciphertextName);
|
cloudFile = inflatePermanently(cloudFile, ciphertextName);
|
||||||
}
|
}
|
||||||
} catch (NoSuchCloudFileException e) {
|
} catch (NoSuchCloudFileException e) {
|
||||||
|
@ -81,7 +81,7 @@ public class MasterkeyCryptoCloudProvider implements CryptoCloudProvider {
|
|||||||
.vaultFormat(MAX_VAULT_VERSION) //
|
.vaultFormat(MAX_VAULT_VERSION) //
|
||||||
.cipherCombo(DEFAULT_CIPHER_COMBO) //
|
.cipherCombo(DEFAULT_CIPHER_COMBO) //
|
||||||
.keyId(URI.create(String.format("%s:%s", MASTERKEY_SCHEME, MASTERKEY_FILE_NAME))) //
|
.keyId(URI.create(String.format("%s:%s", MASTERKEY_SCHEME, MASTERKEY_FILE_NAME))) //
|
||||||
.maxFilenameLength(DEFAULT_MAX_FILE_NAME) //
|
.shorteningThreshold(DEFAULT_MAX_FILE_NAME) //
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
byte[] encodedVaultConfig = vaultConfig.toToken(masterkey.getEncoded()).getBytes(UTF_8);
|
byte[] encodedVaultConfig = vaultConfig.toToken(masterkey.getEncoded()).getBytes(UTF_8);
|
||||||
@ -114,19 +114,19 @@ public class MasterkeyCryptoCloudProvider implements CryptoCloudProvider {
|
|||||||
Masterkey masterkey = impl.getKeyFile(password);
|
Masterkey masterkey = impl.getKeyFile(password);
|
||||||
|
|
||||||
int vaultFormat;
|
int vaultFormat;
|
||||||
int maxFileNameLength;
|
int shorteningThreshold;
|
||||||
Cryptor cryptor;
|
Cryptor cryptor;
|
||||||
|
|
||||||
if (unverifiedVaultConfig.isPresent()) {
|
if (unverifiedVaultConfig.isPresent()) {
|
||||||
VaultConfig vaultConfig = VaultConfig.verify(masterkey.getEncoded(), unverifiedVaultConfig.get());
|
VaultConfig vaultConfig = VaultConfig.verify(masterkey.getEncoded(), unverifiedVaultConfig.get());
|
||||||
vaultFormat = vaultConfig.getVaultFormat();
|
vaultFormat = vaultConfig.getVaultFormat();
|
||||||
assertVaultVersionIsSupported(vaultConfig.getVaultFormat());
|
assertVaultVersionIsSupported(vaultConfig.getVaultFormat());
|
||||||
maxFileNameLength = vaultConfig.getMaxFilenameLength();
|
shorteningThreshold = vaultConfig.getShorteningThreshold();
|
||||||
cryptor = cryptorFor(masterkey, vaultConfig.getCipherCombo());
|
cryptor = cryptorFor(masterkey, vaultConfig.getCipherCombo());
|
||||||
} else {
|
} else {
|
||||||
vaultFormat = MasterkeyFileAccess.readAllegedVaultVersion(impl.keyFileData);
|
vaultFormat = MasterkeyFileAccess.readAllegedVaultVersion(impl.keyFileData);
|
||||||
assertLegacyVaultVersionIsSupported(vaultFormat);
|
assertLegacyVaultVersionIsSupported(vaultFormat);
|
||||||
maxFileNameLength = vaultFormat > 6 ? CryptoConstants.DEFAULT_MAX_FILE_NAME : CryptoImplVaultFormatPre7.MAX_FILE_NAME_LENGTH;
|
shorteningThreshold = vaultFormat > 6 ? CryptoConstants.DEFAULT_MAX_FILE_NAME : CryptoImplVaultFormatPre7.SHORTENING_THRESHOLD;
|
||||||
cryptor = cryptorFor(masterkey, SIV_CTRMAC);
|
cryptor = cryptorFor(masterkey, SIV_CTRMAC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public class MasterkeyCryptoCloudProvider implements CryptoCloudProvider {
|
|||||||
Vault vault = aCopyOf(token.getVault()) //
|
Vault vault = aCopyOf(token.getVault()) //
|
||||||
.withUnlocked(true) //
|
.withUnlocked(true) //
|
||||||
.withFormat(vaultFormat) //
|
.withFormat(vaultFormat) //
|
||||||
.withMaxFileNameLength(maxFileNameLength) //
|
.withShorteningThreshold(shorteningThreshold) //
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
cryptoCloudContentRepositoryFactory.registerCryptor(vault, cryptor);
|
cryptoCloudContentRepositoryFactory.registerCryptor(vault, cryptor);
|
||||||
|
@ -24,7 +24,7 @@ class VaultConfig private constructor(builder: VaultConfigBuilder) {
|
|||||||
val id: String
|
val id: String
|
||||||
val vaultFormat: Int
|
val vaultFormat: Int
|
||||||
val cipherCombo: VaultCipherCombo
|
val cipherCombo: VaultCipherCombo
|
||||||
val maxFilenameLength: Int
|
val shorteningThreshold: Int
|
||||||
|
|
||||||
fun toToken(rawKey: ByteArray): String {
|
fun toToken(rawKey: ByteArray): String {
|
||||||
return Jwts.builder()
|
return Jwts.builder()
|
||||||
@ -32,7 +32,7 @@ class VaultConfig private constructor(builder: VaultConfigBuilder) {
|
|||||||
.setId(id) //
|
.setId(id) //
|
||||||
.claim(JSON_KEY_VAULTFORMAT, vaultFormat) //
|
.claim(JSON_KEY_VAULTFORMAT, vaultFormat) //
|
||||||
.claim(JSON_KEY_CIPHERCONFIG, cipherCombo.name) //
|
.claim(JSON_KEY_CIPHERCONFIG, cipherCombo.name) //
|
||||||
.claim(JSON_KEY_MAXFILENAMELEN, maxFilenameLength) //
|
.claim(JSON_KEY_SHORTENING_THRESHOLD, shorteningThreshold) //
|
||||||
.signWith(Keys.hmacShaKeyFor(rawKey)) //
|
.signWith(Keys.hmacShaKeyFor(rawKey)) //
|
||||||
.compact()
|
.compact()
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ class VaultConfig private constructor(builder: VaultConfigBuilder) {
|
|||||||
internal var id: String = UUID.randomUUID().toString()
|
internal var id: String = UUID.randomUUID().toString()
|
||||||
internal var vaultFormat = CryptoConstants.MAX_VAULT_VERSION;
|
internal var vaultFormat = CryptoConstants.MAX_VAULT_VERSION;
|
||||||
internal var cipherCombo = VaultCipherCombo.SIV_CTRMAC
|
internal var cipherCombo = VaultCipherCombo.SIV_CTRMAC
|
||||||
internal var maxFilenameLength = CryptoConstants.DEFAULT_MAX_FILE_NAME;
|
internal var shorteningThreshold = CryptoConstants.DEFAULT_MAX_FILE_NAME;
|
||||||
lateinit var keyId: URI
|
lateinit var keyId: URI
|
||||||
|
|
||||||
fun keyId(keyId: URI): VaultConfigBuilder {
|
fun keyId(keyId: URI): VaultConfigBuilder {
|
||||||
@ -55,8 +55,8 @@ class VaultConfig private constructor(builder: VaultConfigBuilder) {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun maxFilenameLength(maxFilenameLength: Int): VaultConfigBuilder {
|
fun shorteningThreshold(shorteningThreshold: Int): VaultConfigBuilder {
|
||||||
this.maxFilenameLength = maxFilenameLength
|
this.shorteningThreshold = shorteningThreshold
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ class VaultConfig private constructor(builder: VaultConfigBuilder) {
|
|||||||
|
|
||||||
private const val JSON_KEY_VAULTFORMAT = "format"
|
private const val JSON_KEY_VAULTFORMAT = "format"
|
||||||
private const val JSON_KEY_CIPHERCONFIG = "cipherCombo"
|
private const val JSON_KEY_CIPHERCONFIG = "cipherCombo"
|
||||||
private const val JSON_KEY_MAXFILENAMELEN = "maxFilenameLen"
|
private const val JSON_KEY_SHORTENING_THRESHOLD = "shorteningThreshold"
|
||||||
private const val JSON_KEY_ID = "kid"
|
private const val JSON_KEY_ID = "kid"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ -112,7 +112,7 @@ class VaultConfig private constructor(builder: VaultConfigBuilder) {
|
|||||||
.id(parser.header[JSON_KEY_ID] as String) //
|
.id(parser.header[JSON_KEY_ID] as String) //
|
||||||
.cipherCombo(VaultCipherCombo.valueOf(parser.body.get(JSON_KEY_CIPHERCONFIG, String::class.java))) //
|
.cipherCombo(VaultCipherCombo.valueOf(parser.body.get(JSON_KEY_CIPHERCONFIG, String::class.java))) //
|
||||||
.vaultFormat(unverifiedVaultConfig.vaultFormat) //
|
.vaultFormat(unverifiedVaultConfig.vaultFormat) //
|
||||||
.maxFilenameLength(parser.body[JSON_KEY_MAXFILENAMELEN] as Int)
|
.shorteningThreshold(parser.body[JSON_KEY_SHORTENING_THRESHOLD] as Int)
|
||||||
|
|
||||||
VaultConfig(vaultConfigBuilder)
|
VaultConfig(vaultConfigBuilder)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@ -148,6 +148,6 @@ class VaultConfig private constructor(builder: VaultConfigBuilder) {
|
|||||||
keyId = builder.keyId
|
keyId = builder.keyId
|
||||||
vaultFormat = builder.vaultFormat
|
vaultFormat = builder.vaultFormat
|
||||||
cipherCombo = builder.cipherCombo
|
cipherCombo = builder.cipherCombo
|
||||||
maxFilenameLength = builder.maxFilenameLength
|
shorteningThreshold = builder.shorteningThreshold
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ class MasterkeyCryptoCloudProviderTest {
|
|||||||
|
|
||||||
private final String masterkeyV8 = "{ \"version\": 999, \"scryptSalt\": \"AAAAAAAAAAA=\", \"scryptCostParam\": 32768, \"scryptBlockSize\": 8, \"primaryMasterKey\": \"D2kc+xBoAcVY+M7s74YBEy6l7ga2+Nz+HS5o0TQY3JMW1uQ5jTlLIQ==\", \"hmacMasterKey\": \"D2kc+xBoAcVY+M7s74YBEy6l7ga2+Nz+HS5o0TQY3JMW1uQ5jTlLIQ==\", \"versionMac\": \"trDKXqDhu94/VPuoWaQGBm8hwSPYc0D9t6DRRxKZ65k=\"}";
|
private final String masterkeyV8 = "{ \"version\": 999, \"scryptSalt\": \"AAAAAAAAAAA=\", \"scryptCostParam\": 32768, \"scryptBlockSize\": 8, \"primaryMasterKey\": \"D2kc+xBoAcVY+M7s74YBEy6l7ga2+Nz+HS5o0TQY3JMW1uQ5jTlLIQ==\", \"hmacMasterKey\": \"D2kc+xBoAcVY+M7s74YBEy6l7ga2+Nz+HS5o0TQY3JMW1uQ5jTlLIQ==\", \"versionMac\": \"trDKXqDhu94/VPuoWaQGBm8hwSPYc0D9t6DRRxKZ65k=\"}";
|
||||||
private final String masterkeyV7 = "{ \"version\": 7, \"scryptSalt\": \"AAAAAAAAAAA=\", \"scryptCostParam\": 32768, \"scryptBlockSize\": 8, \"primaryMasterKey\": \"D2kc+xBoAcVY+M7s74YBEy6l7ga2+Nz+HS5o0TQY3JMW1uQ5jTlLIQ==\", \"hmacMasterKey\": \"D2kc+xBoAcVY+M7s74YBEy6l7ga2+Nz+HS5o0TQY3JMW1uQ5jTlLIQ==\", \"versionMac\": \"cn2sAK6l9p1/w9deJVUuW3h7br056mpv5srvALiYw+g=\"}";
|
private final String masterkeyV7 = "{ \"version\": 7, \"scryptSalt\": \"AAAAAAAAAAA=\", \"scryptCostParam\": 32768, \"scryptBlockSize\": 8, \"primaryMasterKey\": \"D2kc+xBoAcVY+M7s74YBEy6l7ga2+Nz+HS5o0TQY3JMW1uQ5jTlLIQ==\", \"hmacMasterKey\": \"D2kc+xBoAcVY+M7s74YBEy6l7ga2+Nz+HS5o0TQY3JMW1uQ5jTlLIQ==\", \"versionMac\": \"cn2sAK6l9p1/w9deJVUuW3h7br056mpv5srvALiYw+g=\"}";
|
||||||
private final String vaultConfig = "eyJraWQiOiJtYXN0ZXJrZXlmaWxlOm1hc3RlcmtleS5jcnlwdG9tYXRvciIsImFsZyI6IkhTNTEyIn0.eyJtYXhGaWxlbmFtZUxlbiI6MjIwLCJmb3JtYXQiOjgsImNpcGhlckNvbWJvIjoiU0lWX0NUUk1BQyJ9.umiAcGObWuVISugrQu16hznDHIFM7moD1ukA1r5V1DRA0GjHQk1p6S9hkL0PaMD7xl04jSttMRalOYU1sg4wqQ";
|
private final String vaultConfig = "eyJraWQiOiJtYXN0ZXJrZXlmaWxlOm1hc3RlcmtleS5jcnlwdG9tYXRvciIsImFsZyI6IkhTNTEyIn0.eyJmb3JtYXQiOjgsInNob3J0ZW5pbmdUaHJlc2hvbGQiOjIyMCwiY2lwaGVyQ29tYm8iOiJTSVZfQ1RSTUFDIn0.Evt5KXS_35pm53DynIwL3qvXWF56UkfqDZKv12n7SD288jzcdvvmtvu5sQhhqvxU6CPL4Q9v3yFQ_lvBynyrYA";
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private Cloud cloud;
|
private Cloud cloud;
|
||||||
@ -173,7 +173,7 @@ class MasterkeyCryptoCloudProviderTest {
|
|||||||
|
|
||||||
MatcherAssert.assertThat(result.isUnlocked(), is(true));
|
MatcherAssert.assertThat(result.isUnlocked(), is(true));
|
||||||
MatcherAssert.assertThat(result.getFormat(), is(8));
|
MatcherAssert.assertThat(result.getFormat(), is(8));
|
||||||
MatcherAssert.assertThat(result.getMaxFileNameLength(), is(DEFAULT_MAX_FILE_NAME));
|
MatcherAssert.assertThat(result.getShorteningThreshold(), is(DEFAULT_MAX_FILE_NAME));
|
||||||
|
|
||||||
Mockito.verify(inTest).cryptorFor(unlockToken.getKeyFile("foo"), SIV_CTRMAC);
|
Mockito.verify(inTest).cryptorFor(unlockToken.getKeyFile("foo"), SIV_CTRMAC);
|
||||||
Mockito.verify(cryptoCloudContentRepositoryFactory).registerCryptor(Mockito.any(Vault.class), Mockito.any(Cryptor.class));
|
Mockito.verify(cryptoCloudContentRepositoryFactory).registerCryptor(Mockito.any(Vault.class), Mockito.any(Cryptor.class));
|
||||||
@ -200,7 +200,7 @@ class MasterkeyCryptoCloudProviderTest {
|
|||||||
|
|
||||||
MatcherAssert.assertThat(result.isUnlocked(), is(true));
|
MatcherAssert.assertThat(result.isUnlocked(), is(true));
|
||||||
MatcherAssert.assertThat(result.getFormat(), is(MAX_VAULT_VERSION_WITHOUT_VAULT_CONFIG));
|
MatcherAssert.assertThat(result.getFormat(), is(MAX_VAULT_VERSION_WITHOUT_VAULT_CONFIG));
|
||||||
MatcherAssert.assertThat(result.getMaxFileNameLength(), is(DEFAULT_MAX_FILE_NAME));
|
MatcherAssert.assertThat(result.getShorteningThreshold(), is(DEFAULT_MAX_FILE_NAME));
|
||||||
|
|
||||||
Mockito.verify(inTest).cryptorFor(unlockToken.getKeyFile("foo"), SIV_CTRMAC);
|
Mockito.verify(inTest).cryptorFor(unlockToken.getKeyFile("foo"), SIV_CTRMAC);
|
||||||
Mockito.verify(cryptoCloudContentRepositoryFactory).registerCryptor(Mockito.any(Vault.class), Mockito.any(Cryptor.class));
|
Mockito.verify(cryptoCloudContentRepositoryFactory).registerCryptor(Mockito.any(Vault.class), Mockito.any(Cryptor.class));
|
||||||
|
@ -13,7 +13,7 @@ public class Vault implements Serializable {
|
|||||||
private final boolean unlocked;
|
private final boolean unlocked;
|
||||||
private final String password;
|
private final String password;
|
||||||
private final int format;
|
private final int format;
|
||||||
private final int maxFileNameLength;
|
private final int shorteningThreshold;
|
||||||
private final int position;
|
private final int position;
|
||||||
|
|
||||||
private Vault(Builder builder) {
|
private Vault(Builder builder) {
|
||||||
@ -25,7 +25,7 @@ public class Vault implements Serializable {
|
|||||||
this.cloudType = builder.cloudType;
|
this.cloudType = builder.cloudType;
|
||||||
this.password = builder.password;
|
this.password = builder.password;
|
||||||
this.format = builder.format;
|
this.format = builder.format;
|
||||||
this.maxFileNameLength = builder.maxFileNameLength;
|
this.shorteningThreshold = builder.shorteningThreshold;
|
||||||
this.position = builder.position;
|
this.position = builder.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public class Vault implements Serializable {
|
|||||||
.withUnlocked(vault.isUnlocked()) //
|
.withUnlocked(vault.isUnlocked()) //
|
||||||
.withSavedPassword(vault.getPassword()) //
|
.withSavedPassword(vault.getPassword()) //
|
||||||
.withFormat(vault.getFormat()) //
|
.withFormat(vault.getFormat()) //
|
||||||
.withMaxFileNameLength(vault.getMaxFileNameLength()) //
|
.withShorteningThreshold(vault.getShorteningThreshold()) //
|
||||||
.withPosition(vault.getPosition());
|
.withPosition(vault.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ public class Vault implements Serializable {
|
|||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxFileNameLength() {
|
public int getShorteningThreshold() {
|
||||||
return maxFileNameLength;
|
return shorteningThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPosition() {
|
public int getPosition() {
|
||||||
@ -117,7 +117,7 @@ public class Vault implements Serializable {
|
|||||||
private boolean unlocked;
|
private boolean unlocked;
|
||||||
private String password;
|
private String password;
|
||||||
private int format = -1;
|
private int format = -1;
|
||||||
private int maxFileNameLength = -1;
|
private int shorteningThreshold = -1;
|
||||||
private int position = -1;
|
private int position = -1;
|
||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
@ -189,8 +189,8 @@ public class Vault implements Serializable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder withMaxFileNameLength(int maxFileNameLength) {
|
public Builder withShorteningThreshold(int shorteningThreshold) {
|
||||||
this.maxFileNameLength = maxFileNameLength;
|
this.shorteningThreshold = shorteningThreshold;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ class VaultModel(private val vault: Vault) : Serializable {
|
|||||||
get() = vault.position
|
get() = vault.position
|
||||||
val format: Int
|
val format: Int
|
||||||
get() = vault.format
|
get() = vault.format
|
||||||
val maxFileNameLength: Int
|
val shorteningThreshold: Int
|
||||||
get() = vault.maxFileNameLength
|
get() = vault.shorteningThreshold
|
||||||
|
|
||||||
fun toVault(): Vault {
|
fun toVault(): Vault {
|
||||||
return vault
|
return vault
|
||||||
|
Loading…
x
Reference in New Issue
Block a user