|
|
@ -14,9 +14,18 @@ public class Vault implements VaultInterface { |
|
|
|
public boolean credentialM; |
|
|
|
public String userName; |
|
|
|
public String password; |
|
|
|
public boolean isInt = false; |
|
|
|
public int newID; |
|
|
|
public String newString; |
|
|
|
public boolean decision; |
|
|
|
InputStream inputS = System.in; |
|
|
|
OutputStream outputS = System.out; |
|
|
|
private CredentialRepository credentialRepository = new CredentialRepository(); |
|
|
|
|
|
|
|
public static void main (String args[]) { |
|
|
|
Vault vault = new Vault(); |
|
|
|
vault.credentialMenu(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void println(String output) { |
|
|
|
try { |
|
|
@ -63,7 +72,7 @@ public class Vault implements VaultInterface { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void setPWLength(String pwLength){ |
|
|
|
public void setPWLength(String pwLength) { |
|
|
|
try { |
|
|
|
PWLength = Integer.parseInt(pwLength); |
|
|
|
} catch (NumberFormatException e) { |
|
|
@ -74,33 +83,23 @@ public class Vault implements VaultInterface { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void addCredential(){ |
|
|
|
Scanner scan = new Scanner(inputS); |
|
|
|
println("Type in username"); |
|
|
|
userName = scan.nextLine(); |
|
|
|
|
|
|
|
println("Type in password"); |
|
|
|
password = scan.nextLine(); |
|
|
|
//createNewCredential(userName, password); |
|
|
|
|
|
|
|
public void addCredential(String userName, String password){ |
|
|
|
credentialRepository.createNewCredential(userName, password); |
|
|
|
} |
|
|
|
|
|
|
|
public void showCredential(){ |
|
|
|
Scanner scan = new Scanner(inputS); |
|
|
|
println("Type in ID or username"); |
|
|
|
|
|
|
|
String str = scan.nextLine(); |
|
|
|
public void showCredential(String str) { |
|
|
|
|
|
|
|
if(str.matches("[0-9]+")) { |
|
|
|
isInt = true; |
|
|
|
//getCredentialsViaId(Integer.parseInt(str)); |
|
|
|
println("Getting credential via ID"); |
|
|
|
credentialRepository.getCredentialsViaId(Integer.parseInt(str)); |
|
|
|
} else { |
|
|
|
isInt = false; |
|
|
|
//getCredentialsViaName(str); |
|
|
|
} |
|
|
|
|
|
|
|
println("Getting credential via name"); |
|
|
|
credentialRepository.getCredentialsViaName(str); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void getAsJson(){ |
|
|
|
|
|
|
|
} |
|
|
@ -158,14 +157,40 @@ public class Vault implements VaultInterface { |
|
|
|
|
|
|
|
String input = scan.nextLine(); |
|
|
|
|
|
|
|
|
|
|
|
if (input.equals("e")) { |
|
|
|
credentialM = false; |
|
|
|
} else if (input.equals("a")) { |
|
|
|
println("Type username:"); |
|
|
|
} else if (input.equals("c")) { |
|
|
|
println("Type username or ID to show credential:"); |
|
|
|
} |
|
|
|
|
|
|
|
if (input.equals("a")) { |
|
|
|
println("Type in username"); |
|
|
|
userName = scan.nextLine(); |
|
|
|
|
|
|
|
println("Type in password"); |
|
|
|
password = scan.nextLine(); |
|
|
|
addCredential(userName, password); |
|
|
|
} |
|
|
|
|
|
|
|
if (input.equals("c")) { |
|
|
|
println("Type in ID or username"); |
|
|
|
|
|
|
|
String str = scan.nextLine(); |
|
|
|
showCredential(str); |
|
|
|
|
|
|
|
} else if (input.equals("l")) { |
|
|
|
println("Type username or ID to select credential:"); |
|
|
|
println("Type ID to select credential:"); |
|
|
|
newID = Integer.parseInt(scan.nextLine()); |
|
|
|
println("-change username: u\n-change password: p"); |
|
|
|
input = scan.nextLine(); |
|
|
|
|
|
|
|
if (input.equals("u")) { |
|
|
|
decision = true; |
|
|
|
}else{ |
|
|
|
decision = false; |
|
|
|
} |
|
|
|
println("Type new:"); |
|
|
|
newString = scan.nextLine(); |
|
|
|
//editCredential(newID, newString, decision); |
|
|
|
} |
|
|
|
} |
|
|
|
} |