Added password check for estate agent management
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
@ -6,6 +6,8 @@ import de.dis2017.data.EstateAgent;
|
||||
import de.dis2017.data.House;
|
||||
import de.dis2017.data.db.ORM;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Main class
|
||||
*/
|
||||
@ -41,7 +43,12 @@ public class Main {
|
||||
|
||||
switch(response) {
|
||||
case MENU_AGENT:
|
||||
if (checkPassword()) {
|
||||
showEstateAgentMenu();
|
||||
}
|
||||
else {
|
||||
System.out.println("The password was wrong.");
|
||||
}
|
||||
break;
|
||||
case MENU_ESTATES:
|
||||
showEstateMenu();
|
||||
@ -52,6 +59,16 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Shows the estate management.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user