import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.Scanner; public class Vault implements VaultInterface { public boolean config; public int PWLength; public boolean haveCapitals; public boolean hasSpecialChars; public boolean hasNumbers; public String userName; InputStream inputS = System.in; OutputStream outputS = System.out; private void println(String output) { try { outputS.write((output + "\n").getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { e.printStackTrace(); } } public void configure(){ StringBuilder sbcm = new StringBuilder(); Scanner scan = new Scanner(inputS); config = true; sbcm.append("Configure:\n"); sbcm.append("- Password length: l\n"); sbcm.append("- Have Capitals: h\n"); sbcm.append("- exit: e\n"); println(sbcm.toString()); String input = scan.nextLine(); if (input.equals("e")) { config = false; } } public void setPWLength(){ println("Set PW length:"); Scanner scan = new Scanner(inputS); String input = scan.nextLine(); try { PWLength = Integer.parseInt(input); } catch (NumberFormatException e) { println("Please Enter Valid Number."); } println("\nNew PWlength is now: "); } public void addCredential(){ println("Add user name"); Scanner scan = new Scanner(inputS); String input = scan.nextLine(); userName = input; } public void showCredential(){ } public void getAsJson(){ } public void loadFromJson(){ } public void setCapital() { println("Should you PW have capitals? Type in yes or no."); Scanner scan = new Scanner(inputS); String input = scan.nextLine(); if(input.equals("yes")){ haveCapitals = true; println("Your PWs contain now capitals."); }else if(input.equals("no")){ haveCapitals = false; println("Your PWs don´t have capitals anymore."); } } public void setSpecialChar() { println("Should you PW have special characters? Type in yes or no."); Scanner scan = new Scanner(inputS); String input = scan.nextLine(); if(input.equals("yes")){ hasSpecialChars = true; println("Your PWs contain now special characters."); }else if(input.equals("no")){ hasSpecialChars = false; println("Your PWs don´t have special characters anymore."); } } public void SetNumbers() { println("Should you PW have numbers? Type in yes or no."); Scanner scan = new Scanner(inputS); String input = scan.nextLine(); if(input.equals("yes")){ hasNumbers = true; println("Your PWs contains now numbers."); }else if(input.equals("no")){ hasNumbers = false; println("Your PWs don´t have numbers anymore."); } } }