handler.sendClientMsg("+OK Username required");
return null;
}
public AuthStatus handleAuthentication(ClientHandler handler, String command) throws IOException, AppException {
Data data = (Data)handler.getClientData();
if(data.getLastAsked().equals("U")) {
data.setUsername(command);
data.setLastAsked("P");
handler.sendClientMsg("+OK Password required");
}
else if(data.getLastAsked().equals("P")) {
data.setPassword(command.getBytes());
if(Authenticator.validate(data.getUsername(), data.getPassword())) {
handler.sendClientMsg("+OK Logged in");
data.setPassword(null);
return AuthStatus.SUCCESS;
}
else {
handler.sendClientMsg("-ERR Authorisation Failed");
data.setPassword(null);
return AuthStatus.FAILURE;
}
}
else {
throw new AppException("Unknown LastAsked!");