Question: import java.io . * ; import java.net. * ; import java.util. * ; public class MiddleServer { private static Map users = new HashMap >
import java.io;
import java.net.;
import java.util.;
public class MiddleServer
private static Map users new HashMap;
public static void mainString args throws IOException
int port Integer.parseIntargs;
loadUsers;
ServerSocket serverSocket new ServerSocketport;
while true
new ClientHandlerserverSocketacceptstart;
private static void loadUsers throws IOException
Load users from userList.txt
private static class ClientHandler extends Thread
private Socket socket;
public ClientHandlerSocket socket
this.socket socket;
public void run
try BufferedReader input new BufferedReadernew InputStreamReadersocketgetInputStream;
PrintWriter output new PrintWritersocketgetOutputStream true
String credentials input.readLine;
String parts credentials.split;
String username parts;
String password parts;
if authenticateusername password
output.printlnSUCCESS;
Connect to appropriate group server
else
output.printlnFAIL;
catch IOException e
eprintStackTrace;
private boolean authenticateString username, String password
User user users.getusername;
return user null && user.password.equalspassword;
private static class User
String username;
String password;
String group;
int points;
Constructor and other methods
I need Send me the instructions to execute and Outputs of this program
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
