|
|
@ -118,14 +118,19 @@ public class Vault implements VaultInterface { |
|
|
|
println("Type in ID or username"); |
|
|
|
|
|
|
|
String str = scan.nextLine(); |
|
|
|
Credential credential = null; |
|
|
|
|
|
|
|
if(str.matches("[0-9]+")) { |
|
|
|
println("Getting credential via ID"); |
|
|
|
credentialRepository.getCredentialsViaId(Integer.parseInt(str)); |
|
|
|
credential = credentialRepository.getCredentialsViaId(Integer.parseInt(str)); |
|
|
|
} else { |
|
|
|
|
|
|
|
println("Getting credential via name"); |
|
|
|
credentialRepository.getCredentialsViaName(str); |
|
|
|
credential = credentialRepository.getCredentialsViaName(str); |
|
|
|
} |
|
|
|
|
|
|
|
if (credential != null) { |
|
|
|
println(credential.getName() + ": " + credential.getPassword()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -158,6 +163,11 @@ public class Vault implements VaultInterface { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void listCredentials() { |
|
|
|
for (Credential credential : credentialRepository.getCredentialList()) { |
|
|
|
println(String.format("ID: %d - Username: %s", credential.getId(), credential.getName())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void getAsJson(){ |
|
|
|
|
|
|
@ -210,6 +220,7 @@ public class Vault implements VaultInterface { |
|
|
|
sbcm.append("- add credential: a\n"); |
|
|
|
sbcm.append("- show credential: c\n"); |
|
|
|
sbcm.append("- edit credential: l\n"); |
|
|
|
sbcm.append("- list credentials: s\n"); |
|
|
|
sbcm.append("- exit: e\n"); |
|
|
|
|
|
|
|
println(sbcm.toString()); |
|
|
@ -233,6 +244,10 @@ public class Vault implements VaultInterface { |
|
|
|
case "l": |
|
|
|
editCredential(); |
|
|
|
break; |
|
|
|
|
|
|
|
case "s": |
|
|
|
listCredentials(); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |