- All Implemented Interfaces:
Serializable,Comparable<DirStructure>,Constable
Enumeration of the vault directory structure resemblances.
A valid vault must contain a `d` directory. Beginning with vault format 8, it must also contain a vault config file. If the vault format is lower than 8, it must instead contain a masterkey file.
In the latter case, to distinguish between a damaged vault 8 directory and a legacy vault the masterkey file must be read.
For efficiency reasons, this class only checks for existence/readability of the above elements.
Hence, if the result of checkDirStructure(Path, String, String) is MAYBE_LEGACY, one needs to parse
the masterkey file and read out the vault version to determine this case.
- Since:
- 2.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionDir contains addir and a masterkey file, but misses a vault config file.Dir does not qualify as vault.Dir contains addir as well as a vault config file. -
Method Summary
Modifier and TypeMethodDescriptionstatic DirStructurecheckDirStructure(Path pathToVault, String vaultConfigFilename, String masterkeyFilename) Analyzes the structure of the given directory under certain vault existence criteria.static DirStructureReturns the enum constant of this class with the specified name.static DirStructure[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
VAULT
Dir contains addir as well as a vault config file. -
MAYBE_LEGACY
Dir contains addir and a masterkey file, but misses a vault config file. Either needs migration to a newer format or damaged. -
UNRELATED
Dir does not qualify as vault.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
checkDirStructure
public static DirStructure checkDirStructure(Path pathToVault, String vaultConfigFilename, String masterkeyFilename) throws IOException Analyzes the structure of the given directory under certain vault existence criteria.- Parameters:
pathToVault- A directory pathvaultConfigFilename- Name of the vault config filemasterkeyFilename- Name of the masterkey file (may be null to skip detection of legacy vaults)- Returns:
- enum indicating what this directory might be
- Throws:
IOException- if the provided path is not a directory, does not exist or cannot be read
-