public void migrate ( Path pathToVault , String masterkeyFilename , CharSequence passphrase ) throws NoApplicableMigratorException , InvalidPassphraseException , IOException { Path masterKeyPath = pathToVault . resolve ( masterkeyFilename ) ; byte [ ] keyFileContents = Files . readAllBytes ( masterKeyPath ) ; KeyFile keyFile = KeyFile . parse ( keyFileContents ) ; try { Migrator migrator = findApplicableMigrator ( keyFile . getVersion ( ) ) . orElseThrow ( NoApplicableMigratorException :: new ) ; migrator . migrate ( pathToVault , masterkeyFilename , passphrase ) ; } catch ( UnsupportedVaultFormatException e ) { // might be a tampered masterkey file, as this exception is also thrown if the vault version MAC is not authentic. throw new IllegalStateException ( "Vault version checked beforehand but not supported by migrator." ) ; } }
Performs the actual migration . This task may take a while and this method will block .