@@ -59,22 +59,20 @@ public class Create implements Callable<Integer> {
5959 public Integer call () throws Exception {
6060 csprng = SecureRandom .getInstanceStrong ();
6161
62- createVault (pathToVault );
62+ try (var passphraseContainer = passwordSource .readPassphrase ()) {
63+ passwordSource .confirmPassphrase ();
6364
64- LOG .info ("Vault created successfully in {}" , pathToVault );
65- return 0 ;
66- }
67-
68- private void createVault (Path path ) throws IOException {
69- // Throw exception if there's something already there.
70- Files .createDirectory (path );
65+ // Throw exception if there's something already there.
66+ Files .createDirectory (pathToVault );
7167
72- try (var passphraseContainer = passwordSource .readPassphrase ();
73- var masterkey = Masterkey .generate (csprng )) {
74-
75- persistMasterkey (path , masterkey , passphraseContainer .content ());
76- initializeVault (path , masterkey );
68+ try (var masterkey = Masterkey .generate (csprng )) {
69+ persistMasterkey (pathToVault , masterkey , passphraseContainer .content ());
70+ initializeVault (pathToVault , masterkey );
71+ }
7772 }
73+
74+ LOG .info ("Vault created successfully in {}" , pathToVault );
75+ return 0 ;
7876 }
7977
8078 private void persistMasterkey (Path path , Masterkey masterkey , char [] passphrase )
0 commit comments