Question: Question 1 0 . Is the following Java code security - compliant? In case it is not compliant, please change it to make security -

Question 10. Is the following Java code security-compliant? In case it is not compliant, please change it to make security-compliant.
class Password {
public static void main (String args[]) throws IOException {
Console c = System.console();
if (c == null){
System.err.println("No console.");
System.exit(1);
}
String username = c.readLine("Enter your user name: ");
String password = c.readLine("Enter your password: ");
if (!verify(username, password)){
throw new SecurityException("Invalid Credentials");
}
//...
}
// Dummy verify method, always returns true
private static final boolean verify(String username, String password){
return true;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!