Added password check for estate agent management
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
parent
c33ddd4d4c
commit
b3fe215dcd
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue