Added password check for estate agent management

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
Jim Martens 2017-04-18 18:37:48 +02:00
parent c33ddd4d4c
commit b3fe215dcd
1 changed files with 18 additions and 1 deletions

View File

@ -3,6 +3,8 @@ package de.dis2017;
import de.dis2017.data.EstateAgent;
import de.dis2017.data.db.ORM;
import java.util.Arrays;
/**
* Main class
*/
@ -36,13 +38,28 @@ public class Main {
switch(response) {
case MENU_AGENT:
showEstateAgentMenu();
if (checkPassword()) {
showEstateAgentMenu();
}
else {
System.out.println("The password was wrong.");
}
break;
case QUIT:
return;
}
}
}
/**
* Checks the password for sudo-like menu areas.
*/
private static boolean checkPassword() {
System.out.println("Please insert the sudo password. You are entering dangerous territory.");
char[] passwordInput = System.console().readPassword();
char[] sudoPassword = "ea-sudo".toCharArray();
return Arrays.equals(sudoPassword, passwordInput);
}
/**
* Shows the estate management.