if (state == LOGIN_SUPPLIED) {
session.getState().put(USERNAME, line);
session.getState().put(AUTHORIZATION_STATE, PASSWORD_SUPPLIED);
session.writeResponse(new RemoteManagerResponse("Password:"));
} else if (state == PASSWORD_SUPPLIED) {
String password = line;
String username = (String) session.getState().get(USERNAME);
if (!password.equals(session.getAdministrativeAccountData().get(username)) || password.length() == 0) {
final String message = "Login failed for " + username;
session.writeResponse(new RemoteManagerResponse(message));
session.writeResponse(new RemoteManagerResponse("Login id:"));
// we need to handle the next line as login again
session.getState().put(AUTHORIZATION_STATE, LOGIN_SUPPLIED);
} else {
StringBuilder messageBuffer = new StringBuilder(64).append("Welcome ").append(username).append(". HELP for a list of commands");
session.writeResponse(new RemoteManagerResponse(messageBuffer.toString()));
if (session.getLogger().isInfoEnabled()) {
StringBuilder infoBuffer = new StringBuilder(128).append("Login for ").append(username).append(" successful");
session.getLogger().info(infoBuffer.toString());
}
session.popLineHandler();