CommandTerm v1.1 (securing user input)
This commit is contained in:
parent
dc7016355a
commit
139de56401
Binary file not shown.
|
@ -125,14 +125,28 @@ public class ControlTerminal {
|
||||||
socket.send(p);
|
socket.send(p);
|
||||||
System.out.println("Request sent, waiting for response");
|
System.out.println("Request sent, waiting for response");
|
||||||
|
|
||||||
}else{
|
}else if(input.equals("u")){
|
||||||
System.out.println("Please enter plane number");
|
System.out.println("Please enter plane number");
|
||||||
|
try{
|
||||||
planeNumber = s.nextInt();
|
planeNumber = s.nextInt();
|
||||||
|
}catch(Exception e){
|
||||||
|
System.out.println("Wrong input please retry");
|
||||||
|
s.nextLine();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
keys = new ArrayList(container.getMap().keySet());
|
keys = new ArrayList(container.getMap().keySet());
|
||||||
plane = container.getMap().get(keys.get(planeNumber-1));
|
plane = container.getMap().get(keys.get(planeNumber-1));
|
||||||
|
}catch(Exception e){
|
||||||
|
System.out.println("Unknown plane please retry");
|
||||||
|
s.nextLine();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
flags = 0x01;
|
flags = 0x01;
|
||||||
while(true){
|
while(true){
|
||||||
System.out.println("Enter the information you want to update (1: alt,2:cap,3:speed)");
|
System.out.println("Enter the information you want to update (1: alt,2:cap,3:speed)");
|
||||||
|
try{
|
||||||
data = s.nextInt();
|
data = s.nextInt();
|
||||||
switch(data){
|
switch(data){
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -154,6 +168,12 @@ public class ControlTerminal {
|
||||||
flags = (byte) (flags|0x04);
|
flags = (byte) (flags|0x04);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
System.out.println("Wrong input please retry");
|
||||||
|
s.nextLine();
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
System.out.println("Do you want to update more data on this plane (y/n)");
|
System.out.println("Do you want to update more data on this plane (y/n)");
|
||||||
|
|
||||||
if(s.next().equals("n")){
|
if(s.next().equals("n")){
|
||||||
|
@ -168,6 +188,8 @@ public class ControlTerminal {
|
||||||
socket.send(p);
|
socket.send(p);
|
||||||
System.out.println("Request sent, waiting for response");
|
System.out.println("Request sent, waiting for response");
|
||||||
s.nextLine();
|
s.nextLine();
|
||||||
|
}else{
|
||||||
|
System.out.println("Unknown command, please retry");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue